diff options
Diffstat (limited to 'libunwindstack/tests/MemoryRemoteTest.cpp')
-rw-r--r-- | libunwindstack/tests/MemoryRemoteTest.cpp | 37 |
1 files changed, 19 insertions, 18 deletions
diff --git a/libunwindstack/tests/MemoryRemoteTest.cpp b/libunwindstack/tests/MemoryRemoteTest.cpp index 2b6e682..ed58eb9 100644 --- a/libunwindstack/tests/MemoryRemoteTest.cpp +++ b/libunwindstack/tests/MemoryRemoteTest.cpp @@ -32,6 +32,7 @@ #include "MemoryRemote.h" +#include "PidUtils.h" #include "TestUtils.h" #include "utils/MemoryFake.h" @@ -49,7 +50,7 @@ TEST(MemoryRemoteTest, read) { ASSERT_LT(0, pid); TestScopedPidReaper reap(pid); - ASSERT_TRUE(TestAttach(pid)); + ASSERT_TRUE(Attach(pid)); MemoryRemote remote(pid); @@ -59,7 +60,7 @@ TEST(MemoryRemoteTest, read) { ASSERT_EQ(0x4cU, dst[i]) << "Failed at byte " << i; } - ASSERT_TRUE(TestDetach(pid)); + ASSERT_TRUE(Detach(pid)); } TEST(MemoryRemoteTest, read_large) { @@ -78,7 +79,7 @@ TEST(MemoryRemoteTest, read_large) { ASSERT_LT(0, pid); TestScopedPidReaper reap(pid); - ASSERT_TRUE(TestAttach(pid)); + ASSERT_TRUE(Attach(pid)); MemoryRemote remote(pid); @@ -88,7 +89,7 @@ TEST(MemoryRemoteTest, read_large) { ASSERT_EQ(i / getpagesize(), dst[i]) << "Failed at byte " << i; } - ASSERT_TRUE(TestDetach(pid)); + ASSERT_TRUE(Detach(pid)); } TEST(MemoryRemoteTest, read_partial) { @@ -111,7 +112,7 @@ TEST(MemoryRemoteTest, read_partial) { // Unmap from our process. ASSERT_EQ(0, munmap(mapping, 3 * getpagesize())); - ASSERT_TRUE(TestAttach(pid)); + ASSERT_TRUE(Attach(pid)); MemoryRemote remote(pid); @@ -132,7 +133,7 @@ TEST(MemoryRemoteTest, read_partial) { ASSERT_EQ(0x4cU, dst[i]) << "Failed at byte " << i; } - ASSERT_TRUE(TestDetach(pid)); + ASSERT_TRUE(Detach(pid)); } TEST(MemoryRemoteTest, read_fail) { @@ -152,7 +153,7 @@ TEST(MemoryRemoteTest, read_fail) { ASSERT_LT(0, pid); TestScopedPidReaper reap(pid); - ASSERT_TRUE(TestAttach(pid)); + ASSERT_TRUE(Attach(pid)); MemoryRemote remote(pid); @@ -171,7 +172,7 @@ TEST(MemoryRemoteTest, read_fail) { ASSERT_EQ(0, munmap(src, pagesize)); - ASSERT_TRUE(TestDetach(pid)); + ASSERT_TRUE(Detach(pid)); } TEST(MemoryRemoteTest, read_overflow) { @@ -184,7 +185,7 @@ TEST(MemoryRemoteTest, read_overflow) { ASSERT_LT(0, pid); TestScopedPidReaper reap(pid); - ASSERT_TRUE(TestAttach(pid)); + ASSERT_TRUE(Attach(pid)); MemoryRemote remote(pid); @@ -192,7 +193,7 @@ TEST(MemoryRemoteTest, read_overflow) { std::vector<uint8_t> dst(200); ASSERT_FALSE(remote.ReadFully(UINT64_MAX - 100, dst.data(), 200)); - ASSERT_TRUE(TestDetach(pid)); + ASSERT_TRUE(Detach(pid)); } TEST(MemoryRemoteTest, read_illegal) { @@ -204,7 +205,7 @@ TEST(MemoryRemoteTest, read_illegal) { ASSERT_LT(0, pid); TestScopedPidReaper reap(pid); - ASSERT_TRUE(TestAttach(pid)); + ASSERT_TRUE(Attach(pid)); MemoryRemote remote(pid); @@ -212,7 +213,7 @@ TEST(MemoryRemoteTest, read_illegal) { ASSERT_FALSE(remote.ReadFully(0, dst.data(), 1)); ASSERT_FALSE(remote.ReadFully(0, dst.data(), 100)); - ASSERT_TRUE(TestDetach(pid)); + ASSERT_TRUE(Detach(pid)); } TEST(MemoryRemoteTest, read_mprotect_hole) { @@ -233,7 +234,7 @@ TEST(MemoryRemoteTest, read_mprotect_hole) { ASSERT_EQ(0, munmap(mapping, 3 * page_size)); - ASSERT_TRUE(TestAttach(pid)); + ASSERT_TRUE(Attach(pid)); MemoryRemote remote(pid); std::vector<uint8_t> dst(getpagesize() * 4, 0xCC); @@ -247,7 +248,7 @@ TEST(MemoryRemoteTest, read_mprotect_hole) { ASSERT_EQ(0xCC, dst[i]); } - ASSERT_TRUE(TestDetach(pid)); + ASSERT_TRUE(Detach(pid)); } TEST(MemoryRemoteTest, read_munmap_hole) { @@ -270,7 +271,7 @@ TEST(MemoryRemoteTest, read_munmap_hole) { ASSERT_EQ(0, munmap(mapping, page_size)); ASSERT_EQ(0, munmap(static_cast<char*>(mapping) + 2 * page_size, page_size)); - ASSERT_TRUE(TestAttach(pid)); + ASSERT_TRUE(Attach(pid)); MemoryRemote remote(pid); std::vector<uint8_t> dst(getpagesize() * 4, 0xCC); @@ -283,7 +284,7 @@ TEST(MemoryRemoteTest, read_munmap_hole) { ASSERT_EQ(0xCC, dst[i]); } - ASSERT_TRUE(TestDetach(pid)); + ASSERT_TRUE(Detach(pid)); } // Verify that the memory remote object chooses a memory read function @@ -307,7 +308,7 @@ TEST(MemoryRemoteTest, read_choose_correctly) { ASSERT_EQ(0, munmap(mapping, 2 * page_size)); - ASSERT_TRUE(TestAttach(pid)); + ASSERT_TRUE(Attach(pid)); // We know that process_vm_readv of a mprotect'd PROT_NONE region will fail. // Read from the PROT_NONE area first to force the choice of ptrace. @@ -336,7 +337,7 @@ TEST(MemoryRemoteTest, read_choose_correctly) { ASSERT_EQ(sizeof(value), bytes); ASSERT_EQ(0xfcfcfcfcU, value); - ASSERT_TRUE(TestDetach(pid)); + ASSERT_TRUE(Detach(pid)); } } // namespace unwindstack |