Browse Source

allow to compile and run on musl based systems

This is a first shot, more improvements required to
allow to run more tests.
Waldemar Brodkorb 7 years ago
parent
commit
2ce94b3cb4
77 changed files with 226 additions and 52 deletions
  1. 4 0
      test/Makefile
  2. 1 1
      test/argp/argp-ex4.c
  3. 1 1
      test/args/arg_test.c
  4. 22 0
      test/error.h
  5. 2 0
      test/inet/gethost_r-align.c
  6. 4 0
      test/inet/tst-res.c
  7. 1 0
      test/malloc/tst-mallocfork.c
  8. 0 7
      test/misc/tst-statfs.c
  9. 1 1
      test/nptl/tst-atfork1.c
  10. 1 1
      test/nptl/tst-atfork2.c
  11. 11 0
      test/nptl/tst-attr3.c
  12. 1 1
      test/nptl/tst-basic4.c
  13. 2 2
      test/nptl/tst-basic7.c
  14. 1 0
      test/nptl/tst-cancel16.c
  15. 1 1
      test/nptl/tst-cancel18.c
  16. 1 0
      test/nptl/tst-cancel22.c
  17. 5 0
      test/nptl/tst-cancel4.c
  18. 6 1
      test/nptl/tst-cleanup4.c
  19. 2 0
      test/nptl/tst-cleanup4aux.c
  20. 1 0
      test/nptl/tst-clock2.c
  21. 1 1
      test/nptl/tst-clock_nanosleep.c
  22. 6 2
      test/nptl/tst-cond14.c
  23. 6 2
      test/nptl/tst-cond15.c
  24. 6 2
      test/nptl/tst-cond22.c
  25. 6 1
      test/nptl/tst-cond8.c
  26. 6 1
      test/nptl/tst-cond9.c
  27. 1 1
      test/nptl/tst-exec2.c
  28. 1 0
      test/nptl/tst-exec3.c
  29. 2 1
      test/nptl/tst-flock2.c
  30. 1 0
      test/nptl/tst-fork1.c
  31. 1 1
      test/nptl/tst-fork2.c
  32. 1 0
      test/nptl/tst-fork3.c
  33. 1 1
      test/nptl/tst-getpid3.c
  34. 6 0
      test/nptl/tst-initializers1.c
  35. 1 1
      test/nptl/tst-kill6.c
  36. 1 0
      test/nptl/tst-mqueue1.c
  37. 2 0
      test/nptl/tst-mqueue3.c
  38. 1 0
      test/nptl/tst-mqueue5.c
  39. 1 0
      test/nptl/tst-mqueue6.c
  40. 3 0
      test/nptl/tst-mqueue8.c
  41. 1 0
      test/nptl/tst-mqueue9.c
  42. 4 0
      test/nptl/tst-mutex5.c
  43. 6 1
      test/nptl/tst-mutex7.c
  44. 2 1
      test/nptl/tst-mutex9.c
  45. 1 1
      test/nptl/tst-rwlock12.c
  46. 6 2
      test/nptl/tst-rwlock6.c
  47. 6 2
      test/nptl/tst-rwlock7.c
  48. 6 2
      test/nptl/tst-rwlock8.c
  49. 6 2
      test/nptl/tst-rwlock9.c
  50. 1 1
      test/nptl/tst-sem1.c
  51. 1 0
      test/nptl/tst-sem10.c
  52. 1 0
      test/nptl/tst-sem2.c
  53. 1 0
      test/nptl/tst-sem3.c
  54. 5 1
      test/nptl/tst-sem4.c
  55. 1 1
      test/nptl/tst-sem5.c
  56. 4 0
      test/nptl/tst-sem7.c
  57. 4 0
      test/nptl/tst-sem8.c
  58. 4 0
      test/nptl/tst-sem9.c
  59. 1 0
      test/nptl/tst-signal1.c
  60. 1 0
      test/nptl/tst-signal2.c
  61. 1 0
      test/nptl/tst-signal3.c
  62. 2 0
      test/nptl/tst-timer4.c
  63. 1 0
      test/nptl/tst-tls2.c
  64. 1 0
      test/nptl/tst-tls3.c
  65. 1 0
      test/nptl/tst-tsd6.c
  66. 1 0
      test/nptl/tst-vfork1x.c
  67. 1 0
      test/nptl/tst-vfork2x.c
  68. 4 0
      test/regex/tst-regex2.c
  69. 2 3
      test/regex/tst-regexloc.c
  70. 0 5
      test/setjmp/tst-vfork-longjmp.c
  71. 4 0
      test/stdlib/test-canon2.c
  72. 4 0
      test/stdlib/teston_exit.c
  73. 6 0
      test/stdlib/teststrtoq.c
  74. 2 0
      test/string/stratcliff.c
  75. 2 0
      test/string/tester.c
  76. 2 0
      test/test-skeleton.c
  77. 8 0
      test/test-skeleton.h

+ 4 - 0
test/Makefile

@@ -35,6 +35,10 @@ ifeq ($(NO_LOCALE),1)
 DIRS := $(filter-out locale,$(DIRS))
 endif
 
