Add bionic-unit-tests-gcc{32,64}, compiled with gcc.

* bionic-unit-tests{32,64} are compiled with clang/llvm.
* Skip one single test in __cxa_thread_atexit_test.cpp
  when compiled with aarch64 clang/llvm.
  Aarch64 clang/llvm generates relocation references to
  "thread_local" symbols not supported by Android linker.

BUG: 25642296
Change-Id: Ia0497b79c4b335228afeb48a26e0592217909953
This commit is contained in:
Chih-Hung Hsieh 2015-11-20 14:13:24 -08:00
parent a01108d9bf
commit f688c5d5b4
2 changed files with 53 additions and 11 deletions

View file

@ -272,18 +272,20 @@ include $(LOCAL_PATH)/Android.build.mk
# Tests for the device using bionic's .so. Run with:
# adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests32
# adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests64
# adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests-gcc32
# adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests-gcc64
# -----------------------------------------------------------------------------
bionic-unit-tests_whole_static_libraries := \
common_bionic-unit-tests_whole_static_libraries := \
libBionicTests \
libBionicGtestMain \
bionic-unit-tests_static_libraries := \
common_bionic-unit-tests_static_libraries := \
libtinyxml2 \
liblog \
libbase \
# TODO: Include __cxa_thread_atexit_test.cpp to glibc tests once it is upgraded (glibc 2.18+)
bionic-unit-tests_src_files := \
common_bionic-unit-tests_src_files := \
atexit_test.cpp \
dl_test.cpp \
dlext_test.cpp \
@ -293,32 +295,56 @@ bionic-unit-tests_src_files := \
pthread_dlfcn_test.cpp \
thread_local_test.cpp \
bionic-unit-tests_cflags := $(test_cflags)
common_bionic-unit-tests_cflags := $(test_cflags)
bionic-unit-tests_conlyflags := \
common_bionic-unit-tests_conlyflags := \
-fexceptions \
-fnon-call-exceptions \
bionic-unit-tests_cppflags := $(test_cppflags)
common_bionic-unit-tests_cppflags := $(test_cppflags)
bionic-unit-tests_ldflags := \
common_bionic-unit-tests_ldflags := \
-Wl,--export-dynamic
bionic-unit-tests_c_includes := \
common_bionic-unit-tests_c_includes := \
bionic/libc \
bionic-unit-tests_shared_libraries_target := \
common_bionic-unit-tests_shared_libraries_target := \
libdl \
libpagemap \
libdl_preempt_test_1 \
libdl_preempt_test_2
bionic-unit-tests_shared_libraries_target += libdl_test_df_1_global
common_bionic-unit-tests_shared_libraries_target += libdl_test_df_1_global
module := bionic-unit-tests
module_tag := optional
build_type := target
build_target := NATIVE_TEST
module := bionic-unit-tests
bionic-unit-tests_clang_target := true
bionic-unit-tests_whole_static_libraries := $(common_bionic-unit-tests_whole_static_libraries)
bionic-unit-tests_static_libraries := $(common_bionic-unit-tests_static_libraries)
bionic-unit-tests_src_files := $(common_bionic-unit-tests_src_files)
bionic-unit-tests_cflags := $(common_bionic-unit-tests_cflags)
bionic-unit-tests_conlyflags := $(common_bionic-unit-tests_conlyflags)
bionic-unit-tests_cppflags := $(common_bionic-unit-tests_cppflags)
bionic-unit-tests_ldflags := $(common_bionic-unit-tests_ldflags)
bionic-unit-tests_c_includes := $(common_bionic-unit-tests_c_includes)
bionic-unit-tests_shared_libraries_target := $(common_bionic-unit-tests_shared_libraries_target)
include $(LOCAL_PATH)/Android.build.mk
module := bionic-unit-tests-gcc
bionic-unit-tests-gcc_clang_target := false
bionic-unit-tests-gcc_whole_static_libraries := $(common_bionic-unit-tests_whole_static_libraries)
bionic-unit-tests-gcc_static_libraries := $(common_bionic-unit-tests_static_libraries)
bionic-unit-tests-gcc_src_files := $(common_bionic-unit-tests_src_files)
bionic-unit-tests-gcc_cflags := $(common_bionic-unit-tests_cflags)
bionic-unit-tests-gcc_conlyflags := $(common_bionic-unit-tests_conlyflags)
bionic-unit-tests-gcc_cppflags := $(common_bionic-unit-tests_cppflags)
bionic-unit-tests-gcc_ldflags := $(common_bionic-unit-tests_ldflags)
bionic-unit-tests-gcc_c_includes := $(common_bionic-unit-tests_c_includes)
bionic-unit-tests-gcc_shared_libraries_target := $(common_bionic-unit-tests_shared_libraries_target)
include $(LOCAL_PATH)/Android.build.mk
# -----------------------------------------------------------------------------

View file

@ -35,7 +35,12 @@ class ClassWithDtor {
std::string message;
};
#if defined(__clang__) && defined(__aarch64__)
// b/25642296, aarch64 clang compiled "thread_local" does not link.
static ClassWithDtor class_with_dtor;
#else
static thread_local ClassWithDtor class_with_dtor;
#endif
static void* thread_nop(void* arg) {
class_with_dtor.set_message(*static_cast<std::string*>(arg));
@ -47,7 +52,12 @@ TEST(thread_local, smoke) {
pthread_t t;
ASSERT_EQ(0, pthread_create(&t, nullptr, thread_nop, &msg));
ASSERT_EQ(0, pthread_join(t, nullptr));
#if defined(__clang__) && defined(__aarch64__)
GTEST_LOG_(INFO) << "Skipping test, b/25642296, "
<< "thread_local does not work with aarch64 clang/llvm.\n";
#else
ASSERT_EQ("dtor called.", class_with_dtor_output);
#endif
}
class ClassWithDtorForMainThread {
@ -64,7 +74,13 @@ class ClassWithDtorForMainThread {
};
static void thread_atexit_main() {
#if defined(__clang__) && defined(__aarch64__)
static ClassWithDtorForMainThread class_with_dtor_for_main_thread;
GTEST_LOG_(INFO) << "Skipping test, b/25642296, "
<< "thread_local does not work with aarch64 clang/llvm.\n";
#else
static thread_local ClassWithDtorForMainThread class_with_dtor_for_main_thread;
#endif
class_with_dtor_for_main_thread.set_message("d-tor for main thread called.");
exit(0);
}