OverAlignedTest.cpp 744 B

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