Browse Source

test: Some more tests under conditionals

Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Bernhard Reutner-Fischer 9 years ago
parent
commit
bff3a664e6

+ 3 - 0
test/Rules.mak

@@ -78,6 +78,9 @@ CFLAGS         := -nostdinc -I$(top_builddir)$(LOCAL_INSTALL_PATH)/usr/include
 CFLAGS         += $(XCOMMON_CFLAGS) $(KERNEL_INCLUDES) $(CC_INC)
 CFLAGS         += $(XCOMMON_CFLAGS) $(KERNEL_INCLUDES) $(CC_INC)
 CFLAGS         += $(OPTIMIZATION) $(CPU_CFLAGS) $(XWARNINGS)
 CFLAGS         += $(OPTIMIZATION) $(CPU_CFLAGS) $(XWARNINGS)
 
 
+$(eval $(call check-gcc-var,-Wno-missing-field-initializers))
+CFLAGS         += $(CFLAG_-Wno-missing-field-initializers)
+
 # Can't add $(OPTIMIZATION) here, it may be target-specific.
 # Can't add $(OPTIMIZATION) here, it may be target-specific.
 # Just adding -Os for now.
 # Just adding -Os for now.
 HOST_CFLAGS    += $(XCOMMON_CFLAGS) -Os $(XWARNINGS) -std=gnu99
 HOST_CFLAGS    += $(XCOMMON_CFLAGS) -Os $(XWARNINGS) -std=gnu99

+ 8 - 0
test/misc/Makefile.in

@@ -8,6 +8,14 @@ TESTS_DISABLED += tst-statfs # assuming host has LFS on
 endif
 endif
 CFLAGS_dirent64 := -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
 CFLAGS_dirent64 := -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
 
 
+ifeq ($(UCLIBC_LINUX_SPECIFIC),)
+TESTS_DISABLED += tst-inotify
+endif
+
+ifeq ($(UCLIBC_HAS_GLOB),)
+TESTS_DISABLED += bug-glob2
+endif
+
 DODIFF_dirent    := 1
 DODIFF_dirent    := 1
 DODIFF_dirent64  := 1
 DODIFF_dirent64  := 1
 DODIFF_tst-statfs := 1
 DODIFF_tst-statfs := 1

+ 0 - 1
test/misc/bug-glob2.c

@@ -18,7 +18,6 @@
    <http://www.gnu.org/licenses/>.  */
    <http://www.gnu.org/licenses/>.  */
 
 
 #include <errno.h>
 #include <errno.h>
-#include <error.h>
 #include <dirent.h>
 #include <dirent.h>
 #include <glob.h>
 #include <glob.h>
 #include <stdlib.h>
 #include <stdlib.h>

+ 3 - 4
test/misc/tst-inotify.c

@@ -11,7 +11,6 @@
 #include <string.h>
 #include <string.h>
 #include <unistd.h>
 #include <unistd.h>
 #include <errno.h>
 #include <errno.h>
-#include <error.h>
 #include <inttypes.h>
 #include <inttypes.h>
 #include <sys/inotify.h>
 #include <sys/inotify.h>
 #include <sys/fcntl.h>
 #include <sys/fcntl.h>
@@ -39,7 +38,7 @@ do_test(void)
 	/* nonblocking inotify should return immediately with no events */
 	/* nonblocking inotify should return immediately with no events */
 	ret = read(ifd, &e, sizeof(e));
 	ret = read(ifd, &e, sizeof(e));
 	if (ret != -1 || errno != EAGAIN) {
 	if (ret != -1 || errno != EAGAIN) {
-		error(0, 0, "first read() returned %d", ret);
+		fprintf(stderr, "first read() returned %d\n", ret);
 		result = 1;
 		result = 1;
 	}
 	}
 
 
