<div dir="auto"><div>I think this is ok also. <br><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Feb 18, 2024, 10:20 PM Chris Johns <<a href="mailto:chrisj@rtems.org" target="_blank" rel="noreferrer">chrisj@rtems.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Looks good. Thanks<br>
<br>
Chris<br>
<br>
On 19/2/2024 3:16 pm, Kinsey Moore wrote:<br>
> This adds a pthread that runs the test as well to increase test<br>
> coverage. The original test would have passed if all threads returned<br>
> the address of the Init task's errno since no additional threads or<br>
> tasks were checked.<br>
> ---<br>
> testsuites/libtests/dl11/dl-load.c | 72 +++++++++++++++++++++++-------<br>
> testsuites/libtests/dl11/init.c | 2 +<br>
> 2 files changed, 59 insertions(+), 15 deletions(-)<br>
> <br>
> diff --git a/testsuites/libtests/dl11/dl-load.c b/testsuites/libtests/dl11/dl-load.c<br>
> index 70d7bf1c65..b09128acdf 100644<br>
> --- a/testsuites/libtests/dl11/dl-load.c<br>
> +++ b/testsuites/libtests/dl11/dl-load.c<br>
> @@ -27,6 +27,8 @@<br>
> <br>
> #include <errno.h><br>
> #include <stdio.h><br>
> +#include "tmacros.h"<br>
> +#include <pthread.h><br>
> <br>
> #include <dlfcn.h><br>
> <br>
> @@ -79,13 +81,60 @@ typedef int* (*ptr_call_t)(void);<br>
> void* get_errno_ptr(void);<br>
> int get_errno(void);<br>
> <br>
> -int dl_load_test(void)<br>
> +int_call_t int_call;<br>
> +ptr_call_t ptr_call;<br>
> +static int perform_test(void)<br>
> {<br>
> - void* handle;<br>
> - int_call_t int_call;<br>
> - ptr_call_t ptr_call;<br>
> int int_call_ret;<br>
> int* ptr_call_ret;<br>
> + ptr_call_ret = ptr_call ();<br>
> + if (ptr_call_ret != get_errno_ptr())<br>
> + {<br>
> + printf("dlsym ptr_call failed: ret value bad\n");<br>
> + return 1;<br>
> + }<br>
> +<br>
> + errno = 12345;<br>
> + int_call_ret = int_call ();<br>
> + if (int_call_ret != get_errno())<br>
> + {<br>
> + printf("dlsym int_call failed: ret value bad\n");<br>
> + return 1;<br>
> + }<br>
> + errno = 0;<br>
> +<br>
> + return 0;<br>
> +}<br>
> +<br>
> +static void *secondary_thread(void *arg)<br>
> +{<br>
> + printf("Running test on secondary thread\n");<br>
> + if (perform_test()) {<br>
> + printf("Test failed on secondary task\n");<br>
> + return (void *) 1;<br>
> + }<br>
> +<br>
> + return NULL;<br>
> +}<br>
> +<br>
> +static void start_secondary(void)<br>
> +{<br>
> + /* Run the test on a secondary thread */<br>
> + pthread_t threadId;<br>
> + int status;<br>
> + void *ret;<br>
> + status = pthread_create( &threadId, NULL, secondary_thread, NULL );<br>
> + rtems_test_assert( !status );<br>
> +<br>
> + /* Wait on thread to exit */<br>
> + status = pthread_join(threadId, &ret);<br>
> + rtems_test_assert( !status );<br>
> + rtems_test_assert( ret == NULL );<br>
> +}<br>
> +<br>
> +int dl_load_test(void)<br>
> +{<br>
> + void* handle;<br>
> int unresolved;<br>
> char* message = "loaded";<br>
> <br>
> @@ -125,20 +174,13 @@ int dl_load_test(void)<br>
> return 1;<br>
> }<br>
> <br>
> - ptr_call_ret = ptr_call ();<br>
> - if (ptr_call_ret != get_errno_ptr())<br>
> - {<br>
> - printf("dlsym ptr_call failed: ret value bad\n");<br>
> + /* Run the test on the init thread */<br>
> + printf("Running test on init task\n");<br>
> + if (perform_test()) {<br>
> return 1;<br>
> }<br>
> <br>
> - errno = 12345;<br>
> - int_call_ret = int_call ();<br>
> - if (int_call_ret != get_errno())<br>
> - {<br>
> - printf("dlsym int_call failed: ret value bad\n");<br>
> - return 1;<br>
> - }<br>
> + start_secondary();<br>
> <br>
> if (dlclose (handle) < 0)<br>
> {<br>
> diff --git a/testsuites/libtests/dl11/init.c b/testsuites/libtests/dl11/init.c<br>
> index 91f529b055..0ff4557421 100644<br>
> --- a/testsuites/libtests/dl11/init.c<br>
> +++ b/testsuites/libtests/dl11/init.c<br>
> @@ -86,6 +86,8 @@ static void Init(rtems_task_argument arg)<br>
> <br>
> #define CONFIGURE_MAXIMUM_FILE_DESCRIPTORS 4<br>
> <br>
> +#define CONFIGURE_MAXIMUM_POSIX_THREADS 1<br>
> +<br>
> #define CONFIGURE_MAXIMUM_TASKS 1<br>
> <br>
> #define CONFIGURE_MAXIMUM_SEMAPHORES 1<br>
_______________________________________________<br>
devel mailing list<br>
<a href="mailto:devel@rtems.org" rel="noreferrer noreferrer" target="_blank">devel@rtems.org</a><br>
<a href="http://lists.rtems.org/mailman/listinfo/devel" rel="noreferrer noreferrer noreferrer" target="_blank">http://lists.rtems.org/mailman/listinfo/devel</a><br>
</blockquote></div>
</div></div>