+ifeq ($(NO_MATH),1)
+DIRS := $(filter-out math,$(DIRS))
+endif
+
 test check all: run
 
 run: subdirs_run

+ 1 - 1
test/argp/argp-ex4.c

@@ -24,8 +24,8 @@
    current locale.  */
 
 #include <stdlib.h>
-#include <error.h>
 #if (defined(__GLIBC__) && !defined(__UCLIBC__)) || defined(__UCLIBC_HAS_ARGP__)
+#include <error.h>
 #include <argp.h>
 
 const char *argp_program_version =

+ 1 - 1
test/args/arg_test.c

@@ -13,7 +13,7 @@
 int main(int argc, char **argv)
 {
 	int i=0;
-	char** index=__environ;
+	char** index=environ;
 
 #ifdef __powerpc__
 	{

+ 22 - 0
test/error.h

@@ -0,0 +1,22 @@
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+
+static unsigned int error_message_count = 0;
+
+static inline void error(int status, int errnum, const char* format, ...)
+{
+	va_list ap;
+	fprintf(stderr, "%s: ", program_invocation_name);
+	va_start(ap, format);
+	vfprintf(stderr, format, ap);
+	va_end(ap);
+	if (errnum)
+		fprintf(stderr, ": %s", strerror(errnum));
+	fprintf(stderr, "\n");
+	error_message_count++;
+	if (status)
+		exit(status);
+}

+ 2 - 0
test/inet/gethost_r-align.c

@@ -27,9 +27,11 @@ int main(int argc, char *argv[])
 
 		printf("Testing misalignment of %2zi bytes: ", i);
 
+#if defined(__GLIBC__) || defined(__UCLIBC__)
 		memset(&hent, 0x00, sizeof(hent));
 		ret = gethostent_r(&hent, buf + i, sizeof(buf) - i, &hentres, &herr);
 		printf("%sgethostent_r() ", (ret ? "!!!" : ""));
+#endif
 
 		memset(&hent, 0x00, sizeof(hent));
 		ret = gethostbyname_r("localhost", &hent, buf + i, sizeof(buf) - i, &hentres, &herr);

+ 4 - 0
test/inet/tst-res.c

@@ -8,6 +8,7 @@
 
 int main(int argc, char **argv)
 {
+#if defined(__GLIBC__) || defined(__UCLIBC__)
     int r;
     struct __res_state state;
 
@@ -40,5 +41,8 @@ int main(int argc, char **argv)
 	assert (state._u._ext.nscount == 0);
 
     return 0;
+#else
+    return 23;
+#endif
 }
 

+ 1 - 0
test/malloc/tst-mallocfork.c

@@ -7,6 +7,7 @@
 #include <unistd.h>
 #include <sys/types.h>
 #include <sys/wait.h>
+#include "../test-skeleton.h"
 
 static void
 sig_handler (int signum)

+ 0 - 7
test/misc/tst-statfs.c

@@ -19,13 +19,6 @@ main(int argc, char* argv[])
 		++ret;
 		printf("statfs %s:\n\tblocks=%lld\n\tblkfree=%lld\n\tbsize=%d\n",
 			argv[i], s.f_blocks, s.f_bfree, s.f_bsize);
-#ifdef _STATFS_F_FRSIZE
-		printf("\tfrsize=%lld\n", s.f_frsize);
-#elif defined __mips__
-		printf("\tfrsize=mips, unsupported?\n");
-#else
-# error no _STATFS_F_FRSIZE
-#endif
 	}
 	exit(ret ? EXIT_SUCCESS : EXIT_FAILURE);
 }

+ 1 - 1
test/nptl/tst-atfork1.c

@@ -22,7 +22,7 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <sys/wait.h>
-
+#include "../test-skeleton.h"
 
 static int val;
 

+ 1 - 1
test/nptl/tst-atfork2.c

@@ -23,7 +23,7 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <sys/wait.h>
-
+#include "../test-skeleton.h"
 
 /* Must be exported.  */
 int val;

+ 11 - 0
test/nptl/tst-attr3.c

@@ -18,12 +18,17 @@
    <http://www.gnu.org/licenses/>.  */
 
 #include <errno.h>
+#if defined(__GLIBC__) || defined(__UCLIBC__)
 #include <error.h>
+#else
+#include "../error.h"
+#endif
 #include <pthread.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
+#include "../test-skeleton.h"
 
 static void *
 tf (void *arg)
@@ -164,6 +169,7 @@ tf (void *arg)
 	}
     }
 
+#if defined(__GLIBC__) || defined(__UCLIBC__)
   cpu_set_t c1, c2;
   err = pthread_getaffinity_np (pthread_self (), sizeof (c1), &c1);
   if (err == 0)
@@ -180,6 +186,7 @@ tf (void *arg)
 	  result = tf;
 	}
     }
+#endif
 
   err = pthread_attr_destroy (&a);
   if (err)
@@ -216,12 +223,14 @@ do_test (void)
       result = 1;
     }
 