@@ -49,12 +48,12 @@ do_test(void)
 	/* now check whether our event was seen */
 	/* now check whether our event was seen */
 	ret = read(ifd, &e, sizeof(e));
 	ret = read(ifd, &e, sizeof(e));
 	if (ret != sizeof(e)) {
 	if (ret != sizeof(e)) {
-		error(0, 0, "second read() returned %d", ret);
+		fprintf(stderr, "second read() returned %d\n", ret);
 		result = 1;
 		result = 1;
 	}
 	}
 
 
 	if (!(e.mask & IN_DELETE_SELF)) {
 	if (!(e.mask & IN_DELETE_SELF)) {
-		error(0, 0, "incorrect event mask: %" PRIx32, e.mask);
+		fprintf(stderr, "incorrect event mask: %" PRIx32 "\n", e.mask);
 		result = 1;
 		result = 1;
 	}
 	}
 
 

+ 25 - 20
test/misc/tst-utmp.c

@@ -18,7 +18,6 @@
    <http://www.gnu.org/licenses/>.  */
    <http://www.gnu.org/licenses/>.  */
 
 
 #include <errno.h>
 #include <errno.h>
-#include <error.h>
 #include <stdlib.h>
 #include <stdlib.h>
 #include <string.h>
 #include <string.h>
 #include <sys/types.h>
 #include <sys/types.h>
@@ -69,8 +68,11 @@ do_prepare (int argc, char *argv[])
 
 
   /* Open our test file.  */
   /* Open our test file.  */
   fd = mkstemp (name);
   fd = mkstemp (name);
-  if (fd == -1)
-    error (EXIT_FAILURE, errno, "cannot open test file `%s'", name);
+  if (fd == -1) {
+    fprintf (stderr, "cannot open test file `%s': ", name);
+    perror (NULL);
+    exit (EXIT_FAILURE);
+  }
 }
 }
 
 
 struct utmp entry[] =
 struct utmp entry[] =
@@ -110,7 +112,7 @@ do_init (void)
     {
     {
       if (pututline (&entry[n]) == NULL)
       if (pututline (&entry[n]) == NULL)
 	{
 	{
-	  error (0, errno, "cannot write UTMP entry");
+	  perror ("cannot write UTMP entry");
 	  return 1;
 	  return 1;
 	}
 	}
     }
     }
@@ -135,7 +137,7 @@ do_check (void)
       if (n < num_entries &&
       if (n < num_entries &&
 	  memcmp (ut, &entry[n], sizeof (struct utmp)))
 	  memcmp (ut, &entry[n], sizeof (struct utmp)))
 	{
 	{
-	  error (0, 0, "UTMP entry does not match");
+	  fprintf (stderr, "UTMP entry does not match\n");
 	  return 1;
 	  return 1;
 	}
 	}
 
 
@@ -144,7 +146,7 @@ do_check (void)
 
 
   if (n != num_entries)
   if (n != num_entries)
     {
     {
-      error (0, 0, "number of UTMP entries is incorrect");
+      fprintf (stderr, "number of UTMP entries is incorrect\n");
       return 1;
       return 1;
     }
     }
 
 
@@ -176,7 +178,7 @@ simulate_login (const char *line, const char *user)
 
 
 	  if (pututline (&entry[n]) == NULL)
 	  if (pututline (&entry[n]) == NULL)
 	    {
 	    {
-	      error (0, errno, "cannot write UTMP entry");
+	      perror ("cannot write UTMP entry");
 	      return 1;
 	      return 1;
 	    }
 	    }
 
 
@@ -186,7 +188,7 @@ simulate_login (const char *line, const char *user)
 	}
 	}
     }
     }
 
 
-  error (0, 0, "no entries available");
+  fprintf (stderr, "no entries available\n");
   return 1;
   return 1;
 }
 }
 
 
@@ -210,7 +212,7 @@ simulate_logout (const char *line)
 
 
 	  if (pututline (&entry[n]) == NULL)
 	  if (pututline (&entry[n]) == NULL)
 	    {
 	    {
-	      error (0, errno, "cannot write UTMP entry");
+	      perror ("cannot write UTMP entry");
 	      return 1;
 	      return 1;
 	    }
 	    }
 
 
