From 7aba5142e90f1f1ea64707c6c9b14ccd58c8ee79 Mon Sep 17 00:00:00 2001 From: Christopher Ferris Date: Tue, 3 Sep 2019 10:18:42 -0700 Subject: [PATCH] Add test mapping to run the libunwind tests. Created a special target, libunwindstack_unit_test, that doesn't include the test that dlopen's a shared library. It appears atest doesn't understand how to handle the require keyword. Also, move the shared library into the libunwindstack_test directory itself. Test: Ran atest libunwindstack_unit_test. Change-Id: I967919b1d74a08669b61d0363d80861685725609 --- libunwindstack/Android.bp | 24 ++++++++++++++++++---- libunwindstack/TEST_MAPPING | 7 +++++++ libunwindstack/tests/LocalUnwinderTest.cpp | 6 +++--- 3 files changed, 30 insertions(+), 7 deletions(-) create mode 100644 libunwindstack/TEST_MAPPING diff --git a/libunwindstack/Android.bp b/libunwindstack/Android.bp index 14246aeb2..da18af643 100644 --- a/libunwindstack/Android.bp +++ b/libunwindstack/Android.bp @@ -153,12 +153,12 @@ cc_test_library { shared_libs: [ "libunwindstack", ], + relative_install_path: "libunwindstack_test", } -cc_test { - name: "libunwindstack_test", +cc_defaults { + name: "libunwindstack_testlib_flags", defaults: ["libunwindstack_flags"], - isolated: true, srcs: [ "tests/ArmExidxDecodeTest.cpp", @@ -183,7 +183,6 @@ cc_test { "tests/ElfTestUtils.cpp", "tests/IsolatedSettings.cpp", "tests/JitDebugTest.cpp", - "tests/LocalUnwinderTest.cpp", "tests/LogFake.cpp", "tests/MapInfoCreateMemoryTest.cpp", "tests/MapInfoGetBuildIDTest.cpp", @@ -253,11 +252,28 @@ cc_test { "tests/files/offline/straddle_arm/*", "tests/files/offline/straddle_arm64/*", ], +} + +cc_test { + name: "libunwindstack_test", + defaults: ["libunwindstack_testlib_flags"], + isolated: true, + + srcs: [ + "tests/LocalUnwinderTest.cpp", + ], required: [ "libunwindstack_local", ], } +// Skip LocalUnwinderTest until atest understands required properly. +cc_test { + name: "libunwindstack_unit_test", + defaults: ["libunwindstack_testlib_flags"], + isolated: true, +} + //------------------------------------------------------------------------- // Tools //------------------------------------------------------------------------- diff --git a/libunwindstack/TEST_MAPPING b/libunwindstack/TEST_MAPPING new file mode 100644 index 000000000..55771c097 --- /dev/null +++ b/libunwindstack/TEST_MAPPING @@ -0,0 +1,7 @@ +{ + "presubmit": [ + { + "name": "libunwindstack_unit_test" + } + ] +} diff --git a/libunwindstack/tests/LocalUnwinderTest.cpp b/libunwindstack/tests/LocalUnwinderTest.cpp index 56a18cde2..9936f7afa 100644 --- a/libunwindstack/tests/LocalUnwinderTest.cpp +++ b/libunwindstack/tests/LocalUnwinderTest.cpp @@ -170,10 +170,10 @@ TEST_F(LocalUnwinderTest, unwind_after_dlopen) { std::string testlib(testing::internal::GetArgvs()[0]); auto const value = testlib.find_last_of('/'); - if (value == std::string::npos) { - testlib = "../"; + if (value != std::string::npos) { + testlib = testlib.substr(0, value + 1); } else { - testlib = testlib.substr(0, value + 1) + "../"; + testlib = ""; } testlib += "libunwindstack_local.so";