Allow per-test timeout overrides. Give hardlinks more time.
authorWayne Davison <wayned@samba.org>
Tue, 15 Dec 2009 16:44:46 +0000 (08:44 -0800)
committerWayne Davison <wayned@samba.org>
Tue, 15 Dec 2009 16:44:46 +0000 (08:44 -0800)
runtests.sh
testrun.c

index db95d8f..43732ce 100755 (executable)
@@ -229,8 +229,9 @@ echo "    scratchbase=$scratchbase"
 [ -d "$scratchbase" ] || mkdir "$scratchbase"
 
 suitedir="$srcdir/testsuite"
+TESTRUN_TIMEOUT=300
 
-export scratchdir suitedir
+export scratchdir suitedir TESTRUN_TIMEOUT
 
 prep_scratch() {
     [ -d "$scratchdir" ] && chmod -R u+rwX "$scratchdir" && rm -rf "$scratchdir"
@@ -261,6 +262,11 @@ do
 
     prep_scratch
 
+    case "$testscript" in
+    *hardlinks*) TESTRUN_TIMEOUT=600 ;;
+    *) TESTRUN_TIMEOUT=300 ;;
+    esac
+
     set +e
     "$TOOLDIR/"testrun $RUNSHFLAGS "$testscript" >"$scratchdir/test.log" 2>&1
     result=$?
index 46c59e8..ddf596d 100644 (file)
--- a/testrun.c
+++ b/testrun.c
@@ -2,18 +2,25 @@
 
 #include "rsync.h"
 
-#define MAX_TEST_SECONDS (5*60)
+#define DEFAULT_TIMEOUT_SECS (5*60)
+#define TIMEOUT_ENV "TESTRUN_TIMEOUT"
 
  int main(int argc, char *argv[])
 {
        pid_t pid;
-       int status, slept = 0;
+       char *timeout_env;
+       int status, timeout_secs, slept = 0;
 
        if (argc < 2) {
                fprintf(stderr, "Usage: testrun [SHELL_OPTIONS] TESTSUITE_SCRIPT [ARGS]\n");
                exit(1);
        }
 
+       if ((timeout_env = getenv(TIMEOUT_ENV)) != NULL)
+               timeout_secs = atoi(timeout_env);
+       else
+               timeout_secs = DEFAULT_TIMEOUT_SECS;
+
        if ((pid = fork()) < 0) {
                fprintf(stderr, "TESTRUN ERROR: fork failed: %s\n", strerror(errno));
                exit(1);
@@ -36,8 +43,8 @@
                        fprintf(stderr, "TESTRUN ERROR: waitpid failed: %s\n", strerror(errno));
                        exit(1);
                }
-               if (slept++ > MAX_TEST_SECONDS) {
-                       fprintf(stderr, "TESTRUN TIMEOUT: test took over %d seconds.\n", MAX_TEST_SECONDS);
+               if (slept++ > timeout_secs) {
+                       fprintf(stderr, "TESTRUN TIMEOUT: test took over %d seconds.\n", timeout_secs);
                        if (kill(pid, SIGTERM) < 0)
                                fprintf(stderr, "TESTRUN ERROR: failed to kill pid %ld: %s\n", (long)pid, strerror(errno));
                        else