+#if defined(__GLIBC__) || defined(__UCLIBC__)
   err = pthread_attr_getaffinity_np (&a, sizeof (c1), &c1);
   if (err && err != ENOSYS)
     {
       error (0, err, "pthread_attr_getaffinity_np failed");
       result = 1;
     }
+#endif
 
   err = pthread_attr_destroy (&a);
   if (err)
@@ -310,6 +319,7 @@ do_test (void)
       result = 1;
     }
 
+#if defined(__GLIBC__) || defined(__UCLIBC__)
   err = pthread_getaffinity_np (pthread_self (), sizeof (c1), &c1);
   if (err == 0)
     {
@@ -325,6 +335,7 @@ do_test (void)
 	  result = 1;
 	}
     }
+#endif
 
   err = pthread_attr_destroy (&a);
   if (err)

+ 1 - 1
test/nptl/tst-basic4.c

@@ -23,7 +23,7 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <sys/wait.h>
-
+#include "../test-skeleton.h"
 
 static void
 final_test (void)

+ 2 - 2
test/nptl/tst-basic7.c

@@ -32,10 +32,10 @@ use_up_memory (void)
   setrlimit (RLIMIT_AS, &rl);
 
   char *c;
-  int PAGESIZE = getpagesize ();
+  int pagesize = getpagesize ();
   while (1)
     {
-      c = mmap (NULL, PAGESIZE, PROT_NONE, MAP_ANON | MAP_PRIVATE, -1, 0);
+      c = mmap (NULL, pagesize, PROT_NONE, MAP_ANON | MAP_PRIVATE, -1, 0);
       if (c == MAP_FAILED)
 	break;
     }

+ 1 - 0
test/nptl/tst-cancel16.c

@@ -24,6 +24,7 @@
 #include <unistd.h>
 #include <sys/mman.h>
 #include <sys/wait.h>
+#include "../test-skeleton.h"
 
 
 static pthread_barrier_t b2;

+ 1 - 1
test/nptl/tst-cancel18.c

@@ -22,7 +22,7 @@
 #include <stdlib.h>
 #include <time.h>
 #include <unistd.h>
-
+#include "../test-skeleton.h"
 
 static pthread_barrier_t b;
 

+ 1 - 0
test/nptl/tst-cancel22.c

@@ -21,6 +21,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
+#include "../test-skeleton.h"
 
 pthread_barrier_t b;
 int seen;

+ 5 - 0
test/nptl/tst-cancel4.c

@@ -37,8 +37,13 @@
 #include <sys/uio.h>
 #include <sys/un.h>
 #include <sys/wait.h>
+#include "../test-skeleton.h"
 
+#if defined(__GLIBC__) || defined(__UCLIBC__)
 #define SIGCANCEL   __SIGRTMIN
+#else
+#define SIGCANCEL   SIGRTMIN
+#endif
 
 
 /* Since STREAMS are not supported in the standard Linux kernel and

+ 6 - 1
test/nptl/tst-cleanup4.c

@@ -21,6 +21,7 @@
 #include <stdlib.h>
 #include <unistd.h>
 
+#if defined(__GLIBC__) || defined(__UCLIBC__)
 /* LinuxThreads pthread_cleanup_{push,pop} helpers.  */
 extern void _pthread_cleanup_push (struct _pthread_cleanup_buffer *__buffer,
                                    void (*__routine) (void *),
@@ -120,11 +121,12 @@ tf (void *a)
 
   return NULL;
 }
-
+#endif
 
 int
 do_test (void)
 {
+#if defined(__GLIBC__) || defined(__UCLIBC__)
   int result = 0;
 
   if (pipe (fds) != 0)
@@ -191,6 +193,9 @@ do_test (void)
     }
 
   return result;
+#else
+  return 23;
+#endif
 }
 
 #define TEST_FUNCTION do_test ()

+ 2 - 0
test/nptl/tst-cleanup4aux.c

@@ -21,6 +21,7 @@
 #include <stdlib.h>
 #include <unistd.h>
 
+#if defined(__GLIBC__) || defined(__UCLIBC__)
 extern void _pthread_cleanup_push (struct _pthread_cleanup_buffer *__buffer,
                                    void (*__routine) (void *),
                                    void *__arg);
@@ -118,3 +119,4 @@ fn9 (void)
 
   _pthread_cleanup_pop (&b, 1);
 }
+#endif

+ 1 - 0
test/nptl/tst-clock2.c

@@ -22,6 +22,7 @@
 #include <stdlib.h>
 #include <time.h>
 #include <unistd.h>
+#include "../test-skeleton.h"
 
 
 #if defined _POSIX_THREAD_CPUTIME && _POSIX_THREAD_CPUTIME >= 0

+ 1 - 1
test/nptl/tst-clock_nanosleep.c

@@ -20,7 +20,7 @@
 #include <unistd.h>
 #include <sys/time.h>
 #include <time.h>
-
+#include "../test-skeleton.h"
 
 /* Test that clock_nanosleep() does sleep.  */
 static int

+ 6 - 2
test/nptl/tst-cond14.c

@@ -22,7 +22,7 @@
 #include <string.h>
 #include <unistd.h>
 
