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