Index: third_party/crazy_linker/crazy_linker/src/crazy_linker_ashmem_unittest.cpp |
diff --git a/third_party/crazy_linker/crazy_linker/src/crazy_linker_ashmem_unittest.cpp b/third_party/crazy_linker/crazy_linker/src/crazy_linker_ashmem_unittest.cpp |
new file mode 100644 |
index 0000000000000000000000000000000000000000..287028d31733499399c8cb3932ae2bd11d1a0f2a |
--- /dev/null |
+++ b/third_party/crazy_linker/crazy_linker/src/crazy_linker_ashmem_unittest.cpp |
@@ -0,0 +1,34 @@ |
+// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "crazy_linker_ashmem.h" |
+ |
+#include <sys/mman.h> |
+ |
+#include <minitest/minitest.h> |
+ |
+namespace crazy { |
+ |
+TEST(AshmemRegion, Construction) { |
+ AshmemRegion region; |
+ EXPECT_EQ(-1, region.Get()); |
+} |
+ |
+TEST(AshmemRegion, Allocate) { |
+ AshmemRegion region; |
+ const size_t kSize = 4096*10; |
+ EXPECT_TRUE(region.Allocate(kSize, __FUNCTION__)); |
+ void* map = ::mmap(NULL, kSize, PROT_READ|PROT_WRITE, |
+ MAP_ANONYMOUS|MAP_SHARED, region.Get(), 0); |
+ EXPECT_NE(MAP_FAILED, map); |
+ |
+ for (size_t n = 0; n < kSize; ++n) { |
+ TEST_TEXT << "Checking region[" << n << "]"; |
+ EXPECT_EQ(0, ((char*)map)[n]); |
+ } |
+ |
+ EXPECT_EQ(0, ::munmap(map, kSize)); |
+} |
+ |
+} // namespace crazy |