-
+#if defined(__GLIBC__) || defined(__UCLIBC__)
 static pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
 static pthread_mutex_t mut = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
 static pthread_mutex_t mut2 = PTHREAD_MUTEX_INITIALIZER;
@@ -62,11 +62,12 @@ tf (void *p)
 
   return NULL;
 }
-
+#endif
 
 static int
 do_test (void)
 {
+#if defined(__GLIBC__) || defined(__UCLIBC__)
   if (pthread_mutex_lock (&mut2) != 0)
     {
       puts ("1st mutex_lock failed");
@@ -109,6 +110,9 @@ do_test (void)
   puts ("done");
 
   return 0;
+#else
+  return 23;
+#endif
 }
 
 

+ 6 - 2
test/nptl/tst-cond15.c

@@ -24,7 +24,7 @@
 #include <unistd.h>
 #include <sys/time.h>
 
-
+#if defined(__GLIBC__) || defined(__UCLIBC__)
 static pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
 static pthread_mutex_t mut = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
 static pthread_mutex_t mut2 = PTHREAD_MUTEX_INITIALIZER;
@@ -87,11 +87,12 @@ tf (void *p)
 
   return NULL;
 }
-
+#endif
 
 static int
 do_test (void)
 {
+#if defined(__GLIBC__) || defined(__UCLIBC__)
   if (pthread_mutex_lock (&mut2) != 0)
     {
       puts ("1st mutex_lock failed");
@@ -151,6 +152,9 @@ do_test (void)
   puts ("done");
 
   return 0;
+#else
+  return 23;
+#endif
 }
 
 

+ 6 - 2
test/nptl/tst-cond22.c

@@ -2,7 +2,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 
-
+#if defined(__GLIBC__) || defined(__UCLIBC__)
 static pthread_barrier_t b;
 static pthread_cond_t c = PTHREAD_COND_INITIALIZER;
 static pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER;
@@ -49,11 +49,12 @@ tf (void *arg)
     }
   return NULL;
 }
-
+#endif
 
 static int
 do_test (void)
 {
+#if defined(__GLIBC__) || defined(__UCLIBC__)
   int status = 0;
 
   if (pthread_barrier_init (&b, NULL, 2) != 0)
@@ -154,6 +155,9 @@ do_test (void)
 	  c.__data.__nwaiters, c.__data.__broadcast_seq);
 
   return status;
+#else
+  return 23;
+#endif
 }
 
 #define TEST_FUNCTION do_test ()

+ 6 - 1
test/nptl/tst-cond8.c

@@ -24,6 +24,7 @@
 #include <sys/time.h>
 
 
+#if defined(__GLIBC__) || defined(__UCLIBC__)
 static pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
 static pthread_mutex_t mut = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP;
 
@@ -142,11 +143,12 @@ tf2 (void *p)
 
   return NULL;
 }
-
+#endif
 
 static int
 do_test (void)
 {
+#if defined(__GLIBC__) || defined(__UCLIBC__)
   pthread_t th;
   int err;
 
@@ -269,6 +271,9 @@ do_test (void)
   puts ("done");
 
   return 0;
+#else
+  return 23;
+#endif
 }
 
 

+ 6 - 1
test/nptl/tst-cond9.c

@@ -24,6 +24,7 @@
 #include <sys/time.h>
 
 
+#if defined(__GLIBC__) || defined(__UCLIBC__)
 static pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
 static pthread_mutex_t mut = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP;
 
@@ -68,11 +69,12 @@ tf (void *arg)
 
   return (void *) 1l;
 }
-
+#endif
 
 static int
 do_test (void)
 {
+#if defined(__GLIBC__) || defined(__UCLIBC__)
   pthread_t th;
   int err;
 
@@ -142,6 +144,9 @@ do_test (void)
   puts ("done");
 
   return 0;
+#else
+  return 23;
+#endif
 }
 
 

+ 1 - 1
test/nptl/tst-exec2.c

@@ -26,7 +26,7 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <sys/wait.h>
-
+#include "../test-skeleton.h"
 
 static void *
 tf (void *arg)

+ 1 - 0
test/nptl/tst-exec3.c

@@ -26,6 +26,7 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <sys/wait.h>
+#include "../test-skeleton.h"
 
 
 static void *

+ 2 - 1
test/nptl/tst-flock2.c

@@ -21,10 +21,11 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
+#include <fcntl.h>
 #include <sys/file.h>
 #include <sys/mman.h>
 #include <sys/wait.h>
-
+#include "../test-skeleton.h"
 
 static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
 static pthread_mutex_t lock2 = PTHREAD_MUTEX_INITIALIZER;

+ 1 - 0
test/nptl/tst-fork1.c

@@ -23,6 +23,7 @@
 #include <string.h>
 #include <unistd.h>
 #include <sys/wait.h>
+#include "../test-skeleton.h"
 
 static void *
 thread_function (void * arg)

+ 1 - 1
test/nptl/tst-fork2.c

@@ -22,7 +22,7 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <sys/wait.h>
-
+#include "../test-skeleton.h"
 
 static pid_t initial_pid;
 

