From 1cea4ff5e31ef8620db4ac946fb0ce468019a52e Mon Sep 17 00:00:00 2001 From: Yongqin Liu Date: Fri, 16 May 2014 18:33:19 +0800 Subject: bionic libc tests: fix 64bit compilation issues Some changes here: 1. add Android.mk under test/bionic, so that tests under libc can be compiled 2. delete the -static ld flag for test_static_executable_destructor of host side, otherwise we will get the "-pie and -static are incompatible" error 3. changes in c files for 64 bit compatibility 4. remove other/test_vfprintf_leak.c test Change-Id: Ic6d3f55d7c82a639a0bbc9d8a5f713d6cf079117 Signed-off-by: Yongqin Liu Signed-off-by: Amit Pundir --- tests/bionic/Android.mk | 8 ++++++++ tests/bionic/libc/Android.mk | 4 +--- tests/bionic/libc/bionic/test_pthread_cond.c | 8 ++++---- tests/bionic/libc/bionic/test_pthread_create.c | 4 ++-- tests/bionic/libc/common/test_pthread_cleanup_push.c | 12 ++++++------ tests/bionic/libc/common/test_pthread_join.c | 4 ++-- 6 files changed, 23 insertions(+), 17 deletions(-) create mode 100644 tests/bionic/Android.mk diff --git a/tests/bionic/Android.mk b/tests/bionic/Android.mk new file mode 100644 index 00000000..b72df254 --- /dev/null +++ b/tests/bionic/Android.mk @@ -0,0 +1,8 @@ +ifdef BIONIC_TESTS +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) + +subdirs := $(addprefix $(LOCAL_PATH)/,$(addsuffix /Android.mk,libc)) + +include $(subdirs) +endif diff --git a/tests/bionic/libc/Android.mk b/tests/bionic/libc/Android.mk index 1e64591d..267bd09f 100644 --- a/tests/bionic/libc/Android.mk +++ b/tests/bionic/libc/Android.mk @@ -100,7 +100,6 @@ include $(CLEAR_VARS) LOCAL_MODULE := test_static_executable_destructor LOCAL_SRC_FILES := common/test_executable_destructor.c LOCAL_MODULE_TAGS := tests -LOCAL_LDFLAGS := -static include $(BUILD_HOST_EXECUTABLE) # The 'test_dlopen_null' tests requires specific linker flags @@ -138,8 +137,7 @@ $(call device-test, $(sources)) # Third, the other tests sources := \ - other/test_sysconf.c \ - other/test_vfprintf_leak.c \ + other/test_sysconf.c $(call device-test, $(sources)) diff --git a/tests/bionic/libc/bionic/test_pthread_cond.c b/tests/bionic/libc/bionic/test_pthread_cond.c index 26746fa7..a29111e7 100644 --- a/tests/bionic/libc/bionic/test_pthread_cond.c +++ b/tests/bionic/libc/bionic/test_pthread_cond.c @@ -12,7 +12,7 @@ static pthread_mutex_t test_lock = PTHREAD_MUTEX_INITIALIZER; static void * thread1_func(void* arg) { - printf("Thread 1 (arg=%d tid=%d) entered.\n", (unsigned)arg, gettid()); + printf("Thread 1 (arg=%p tid=%d) entered.\n", arg, gettid()); printf("1 waiting for cond1\n"); pthread_mutex_lock(&test_lock); pthread_cond_wait(&cond1, &test_lock ); @@ -24,7 +24,7 @@ thread1_func(void* arg) static void * thread2_func(void* arg) { - printf("Thread 2 (arg=%d tid=%d) entered.\n", (unsigned)arg, gettid()); + printf("Thread 2 (arg=%p tid=%d) entered.\n", arg, gettid()); printf("2 waiting for cond2\n"); pthread_mutex_lock(&test_lock); pthread_cond_wait(&cond2, &test_lock ); @@ -37,7 +37,7 @@ thread2_func(void* arg) static void * thread3_func(void* arg) { - printf("Thread 3 (arg=%d tid=%d) entered.\n", (unsigned)arg, gettid()); + printf("Thread 3 (arg=%p tid=%d) entered.\n", arg, gettid()); printf("3 waiting for cond1\n"); pthread_mutex_lock(&test_lock); pthread_cond_wait(&cond1, &test_lock ); @@ -54,7 +54,7 @@ thread3_func(void* arg) static void * thread4_func(void* arg) { - printf("Thread 4 (arg=%d tid=%d) entered.\n", (unsigned)arg, gettid()); + printf("Thread 4 (arg=%p tid=%d) entered.\n", arg, gettid()); printf("4 Sleeping\n"); sleep(5); diff --git a/tests/bionic/libc/bionic/test_pthread_create.c b/tests/bionic/libc/bionic/test_pthread_create.c index edac0ff1..66139c9f 100644 --- a/tests/bionic/libc/bionic/test_pthread_create.c +++ b/tests/bionic/libc/bionic/test_pthread_create.c @@ -5,14 +5,14 @@ static void * thread1_func(void* arg) { - printf("Thread 1 (arg=%d tid=%d) entered.\n", (unsigned)arg, gettid()); + printf("Thread 1 (arg=%p tid=%d) entered.\n", arg, gettid()); return 0; } static void * thread2_func(void* arg) { - printf("thread 2 (arg=%d tid=%d) entered.\n", (unsigned)arg, gettid()); + printf("thread 2 (arg=%p tid=%d) entered.\n", arg, gettid()); return 1; } diff --git a/tests/bionic/libc/common/test_pthread_cleanup_push.c b/tests/bionic/libc/common/test_pthread_cleanup_push.c index 87634adf..b94ecf06 100644 --- a/tests/bionic/libc/common/test_pthread_cleanup_push.c +++ b/tests/bionic/libc/common/test_pthread_cleanup_push.c @@ -41,7 +41,7 @@ static int g_ok3 = 0; static void cleanup1( void* arg ) { - if ((unsigned)arg != MAGIC1) + if ((unsigned long)arg != MAGIC1) g_ok1 = -1; else g_ok1 = +1; @@ -50,7 +50,7 @@ cleanup1( void* arg ) static void cleanup2( void* arg ) { - if ((unsigned)arg != MAGIC2) { + if ((unsigned long)arg != MAGIC2) { g_ok2 = -1; } else g_ok2 = +1; @@ -59,7 +59,7 @@ cleanup2( void* arg ) static void cleanup3( void* arg ) { - if ((unsigned)arg != MAGIC3) + if ((unsigned long)arg != MAGIC3) g_ok3 = -1; else g_ok3 = +1; @@ -83,7 +83,7 @@ thread1_func( void* arg ) return NULL; } -static int test( int do_exit ) +static int test( long do_exit ) { pthread_t t; @@ -127,8 +127,8 @@ static int test( int do_exit ) int main( void ) { - test(0); - test(1); + test(0l); + test(1l); printf("OK\n"); return 0; } diff --git a/tests/bionic/libc/common/test_pthread_join.c b/tests/bionic/libc/common/test_pthread_join.c index 4fe2561a..13bab68f 100644 --- a/tests/bionic/libc/common/test_pthread_join.c +++ b/tests/bionic/libc/common/test_pthread_join.c @@ -44,7 +44,7 @@ thread2_func(void* arg) void* result; pthread_join(t1, &result); - printf("thread2 received code %08x from thread1\n", (int)result); + printf("thread2 received code %p from thread1\n", result); return NULL; } @@ -56,7 +56,7 @@ thread3_func(void* arg) void* result; pthread_join(t1, &result); - printf("thread3 received code %08x from thread1\n", (int)result); + printf("thread3 received code %p from thread1\n", result); return NULL; } -- cgit v1.2.3