]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
C11 threads: Fix inaccuracies in testsuite
authorCorinna Vinschen <vinschen@redhat.com>
Mon, 7 Sep 2020 09:42:51 +0000 (11:42 +0200)
committerFlorian Weimer <fweimer@redhat.com>
Mon, 7 Sep 2020 09:42:52 +0000 (11:42 +0200)
- 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.

sysdeps/pthread/tst-mtx-recursive.c
sysdeps/pthread/tst-thrd-sleep.c
sysdeps/pthread/tst-tss-basic.c

index 6b471ac724df939aaadc388cef64c3d4402ab3c5..aca8cee6eb992ff8d2a6b3138c207e7184e593a0 100644 (file)
@@ -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)
index 39d5fc70794552a90f9c9d34c5534ab1fcc65df3..8cc4bb2690c4405bb558e554a56154b71bc371b9 100644 (file)
@@ -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);
index 3b06abc5cfe5e4d6f836c3ae17abd535de3e3f92..5a2c1bd1ee3e938e89878ae4563bbd26111509d5 100644 (file)
@@ -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);