+ 1 - 0
test/nptl/tst-fork3.c

@@ -22,6 +22,7 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <sys/wait.h>
+#include "../test-skeleton.h"
 
 
 static pid_t initial_pid;

+ 1 - 1
test/nptl/tst-getpid3.c

@@ -5,7 +5,7 @@
 #include <string.h>
 #include <unistd.h>
 #include <sys/wait.h>
-
+#include "../test-skeleton.h"
 
 static pid_t pid;
 

+ 6 - 0
test/nptl/tst-initializers1.c

@@ -18,6 +18,7 @@
 
 #include <pthread.h>
 
+#if defined(__GLIBC__) || defined(__UCLIBC__)
 pthread_mutex_t mtx_normal = PTHREAD_MUTEX_INITIALIZER;
 pthread_mutex_t mtx_recursive = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
 pthread_mutex_t mtx_errorchk = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP;
@@ -26,10 +27,12 @@ pthread_rwlock_t rwl_normal = PTHREAD_RWLOCK_INITIALIZER;
 pthread_rwlock_t rwl_writer
   = PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP;
 pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
+#endif
 
 int
 main (void)
 {
+#if defined(__GLIBC__) || defined(__UCLIBC__)
   if (mtx_normal.__data.__kind != PTHREAD_MUTEX_TIMED_NP)
     return 1;
   if (mtx_recursive.__data.__kind != PTHREAD_MUTEX_RECURSIVE_NP)
@@ -44,4 +47,7 @@ main (void)
       != PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP)
     return 1;
   return 0;
+#else
+  return 23;
+#endif
 }

+ 1 - 1
test/nptl/tst-kill6.c

@@ -23,7 +23,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
-
+#include "../test-skeleton.h"
 
 static pthread_t receiver;
 static sem_t sem;

+ 1 - 0
test/nptl/tst-mqueue1.c

@@ -27,6 +27,7 @@
 #include <time.h>
 #include <unistd.h>
 #include "tst-mqueue.h"
+#include "../test-skeleton.h"
 
 static int
 intcmp (const void *a, const void *b)

+ 2 - 0
test/nptl/tst-mqueue3.c

@@ -18,6 +18,7 @@
    <http://www.gnu.org/licenses/>.  */
 
 #include <errno.h>
+#include <fcntl.h>
 #include <mqueue.h>
 #include <signal.h>
 #include <stddef.h>
@@ -28,6 +29,7 @@
 #include <sys/mman.h>
 #include <sys/wait.h>
 #include <unistd.h>
+#include "../test-skeleton.h"
 
 #if _POSIX_THREADS
 # include <pthread.h>

+ 1 - 0
test/nptl/tst-mqueue5.c

@@ -32,6 +32,7 @@
 #include <time.h>
 #include <unistd.h>
 #include "tst-mqueue.h"
+#include "../test-skeleton.h"
 
 #define TIMEOUT 3
 

+ 1 - 0
test/nptl/tst-mqueue6.c

@@ -32,6 +32,7 @@
 #include <time.h>
 #include <unistd.h>
 #include "tst-mqueue.h"
+#include "../test-skeleton.h"
 
 #if _POSIX_THREADS
 # include <pthread.h>

+ 3 - 0
test/nptl/tst-mqueue8.c

@@ -17,11 +17,14 @@
    <http://www.gnu.org/licenses/>.  */
 
 #include <errno.h>
+#include <fcntl.h>
 #include <mqueue.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
+#include "../test-skeleton.h"
+
 #if _POSIX_THREADS
 # include <pthread.h>
 

+ 1 - 0
test/nptl/tst-mqueue9.c

@@ -17,6 +17,7 @@
    <http://www.gnu.org/licenses/>.  */
 
 #include <errno.h>
+#include <fcntl.h>
 #include <mqueue.h>
 #include <stdio.h>
 #include <stdlib.h>

+ 4 - 0
test/nptl/tst-mutex5.c

@@ -32,6 +32,7 @@
 static int
 do_test (void)
 {
+#if defined(__GLIBC__) || defined(__UCLIBC__)
   pthread_mutex_t m;
   struct timespec ts;
   struct timeval tv;
@@ -178,6 +179,9 @@ do_test (void)
     }
 
   return 0;
+#else
+  return 23;
+#endif
 }
 
 #define TIMEOUT 4

+ 6 - 1
test/nptl/tst-mutex7.c

@@ -20,6 +20,7 @@
 #include <stdio.h>
 #include <time.h>
 
+#if defined(__GLIBC__) || defined(__UCLIBC__)
 
 #ifndef INIT
 # define INIT PTHREAD_MUTEX_INITIALIZER
@@ -59,11 +60,12 @@ tf (void *arg)
 
   return NULL;
 }
-
+#endif
 
 static int
 do_test (void)
 {
+#if defined(__GLIBC__) || defined(__UCLIBC__)
   pthread_attr_t at;
   pthread_t th[N];
   int cnt;
@@ -113,6 +115,9 @@ do_test (void)
       }
 
   return 0;
+#else
+  return 23;
+#endif
 }
 
 #define TIMEOUT 60

