Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2008)

Unified Diff: tests/MemsetTest.cpp

Issue 1849183004: MIPS32r2: Fix Chromium runtime crash (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/core/SkChunkAlloc.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/MemsetTest.cpp
diff --git a/tests/MemsetTest.cpp b/tests/MemsetTest.cpp
index e1f844e05c5c92a25abcf67362b6e3edf318473f..fb5a337738802bba6cccac70b07aedafb8db0d77 100644
--- a/tests/MemsetTest.cpp
+++ b/tests/MemsetTest.cpp
@@ -6,6 +6,7 @@
*/
#include "SkChunkAlloc.h"
+#include "SkRandom.h"
#include "SkUtils.h"
#include "Test.h"
@@ -23,6 +24,14 @@ static void* simple_alloc(skiatest::Reporter* reporter, SkChunkAlloc* alloc, siz
return ptr;
}
+static void check_alloc_alignment(skiatest::Reporter* reporter,
+ SkChunkAlloc* alloc, size_t size) {
+ const size_t kAlignment = 8;
+ void* ptr = alloc->allocThrow(size);
+ REPORTER_ASSERT(reporter, ptr != nullptr);
+ REPORTER_ASSERT(reporter, (size_t)ptr % kAlignment == 0);
+}
+
static void test_chunkalloc(skiatest::Reporter* reporter) {
static const size_t kMin = 1024;
SkChunkAlloc alloc(kMin);
@@ -76,6 +85,14 @@ static void test_chunkalloc(skiatest::Reporter* reporter) {
REPORTER_ASSERT(reporter, freed == kMin);
check_alloc(reporter, alloc, 2*kMin, size, 2);
REPORTER_ASSERT(reporter, !alloc.contains(ptr));
+
+ //------------------------------------------------------------------------
+ // test the alignment
+ alloc.reset();
+ SkRandom rand;
+ for (int i = 0; i < 1000; i++) {
+ check_alloc_alignment(reporter, &alloc, rand.nextU16());
+ }
}
///////////////////////////////////////////////////////////////////////////////
« no previous file with comments | « src/core/SkChunkAlloc.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698