This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH 6/6] nptl/tst-abstime: Use libsupport


* nptl/tst-abstime.c: Use libsupport.
---
 ChangeLog          |  4 +++-
 nptl/tst-abstime.c | 57 +++++++++--------------------------------------
 2 files changed, 16 insertions(+), 45 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 5a03d42..f558bbd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2019-03-28  Mike Crowe  <mac@mcrowe.com>
 
+	* nptl/tst-abstime.c: Use libsupport.
+
+2019-03-28  Mike Crowe  <mac@mcrowe.com>
+
 	* support/check.h: Introduce FAIL_THREAD_EXIT1 and FAIL_PRINT
 	macros.
 
diff --git a/nptl/tst-abstime.c b/nptl/tst-abstime.c
index 71610f8..7d55fe3 100644
--- a/nptl/tst-abstime.c
+++ b/nptl/tst-abstime.c
@@ -20,6 +20,7 @@
 #include <pthread.h>
 #include <semaphore.h>
 #include <stdio.h>
+#include <support/check.h>
 
 static pthread_cond_t c = PTHREAD_COND_INITIALIZER;
 static pthread_mutex_t m1 = PTHREAD_MUTEX_INITIALIZER;
@@ -31,67 +32,33 @@ static sem_t sem;
 static void *
 th (void *arg)
 {
-  long int res = 0;
-  int r;
   struct timespec t = { -2, 0 };
 
-  r = pthread_mutex_timedlock (&m1, &t);
-  if (r != ETIMEDOUT)
-    {
-      puts ("pthread_mutex_timedlock did not return ETIMEDOUT");
-      res = 1;
-    }
-  r = pthread_rwlock_timedrdlock (&rw1, &t);
-  if (r != ETIMEDOUT)
-    {
-      puts ("pthread_rwlock_timedrdlock did not return ETIMEDOUT");
-      res = 1;
-    }
-  r = pthread_rwlock_timedwrlock (&rw2, &t);
-  if (r != ETIMEDOUT)
-    {
-      puts ("pthread_rwlock_timedwrlock did not return ETIMEDOUT");
-      res = 1;
-    }
-  return (void *) res;
+  TEST_COMPARE (pthread_mutex_timedlock (&m1, &t), ETIMEDOUT);
+  TEST_COMPARE (pthread_rwlock_timedrdlock (&rw1, &t), ETIMEDOUT);
+  TEST_COMPARE (pthread_rwlock_timedwrlock (&rw2, &t), ETIMEDOUT);
+  return NULL;
 }
 
 static int
 do_test (void)
 {
-  int res = 0;
-  int r;
   struct timespec t = { -2, 0 };
   pthread_t pth;
 
   sem_init (&sem, 0, 0);
-  r = sem_timedwait (&sem, &t);
-  if (r != -1 || errno != ETIMEDOUT)
-    {
-      puts ("sem_timedwait did not fail with ETIMEDOUT");
-      res = 1;
-    }
+  TEST_COMPARE (sem_timedwait (&sem, &t), -1);
+  TEST_COMPARE (errno, ETIMEDOUT);
 
   pthread_mutex_lock (&m1);
   pthread_rwlock_wrlock (&rw1);
   pthread_rwlock_rdlock (&rw2);
   pthread_mutex_lock (&m2);
   if (pthread_create (&pth, 0, th, 0) != 0)
-    {
-      puts ("cannot create thread");
-      return 1;
-    }
-  r = pthread_cond_timedwait (&c, &m2, &t);
-  if (r != ETIMEDOUT)
-    {
-      puts ("pthread_cond_timedwait did not return ETIMEDOUT");
-      res = 1;
-    }
-  void *thres;
-  pthread_join (pth, &thres);
-  return res | (thres != NULL);
+    FAIL_RET ("cannot create thread");
+  TEST_COMPARE (pthread_cond_timedwait (&c, &m2, &t), ETIMEDOUT);
+  pthread_join (pth, NULL);
+  return 0;
 }
 
-
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"
+#include <support/test-driver.c>
-- 
git-series 0.9.1


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]