From 8d8138aad12f9bf7e424059848157aa03d91a5b2 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Tue, 12 Mar 2024 22:37:13 +0000 Subject: [PATCH] Fix orthography of GetTestLibRoot(). Change-Id: Ib052329b3ebced12a7e2d75b3628b33c7043e0d8 --- tests/cfi_test.cpp | 4 +- tests/dl_test.cpp | 36 ++++----- tests/dlext_test.cpp | 130 +++++++++++++++--------------- tests/dlfcn_test.cpp | 2 +- tests/elftls_dl_test.cpp | 10 +-- tests/gtest_globals.cpp | 2 +- tests/gtest_globals.h | 4 +- tests/heap_tagging_level_test.cpp | 2 +- tests/memtag_stack_test.cpp | 2 +- 9 files changed, 96 insertions(+), 96 deletions(-) diff --git a/tests/cfi_test.cpp b/tests/cfi_test.cpp index 4b061b34f..5324c68e6 100644 --- a/tests/cfi_test.cpp +++ b/tests/cfi_test.cpp @@ -160,7 +160,7 @@ TEST(cfi_test, invalid) { // cfi_test_helper exports __cfi_check, which triggers CFI initialization at startup. TEST(cfi_test, early_init) { #if defined(__BIONIC__) - std::string helper = GetTestlibRoot() + "/cfi_test_helper"; + std::string helper = GetTestLibRoot() + "/cfi_test_helper"; chmod(helper.c_str(), 0755); // TODO: "x" lost in CTS, b/34945607 ExecTestHelper eth; eth.SetArgs({ helper.c_str(), nullptr }); @@ -172,7 +172,7 @@ TEST(cfi_test, early_init) { // at startup. TEST(cfi_test, early_init2) { #if defined(__BIONIC__) - std::string helper = GetTestlibRoot() + "/cfi_test_helper2"; + std::string helper = GetTestLibRoot() + "/cfi_test_helper2"; chmod(helper.c_str(), 0755); // TODO: "x" lost in CTS, b/34945607 ExecTestHelper eth; eth.SetArgs({ helper.c_str(), nullptr }); diff --git a/tests/dl_test.cpp b/tests/dl_test.cpp index 2f3e9056f..434eee5b0 100644 --- a/tests/dl_test.cpp +++ b/tests/dl_test.cpp @@ -118,7 +118,7 @@ TEST(dl, exec_linker) { TEST(dl, exec_linker_load_file) { #if defined(__BIONIC__) const char* path_to_linker = PathToLinker(); - std::string helper = GetTestlibRoot() + "/exec_linker_helper"; + std::string helper = GetTestLibRoot() + "/exec_linker_helper"; std::string expected_output = "ctor: argc=1 argv[0]=" + helper + "\n" + "main: argc=1 argv[0]=" + helper + "\n" + @@ -134,7 +134,7 @@ TEST(dl, exec_linker_load_file) { TEST(dl, exec_linker_load_from_zip) { #if defined(__BIONIC__) const char* path_to_linker = PathToLinker(); - std::string helper = GetTestlibRoot() + + std::string helper = GetTestLibRoot() + "/libdlext_test_zip/libdlext_test_zip_zipaligned.zip!/libdir/exec_linker_helper"; std::string expected_output = "ctor: argc=1 argv[0]=" + helper + "\n" + @@ -161,7 +161,7 @@ TEST(dl, exec_linker_load_self) { TEST(dl, preinit_system_calls) { #if defined(__BIONIC__) SKIP_WITH_HWASAN << "hwasan not initialized in preinit_array, b/124007027"; - std::string helper = GetTestlibRoot() + "/preinit_syscall_test_helper"; + std::string helper = GetTestLibRoot() + "/preinit_syscall_test_helper"; chmod(helper.c_str(), 0755); // TODO: "x" lost in CTS, b/34945607 ExecTestHelper eth; eth.SetArgs({ helper.c_str(), nullptr }); @@ -172,7 +172,7 @@ TEST(dl, preinit_system_calls) { TEST(dl, preinit_getauxval) { #if defined(__BIONIC__) SKIP_WITH_HWASAN << "hwasan not initialized in preinit_array, b/124007027"; - std::string helper = GetTestlibRoot() + "/preinit_getauxval_test_helper"; + std::string helper = GetTestLibRoot() + "/preinit_getauxval_test_helper"; chmod(helper.c_str(), 0755); // TODO: "x" lost in CTS, b/34945607 ExecTestHelper eth; eth.SetArgs({ helper.c_str(), nullptr }); @@ -186,7 +186,7 @@ TEST(dl, preinit_getauxval) { TEST(dl, exec_without_ld_preload) { #if defined(__BIONIC__) - std::string helper = GetTestlibRoot() + "/ld_preload_test_helper"; + std::string helper = GetTestLibRoot() + "/ld_preload_test_helper"; chmod(helper.c_str(), 0755); ExecTestHelper eth; eth.SetArgs({ helper.c_str(), nullptr }); @@ -196,8 +196,8 @@ TEST(dl, exec_without_ld_preload) { TEST(dl, exec_with_ld_preload) { #if defined(__BIONIC__) - std::string helper = GetTestlibRoot() + "/ld_preload_test_helper"; - std::string env = std::string("LD_PRELOAD=") + GetTestlibRoot() + "/ld_preload_test_helper_lib2.so"; + std::string helper = GetTestLibRoot() + "/ld_preload_test_helper"; + std::string env = std::string("LD_PRELOAD=") + GetTestLibRoot() + "/ld_preload_test_helper_lib2.so"; chmod(helper.c_str(), 0755); ExecTestHelper eth; eth.SetArgs({ helper.c_str(), nullptr }); @@ -222,10 +222,10 @@ TEST(dl, exec_with_ld_preload) { // The two libs are in ns2/ subdir. TEST(dl, exec_without_ld_config_file) { #if defined(__BIONIC__) - std::string error_message = "CANNOT LINK EXECUTABLE \"" + GetTestlibRoot() + + std::string error_message = "CANNOT LINK EXECUTABLE \"" + GetTestLibRoot() + "/ld_config_test_helper\": library \"ld_config_test_helper_lib1.so\" " "not found: needed by main executable\n"; - std::string helper = GetTestlibRoot() + "/ld_config_test_helper"; + std::string helper = GetTestLibRoot() + "/ld_config_test_helper"; chmod(helper.c_str(), 0755); ExecTestHelper eth; eth.SetArgs({ helper.c_str(), nullptr }); @@ -240,15 +240,15 @@ static void create_ld_config_file(const char* config_file) { android_get_LD_LIBRARY_PATH(default_search_paths, sizeof(default_search_paths)); std::ofstream fout(config_file, std::ios::out); - fout << "dir.test = " << GetTestlibRoot() << "/" << std::endl + fout << "dir.test = " << GetTestLibRoot() << "/" << std::endl << "[test]" << std::endl << "additional.namespaces = ns2" << std::endl - << "namespace.default.search.paths = " << GetTestlibRoot() << std::endl + << "namespace.default.search.paths = " << GetTestLibRoot() << std::endl << "namespace.default.links = ns2" << std::endl << "namespace.default.link.ns2.shared_libs = " "libc.so:libm.so:libdl.so:ld_config_test_helper_lib1.so" << std::endl - << "namespace.ns2.search.paths = " << default_search_paths << ":" << GetTestlibRoot() + << "namespace.ns2.search.paths = " << default_search_paths << ":" << GetTestLibRoot() << "/ns2" << std::endl; fout.close(); } @@ -279,7 +279,7 @@ TEST(dl, exec_with_ld_config_file) { if (is_user_build()) { GTEST_SKIP() << "LD_CONFIG_FILE is not supported on user build"; } - std::string helper = GetTestlibRoot() + "/ld_config_test_helper"; + std::string helper = GetTestLibRoot() + "/ld_config_test_helper"; TemporaryFile config_file; create_ld_config_file(config_file.path); std::string env = std::string("LD_CONFIG_FILE=") + config_file.path; @@ -315,11 +315,11 @@ TEST(dl, exec_with_ld_config_file_with_ld_preload) { if (is_user_build()) { GTEST_SKIP() << "LD_CONFIG_FILE is not supported on user build"; } - std::string helper = GetTestlibRoot() + "/ld_config_test_helper"; + std::string helper = GetTestLibRoot() + "/ld_config_test_helper"; TemporaryFile config_file; create_ld_config_file(config_file.path); std::string env = std::string("LD_CONFIG_FILE=") + config_file.path; - std::string env2 = std::string("LD_PRELOAD=") + GetTestlibRoot() + "/ld_config_test_helper_lib3.so"; + std::string env2 = std::string("LD_PRELOAD=") + GetTestLibRoot() + "/ld_config_test_helper_lib3.so"; chmod(helper.c_str(), 0755); ExecTestHelper eth; eth.SetArgs({ helper.c_str(), nullptr }); @@ -353,10 +353,10 @@ TEST(dl, disable_ld_config_file) { } std::string error_message = - std::string("CANNOT LINK EXECUTABLE ") + "\"" + GetTestlibRoot() + + std::string("CANNOT LINK EXECUTABLE ") + "\"" + GetTestLibRoot() + "/ld_config_test_helper\": " + "library \"ld_config_test_helper_lib1.so\" not found: needed by main executable\n"; - std::string helper = GetTestlibRoot() + "/ld_config_test_helper"; + std::string helper = GetTestLibRoot() + "/ld_config_test_helper"; TemporaryFile config_file; create_ld_config_file(config_file.path); std::string env = std::string("LD_CONFIG_FILE=") + config_file.path; @@ -371,7 +371,7 @@ TEST(dl, disable_ld_config_file) { static void RelocationsTest(const char* lib, const char* expectation) { #if defined(__BIONIC__) // Does readelf think the .so file looks right? - const std::string path = GetTestlibRoot() + "/" + lib; + const std::string path = GetTestLibRoot() + "/" + lib; ExecTestHelper eth; eth.SetArgs({ "readelf", "-SW", path.c_str(), nullptr }); eth.Run([&]() { execvpe("readelf", eth.GetArgs(), eth.GetEnv()); }, 0, nullptr); diff --git a/tests/dlext_test.cpp b/tests/dlext_test.cpp index d078e500b..a0f037a15 100644 --- a/tests/dlext_test.cpp +++ b/tests/dlext_test.cpp @@ -107,7 +107,7 @@ TEST_F(DlExtTest, ExtInfoNoFlags) { } TEST_F(DlExtTest, ExtInfoUseFd) { - const std::string lib_path = GetTestlibRoot() + "/libdlext_test_fd/libdlext_test_fd.so"; + const std::string lib_path = GetTestLibRoot() + "/libdlext_test_fd/libdlext_test_fd.so"; android_dlextinfo extinfo; extinfo.flags = ANDROID_DLEXT_USE_LIBRARY_FD; @@ -125,7 +125,7 @@ TEST_F(DlExtTest, ExtInfoUseFd) { } TEST_F(DlExtTest, ExtInfoUseFdWithOffset) { - const std::string lib_path = GetTestlibRoot() + "/libdlext_test_zip/libdlext_test_zip_zipaligned.zip"; + const std::string lib_path = GetTestLibRoot() + "/libdlext_test_zip/libdlext_test_zip_zipaligned.zip"; android_dlextinfo extinfo; extinfo.flags = ANDROID_DLEXT_USE_LIBRARY_FD | ANDROID_DLEXT_USE_LIBRARY_FD_OFFSET; @@ -148,7 +148,7 @@ TEST_F(DlExtTest, ExtInfoUseFdWithOffset) { } TEST_F(DlExtTest, ExtInfoUseFdWithInvalidOffset) { - const std::string lib_path = GetTestlibRoot() + "/libdlext_test_zip/libdlext_test_zip_zipaligned.zip"; + const std::string lib_path = GetTestLibRoot() + "/libdlext_test_zip/libdlext_test_zip_zipaligned.zip"; android_dlextinfo extinfo; extinfo.flags = ANDROID_DLEXT_USE_LIBRARY_FD | ANDROID_DLEXT_USE_LIBRARY_FD_OFFSET; @@ -258,7 +258,7 @@ TEST(dlfcn, dlopen_system_libicuuc_android_api_level_current) { TEST(dlfcn, dlopen_from_zip_absolute_path) { const std::string lib_zip_path = "/libdlext_test_zip/libdlext_test_zip_zipaligned.zip"; - const std::string lib_path = GetTestlibRoot() + lib_zip_path; + const std::string lib_path = GetTestLibRoot() + lib_zip_path; void* handle = dlopen((lib_path + "!/libdir/libatest_simple_zip.so").c_str(), RTLD_NOW); ASSERT_TRUE(handle != nullptr) << dlerror(); @@ -272,7 +272,7 @@ TEST(dlfcn, dlopen_from_zip_absolute_path) { TEST(dlfcn, dlopen_from_zip_with_dt_runpath) { const std::string lib_zip_path = "/libdlext_test_runpath_zip/libdlext_test_runpath_zip_zipaligned.zip"; - const std::string lib_path = GetTestlibRoot() + lib_zip_path; + const std::string lib_path = GetTestLibRoot() + lib_zip_path; void* handle = dlopen((lib_path + "!/libdir/libtest_dt_runpath_d_zip.so").c_str(), RTLD_NOW); @@ -291,7 +291,7 @@ TEST(dlfcn, dlopen_from_zip_with_dt_runpath) { TEST(dlfcn, dlopen_from_zip_ld_library_path) { const std::string lib_zip_path = "/libdlext_test_zip/libdlext_test_zip_zipaligned.zip"; - const std::string lib_path = GetTestlibRoot() + lib_zip_path + "!/libdir"; + const std::string lib_path = GetTestLibRoot() + lib_zip_path + "!/libdir"; typedef void (*fn_t)(const char*); fn_t android_update_LD_LIBRARY_PATH = @@ -742,7 +742,7 @@ TEST(dlext, ns_smoke) { " \"(anonymous)\"->\"(default)\": the list of shared libraries is empty.", dlerror()); - const std::string lib_public_path = GetTestlibRoot() + "/public_namespace_libs/" + g_public_lib; + const std::string lib_public_path = GetTestLibRoot() + "/public_namespace_libs/" + g_public_lib; void* handle_public = dlopen(lib_public_path.c_str(), RTLD_NOW); ASSERT_TRUE(handle_public != nullptr) << dlerror(); @@ -762,7 +762,7 @@ TEST(dlext, ns_smoke) { android_namespace_t* ns1 = android_create_namespace("private", nullptr, - (GetTestlibRoot() + "/private_namespace_libs").c_str(), + (GetTestLibRoot() + "/private_namespace_libs").c_str(), ANDROID_NAMESPACE_TYPE_REGULAR, nullptr, nullptr); @@ -772,7 +772,7 @@ TEST(dlext, ns_smoke) { android_namespace_t* ns2 = android_create_namespace("private_isolated", nullptr, - (GetTestlibRoot() + "/private_namespace_libs").c_str(), + (GetTestLibRoot() + "/private_namespace_libs").c_str(), ANDROID_NAMESPACE_TYPE_ISOLATED, nullptr, nullptr); @@ -916,10 +916,10 @@ TEST(dlext, ns_smoke) { } TEST(dlext, dlopen_ext_use_o_tmpfile_fd) { - const std::string lib_path = GetTestlibRoot() + "/libtest_simple.so"; + const std::string lib_path = GetTestLibRoot() + "/libtest_simple.so"; int tmpfd = TEMP_FAILURE_RETRY( - open(GetTestlibRoot().c_str(), O_TMPFILE | O_CLOEXEC | O_RDWR | O_EXCL, 0)); + open(GetTestLibRoot().c_str(), O_TMPFILE | O_CLOEXEC | O_RDWR | O_EXCL, 0)); // Ignore kernels without O_TMPFILE flag support if (tmpfd == -1 && (errno == EISDIR || errno == EINVAL || errno == EOPNOTSUPP)) { @@ -931,7 +931,7 @@ TEST(dlext, dlopen_ext_use_o_tmpfile_fd) { android_namespace_t* ns = android_create_namespace("testing-o_tmpfile", nullptr, - GetTestlibRoot().c_str(), + GetTestLibRoot().c_str(), ANDROID_NAMESPACE_TYPE_ISOLATED, nullptr, nullptr); @@ -960,7 +960,7 @@ TEST(dlext, dlopen_ext_use_o_tmpfile_fd) { } TEST(dlext, dlopen_ext_use_memfd) { - const std::string lib_path = GetTestlibRoot() + "/libtest_simple.so"; + const std::string lib_path = GetTestLibRoot() + "/libtest_simple.so"; // create memfd int memfd = memfd_create("foobar", MFD_CLOEXEC); @@ -975,7 +975,7 @@ TEST(dlext, dlopen_ext_use_memfd) { android_namespace_t* ns = android_create_namespace("testing-memfd", nullptr, - GetTestlibRoot().c_str(), + GetTestLibRoot().c_str(), ANDROID_NAMESPACE_TYPE_ISOLATED, nullptr, nullptr); @@ -1008,8 +1008,8 @@ TEST(dlext, ns_symbol_visibilty_one_namespace) { static const char* root_lib = "libnstest_root.so"; ASSERT_TRUE(android_init_anonymous_namespace(g_core_shared_libs.c_str(), nullptr)); - const std::string ns_search_path = GetTestlibRoot() + "/public_namespace_libs:" + - GetTestlibRoot() + "/private_namespace_libs"; + const std::string ns_search_path = GetTestLibRoot() + "/public_namespace_libs:" + + GetTestLibRoot() + "/private_namespace_libs"; android_namespace_t* ns = android_create_namespace("one", @@ -1046,8 +1046,8 @@ TEST(dlext, ns_symbol_visibilty_between_namespaces) { static const char* root_lib = "libnstest_root.so"; ASSERT_TRUE(android_init_anonymous_namespace(g_core_shared_libs.c_str(), nullptr)); - const std::string public_ns_search_path = GetTestlibRoot() + "/public_namespace_libs"; - const std::string private_ns_search_path = GetTestlibRoot() + "/private_namespace_libs"; + const std::string public_ns_search_path = GetTestLibRoot() + "/public_namespace_libs"; + const std::string private_ns_search_path = GetTestLibRoot() + "/private_namespace_libs"; android_namespace_t* ns_public = android_create_namespace("public", @@ -1097,8 +1097,8 @@ TEST(dlext, ns_unload_between_namespaces) { static const char* root_lib = "libnstest_root.so"; ASSERT_TRUE(android_init_anonymous_namespace(g_core_shared_libs.c_str(), nullptr)); - const std::string public_ns_search_path = GetTestlibRoot() + "/public_namespace_libs"; - const std::string private_ns_search_path = GetTestlibRoot() + "/private_namespace_libs"; + const std::string public_ns_search_path = GetTestLibRoot() + "/public_namespace_libs"; + const std::string private_ns_search_path = GetTestLibRoot() + "/private_namespace_libs"; android_namespace_t* ns_public = android_create_namespace("public", @@ -1146,8 +1146,8 @@ TEST(dlext, ns_unload_between_namespaces) { TEST(dlext, ns_unload_between_namespaces_missing_symbol_direct) { ASSERT_TRUE(android_init_anonymous_namespace(g_core_shared_libs.c_str(), nullptr)); - const std::string public_ns_search_path = GetTestlibRoot() + "/public_namespace_libs"; - const std::string private_ns_search_path = GetTestlibRoot() + "/private_namespace_libs"; + const std::string public_ns_search_path = GetTestLibRoot() + "/public_namespace_libs"; + const std::string private_ns_search_path = GetTestLibRoot() + "/private_namespace_libs"; android_namespace_t* ns_public = android_create_namespace("public", @@ -1186,8 +1186,8 @@ TEST(dlext, ns_unload_between_namespaces_missing_symbol_direct) { TEST(dlext, ns_unload_between_namespaces_missing_symbol_indirect) { ASSERT_TRUE(android_init_anonymous_namespace(g_core_shared_libs.c_str(), nullptr)); - const std::string public_ns_search_path = GetTestlibRoot() + "/public_namespace_libs"; - const std::string private_ns_search_path = GetTestlibRoot() + "/private_namespace_libs"; + const std::string public_ns_search_path = GetTestLibRoot() + "/public_namespace_libs"; + const std::string private_ns_search_path = GetTestLibRoot() + "/private_namespace_libs"; android_namespace_t* ns_public = android_create_namespace("public", @@ -1227,7 +1227,7 @@ TEST(dlext, ns_unload_between_namespaces_missing_symbol_indirect) { TEST(dlext, ns_exempt_list_enabled) { ASSERT_TRUE(android_init_anonymous_namespace(g_core_shared_libs.c_str(), nullptr)); - const std::string ns_search_path = GetTestlibRoot() + "/private_namespace_libs"; + const std::string ns_search_path = GetTestLibRoot() + "/private_namespace_libs"; android_namespace_t* ns = android_create_namespace("namespace", @@ -1265,7 +1265,7 @@ TEST(dlext, ns_exempt_list_enabled) { TEST(dlext, ns_exempt_list_disabled_by_default) { ASSERT_TRUE(android_init_anonymous_namespace(g_core_shared_libs.c_str(), nullptr)); - const std::string ns_search_path = GetTestlibRoot() + "/private_namespace_libs"; + const std::string ns_search_path = GetTestLibRoot() + "/private_namespace_libs"; android_namespace_t* ns = android_create_namespace("namespace", @@ -1292,7 +1292,7 @@ TEST(dlext, ns_cyclic_namespaces) { ASSERT_TRUE(android_init_anonymous_namespace(g_core_shared_libs.c_str(), nullptr)); std::string shared_libs = g_core_shared_libs + ":libthatdoesnotexist.so"; - const std::string ns_search_path = GetTestlibRoot() + "/public_namespace_libs"; + const std::string ns_search_path = GetTestLibRoot() + "/public_namespace_libs"; android_namespace_t* ns1 = android_create_namespace("ns1", @@ -1330,7 +1330,7 @@ TEST(dlext, ns_isolated) { static const char* root_lib = "libnstest_root_not_isolated.so"; std::string shared_libs = g_core_shared_libs + ":" + g_public_lib; - const std::string lib_public_path = GetTestlibRoot() + "/public_namespace_libs/" + g_public_lib; + const std::string lib_public_path = GetTestLibRoot() + "/public_namespace_libs/" + g_public_lib; void* handle_public = dlopen(lib_public_path.c_str(), RTLD_NOW); ASSERT_TRUE(handle_public != nullptr) << dlerror(); @@ -1341,7 +1341,7 @@ TEST(dlext, ns_isolated) { android_namespace_t* ns_not_isolated = android_create_namespace("private", nullptr, - (GetTestlibRoot() + "/private_namespace_libs").c_str(), + (GetTestLibRoot() + "/private_namespace_libs").c_str(), ANDROID_NAMESPACE_TYPE_REGULAR, nullptr, nullptr); @@ -1351,7 +1351,7 @@ TEST(dlext, ns_isolated) { android_namespace_t* ns_isolated = android_create_namespace("private_isolated1", nullptr, - (GetTestlibRoot() + "/private_namespace_libs").c_str(), + (GetTestLibRoot() + "/private_namespace_libs").c_str(), ANDROID_NAMESPACE_TYPE_ISOLATED, nullptr, nullptr); @@ -1360,10 +1360,10 @@ TEST(dlext, ns_isolated) { android_namespace_t* ns_isolated2 = android_create_namespace("private_isolated2", - (GetTestlibRoot() + "/private_namespace_libs").c_str(), + (GetTestLibRoot() + "/private_namespace_libs").c_str(), nullptr, ANDROID_NAMESPACE_TYPE_ISOLATED, - GetTestlibRoot().c_str(), + GetTestLibRoot().c_str(), nullptr); ASSERT_TRUE(ns_isolated2 != nullptr) << dlerror(); ASSERT_TRUE(android_link_namespaces(ns_isolated2, nullptr, shared_libs.c_str())) << dlerror(); @@ -1372,7 +1372,7 @@ TEST(dlext, ns_isolated) { ASSERT_STREQ("dlopen failed: library \"libnstest_root_not_isolated.so\" not found", dlerror()); std::string lib_private_external_path = - GetTestlibRoot() + "/private_namespace_libs_external/libnstest_private_external.so"; + GetTestLibRoot() + "/private_namespace_libs_external/libnstest_private_external.so"; // Load lib_private_external_path to default namespace // (it should remain invisible for the isolated namespaces after this) @@ -1404,7 +1404,7 @@ TEST(dlext, ns_isolated) { extinfo.library_namespace = ns_isolated2; - // this should work because isolation_path for private_isolated2 includes GetTestlibRoot() + // this should work because isolation_path for private_isolated2 includes GetTestLibRoot() handle2 = android_dlopen_ext(root_lib, RTLD_NOW, &extinfo); ASSERT_TRUE(handle2 != nullptr) << dlerror(); dlclose(handle2); @@ -1463,7 +1463,7 @@ TEST(dlext, ns_shared) { extinfo.flags = ANDROID_DLEXT_USE_NAMESPACE; extinfo.library_namespace = ns_parent; - const std::string lib_public_path = GetTestlibRoot() + "/public_namespace_libs/" + g_public_lib; + const std::string lib_public_path = GetTestLibRoot() + "/public_namespace_libs/" + g_public_lib; void* handle_public = android_dlopen_ext(lib_public_path.c_str(), RTLD_NOW, &extinfo); ASSERT_TRUE(handle_public != nullptr) << dlerror(); @@ -1474,7 +1474,7 @@ TEST(dlext, ns_shared) { // preload this library to the parent namespace to check if it // is shared later on. void* handle_dlopened = - android_dlopen_ext((GetTestlibRoot() + "/private_namespace_libs/libnstest_dlopened.so").c_str(), RTLD_NOW, &extinfo); + android_dlopen_ext((GetTestLibRoot() + "/private_namespace_libs/libnstest_dlopened.so").c_str(), RTLD_NOW, &extinfo); ASSERT_TRUE(handle_dlopened != nullptr) << dlerror(); // create two child namespaces of 'ns_parent'. One with regular, the other @@ -1482,7 +1482,7 @@ TEST(dlext, ns_shared) { android_namespace_t* ns_not_isolated = android_create_namespace("private", nullptr, - (GetTestlibRoot() + "/private_namespace_libs").c_str(), + (GetTestLibRoot() + "/private_namespace_libs").c_str(), ANDROID_NAMESPACE_TYPE_REGULAR, nullptr, ns_parent); @@ -1493,7 +1493,7 @@ TEST(dlext, ns_shared) { android_namespace_t* ns_isolated_shared = android_create_namespace("private_isolated_shared", nullptr, - (GetTestlibRoot() + "/private_namespace_libs").c_str(), + (GetTestLibRoot() + "/private_namespace_libs").c_str(), ANDROID_NAMESPACE_TYPE_ISOLATED | ANDROID_NAMESPACE_TYPE_SHARED, nullptr, ns_parent); @@ -1505,7 +1505,7 @@ TEST(dlext, ns_shared) { ASSERT_STREQ("dlopen failed: library \"libnstest_root_not_isolated.so\" not found", dlerror()); std::string lib_private_external_path = - GetTestlibRoot() + "/private_namespace_libs_external/libnstest_private_external.so"; + GetTestLibRoot() + "/private_namespace_libs_external/libnstest_private_external.so"; // Load lib_private_external_path to the parent namespace // (it should remain invisible for the isolated namespaces after this) @@ -1591,9 +1591,9 @@ TEST(dlext, ns_shared_links_and_paths) { android_namespace_t* ns_isolated = android_create_namespace("private_isolated", nullptr, - (GetTestlibRoot() + "/private_namespace_libs").c_str(), + (GetTestLibRoot() + "/private_namespace_libs").c_str(), ANDROID_NAMESPACE_TYPE_ISOLATED, - (GetTestlibRoot() + "/public_namespace_libs").c_str(), + (GetTestLibRoot() + "/public_namespace_libs").c_str(), nullptr); ASSERT_TRUE(ns_isolated != nullptr) << dlerror(); ASSERT_TRUE(android_link_namespaces(ns_isolated, nullptr, g_core_shared_libs.c_str())) << dlerror(); @@ -1627,7 +1627,7 @@ TEST(dlext, ns_shared_links_and_paths) { // it has inherited permitted_when_isolated_path { void* handle = android_dlopen_ext( - (GetTestlibRoot() + "/public_namespace_libs/libnstest_public.so").c_str(), + (GetTestLibRoot() + "/public_namespace_libs/libnstest_public.so").c_str(), RTLD_NOW, &extinfo); @@ -1642,7 +1642,7 @@ TEST(dlext, ns_shared_links_and_paths) { // 3. Check that it is still isolated. { void* handle = android_dlopen_ext( - (GetTestlibRoot() + "/libtest_empty.so").c_str(), + (GetTestLibRoot() + "/libtest_empty.so").c_str(), RTLD_NOW, &extinfo); @@ -1658,13 +1658,13 @@ TEST(dlext, ns_shared_dlclose) { // preload this library to the default namespace to check if it // is shared later on. void* handle_dlopened = - dlopen((GetTestlibRoot() + "/private_namespace_libs/libnstest_dlopened.so").c_str(), RTLD_NOW); + dlopen((GetTestLibRoot() + "/private_namespace_libs/libnstest_dlopened.so").c_str(), RTLD_NOW); ASSERT_TRUE(handle_dlopened != nullptr) << dlerror(); android_namespace_t* ns_isolated_shared = android_create_namespace("private_isolated_shared", nullptr, - (GetTestlibRoot() + "/private_namespace_libs").c_str(), + (GetTestLibRoot() + "/private_namespace_libs").c_str(), ANDROID_NAMESPACE_TYPE_ISOLATED | ANDROID_NAMESPACE_TYPE_SHARED, nullptr, nullptr); @@ -1687,7 +1687,7 @@ TEST(dlext, ns_shared_dlclose) { ASSERT_TRUE(handle == nullptr) << "Error: libnstest_dlopened.so is still accessible in shared namespace"; - handle = android_dlopen_ext((GetTestlibRoot() + "/private_namespace_libs/libnstest_dlopened.so").c_str(), + handle = android_dlopen_ext((GetTestLibRoot() + "/private_namespace_libs/libnstest_dlopened.so").c_str(), RTLD_NOW | RTLD_NOLOAD, &extinfo); ASSERT_TRUE(handle == nullptr) << "Error: libnstest_dlopened.so is still accessible in shared namespace"; @@ -1696,14 +1696,14 @@ TEST(dlext, ns_shared_dlclose) { ASSERT_TRUE(handle == nullptr) << "Error: libnstest_dlopened.so is still accessible in default namespace"; - handle = dlopen((GetTestlibRoot() + "/private_namespace_libs/libnstest_dlopened.so").c_str(), + handle = dlopen((GetTestLibRoot() + "/private_namespace_libs/libnstest_dlopened.so").c_str(), RTLD_NOW | RTLD_NOLOAD); ASSERT_TRUE(handle == nullptr) << "Error: libnstest_dlopened.so is still accessible in default namespace"; // Now lets see if the soinfo area gets reused in the wrong way: // load a library to default namespace. - const std::string lib_public_path = GetTestlibRoot() + "/public_namespace_libs/" + g_public_lib; + const std::string lib_public_path = GetTestLibRoot() + "/public_namespace_libs/" + g_public_lib; void* handle_public = dlopen(lib_public_path.c_str(), RTLD_NOW); ASSERT_TRUE(handle_public != nullptr) << dlerror(); @@ -1717,12 +1717,12 @@ TEST(dlext, ns_isolated_rtld_global) { static const char* root_lib = "libnstest_root.so"; ASSERT_TRUE(android_init_anonymous_namespace(g_core_shared_libs.c_str(), nullptr)); - const std::string lib_public_path = GetTestlibRoot() + "/public_namespace_libs"; + const std::string lib_public_path = GetTestLibRoot() + "/public_namespace_libs"; android_namespace_t* ns1 = android_create_namespace("isolated1", nullptr, - (GetTestlibRoot() + "/private_namespace_libs").c_str(), + (GetTestLibRoot() + "/private_namespace_libs").c_str(), ANDROID_NAMESPACE_TYPE_ISOLATED, lib_public_path.c_str(), nullptr); @@ -1732,7 +1732,7 @@ TEST(dlext, ns_isolated_rtld_global) { android_namespace_t* ns2 = android_create_namespace("isolated2", nullptr, - (GetTestlibRoot() + "/private_namespace_libs").c_str(), + (GetTestLibRoot() + "/private_namespace_libs").c_str(), ANDROID_NAMESPACE_TYPE_ISOLATED, lib_public_path.c_str(), nullptr); @@ -1752,7 +1752,7 @@ TEST(dlext, ns_isolated_rtld_global) { android_namespace_t* ns1_child = android_create_namespace("isolated1_child", nullptr, - (GetTestlibRoot() + "/private_namespace_libs").c_str(), + (GetTestLibRoot() + "/private_namespace_libs").c_str(), ANDROID_NAMESPACE_TYPE_ISOLATED, nullptr, ns1); @@ -1802,7 +1802,7 @@ TEST(dlext, ns_inaccessible_error_message) { android_namespace_t* ns_a = android_create_namespace("ns_a", nullptr, - (GetTestlibRoot() + "/private_namespace_libs").c_str(), + (GetTestLibRoot() + "/private_namespace_libs").c_str(), ANDROID_NAMESPACE_TYPE_ISOLATED, nullptr, nullptr); @@ -1812,7 +1812,7 @@ TEST(dlext, ns_inaccessible_error_message) { android_namespace_t* ns_b = android_create_namespace("ns_b", nullptr, - GetTestlibRoot().c_str(), + GetTestLibRoot().c_str(), ANDROID_NAMESPACE_TYPE_ISOLATED, nullptr, nullptr); @@ -1825,7 +1825,7 @@ TEST(dlext, ns_inaccessible_error_message) { extinfo.flags = ANDROID_DLEXT_USE_NAMESPACE; extinfo.library_namespace = ns_a; - std::string library_path = GetTestlibRoot() + "/inaccessible_libs/libtestshared.so"; + std::string library_path = GetTestLibRoot() + "/inaccessible_libs/libtestshared.so"; void* handle = android_dlopen_ext(library_path.c_str(), RTLD_NOW, &extinfo); ASSERT_TRUE(handle == nullptr); @@ -1846,7 +1846,7 @@ TEST(dlext, ns_link_namespaces_invalid_arguments) { android_namespace_t* ns = android_create_namespace("private", nullptr, - (GetTestlibRoot() + "/private_namespace_libs").c_str(), + (GetTestLibRoot() + "/private_namespace_libs").c_str(), ANDROID_NAMESPACE_TYPE_REGULAR, nullptr, nullptr); @@ -1887,7 +1887,7 @@ TEST(dlext, ns_allow_all_shared_libs) { android_namespace_t* ns_a = android_create_namespace("ns_a", nullptr, - (GetTestlibRoot() + "/ns_a").c_str(), + (GetTestLibRoot() + "/ns_a").c_str(), ANDROID_NAMESPACE_TYPE_ISOLATED, nullptr, nullptr); @@ -1897,7 +1897,7 @@ TEST(dlext, ns_allow_all_shared_libs) { android_namespace_t* ns_b = android_create_namespace("ns_b", nullptr, - (GetTestlibRoot() + "/ns_b").c_str(), + (GetTestLibRoot() + "/ns_b").c_str(), ANDROID_NAMESPACE_TYPE_ISOLATED, nullptr, nullptr); @@ -1961,20 +1961,20 @@ TEST(dlext, ns_anonymous) { static const char* root_lib = "libnstest_root.so"; std::string shared_libs = g_core_shared_libs + ":" + g_public_lib; - const std::string lib_public_path = GetTestlibRoot() + "/public_namespace_libs/" + g_public_lib; + const std::string lib_public_path = GetTestLibRoot() + "/public_namespace_libs/" + g_public_lib; void* handle_public = dlopen(lib_public_path.c_str(), RTLD_NOW); ASSERT_TRUE(handle_public != nullptr) << dlerror(); ASSERT_TRUE( android_init_anonymous_namespace(shared_libs.c_str(), - (GetTestlibRoot() + "/private_namespace_libs").c_str()) + (GetTestLibRoot() + "/private_namespace_libs").c_str()) ) << dlerror(); android_namespace_t* ns = android_create_namespace("private", nullptr, - (GetTestlibRoot() + "/private_namespace_libs").c_str(), + (GetTestLibRoot() + "/private_namespace_libs").c_str(), ANDROID_NAMESPACE_TYPE_REGULAR, nullptr, nullptr); @@ -1982,7 +1982,7 @@ TEST(dlext, ns_anonymous) { ASSERT_TRUE(ns != nullptr) << dlerror(); ASSERT_TRUE(android_link_namespaces(ns, nullptr, shared_libs.c_str())) << dlerror(); - std::string private_library_absolute_path = GetTestlibRoot() + "/private_namespace_libs/" + root_lib; + std::string private_library_absolute_path = GetTestLibRoot() + "/private_namespace_libs/" + root_lib; android_dlextinfo extinfo; extinfo.flags = ANDROID_DLEXT_USE_NAMESPACE; @@ -2073,13 +2073,13 @@ TEST(dlext, ns_anonymous) { TEST(dlext, ns_hidden_child) { ExecTestHelper eth; - std::string helper = GetTestlibRoot() + "/ns_hidden_child_helper"; + std::string helper = GetTestLibRoot() + "/ns_hidden_child_helper"; chmod(helper.c_str(), 0755); // TODO: "x" lost in CTS, b/34945607 - std::string app_ns_dir = GetTestlibRoot() + "/ns_hidden_child_app"; + std::string app_ns_dir = GetTestLibRoot() + "/ns_hidden_child_app"; eth.SetArgs({ helper.c_str(), app_ns_dir.c_str(), nullptr }); // Add the main libns_hidden_child_*.so libraries to the search path of the default namespace. - std::string env = "LD_LIBRARY_PATH=" + GetTestlibRoot(); + std::string env = "LD_LIBRARY_PATH=" + GetTestLibRoot(); eth.SetEnv({ env.c_str(), nullptr }); eth.Run([&]() { execve(helper.c_str(), eth.GetArgs(), eth.GetEnv()); }, 0, diff --git a/tests/dlfcn_test.cpp b/tests/dlfcn_test.cpp index 5b3eaf87d..c27adb6d1 100644 --- a/tests/dlfcn_test.cpp +++ b/tests/dlfcn_test.cpp @@ -1301,7 +1301,7 @@ TEST(dlfcn, dt_runpath_smoke) { } TEST(dlfcn, dt_runpath_absolute_path) { - std::string libpath = GetTestlibRoot() + "/libtest_dt_runpath_d.so"; + std::string libpath = GetTestLibRoot() + "/libtest_dt_runpath_d.so"; void* handle = dlopen(libpath.c_str(), RTLD_NOW); ASSERT_TRUE(handle != nullptr) << dlerror(); diff --git a/tests/elftls_dl_test.cpp b/tests/elftls_dl_test.cpp index bcb2b40b3..e160958f1 100644 --- a/tests/elftls_dl_test.cpp +++ b/tests/elftls_dl_test.cpp @@ -68,9 +68,9 @@ TEST(elftls_dl, dlopen_shared_var_ie) { } TEST(elftls_dl, dlopen_ie_error) { - std::string helper = GetTestlibRoot() + "/elftls_dlopen_ie_error_helper"; - std::string src_path = GetTestlibRoot() + "/libtest_elftls_shared_var_ie.so"; - std::string dst_path = GetTestlibRoot() + "/libtest_elftls_shared_var.so"; + std::string helper = GetTestLibRoot() + "/elftls_dlopen_ie_error_helper"; + std::string src_path = GetTestLibRoot() + "/libtest_elftls_shared_var_ie.so"; + std::string dst_path = GetTestLibRoot() + "/libtest_elftls_shared_var.so"; #if defined(__BIONIC__) std::string error = "dlerror: dlopen failed: TLS symbol \"elftls_shared_var\" in dlopened \"" + dst_path + "\" " + @@ -154,7 +154,7 @@ TEST(elftls_dl, tlsdesc_missing_weak) { TEST(elftls_dl, dtv_resize) { #if defined(__BIONIC__) - std::string helper = GetTestlibRoot() + "/elftls_dtv_resize_helper"; + std::string helper = GetTestLibRoot() + "/elftls_dtv_resize_helper"; chmod(helper.c_str(), 0755); // TODO: "x" lost in CTS, b/34945607 ExecTestHelper eth; eth.SetArgs({helper.c_str(), nullptr}); @@ -273,7 +273,7 @@ TEST(elftls_dl, dladdr_skip_tls_symbol) { Dl_info info; ASSERT_NE(0, dladdr(local_addr, &info)); - std::string libpath = GetTestlibRoot() + "/libtest_elftls_dynamic.so"; + std::string libpath = GetTestLibRoot() + "/libtest_elftls_dynamic.so"; char dli_realpath[PATH_MAX]; ASSERT_TRUE(realpath(info.dli_fname, dli_realpath)); ASSERT_STREQ(libpath.c_str(), dli_realpath); diff --git a/tests/gtest_globals.cpp b/tests/gtest_globals.cpp index 11b2dffe2..f146c08bb 100644 --- a/tests/gtest_globals.cpp +++ b/tests/gtest_globals.cpp @@ -23,7 +23,7 @@ #include -std::string GetTestlibRoot() { +std::string GetTestLibRoot() { // Typically the executable is /data/nativetest[64]/bionic-unit-tests/bionic-unit-tests, and the // test libraries are in /data/nativetest[64]/bionic-unit-tests/bionic-loader-test-libs. std::string path = android::base::GetExecutableDirectory(); diff --git a/tests/gtest_globals.h b/tests/gtest_globals.h index 1bebb7006..3b780a402 100644 --- a/tests/gtest_globals.h +++ b/tests/gtest_globals.h @@ -19,10 +19,10 @@ #include -std::string GetTestlibRoot(); +std::string GetTestLibRoot(); inline std::string GetPrebuiltElfDir() { - return GetTestlibRoot() + "/prebuilt-elf-files"; + return GetTestLibRoot() + "/prebuilt-elf-files"; } #endif // _BIONIC_TESTS_GTEST_GLOBALS_H diff --git a/tests/heap_tagging_level_test.cpp b/tests/heap_tagging_level_test.cpp index b88d64a89..dd8eea3f6 100644 --- a/tests/heap_tagging_level_test.cpp +++ b/tests/heap_tagging_level_test.cpp @@ -247,7 +247,7 @@ TEST_P(MemtagNoteTest, SEGV) { bool isStatic = std::get<1>(GetParam()); std::string helper_base = std::string("heap_tagging_") + (isStatic ? "static_" : "") + kNoteSuffix[static_cast(note)] + "_helper"; - std::string helper = GetTestlibRoot() + "/" + helper_base; + std::string helper = GetTestLibRoot() + "/" + helper_base; chmod(helper.c_str(), 0755); ExecTestHelper eth; eth.SetArgs({helper.c_str(), nullptr}); diff --git a/tests/memtag_stack_test.cpp b/tests/memtag_stack_test.cpp index 97084ecf6..163fc112e 100644 --- a/tests/memtag_stack_test.cpp +++ b/tests/memtag_stack_test.cpp @@ -33,7 +33,7 @@ TEST_P(MemtagStackTest, test) { } bool is_static = std::get<1>(GetParam()); std::string helper = - GetTestlibRoot() + (is_static ? "/stack_tagging_static_helper" : "/stack_tagging_helper"); + GetTestLibRoot() + (is_static ? "/stack_tagging_static_helper" : "/stack_tagging_helper"); const char* arg = std::get<0>(GetParam()); chmod(helper.c_str(), 0755); ExecTestHelper eth;