use IO::File;
use POSIX qw(:signal_h);
use File::Temp;
+use FindBin qw($Bin);
# Start up our test process, and send it various signals. Check that these
# signals make it to it correctly, and are reported on the command line.
-
-my $pid=open(HELPER, "./softsig-helper |")
+my $softsig_helper = $Bin . "/softsig-helper";
+my $pid=open(HELPER, "$softsig_helper |")
or die "Couldn't start test helper.";
# Wait for softsig to start up.
# Check that an internal segmentation fault kills the process.
-$pid = open(HELPER, "./softsig-helper -crash |")
+$pid = open(HELPER, "$softsig_helper -crash |")
or die "Couldn't start test helper.";
close(HELPER);
is($? & 0x7f, SIGSEGV, "Helper exited on SEGV signal.");
# Check that an internal bus error kills the process.
-
-my ($fh, $path) = mkstemp("/tmp/softsig-t_XXXXXX");
-$pid = open(HELPER, "./softsig-helper -buserror $path |")
- or die "Couldn't start test helper.";
-close(HELPER);
-is($? & 0x7f, SIGBUS, "Helper exited on BUS signal.");
-$fh->close;
-unlink $path;
+# Skip this test when running on ancient versions of Perl
+# which do not have SIGBUS defined.
+SKIP: {
+ my $sigbus = eval "SIGBUS";
+ skip("Skipping buserror test; SIGBUS constant is not defined.", 1) unless $sigbus;
+
+ my ($fh, $path) = mkstemp("/tmp/softsig-t_XXXXXX");
+ $pid = open(HELPER, "$softsig_helper -buserror $path |")
+ or die "Couldn't start test helper.";
+ close(HELPER);
+ is($? & 0x7f, $sigbus, "Helper exited on BUS signal.");
+ $fh->close;
+ unlink $path;
+}