public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc] C11 threads: Fix inaccuracies in testsuite
@ 2020-09-07  9:43 Florian Weimer
  0 siblings, 0 replies; only message in thread
From: Florian Weimer @ 2020-09-07  9:43 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=7b51d9f69e742d29b335f4ced07ed0f191b12f82

commit 7b51d9f69e742d29b335f4ced07ed0f191b12f82
Author: Corinna Vinschen <vinschen@redhat.com>
Date:   Mon Sep 7 11:42:51 2020 +0200

    C11 threads: Fix inaccuracies in testsuite
    
    - tst-mtx-recursive.c: mtx_init fails to use mtx_plain.  Per C11
      specs, using mtx_recursive alone is not supported.  This isn't
      catched because mtx_plain is defined as 0.
    
    - tst-thrd-sleep.c: thrd_sleep returns 0 on success, a negative
      value on failure.  Testing against thrd_success is incorrect.
    
    - tst-tss-basic.c: tss_set is incorrectly checkd for a non-0
      value.  The test should test aginst C11 threads error codes.
      This isn't catched because thrd_success is defined as 0.
    
    Note that all three tests fail on FreeBSD, which defines all mutex type
    values, as well as all C11 threads error codes with non-0 values.

Diff:
---
 sysdeps/pthread/tst-mtx-recursive.c | 2 +-
 sysdeps/pthread/tst-thrd-sleep.c    | 2 +-
 sysdeps/pthread/tst-tss-basic.c     | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/sysdeps/pthread/tst-mtx-recursive.c b/sysdeps/pthread/tst-mtx-recursive.c
index 6b471ac724..aca8cee6eb 100644
--- a/sysdeps/pthread/tst-mtx-recursive.c
+++ b/sysdeps/pthread/tst-mtx-recursive.c
@@ -27,7 +27,7 @@ do_test (void)
 {
   static mtx_t mutex;
 
-  if (mtx_init (&mutex, mtx_recursive) != thrd_success)
+  if (mtx_init (&mutex, mtx_plain | mtx_recursive) != thrd_success)
     FAIL_EXIT1 ("mtx_init failed");
 
   if (mtx_lock (&mutex) != thrd_success)
diff --git a/sysdeps/pthread/tst-thrd-sleep.c b/sysdeps/pthread/tst-thrd-sleep.c
index 39d5fc7079..8cc4bb2690 100644
--- a/sysdeps/pthread/tst-thrd-sleep.c
+++ b/sysdeps/pthread/tst-thrd-sleep.c
@@ -27,7 +27,7 @@ static int
 sleep_thrd (void *arg)
 {
   struct timespec const *tl = (struct timespec const *) arg;
-  if (thrd_sleep (tl, NULL) != thrd_success)
+  if (thrd_sleep (tl, NULL) != 0)
     FAIL_EXIT1 ("thrd_sleep failed");
 
   thrd_exit (thrd_success);
diff --git a/sysdeps/pthread/tst-tss-basic.c b/sysdeps/pthread/tst-tss-basic.c
index 3b06abc5cf..5a2c1bd1ee 100644
--- a/sysdeps/pthread/tst-tss-basic.c
+++ b/sysdeps/pthread/tst-tss-basic.c
@@ -33,7 +33,7 @@ tss_thrd (void *arg)
   if (tss_create (&key, NULL) != thrd_success)
     FAIL_EXIT1 ("tss_create failed");
 
-  if (tss_set (key, TSS_VALUE))
+  if (tss_set (key, TSS_VALUE) != thrd_success)
     FAIL_EXIT1 ("tss_set failed");
 
   void *value = tss_get (key);


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-09-07  9:43 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-07  9:43 [glibc] C11 threads: Fix inaccuracies in testsuite Florian Weimer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).