powerpc: Convert tests to the new support test-driver
Commit Message
Change the powerpc tests to use <support/test-driver.c>.
Also replace some of pthread calls to its xpthread equivalent.
Tested on ppc64le.
2016-12-15 Wainer dos Santos Moschetta <wainersm@linux.vnet.ibm.com>
* sysdeps/powerpc/test-get_hwcap.c: Use <support/test-driver.c>
instead of test-skeleton.c.
(do_test): Replaced pthread_create and pthread_join with
xpthread_create and xpthread_join.
* sysdeps/powerpc/test-gettimebase.c: Use <support/test-driver.c>
instead of test-skeleton.c.
* sysdeps/powerpc/tst-tlsopt-powerpc.c: Likewise.
---
sysdeps/powerpc/test-get_hwcap.c | 17 +++++------------
sysdeps/powerpc/test-gettimebase.c | 3 +--
sysdeps/powerpc/tst-tlsopt-powerpc.c | 3 +--
3 files changed, 7 insertions(+), 16 deletions(-)
Comments
On 12/19/16, 3:49 PM, "Wainer dos Santos Moschetta" <libc-alpha-owner@sourceware.org on behalf of wainersm@linux.vnet.ibm.com> wrote:
diff --git a/sysdeps/powerpc/test-get_hwcap.c b/sysdeps/powerpc/test-get_hwcap.c
index 14fe73b..14093f0 100644
--- a/sysdeps/powerpc/test-get_hwcap.c
+++ b/sysdeps/powerpc/test-get_hwcap.c
@@ -23,6 +23,8 @@
#include <stdint.h>
#include <pthread.h>
+#include <support/xthread.h>
+
#include <sys/auxv.h>
#include <dl-procinfo.h>
@@ -160,18 +162,10 @@ do_test (void)
/* Check for other thread. */
i++;
- if (pthread_create (&threads[i], &attr, t1, (void *)i))
- {
- printf ("FAIL: error creating thread %ld.\n", i);
- return 1;
- }
+ threads[i] = xpthread_create (&attr, t1, (void *)i);
pthread_attr_destroy (&attr);
- if (pthread_join (threads[i], &status))
- {
- printf ("FAIL: error joining thread %ld.\n", i);
- return 1;
- }
+ status = xpthread_join (threads[i]);
if (status)
{
return 1;
@@ -184,5 +178,4 @@ do_test (void)
I don’t think you should omit the FAIL message here. Other than that, LGTM.
--
Carlos Eduardo Seo
Software Engineer - Linux on Power Toolchain
cseo@linux.vnet.ibm.com
On 12/19/2016 07:43 PM, Carlos Eduardo Seo wrote:
> pthread_attr_destroy (&attr);
> - if (pthread_join (threads[i], &status))
> - {
> - printf ("FAIL: error joining thread %ld.\n", i);
> - return 1;
> - }
> + status = xpthread_join (threads[i]);
> if (status)
> {
> return 1;
> @@ -184,5 +178,4 @@ do_test (void)
>
> I don’t think you should omit the FAIL message here. Other than that, LGTM.
Right. I could add a TEST_VERIFY macro which would allow you to write:
TEST_VERIFY (xpthread_join (threads[i]) != NULL);
or
TEST_VERIFY_FAIL (xpthread_join (threads[i]) != NULL);
(in case execution is not expected to continue).
Thanks,
Florian
On 12/20/2016 12:13 AM, Carlos Eduardo Seo wrote:
>
> On 12/19/16, 3:49 PM, "Wainer dos Santos Moschetta" <libc-alpha-owner@sourceware.org on behalf of wainersm@linux.vnet.ibm.com> wrote:
>
> diff --git a/sysdeps/powerpc/test-get_hwcap.c b/sysdeps/powerpc/test-get_hwcap.c
> index 14fe73b..14093f0 100644
> --- a/sysdeps/powerpc/test-get_hwcap.c
> +++ b/sysdeps/powerpc/test-get_hwcap.c
> @@ -23,6 +23,8 @@
> #include <stdint.h>
> #include <pthread.h>
>
> +#include <support/xthread.h>
> +
> #include <sys/auxv.h>
>
> #include <dl-procinfo.h>
> @@ -160,18 +162,10 @@ do_test (void)
>
> /* Check for other thread. */
> i++;
> - if (pthread_create (&threads[i], &attr, t1, (void *)i))
> - {
> - printf ("FAIL: error creating thread %ld.\n", i);
> - return 1;
> - }
> + threads[i] = xpthread_create (&attr, t1, (void *)i);
>
> pthread_attr_destroy (&attr);
> - if (pthread_join (threads[i], &status))
> - {
> - printf ("FAIL: error joining thread %ld.\n", i);
> - return 1;
> - }
> + status = xpthread_join (threads[i]);
> if (status)
> {
> return 1;
> @@ -184,5 +178,4 @@ do_test (void)
>
> I don’t think you should omit the FAIL message here. Other than that, LGTM.
>
I think xpthread_check_return() called from xpthread_join()
is already handling it.
> --
> Carlos Eduardo Seo
> Software Engineer - Linux on Power Toolchain
> cseo@linux.vnet.ibm.com
>
>
>
>
>
>
On 12/20/2016 06:30 AM, Rajalakshmi Srinivasaraghavan wrote:
>> + status = xpthread_join (threads[i]);
>> if (status)
>> {
>> return 1;
>> @@ -184,5 +178,4 @@ do_test (void)
>>
>> I don’t think you should omit the FAIL message here. Other than that,
>> LGTM.
>>
> I think xpthread_check_return() called from xpthread_join()
> is already handling it.
Not for the status == NULL case.
Florian
On 12/19/2016 06:01 PM, Florian Weimer wrote:
> On 12/19/2016 07:43 PM, Carlos Eduardo Seo wrote:
>
>> pthread_attr_destroy (&attr);
>> - if (pthread_join (threads[i], &status))
>> - {
>> - printf ("FAIL: error joining thread %ld.\n", i);
>> - return 1;
>> - }
>> + status = xpthread_join (threads[i]);
>> if (status)
>> {
>> return 1;
>> @@ -184,5 +178,4 @@ do_test (void)
>>
>> I don’t think you should omit the FAIL message here. Other than that, LGTM.
>
> Right. I could add a TEST_VERIFY macro which would allow you to write:
>
> TEST_VERIFY (xpthread_join (threads[i]) != NULL);
>
> or
>
> TEST_VERIFY_FAIL (xpthread_join (threads[i]) != NULL);
>
> (in case execution is not expected to continue).
It sounds good. I'll wait your patch instead of printing a fail message to stdout.
>
>
> Thanks,
> Florian
>
@@ -23,6 +23,8 @@
#include <stdint.h>
#include <pthread.h>
+#include <support/xthread.h>
+
#include <sys/auxv.h>
#include <dl-procinfo.h>
@@ -160,18 +162,10 @@ do_test (void)
/* Check for other thread. */
i++;
- if (pthread_create (&threads[i], &attr, t1, (void *)i))
- {
- printf ("FAIL: error creating thread %ld.\n", i);
- return 1;
- }
+ threads[i] = xpthread_create (&attr, t1, (void *)i);
pthread_attr_destroy (&attr);
- if (pthread_join (threads[i], &status))
- {
- printf ("FAIL: error joining thread %ld.\n", i);
- return 1;
- }
+ status = xpthread_join (threads[i]);
if (status)
{
return 1;
@@ -184,5 +178,4 @@ do_test (void)
}
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"
+#include <support/test-driver.c>
@@ -43,5 +43,4 @@ do_test (void)
return 1;
}
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"
+#include <support/test-driver.c>
@@ -8,7 +8,6 @@
COMMON_INT_DEF(foo);
-#define TEST_FUNCTION do_test ()
static int
do_test (void)
{
@@ -49,4 +48,4 @@ do_test (void)
return result;
}
-#include "../../test-skeleton.c"
+#include <support/test-driver.c>