diff mbox series

[v1,5/6] nptl: mutex-test5: Include CLOCK_MONOTONIC for PI

Message ID 20210625081104.1134598-6-kurt@linutronix.de
State Superseded
Headers show
Series nptl: Introduce and use FUTEX_LOCK_PI2 | expand

Commit Message

Kurt Kanzenbach June 25, 2021, 8:11 a.m. UTC
pthread_mutex_clocklock(MONOTONIC)/PI is now supported.

Adjust the test accordingly.

Signed-off-by: Kurt Kanzenbach <kurt@linutronix.de>
---
 sysdeps/pthread/tst-mutex5.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/sysdeps/pthread/tst-mutex5.c b/sysdeps/pthread/tst-mutex5.c
index 7dc5331cfc08..6ad50f845601 100644
--- a/sysdeps/pthread/tst-mutex5.c
+++ b/sysdeps/pthread/tst-mutex5.c
@@ -77,11 +77,21 @@  do_test_clock (clockid_t clockid, const char *fnname)
                                              make_timespec (2, 0));
 
   if (clockid == CLOCK_USE_TIMEDLOCK)
-    TEST_COMPARE (pthread_mutex_timedlock (&m, &ts_timeout), ETIMEDOUT);
+    {
+      err = pthread_mutex_timedlock (&m, &ts_timeout);
+      TEST_COMPARE (err, ETIMEDOUT);
+    }
   else
-    TEST_COMPARE (pthread_mutex_clocklock (&m, clockid, &ts_timeout),
-		  ETIMEDOUT);
-  TEST_TIMESPEC_BEFORE_NOW (ts_timeout, clockid_for_get);
+    {
+      err = pthread_mutex_clocklock (&m, clockid, &ts_timeout);
+
+      /* In case of CLOCK_MONOTONIC the error might be EINVAL if CLOCK_MONOTONIC
+         is not supported. */
+      TEST_VERIFY (err == ETIMEDOUT ||
+		   (clockid == CLOCK_MONOTONIC && err == EINVAL));
+    }
+  if (err == ETIMEDOUT)
+    TEST_TIMESPEC_BEFORE_NOW (ts_timeout, clockid_for_get);
 
   /* The following makes the ts value invalid.  */
   ts_timeout.tv_nsec += 1000000000;
@@ -122,9 +132,7 @@  static int do_test (void)
 
   do_test_clock (CLOCK_USE_TIMEDLOCK, "timedlock");
   do_test_clock (CLOCK_REALTIME, "clocklock(realtime)");
-#ifndef ENABLE_PI
   do_test_clock (CLOCK_MONOTONIC, "clocklock(monotonic)");
-#endif
   return 0;
 }