X-Git-Url: http://rtime.felk.cvut.cz/gitweb/can-benchmark.git/blobdiff_plain/1e967327a9c288b5fff8e9db78b678d2192c5b0e..5e86a605b58d5c3717b81528df44c73d9d1aaf25:/continuous/gw-setup/run.pl diff --git a/continuous/gw-setup/run.pl b/continuous/gw-setup/run.pl index 068c5dd..47997d4 100755 --- a/continuous/gw-setup/run.pl +++ b/continuous/gw-setup/run.pl @@ -2,20 +2,25 @@ use FindBin; +# Create startup script in ramdisk my $S99 = "$FindBin::Bin/initramfs/etc/init.d/S99benchmark"; system("rm -f $S99"); system("cat > $S99; chmod +x $S99") unless -t STDIN; +# Boot gateway my $boot; my $pid = &run_boot; $|=1; my $ready; while (<$boot>){ - last if ($ready = /Welcome to Buildroot/ || /UGW started/); + last if ($ready = m/Welcome to Buildroot/ || + m/UGW started/ || + m/t...a...s...k...s... ...s...t...a...r...t...e...d/); # RTEMS has bug - it sends 4 characters instead of just one } die "Boot failed" unless $ready; +# Measure latencies my $latester=<<'EOF'; rm -f tmp-stat.txt echo "Starting latester" @@ -34,15 +39,18 @@ my $status = system((qw(ssh -T glab), $latester)); kill('TERM', -$pid); exit($status >> 8); +# Helper functions sub kill_boot() { kill('TERM', -$pid) if defined $pid; } sub run_boot() { # die("No boot command") if ($#ARGV eq -1); - # my $bootcmd = "'".join("' '", @ARGV)."'"; - - my $bootcmd = "$FindBin::Bin/boot"; + my $bootcmd = scalar @ARGV ? "'".join("' '", @ARGV)."'" : "$FindBin::Bin/boot"; $SIG{INT} = sub { kill_boot(); exit; }; + $SIG{HUP} = sub { kill_boot(); exit; }; + $SIG{ALRM} = sub { kill_boot(); exit; }; + $SIG{TERM} = sub { kill_boot(); exit; }; + $SIG{QUIT} = sub { kill_boot(); exit; }; pipe($boot, $wh) || die("pipe: $!"); my $pid = fork() // die("fork: $!");