X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/e9ad7bb1f846834190ae8377d5e8f0ded543ff3a..18070203c27337c33101bb22f54f924da65387b2:/testrun.c diff --git a/testrun.c b/testrun.c index 46c59e89..ddf596d3 100644 --- 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