From 62f7dc2a48d54294933ea72eb40d4a0cbb9b7e1b Mon Sep 17 00:00:00 2001 From: Yong Zhao Date: Wed, 15 Aug 2018 12:06:34 -0400 Subject: [PATCH] kfdtest: Do not set GTEST_FLAG throw_on_failure The flag makes EXPECT_* to behave like ASSERT_*, which actually work against our favor, so disable the flag. Change-Id: I2ea1dfeaf916b396593a504d081148abdac0fc70 Signed-off-by: Yong Zhao --- tests/kfdtest/src/KFDMemoryTest.cpp | 43 +++++++++++++---------------- tests/kfdtest/src/KFDTestMain.cpp | 2 -- 2 files changed, 19 insertions(+), 26 deletions(-) diff --git a/tests/kfdtest/src/KFDMemoryTest.cpp b/tests/kfdtest/src/KFDMemoryTest.cpp index 95cb14d543..df193ff754 100644 --- a/tests/kfdtest/src/KFDMemoryTest.cpp +++ b/tests/kfdtest/src/KFDMemoryTest.cpp @@ -1153,12 +1153,10 @@ TEST_F(KFDMemoryTest, PtraceAccess) { int traceStatus; int err = 0, r; - // Child process: don't use ASSERTs after attaching to parent - // process because terminating without detaching from the - // traced process leaves it stopped. Unfortunately, main() - // sets throw_on_failure to true, which seems to affect EXPECT - // as well. So we catch any exceptions and detach before - // terminating. + /* Child process: we catch any exceptions to make sure we detach + * from the traced process, because terminating without detaching + * leaves the traced process stopped. + */ r = ptrace(PTRACE_ATTACH, tracePid, NULL, NULL); if (r) { WARN() << "PTRACE_ATTACH failed: " << r << std::endl; @@ -1175,8 +1173,8 @@ TEST_F(KFDMemoryTest, PtraceAccess) { HSAuint8 *addr = reinterpret_cast(reinterpret_cast(mem[0]) + i) + i; errno = 0; long data = ptrace(PTRACE_PEEKDATA, tracePid, addr, NULL); - EXPECT_EQ(0, errno); - EXPECT_EQ(0, ptrace(PTRACE_POKEDATA, tracePid, addr + PAGE_SIZE, + ASSERT_EQ(0, errno); + ASSERT_EQ(0, ptrace(PTRACE_POKEDATA, tracePid, addr + PAGE_SIZE, reinterpret_cast(data))); if (mem[1] == NULL) @@ -1185,8 +1183,8 @@ TEST_F(KFDMemoryTest, PtraceAccess) { addr = reinterpret_cast(reinterpret_cast(mem[1]) + i) + i; errno = 0; data = ptrace(PTRACE_PEEKDATA, tracePid, addr, NULL); - EXPECT_EQ(0, errno); - EXPECT_EQ(0, ptrace(PTRACE_POKEDATA, tracePid, addr + PAGE_SIZE, + ASSERT_EQ(0, errno); + ASSERT_EQ(0, ptrace(PTRACE_POKEDATA, tracePid, addr + PAGE_SIZE, reinterpret_cast(data))); } } catch (...) { @@ -1297,12 +1295,9 @@ TEST_F(KFDMemoryTest, PtraceAccessInvisibleVram) { int traceStatus; int err = 0, r; - /* Child process: don't use ASSERTs after attaching to parent - * process because terminating without detaching from the - * traced process leaves it stopped. Unfortunately, main() - * sets throw_on_failure to true, which seems to affect EXPECT - * as well. So we catch any exceptions and detach before - * terminating. + /* Child process: we catch any exceptions to make sure we detach + * from the traced process, because terminating without detaching + * leaves the traced process stopped. */ r = ptrace(PTRACE_ATTACH, tracePid, NULL, NULL); if (r) { @@ -1317,17 +1312,17 @@ TEST_F(KFDMemoryTest, PtraceAccessInvisibleVram) { /* peek the memory */ errno = 0; HSAint64 data0 = ptrace(PTRACE_PEEKDATA, tracePid, mem0, NULL); - EXPECT_EQ(0, errno); - EXPECT_EQ(data[0], data0); + ASSERT_EQ(0, errno); + ASSERT_EQ(data[0], data0); HSAint64 data1 = ptrace(PTRACE_PEEKDATA, tracePid, mem1, NULL); - EXPECT_EQ(0, errno); - EXPECT_EQ(data[1], data1); + ASSERT_EQ(0, errno); + ASSERT_EQ(data[1], data1); /* swap mem0 and mem1 by poking */ - EXPECT_EQ(0, ptrace(PTRACE_POKEDATA, tracePid, mem0, reinterpret_cast(data[1]))); - EXPECT_EQ(0, errno); - EXPECT_EQ(0, ptrace(PTRACE_POKEDATA, tracePid, mem1, reinterpret_cast(data[0]))); - EXPECT_EQ(0, errno); + ASSERT_EQ(0, ptrace(PTRACE_POKEDATA, tracePid, mem0, reinterpret_cast(data[1]))); + ASSERT_EQ(0, errno); + ASSERT_EQ(0, ptrace(PTRACE_POKEDATA, tracePid, mem1, reinterpret_cast(data[0]))); + ASSERT_EQ(0, errno); } catch (...) { err = 1; } diff --git a/tests/kfdtest/src/KFDTestMain.cpp b/tests/kfdtest/src/KFDTestMain.cpp index 847582c2bc..5021445099 100644 --- a/tests/kfdtest/src/KFDTestMain.cpp +++ b/tests/kfdtest/src/KFDTestMain.cpp @@ -61,8 +61,6 @@ GTEST_API_ int main(int argc, char **argv) { g_TestENVCaps = ENVCAPS_NOADDEDCAPS | ENVCAPS_64BITLINUX; g_TestTimeOut = KFD_TEST_DEFAULT_TIMEOUT; - // every fatal fail ( = assert that failed ) will throw an exption - testing::GTEST_FLAG(throw_on_failure) = true; testing::InitGoogleTest(&argc, argv); CommandLineArguments args;