[4/5] In gdb.threads/pthreads.c, handle pthread_attr_setscope ENOTSUP

Message ID 20230920175959.2305271-5-pedro@palves.net
State New
Headers
Series Adjust/fix gdb.thread/pthreads.exp for Cygwin |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-arm success Testing passed
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_gdb_check--master-arm success Testing passed

Commit Message

Pedro Alves Sept. 20, 2023, 5:59 p.m. UTC
  On Cygwin, I see:

 (gdb) PASS: gdb.threads/pthreads.exp: break thread1
 continue
 Continuing.
 pthread_attr_setscope 1: Not supported (134)
 [Thread 3732.0x265c exited with code 1]
 [Thread 3732.0x2834 exited with code 1]
 [Thread 3732.0x2690 exited with code 1]

 Program terminated with signal SIGHUP, Hangup.
 The program no longer exists.
 (gdb) FAIL: gdb.threads/pthreads.exp: Continue to creation of first thread

 ... and then a set of cascading failures.

Fix this by treating ENOTSUP the same way as if PTHREAD_SCOPE_SYSTEM
were not defined.  I.e., ignore ENOTSUP errors, and proceed with
testing.

Change-Id: Iea68ff8b9937570726154f36610c48ef96101871
---
 gdb/testsuite/gdb.threads/pthreads.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
  

Patch

diff --git a/gdb/testsuite/gdb.threads/pthreads.c b/gdb/testsuite/gdb.threads/pthreads.c
index 547bf0fe3f0..4b8b283b048 100644
--- a/gdb/testsuite/gdb.threads/pthreads.c
+++ b/gdb/testsuite/gdb.threads/pthreads.c
@@ -24,6 +24,7 @@ 
 #include <pthread.h>
 #include <unistd.h>
 #include <string.h>
+#include <errno.h>
 
 static int verbose = 0;
 
@@ -135,7 +136,7 @@  main (int argc, char **argv)
 
 #ifdef PTHREAD_SCOPE_SYSTEM
   res = pthread_attr_setscope (&attr, PTHREAD_SCOPE_SYSTEM);
-  if (res != 0)
+  if (res != 0 && res != ENOTSUP)
     {
       print_error ("pthread_attr_setscope 1", res);
       exit (1);