summary refs log tree commit diff
path: root/test-skeleton.c
diff options
context:
space:
mode:
authorLeonhard Holz <leonhard.holz@web.de>2014-11-12 17:10:21 +0530
committerSiddhesh Poyarekar <siddhesh@redhat.com>2014-11-12 17:10:21 +0530
commitfffa1cf8a7f95830d488d5fc6bf73cb9599143f4 (patch)
tree8b403ababaaa45686715211c3f2bb8fc68bd173f /test-skeleton.c
parentfb89b46d1d1cdbaaec1af918a3a3e1bd72a164e0 (diff)
downloadglibc-fffa1cf8a7f95830d488d5fc6bf73cb9599143f4.tar.gz
glibc-fffa1cf8a7f95830d488d5fc6bf73cb9599143f4.tar.xz
glibc-fffa1cf8a7f95830d488d5fc6bf73cb9599143f4.zip
Fix tst-strcoll-overflow returning before timeout (BZ #17506)
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.
Diffstat (limited to 'test-skeleton.c')
-rw-r--r--test-skeleton.c63
1 files changed, 35 insertions, 28 deletions
diff --git a/test-skeleton.c b/test-skeleton.c
index c1278ca3b2..3621009b7e 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
+    }
 }