@@ -220,7 +222,7 @@ simulate_logout (const char *line)
 	}
 	}
     }
     }
 
 
-  error (0, 0, "no entry found for `%s'", line);
+  fprintf (stderr, "no entry found for `%s'\n", line);
   return 1;
   return 1;
 }
 }
 
 
@@ -237,7 +239,8 @@ check_login (const char *line)
   up = getutline (&ut);
   up = getutline (&ut);
   if (up == NULL)
   if (up == NULL)
     {
     {
-      error (0, errno, "cannot get entry for line `%s'", line);
+      fprintf (stderr, "cannot get entry for line `%s': ", line);
+	  perror(NULL);
       return 1;
       return 1;
     }
     }
 
 
@@ -249,7 +252,7 @@ check_login (const char *line)
 	{
 	{
 	  if (memcmp (up, &entry[n], sizeof (struct utmp)))
 	  if (memcmp (up, &entry[n], sizeof (struct utmp)))
 	    {
 	    {
-	      error (0, 0, "UTMP entry does not match");
+	      fprintf (stderr, "UTMP entry does not match\n");
 	      return 1;
 	      return 1;
 	    }
 	    }
 
 
@@ -257,7 +260,7 @@ check_login (const char *line)
 	}
 	}
     }
     }
 
 
-  error (0, 0, "bogus entry for line `%s'", line);
+  fprintf (stderr, "bogus entry for line `%s'\n", line);
   return 1;
   return 1;
 }
 }
 
 
@@ -271,7 +274,7 @@ check_logout (const char *line)
   strcpy (ut.ut_line, line);
   strcpy (ut.ut_line, line);
   if (getutline (&ut) != NULL)
   if (getutline (&ut) != NULL)
     {
     {
-      error (0, 0, "bogus login entry for `%s'", line);
+      fprintf (stderr, "bogus login entry for `%s'\n", line);
       return 1;
       return 1;
     }
     }
 
 
@@ -294,7 +297,8 @@ check_id (const char *id)
   up = getutid (&ut);
   up = getutid (&ut);
   if (up == NULL)
   if (up == NULL)
     {
     {
-      error (0, errno, "cannot get entry for ID `%s'", id);
+      fprintf (stderr, "cannot get entry for ID `%s': ", id);
+	  perror (NULL);
       return 1;
       return 1;
     }
     }
 
 
@@ -306,7 +310,7 @@ check_id (const char *id)
 	{
 	{
 	  if (memcmp (up, &entry[n], sizeof (struct utmp)))
 	  if (memcmp (up, &entry[n], sizeof (struct utmp)))
 	    {
 	    {
-	      error (0, 0, "UTMP entry does not match");
+	      fprintf (stderr, "UTMP entry does not match\n");
 	      return 1;
 	      return 1;
 	    }
 	    }
 
 
@@ -314,7 +318,7 @@ check_id (const char *id)
 	}
 	}
     }
     }
 
 
-  error (0, 0, "bogus entry for ID `%s'", id);
+  fprintf (stderr, "bogus entry for ID `%s'\n", id);
   return 1;
   return 1;
 }
 }
 
 
@@ -331,7 +335,8 @@ check_type (int type)
   up = getutid (&ut);
   up = getutid (&ut);
   if (up == NULL)
   if (up == NULL)
     {
     {
-      error (0, errno, "cannot get entry for type `%d'", type);
+      fprintf (stderr, "cannot get entry for type `%d': ", type);
+	  perror (NULL);
       return 1;
       return 1;
     }
     }
 
 
@@ -343,7 +348,7 @@ check_type (int type)
 	{
 	{
 	  if (memcmp (up, &entry[n], sizeof (struct utmp)))
 	  if (memcmp (up, &entry[n], sizeof (struct utmp)))
 	    {
 	    {
-	      error (0, 0, "UTMP entry does not match");
+	      fprintf (stderr, "UTMP entry does not match\n");
 	      return 1;
 	      return 1;
 	    }
 	    }
 
 
@@ -351,7 +356,7 @@ check_type (int type)
 	}
 	}
     }
     }
 
 
