[Patch][BZ 17506] fix tst-strcoll-overflow returning before timeout

Leonhard Holz leonhard.holz@web.de
Sat Oct 25 11:48:00 GMT 2014


Modifies the test examination in test-skeleton.c so that a test can be 
successful if it is interrupted or it returns uninterrupted with the 
expected status. For this both EXPECTED_SIGNAL and EXPECTED_STATUS have 
to be set, as is done in tst-strcoll-overflow.c.

2014-10-25  Leonhard Holz  <leonhard.holz@web.de>

	* test-skeleton.c (main): Return successful if one of
	EXPECTED_SIGNAL or EXPECTED_STATUS is met when both given.
	* string/tst-strcoll-overflow.c: Define expected status.

-------------- next part --------------
diff --git a/test-skeleton.c b/test-skeleton.c
index c1278ca..3621009 100644
--- a/test-skeleton.c
+++ b/test-skeleton.c
@@ -383,39 +383,46 @@ main (int argc, char *argv[])
       exit (1);
     }
 
-#ifndef EXPECTED_SIGNAL
-  /* We don't expect any signal.  */
-# define EXPECTED_SIGNAL 0
-#endif
-  if (WTERMSIG (status) != EXPECTED_SIGNAL)
+  /* Process terminated normaly without timeout etc.  */
+  if (WIFEXITED (status))
     {
-      if (EXPECTED_SIGNAL != 0)
-	{
-	  if (WTERMSIG (status) == 0)
-	    printf ("Expected signal '%s' from child, got none\n",
-		    strsignal (EXPECTED_SIGNAL));
-	  else
-	    printf ("Incorrect signal from child: got `%s', need `%s'\n",
-		    strsignal (WTERMSIG (status)),
-		    strsignal (EXPECTED_SIGNAL));
-	}
-      else
-	printf ("Didn't expect signal from child: got `%s'\n",
-		strsignal (WTERMSIG (status)));
-      exit (1);
-    }
-
-  /* Simply exit with the return value of the test.  */
 #ifndef EXPECTED_STATUS
-  return WEXITSTATUS (status);
+# ifndef EXPECTED_SIGNAL
+      /* Simply exit with the return value of the test.  */
+      return WEXITSTATUS (status);
+# else
+      printf ("Expected signal '%s' from child, got none\n",
+	      strsignal (EXPECTED_SIGNAL));
+      exit (1);
+# endif
 #else
-  if (WEXITSTATUS (status) != EXPECTED_STATUS)
+      if (WEXITSTATUS (status) != EXPECTED_STATUS)
+        {
+          printf ("Expected status %d, got %d\n",
+	          EXPECTED_STATUS, WEXITSTATUS (status));
+          exit (1);
+        }
+
+      return 0;
+#endif
+    }
+  /* Process was killed by timer or other signal.  */
+  else
     {
-      printf ("Expected status %d, got %d\n",
-	      EXPECTED_STATUS, WEXITSTATUS (status));
+#ifndef EXPECTED_SIGNAL
+      printf ("Didn't expect signal from child: got `%s'\n",
+	      strsignal (WTERMSIG (status)));
       exit (1);
-    }
+#else
+      if (WTERMSIG (status) != EXPECTED_SIGNAL)
+	{
+	  printf ("Incorrect signal from child: got `%s', need `%s'\n",
+		  strsignal (WTERMSIG (status)),
+		  strsignal (EXPECTED_SIGNAL));
+	  exit (1);
+	}
 
-  return 0;
+      return 0;
 #endif
+    }
 }
-------------- next part --------------
diff --git a/string/tst-strcoll-overflow.c b/string/tst-strcoll-overflow.c
index e7a43ea..0d764af 100644
--- a/string/tst-strcoll-overflow.c
+++ b/string/tst-strcoll-overflow.c
@@ -57,5 +57,6 @@ do_test (void)
 
 #define TIMEOUT 300
 #define EXPECTED_SIGNAL SIGALRM
+#define EXPECTED_STATUS 0
 #define TEST_FUNCTION do_test ()
 #include "../test-skeleton.c"


More information about the Libc-alpha mailing list