skia2/tests/OverAlignedTest.cpp
Mike Klein 615daf0e04 OverAlignedTest: use sk_ malloc and free.
BUG=skia:

GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2712

Change-Id: I73b2b45ba6a1303b957aa03953eef305f8be9144
Reviewed-on: https://skia-review.googlesource.com/2712
Reviewed-by: Ben Wagner <benjaminwagner@google.com>
2016-09-27 16:12:13 +00:00

23 lines
724 B
C++

/*
* Copyright 2016 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "Test.h"
#include "SkRandom.h"
// Clang seems to think only 32-bit alignment is guaranteed on 32-bit x86 Android.
// See https://reviews.llvm.org/D8357
// This is why we have disabled -Wover-aligned there (we allocate 8-byte aligned structs in Ganesh).
DEF_TEST(OverAligned, r) {
SkRandom rand;
// Let's test that assertion. We think it really should be providing 8-byte alignment.
for (int i = 0; i < 1000; i++) {
void* p = sk_malloc_throw(rand.nextRangeU(0,100));
REPORTER_ASSERT(r, SkIsAlign8((uintptr_t)p));
sk_free(p);
}
}