From 5e3d44100be32fd5efffd0c309bd90c04cc9620c Mon Sep 17 00:00:00 2001 From: Jiyong Park Date: Tue, 19 Sep 2017 09:48:07 +0900 Subject: [PATCH] Don't run exec_with_ld_config_file* tests on non-production devices The tests that use LD_CONFIG_FILE environment variable shouldn't be run on non-production devices because LD_CONFIG_FILE is only for debuggable builds. We have used the build-time flag USE_LD_CONFIG_FILE, which is set for the debuggable builds, to conditionally include or exclude the tests. However, this can be a problem when 1) the device is not debuggable but 2) the CTS itself is built with debuggable target. So, instead of relying on the build-time flag USE_LD_CONFIG_FILE, the tests now check the debuggability of the device and skip the tests when it isn't debuggable. Bug: 65842135 Test: 1) flash user build image to a 2017 pixel device. 2) build cts with 'userdebug' build target 3) CtsBionicTestCases pass on the device Change-Id: Ib88e3b26d093e5479d52cd87db47dee5e108cac2 --- tests/Android.bp | 12 ------------ tests/dl_test.cpp | 23 ++++++++++++++++++----- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/tests/Android.bp b/tests/Android.bp index e8fa5bdf9..29204b558 100644 --- a/tests/Android.bp +++ b/tests/Android.bp @@ -299,12 +299,6 @@ cc_test_library { ], } }, - - product_variables: { - debuggable: { - cppflags: ["-DUSE_LD_CONFIG_FILE"], - }, - }, } // ----------------------------------------------------------------------------- @@ -605,12 +599,6 @@ cc_test_host { sanitize: { never: false, }, - - product_variables: { - debuggable: { - cppflags: ["-DUSE_LD_CONFIG_FILE"], - }, - }, } subdirs = ["libs"] diff --git a/tests/dl_test.cpp b/tests/dl_test.cpp index aaf2c3742..d09330dbc 100644 --- a/tests/dl_test.cpp +++ b/tests/dl_test.cpp @@ -180,12 +180,24 @@ static void create_ld_config_file(std::string& config_file) { } #endif -#ifdef USE_LD_CONFIG_FILE +#if defined(__BIONIC__) +static bool is_user_build() { + std::string build_type = android::base::GetProperty("ro.build.type", "user"); + if (build_type == "userdebug" || build_type == "eng") { + return false; + } + return true; +} +#endif // _lib1.so and _lib2.so are now searchable by having another namespace 'ns2' // whose search paths include the 'ns2/' subdir. TEST(dl, exec_with_ld_config_file) { #if defined(__BIONIC__) + if (is_user_build()) { + // LD_CONFIG_FILE is not supported on user build + return; + } std::string helper = get_testlib_root() + "/ld_config_test_helper/ld_config_test_helper"; std::string config_file = get_testlib_root() + "/ld.config.txt"; @@ -204,6 +216,10 @@ TEST(dl, exec_with_ld_config_file) { // additional namespaces other than the default namespace. TEST(dl, exec_with_ld_config_file_with_ld_preload) { #if defined(__BIONIC__) + if (is_user_build()) { + // LD_CONFIG_FILE is not supported on user build + return; + } std::string helper = get_testlib_root() + "/ld_config_test_helper/ld_config_test_helper"; std::string config_file = get_testlib_root() + "/ld.config.txt"; @@ -218,8 +234,6 @@ TEST(dl, exec_with_ld_config_file_with_ld_preload) { #endif } -#endif // USE_LD_CONFIG_FILE - // ensures that LD_CONFIG_FILE env var does not work for production builds. // The test input is the same as exec_with_ld_config_file, but it must fail in // this case. @@ -230,8 +244,7 @@ TEST(dl, disable_ld_config_file) { // This test is only for CTS. return; } - std::string build_type = android::base::GetProperty("ro.build.type", "user"); - if (build_type == "userdebug" || build_type == "eng") { + if (!is_user_build()) { // Skip the test for non production devices return; }