Ticket #161: run_to_death.pl

File run_to_death.pl, 667 bytes (added by Brian Warner, 13 years ago)

tool to run a test program over and over until it fails

Line 
1#!/usr/bin/perl -w
2
3@cmd = @ARGV;
4
5$start = time();
6$count = 0;
7while(1) {
8    print "pass $count, running command '", join(' ',@cmd),"'\n";
9    $rc = system(@cmd);
10    my $signum = $rc & 0xff;
11    if ($signum) {
12        print "Process died from signal $signum\n";
13        last;
14    }
15    my $exitcode = $rc >> 8;
16    if ($exitcode) {
17        print "Process exited with exit code $exitcode\n";
18        last;
19    }
20    my $elapsed = time() - $start;
21    print "command completed successfully, ",
22      "pass $count, elapsed time $elapsed seconds\n";
23    $count++;
24}
25
26$elapsed = time() - $start;
27print "loop terminated on pass $count after $elapsed seconds\n";
28exit 1;