-  error (0, 0, "bogus entry for type `%d'", type);
+  fprintf (stderr, "bogus entry for type `%d'\n", type);
   return 1;
   return 1;
 }
 }
 
 

+ 6 - 5
test/pwd_grp/getgroups.c

@@ -13,7 +13,6 @@
 #include <sys/types.h>
 #include <sys/types.h>
 #include <pwd.h>
 #include <pwd.h>
 #include <grp.h>
 #include <grp.h>
-#include <err.h>
 
 
 /* The number of errors encountered so far. */
 /* The number of errors encountered so far. */
 static int problems = 0;
 static int problems = 0;
@@ -25,7 +24,7 @@ static void print_group(gid_t gid)
 
 
 	grp = getgrgid(gid);
 	grp = getgrgid(gid);
 	if (grp == NULL) {
 	if (grp == NULL) {
-		warn("cannot find name for group ID %u", gid);
+		fprintf(stderr, "cannot find name for group ID %u\n", gid);
 		problems++;
 		problems++;
 	}
 	}
 
 
@@ -46,12 +45,14 @@ static int xgetgroups(gid_t gid, int *n_groups, gid_t ** groups)
 
 
 	/* Add 1 just in case max_n_groups is zero.  */
 	/* Add 1 just in case max_n_groups is zero.  */
 	g = (gid_t *) malloc(max_n_groups * sizeof(gid_t) + 1);
 	g = (gid_t *) malloc(max_n_groups * sizeof(gid_t) + 1);
-	if (g == NULL)
-		err(EXIT_FAILURE, "out of memory");
+	if (g == NULL) {
+		fprintf(stderr, "out of memory\n");
+		exit(EXIT_FAILURE);
+	}
 	ng = getgroups(max_n_groups, g);
 	ng = getgroups(max_n_groups, g);
 
 
 	if (ng < 0) {
 	if (ng < 0) {
-		warn("cannot get supplemental group list");
+		fprintf(stderr, "cannot get supplemental group list\n");
 		++fail;
 		++fail;
 		free(g);
 		free(g);
 	}
 	}

+ 7 - 0
test/test-skeleton.c

@@ -145,7 +145,9 @@ signal_handler (int sig __attribute__ ((unused)))
   /* Wait for it to terminate.  */
   /* Wait for it to terminate.  */
   for (i = 0; i < 5; ++i)
   for (i = 0; i < 5; ++i)
     {
     {
+#ifdef __UCLIBC_HAS_REALTIME__
       struct timespec ts;
       struct timespec ts;
+#endif
       killed = waitpid (pid, &status, WNOHANG|WUNTRACED);
       killed = waitpid (pid, &status, WNOHANG|WUNTRACED);
       if (killed != 0)
       if (killed != 0)
 	break;
 	break;
@@ -154,9 +156,14 @@ signal_handler (int sig __attribute__ ((unused)))
 	 nanosleep() call return prematurely, all the better.  We
 	 nanosleep() call return prematurely, all the better.  We
 	 won't restart it since this probably means the child process
 	 won't restart it since this probably means the child process
 	 finally died.  */
 	 finally died.  */
+#ifdef __UCLIBC_HAS_REALTIME__
       ts.tv_sec = 0;
       ts.tv_sec = 0;
       ts.tv_nsec = 100000000;
       ts.tv_nsec = 100000000;
       nanosleep (&ts, NULL);
       nanosleep (&ts, NULL);
+#else
+	  /* No nanosleep, just sleep 1s instead of 0.1s */
+	  sleep(1);
+#endif
     }
     }
   if (killed != 0 && killed != pid)
   if (killed != 0 && killed != pid)
     {
     {