diff options
Diffstat (limited to 'testsuites/libtests/dl11/dl-load.c')
-rw-r--r-- | testsuites/libtests/dl11/dl-load.c | 95 |
1 files changed, 80 insertions, 15 deletions
diff --git a/testsuites/libtests/dl11/dl-load.c b/testsuites/libtests/dl11/dl-load.c index aee1517269..b09128acdf 100644 --- a/testsuites/libtests/dl11/dl-load.c +++ b/testsuites/libtests/dl11/dl-load.c @@ -27,6 +27,8 @@ #include <errno.h> #include <stdio.h> +#include "tmacros.h" +#include <pthread.h> #include <dlfcn.h> @@ -37,10 +39,17 @@ #define TEST_TRACE 0 #if TEST_TRACE + #define SHOW_GLOBAL_SYMS 1 + #if SHOW_GLOBAL_SYMS + #define TRACE_GLOBAL_SYMBOL RTEMS_RTL_TRACE_GLOBAL_SYM + #else + #define TRACE_GLOBAL_SYMBOL 0 + #endif #define DEBUG_TRACE (RTEMS_RTL_TRACE_DETAIL | \ RTEMS_RTL_TRACE_WARNING | \ RTEMS_RTL_TRACE_LOAD | \ RTEMS_RTL_TRACE_UNLOAD | \ + TRACE_GLOBAL_SYMBOL | \ RTEMS_RTL_TRACE_SYMBOL | \ RTEMS_RTL_TRACE_RELOC | \ RTEMS_RTL_TRACE_ALLOCATOR | \ @@ -69,13 +78,63 @@ static void dl_load_dump (void) typedef int (*int_call_t)(void); typedef int* (*ptr_call_t)(void); -int dl_load_test(void) +void* get_errno_ptr(void); +int get_errno(void); + +int_call_t int_call; +ptr_call_t ptr_call; +static int perform_test(void) { - void* handle; - int_call_t int_call; - ptr_call_t ptr_call; int int_call_ret; int* ptr_call_ret; + ptr_call_ret = ptr_call (); + if (ptr_call_ret != get_errno_ptr()) + { + printf("dlsym ptr_call failed: ret value bad\n"); + return 1; + } + + errno = 12345; + int_call_ret = int_call (); + if (int_call_ret != get_errno()) + { + printf("dlsym int_call failed: ret value bad\n"); + return 1; + } + errno = 0; + + return 0; +} + +static void *secondary_thread(void *arg) +{ + printf("Running test on secondary thread\n"); + if (perform_test()) { + printf("Test failed on secondary task\n"); + return (void *) 1; + } + + return NULL; +} + +static void start_secondary(void) +{ + /* Run the test on a secondary thread */ + pthread_t threadId; + int status; + void *ret; + status = pthread_create( &threadId, NULL, secondary_thread, NULL ); + rtems_test_assert( !status ); + + /* Wait on thread to exit */ + status = pthread_join(threadId, &ret); + rtems_test_assert( !status ); + rtems_test_assert( ret == NULL ); +} + +int dl_load_test(void) +{ + void* handle; int unresolved; char* message = "loaded"; @@ -115,20 +174,13 @@ int dl_load_test(void) return 1; } - ptr_call_ret = ptr_call (); - if (ptr_call_ret != &errno) - { - printf("dlsym ptr_call failed: ret value bad\n"); + /* Run the test on the init thread */ + printf("Running test on init task\n"); + if (perform_test()) { return 1; } - errno = 12345; - int_call_ret = int_call (); - if (int_call_ret != 12345) - { - printf("dlsym int_call failed: ret value bad\n"); - return 1; - } + start_secondary(); if (dlclose (handle) < 0) { @@ -140,3 +192,16 @@ int dl_load_test(void) return 0; } + +/* + * Disasseble these to see how the platform accesses TLS + */ +void* get_errno_ptr(void) +{ + return &errno; +} + +int get_errno(void) +{ + return errno; +} |