summaryrefslogtreecommitdiffstats
path: root/testsuites/libtests
diff options
context:
space:
mode:
authorKinsey Moore <kinsey.moore@oarcorp.com>2024-02-18 20:16:22 -0600
committerJoel Sherrill <joel@rtems.org>2024-02-19 09:26:10 -0600
commit6b1222465e164a975b0591a88651eb41f3f5e872 (patch)
tree3f9a9c7e1da8b87840857a6aef61816759c3a91c /testsuites/libtests
parentbsps/qspipsu: Calculate correct parallel mode size (diff)
downloadrtems-6b1222465e164a975b0591a88651eb41f3f5e872.tar.bz2
testsuites/dl11: Test TLS on a secondary thread
This adds a pthread that runs the test as well to increase test coverage. The original test would have passed if all threads returned the address of the Init task's errno since no additional threads or tasks were checked.
Diffstat (limited to 'testsuites/libtests')
-rw-r--r--testsuites/libtests/dl11/dl-load.c72
-rw-r--r--testsuites/libtests/dl11/init.c2
2 files changed, 59 insertions, 15 deletions
diff --git a/testsuites/libtests/dl11/dl-load.c b/testsuites/libtests/dl11/dl-load.c
index 70d7bf1c65..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>
@@ -79,13 +81,60 @@ typedef int* (*ptr_call_t)(void);
void* get_errno_ptr(void);
int get_errno(void);
-int dl_load_test(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";
@@ -125,20 +174,13 @@ int dl_load_test(void)
return 1;
}
- ptr_call_ret = ptr_call ();
- if (ptr_call_ret != get_errno_ptr())
- {
- 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 != get_errno())
- {
- printf("dlsym int_call failed: ret value bad\n");
- return 1;
- }
+ start_secondary();
if (dlclose (handle) < 0)
{
diff --git a/testsuites/libtests/dl11/init.c b/testsuites/libtests/dl11/init.c
index 91f529b055..0ff4557421 100644
--- a/testsuites/libtests/dl11/init.c
+++ b/testsuites/libtests/dl11/init.c
@@ -86,6 +86,8 @@ static void Init(rtems_task_argument arg)
#define CONFIGURE_MAXIMUM_FILE_DESCRIPTORS 4
+#define CONFIGURE_MAXIMUM_POSIX_THREADS 1
+
#define CONFIGURE_MAXIMUM_TASKS 1
#define CONFIGURE_MAXIMUM_SEMAPHORES 1