[PATCH 5/6] nptl: Use FAIL_UNSUPPORTED in init_tpp_test in tst-tpp.h

Florian Weimer <[email protected]>
Newsgroups gmane.comp.lib.glibc.alpha
Message-ID <7a81c30b79807a1ca3504d69325a60ce8a40d87d.1787168028.git.fweimer@redhat.com>
This allows priority-protect tests to be regular tests.  They
exit with EXIT_UNSUPPORTED if the process does not have sufficient
privileges.
---
 nptl/tst-tpp.h | 25 ++++++++++---------------
 1 file changed, 10 insertions(+), 15 deletions(-)

diff --git a/nptl/tst-tpp.h b/nptl/tst-tpp.h
index b3f698f693..10819cdd0d 100644
--- a/nptl/tst-tpp.h
+++ b/nptl/tst-tpp.h
@@ -24,6 +24,8 @@
 #include <unistd.h>
 #include <sys/syscall.h>
 
+#include <support/check.h>
+
 /* This test is Linux specific.  */
 #define CHECK_TPP_PRIORITY(normal, boosted) \
   do								\
@@ -61,33 +63,26 @@ init_tpp_test (void)
 {
   fifo_min = sched_get_priority_min (SCHED_FIFO);
   if (fifo_min < 0)
-    {
-      printf ("couldn't get min priority for SCHED_FIFO: %m\n");
-      exit (1);
-    }
+    FAIL_EXIT1 ("couldn't get min priority for SCHED_FIFO: %m");
 
   fifo_max = sched_get_priority_max (SCHED_FIFO);
   if (fifo_max < 0)
-    {
-      printf ("couldn't get max priority for SCHED_FIFO: %m\n");
-      exit (1);
-    }
+    FAIL_EXIT1 ("couldn't get max priority for SCHED_FIFO: %m");
 
   if (fifo_min > 4 || fifo_max < 10)
-    {
-      printf ("%d..%d SCHED_FIFO priority interval not suitable for this test\n",
-	      fifo_min, fifo_max);
-      exit (0);
-    }
+    FAIL_UNSUPPORTED ("%d..%d SCHED_FIFO priority interval"
+		      " not suitable for this test",
+		      fifo_min, fifo_max);
 
   struct sched_param sp;
   memset (&sp, 0, sizeof (sp));
   sp.sched_priority = 4;
   int e = pthread_setschedparam (pthread_self (), SCHED_FIFO, &sp);
+  if (e == EPERM)
+    FAIL_UNSUPPORTED ("cannot set SCHED_FIFO scheduling policy");
   if (e != 0)
     {
       errno = e;
-      printf ("cannot set scheduling params: %m\n");
-      exit (0);
+      FAIL_EXIT1 ("pthread_setschedparam: %m");
     }
 }
-- 
2.55.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.