+ 2 - 1
test/nptl/tst-mutex9.c

@@ -26,8 +26,9 @@
 #include <stdint.h>
 #include <stdlib.h>
 #include <sys/time.h>
+#include "../test-skeleton.h"
 
-int gettimeofday(struct timeval *tv, struct timezone *tz);
+//int gettimeofday(struct timeval *tv, struct timezone *tz);
 
 
 static int

+ 1 - 1
test/nptl/tst-rwlock12.c

@@ -25,7 +25,7 @@
 #include <unistd.h>
 #include <sys/mman.h>
 #include <sys/wait.h>
-
+#include "../test-skeleton.h"
 
 static int
 do_test (void)

+ 6 - 2
test/nptl/tst-rwlock6.c

@@ -23,7 +23,7 @@
 #include <string.h>
 #include <sys/time.h>
 
-
+#if defined(__GLIBC__) || defined(__UCLIBC__)
 static int kind[] =
   {
     PTHREAD_RWLOCK_PREFER_READER_NP,
@@ -101,11 +101,12 @@ tf (void *arg)
 
   return NULL;
 }
-
+#endif
 
 static int
 do_test (void)
 {
+#if defined(__GLIBC__) || defined(__UCLIBC__)
   size_t cnt;
   for (cnt = 0; cnt < sizeof (kind) / sizeof (kind[0]); ++cnt)
     {
@@ -219,6 +220,9 @@ do_test (void)
     }
 
   return 0;
+#else
+  return 23;
+#endif
 }
 
 #define TEST_FUNCTION do_test ()

+ 6 - 2
test/nptl/tst-rwlock7.c

@@ -23,7 +23,7 @@
 #include <string.h>
 #include <sys/time.h>
 
-
+#if defined(__GLIBC__) || defined(__UCLIBC__)
 static int kind[] =
   {
     PTHREAD_RWLOCK_PREFER_READER_NP,
@@ -95,11 +95,12 @@ tf (void *arg)
 
   return NULL;
 }
-
+#endif
 
 static int
 do_test (void)
 {
+#if defined(__GLIBC__) || defined(__UCLIBC__)
   size_t cnt;
   for (cnt = 0; cnt < sizeof (kind) / sizeof (kind[0]); ++cnt)
     {
@@ -172,6 +173,9 @@ do_test (void)
     }
 
   return 0;
+#else
+  return 23;
+#endif
 }
 
 #define TEST_FUNCTION do_test ()

+ 6 - 2
test/nptl/tst-rwlock8.c

@@ -24,7 +24,7 @@
 #include <time.h>
 #include <unistd.h>
 
-
+#if defined(__GLIBC__) || defined(__UCLIBC__)
 #define NWRITERS 15
 #define WRITETRIES 10
 #define NREADERS 15
@@ -109,11 +109,12 @@ reader_thread (void *nr)
 
   return NULL;
 }
-
+#endif
 
 static int
 do_test (void)
 {
+#if defined(__GLIBC__) || defined(__UCLIBC__)
   pthread_t thwr[NWRITERS];
   pthread_t thrd[NREADERS];
   int n;
@@ -156,6 +157,9 @@ do_test (void)
       }
 
   return 0;
+#else
+  return 23;
+#endif
 }
 
 #define TIMEOUT 30

+ 6 - 2
test/nptl/tst-rwlock9.c

@@ -25,7 +25,7 @@
 #include <unistd.h>
 #include <sys/time.h>
 
-
+#if defined(__GLIBC__) || defined(__UCLIBC__)
 #define NWRITERS 15
 #define WRITETRIES 10
 #define NREADERS 15
@@ -147,11 +147,12 @@ reader_thread (void *nr)
 
   return NULL;
 }
-
+#endif
 
 static int
 do_test (void)
 {
+#if defined(__GLIBC__) || defined(__UCLIBC__)
   pthread_t thwr[NWRITERS];
   pthread_t thrd[NREADERS];
   int n;
@@ -194,6 +195,9 @@ do_test (void)
       }
 
   return 0;
+#else
+  return 23;
+#endif
 }
 
 #undef TIMEOUT

+ 1 - 1
test/nptl/tst-sem1.c

@@ -20,7 +20,7 @@
 #include <semaphore.h>
 #include <stdio.h>
 #include <unistd.h>
-
+#include "../test-skeleton.h"
 
 static int
 do_test (void)

+ 1 - 0
test/nptl/tst-sem10.c

@@ -23,6 +23,7 @@
 #include <time.h>
 #include <unistd.h>
 #include <sys/time.h>
+#include "../test-skeleton.h"
 
 
 static int

+ 1 - 0
test/nptl/tst-sem2.c

@@ -21,6 +21,7 @@
 #include <signal.h>
 #include <stdio.h>
 #include <unistd.h>
+#include "../test-skeleton.h"
 
 
 static int

+ 1 - 0
test/nptl/tst-sem3.c

@@ -25,6 +25,7 @@
 #include <unistd.h>
 #include <sys/mman.h>
 #include <sys/wait.h>
+#include "../test-skeleton.h"
 
 
 int

