From: Wolfram Schneider Date: Mon, 7 Apr 2014 15:48:05 +0000 (+0000) Subject: save X-Git-Tag: 1.0.0~995^2~8 X-Git-Url: http://git.indexdata.com/?a=commitdiff_plain;ds=sidebyside;h=bd230d3ba29021292ab66acd507242f66e04c904;hp=6e306694d5e2af37bd8575462c533d7fd6e299ac;p=mkws-moved-to-github.git save --- diff --git a/test/Makefile b/test/Makefile index a1142b1..d4033ec 100644 --- a/test/Makefile +++ b/test/Makefile @@ -12,7 +12,7 @@ JASMINE_NODE= ./node_modules/jasmine-node/bin/jasmine-node PHANTOMJS= ./node_modules/phantomjs/bin/phantomjs IMAGES= ./images SCREENSHOT_WIDTH= 360 480 640 768 1024 1200 1440 2048 -PERL_SCRIPTS= bomb.pl +PERL_SCRIPTS= bin/bomb.pl TMP_DIR= ./logs APACHE_HTTPD= /usr/sbin/apache2 @@ -43,7 +43,7 @@ terse: $(MIKE) jasmine-node --noColor --captureExceptions --forceexit spec phantomjs p: apache-stop apache-start - ./bomb.pl --timeout="${PHANTOMJS_TIMEOUT}.5" ${PHANTOMJS} phantom/run-jasmine.js ${PHANTOMJS_URL} ${PHANTOMJS_TIMEOUT} + ./bin/bomb.pl --timeout="${PHANTOMJS_TIMEOUT}.5" ${PHANTOMJS} phantom/run-jasmine.js ${PHANTOMJS_URL} ${PHANTOMJS_TIMEOUT} ${MAKE} apache-stop screenshot: diff --git a/test/bin/bomb.pl b/test/bin/bomb.pl new file mode 100755 index 0000000..a84f40b --- /dev/null +++ b/test/bin/bomb.pl @@ -0,0 +1,73 @@ +#!/usr/local/bin/perl +# Copyright (c) 2014 IndexData ApS. http://indexdata.com +# +# bomb.pl - wrapper to stop a process after N seconds +# + +use Getopt::Long; + +use strict; +use warnings; + +my $debug = 0; +my $help; +my $timeout = 100; + +binmode \*STDOUT, ":utf8"; +binmode \*STDERR, ":utf8"; + +# timeout handler +sub set_alarm { + my $time = shift; + my $message = shift || ""; + + $time = 100 if !defined $time; + + $SIG{ALRM} = sub { + + warn "Time out alarm $time\n"; + + # sends a hang-up signal to all processes in the current process group + # and kill running java processes + local $SIG{HUP} = "IGNORE"; + kill 1, -$$; + + local $SIG{TERM} = "IGNORE"; + kill 15, -$$; + kill 15, -$$; + + warn "Send a hang-up to all childs.\n"; + + #exit 1; + }; + + warn "set alarm time to: $time seconds $message\n" if $debug >= 1; + alarm($time); +} + +sub usage () { + < \$help, + "debug=i" => \$debug, + "timeout=i" => \$timeout, +) or die usage; + +my @system = @ARGV; + +die usage if $help; +die usage if !@system; + +set_alarm( $timeout, join( " ", @system ) ); + +system(@system) == 0 + or die "system @system failed: $?"; + +exit(0); diff --git a/test/bomp.pl b/test/bomp.pl deleted file mode 100644 index a84f40b..0000000 --- a/test/bomp.pl +++ /dev/null @@ -1,73 +0,0 @@ -#!/usr/local/bin/perl -# Copyright (c) 2014 IndexData ApS. http://indexdata.com -# -# bomb.pl - wrapper to stop a process after N seconds -# - -use Getopt::Long; - -use strict; -use warnings; - -my $debug = 0; -my $help; -my $timeout = 100; - -binmode \*STDOUT, ":utf8"; -binmode \*STDERR, ":utf8"; - -# timeout handler -sub set_alarm { - my $time = shift; - my $message = shift || ""; - - $time = 100 if !defined $time; - - $SIG{ALRM} = sub { - - warn "Time out alarm $time\n"; - - # sends a hang-up signal to all processes in the current process group - # and kill running java processes - local $SIG{HUP} = "IGNORE"; - kill 1, -$$; - - local $SIG{TERM} = "IGNORE"; - kill 15, -$$; - kill 15, -$$; - - warn "Send a hang-up to all childs.\n"; - - #exit 1; - }; - - warn "set alarm time to: $time seconds $message\n" if $debug >= 1; - alarm($time); -} - -sub usage () { - < \$help, - "debug=i" => \$debug, - "timeout=i" => \$timeout, -) or die usage; - -my @system = @ARGV; - -die usage if $help; -die usage if !@system; - -set_alarm( $timeout, join( " ", @system ) ); - -system(@system) == 0 - or die "system @system failed: $?"; - -exit(0);