| Index: third_party/android_crazy_linker/src/src/crazy_linker_ashmem_unittest.cpp
|
| diff --git a/third_party/android_crazy_linker/src/src/crazy_linker_ashmem_unittest.cpp b/third_party/android_crazy_linker/src/src/crazy_linker_ashmem_unittest.cpp
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..4a89111e567e3eeb837d18713715845f028ac0dd
|
| --- /dev/null
|
| +++ b/third_party/android_crazy_linker/src/src/crazy_linker_ashmem_unittest.cpp
|
| @@ -0,0 +1,38 @@
|
| +// 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.fd());
|
| +}
|
| +
|
| +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.fd(),
|
| + 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
|
|
|