+ 5 - 1
test/nptl/tst-sem4.c

@@ -22,7 +22,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
-
+#include "../test-skeleton.h"
 
 static void
 remove_sem (int status, void *arg)
@@ -34,6 +34,7 @@ remove_sem (int status, void *arg)
 int
 do_test (void)
 {
+#if defined(__GLIBC__) || defined(__UCLIBC__)
   sem_t *s;
   sem_t *s2;
   pid_t pid;
@@ -143,6 +144,9 @@ do_test (void)
     }
 
   return 0;
+#else
+  return 23;
+#endif
 }
 
 #define TEST_FUNCTION do_test ()

+ 1 - 1
test/nptl/tst-sem5.c

@@ -22,7 +22,7 @@
 #include <time.h>
 #include <unistd.h>
 #include <sys/time.h>
-
+#include "../test-skeleton.h"
 
 static int
 do_test (void)

+ 4 - 0
test/nptl/tst-sem7.c

@@ -34,6 +34,7 @@ remove_sem (int status, void *arg)
 int
 main (void)
 {
+#if defined(__GLIBC__) || defined(__UCLIBC__)
   sem_t *s;
   sem_t *s2;
   sem_t *s3;
@@ -105,4 +106,7 @@ main (void)
     }
 
   return 0;
+#else
+  return 23;
+#endif
 }

+ 4 - 0
test/nptl/tst-sem8.c

@@ -34,6 +34,7 @@ remove_sem (int status, void *arg)
 int
 main (void)
 {
+#if defined(__GLIBC__) || defined(__UCLIBC__)
   sem_t *s;
   int i;
 
@@ -70,4 +71,7 @@ main (void)
     }
 
   return 0;
+#else
+  return 23;
+#endif
 }

+ 4 - 0
test/nptl/tst-sem9.c

@@ -34,6 +34,7 @@ remove_sem (int status, void *arg)
 int
 main (void)
 {
+#if defined(__GLIBC__) || defined(__UCLIBC__)
   sem_t *s;
   int i;
 
@@ -77,4 +78,7 @@ main (void)
     }
 
   return 0;
+#else
+  return 23;
+#endif
 }

+ 1 - 0
test/nptl/tst-signal1.c

@@ -25,6 +25,7 @@
 #include <unistd.h>
 #include <sys/mman.h>
 #include <sys/wait.h>
+#include "../test-skeleton.h"
 
 
 static sigset_t ss;

+ 1 - 0
test/nptl/tst-signal2.c

@@ -25,6 +25,7 @@
 #include <sys/mman.h>
 #include <sys/wait.h>
 #include <string.h>
+#include "../test-skeleton.h"
 
 
 static sigset_t ss;

+ 1 - 0
test/nptl/tst-signal3.c

@@ -23,6 +23,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
+#include "../test-skeleton.h"
 
 
 /* Number of different signalss to use.  Also is the number of

+ 2 - 0
test/nptl/tst-timer4.c

@@ -23,6 +23,8 @@
 #include <string.h>
 #include <time.h>
 #include <unistd.h>
+#include "../test-skeleton.h"
+
 #if _POSIX_THREADS
 # include <pthread.h>
 

+ 1 - 0
test/nptl/tst-tls2.c

@@ -23,6 +23,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
+#include "../test-skeleton.h"
 
 
 #define N 10

+ 1 - 0
test/nptl/tst-tls3.c

@@ -25,6 +25,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
+#include "../test-skeleton.h"
 
 #define THE_SIG SIGUSR1
 

+ 1 - 0
test/nptl/tst-tsd6.c

@@ -4,6 +4,7 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <sys/wait.h>
+#include "../test-skeleton.h"
 
 #define NKEYS 100
 static pthread_key_t keys[NKEYS];

+ 1 - 0
test/nptl/tst-vfork1x.c

@@ -23,6 +23,7 @@
 #include <unistd.h>
 #include <sys/types.h>
 #include <sys/wait.h>
+#include "../test-skeleton.h"
 
 /* This test relies on non-POSIX functionality since the child
    processes call write and getpid.  */

+ 1 - 0
test/nptl/tst-vfork2x.c

@@ -27,6 +27,7 @@
 #include <sys/time.h>
 #include <sys/types.h>
 #include <sys/wait.h>
+#include "../test-skeleton.h"
 
 int raise_fail;
 

+ 4 - 0
test/regex/tst-regex2.c

@@ -15,6 +15,7 @@
 static int
 do_test(void)
 {
+#if defined(__GLIBC__) || defined(__UCLIBC__)
 	static const char *pat[] = {
 		".?.?.?.?.?.?.?Log\\.13",
 		"(.?)(.?)(.?)(.?)(.?)(.?)(.?)Log\\.13",
@@ -243,6 +244,9 @@ do_test(void)
 		}
 	}
 	return exitcode;
+#else
+	return 23;
+#endif
 }
 
 #define TIMEOUT 100

+ 2 - 3
test/regex/tst-regexloc.c

