-
Notifications
You must be signed in to change notification settings - Fork 74
/
test_busted
executable file
·57 lines (46 loc) · 1.07 KB
/
test_busted
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/perl
# These scripts fail..but normal harness doesn't deal well with
# failing scripts..so run them here.
use strict;
# These commands are bad to hang and otherwise mis-behave.
# So, fork before calling them..and kill them if they don't
# die in time.
my $timeout = 120;
sub REAPER {
$SIG{CHLD} = \&REAPER;
wait;
}
$SIG{CHLD} = \&REAPER;
sub fork_sys {
my $cmd = shift;
my $timeout = shift;
my $pid = fork();
if ($pid == 0) {
# child
system($cmd);
}
elsif ($pid > 0) {
# Parent.
my $i;
for ($i = 0; $i<$timeout; $i++) {
if (-f "/proc/$pid/cmdline") {
sleep(1);
}
else {
return;
}
}
my $cmd1 = `cat /proc/$pid/cmdline`;
if ($cmd1 =~ /test_/) {
print "WARNING: Killing hung test child process: $pid\n";
kill(9, $pid);
}
}
else {
print "ERROR: fork failed in test_busted script!\n";
}
}
fork_sys("./test_peering1.sh -l -t test26", $timeout);
fork_sys("./test_peering1.sh -l -t test28_ipv6", $timeout);
fork_sys("./test_peering1.sh -l -t test28_ipv6_ok", $timeout);
exit(0);