@@ -25,7 +25,7 @@ main (int argc, char *argv[])
 {
 /* If uclibc has extended locale, or if it's a host build
  * (assuming host libc always has locale): */
-#if defined __UCLIBC_HAS_XLOCALE__ || !defined __UCLIBC__
+#if defined __UCLIBC_HAS_XLOCALE__ || (defined(__GLIBC__) && !defined __UCLIBC__)
   regex_t re;
   regmatch_t mat[1];
   int exitcode = 1;
@@ -47,7 +47,6 @@ main (int argc, char *argv[])
 
   return exitcode;
 #else
-  puts("Test requires locale; skipping");
-  return 0;
+  return 23;
 #endif
 }

+ 0 - 5
test/setjmp/tst-vfork-longjmp.c

@@ -49,11 +49,6 @@ static int check_sig_mask(void)
 			_exit(1);
 		}
 		ret = memcmp(&orig_mask, &child_mask, sizeof(orig_mask));
-		if (verbose) {
-			printf("sigmsk: %08lx%08lx ", child_mask.__val[1], child_mask.__val[0]);
-			printf("sigmsk: %08lx%08lx ", orig_mask.__val[1], orig_mask.__val[0]);
-			printf("%i\n", ret);
-		}
 		_exit(ret);
 	} else if (child == 1)
 		return 1;

+ 4 - 0
test/stdlib/test-canon2.c

@@ -69,6 +69,7 @@ do_prepare (int argc, char *argv[])
 int
 do_test (int argc, char *argv[])
 {
+#if defined(__GLIBC__) || defined(__UCLIBC__)
   char *canon;
 
   printf ("create symlinks from %s to %s and vice versa\n", name1, name2);
@@ -83,4 +84,7 @@ do_test (int argc, char *argv[])
   canon = canonicalize_file_name (name1);
 
   return canon != NULL || errno != ELOOP;
+#else
+  return 23;
+#endif
 }

+ 4 - 0
test/stdlib/teston_exit.c

@@ -66,6 +66,7 @@ static efuncp func_table[] =
 int
 main ( void )
 {
+#if defined(__GLIBC__) || defined(__UCLIBC__)
 	int i = 0;
 	unsigned long count = 0;
 	int numfuncs = sizeof(func_table)/sizeof(efuncp);
@@ -78,5 +79,8 @@ main ( void )
 	}
 	printf("%lu functions registered with on_exit.\n", count);
 	exit(count);
+#else
+	return 23;
+#endif
 }
 

+ 6 - 0
test/stdlib/teststrtoq.c

@@ -66,6 +66,7 @@ int n_tests=sizeof(strings)/sizeof(strings[0]);
 void do_test(int base);
 void do_test(int base)
 {
+#if defined(__GLIBC__) || defined(__UCLIBC__)
 	int i;
 	quad_t n;
 	char *endptr;
@@ -75,10 +76,12 @@ void do_test(int base)
 		printf("strtoq(\"%s\",%d) len=%lu res=%qd\n",
 			strings[i],base,(unsigned long)(endptr-strings[i]),n);
 	}
+#endif
 }
 
 int main(int argc,char *argv[])
 {
+#if defined(__GLIBC__) || defined(__UCLIBC__)
 	do_test(0);
 	do_test(8);
 	do_test(10);
@@ -86,4 +89,7 @@ int main(int argc,char *argv[])
 	do_test(36);
 
 	return 0;
+#else
+	return 23;
+#endif
 }

+ 2 - 0
test/string/stratcliff.c

@@ -152,6 +152,7 @@ main (int argc, char *argv[])
         }
 
       /* rawmemchr test */
+#if defined(__GLIBC__) || defined(__UCLIBC__)
       for (outer = size - 1; outer >= MAX (0, size - 128); --outer)
         {
 	  for (middle = MAX (outer, size - 64); middle < size; ++middle)
@@ -171,6 +172,7 @@ main (int argc, char *argv[])
 	      adr[middle] = 'T';
 	    }
         }
+#endif
 
       /* strcpy test */
       for (outer = size - 1; outer >= MAX (0, size - 128); --outer)

+ 2 - 0
test/string/tester.c

@@ -1554,7 +1554,9 @@ main (void)
   test_strchrnul ();
 
   /* rawmemchr.  */
+#if defined(__GLIBC__) || defined(__UCLIBC__)
   test_rawmemchr ();
+#endif
 
   /* index - just like strchr.  */
   test_index ();

+ 2 - 0
test/test-skeleton.c

@@ -32,7 +32,9 @@
 #include <sys/param.h>
 #include <time.h>
 #include <features.h>
+#include "test-skeleton.h"
 
+	 
 /* The test function is normally called `do_test' and it is called
    with argc and argv as the arguments.  We nevertheless provide the
    possibility to overwrite this name.  */

+ 8 - 0
test/test-skeleton.h

@@ -0,0 +1,8 @@
+#ifndef TEMP_FAILURE_RETRY 
+#define TEMP_FAILURE_RETRY(expression) \
+  (__extension__                                                              \
+    ({ long int __result;                                                     \
+       do __result = (long int) (expression);                                 \
+       while (__result == -1L && errno == EINTR);                             \
+       __result; }))
+#endif