Skip to content

Commit

Permalink
Fixes to allow test suite to pass when OpenBSD 7.6 firefox SEGVs with…
Browse files Browse the repository at this point in the history
…out Xvfb. Thanks to Veraellyunjie for the bug report in GH#68
  • Loading branch information
david-dick committed Nov 2, 2024
1 parent 032764f commit 8a07a91
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
12 changes: 8 additions & 4 deletions t/01-marionette.t
Original file line number Diff line number Diff line change
Expand Up @@ -5348,9 +5348,13 @@ SKIP: {
} elsif (out_of_time()) {
skip("Skipping exit status b/c out of time", 2);
}
my $exit_status = system { $^X } $^X, (map { "-I$_" } @INC), '-MFirefox::Marionette', '-e', 'my $f = Firefox::Marionette->new(); exit 0';
my $argument_string = q[];
if ($ENV{FIREFOX_VISIBLE}) {
$argument_string = q[visible => 1];
}
my $exit_status = system { $^X } $^X, (map { "-I$_" } @INC), '-MFirefox::Marionette', '-e', "my \$f = Firefox::Marionette->new($argument_string); exit 0";
ok($exit_status == 0, "Firefox::Marionette doesn't alter the exit code of the parent process if it isn't closed cleanly");
$exit_status = system { $^X } $^X, (map { "-I$_" } @INC), '-MFirefox::Marionette', '-e', 'my $f = Firefox::Marionette->new(); $f = undef; exit 0';
$exit_status = system { $^X } $^X, (map { "-I$_" } @INC), '-MFirefox::Marionette', '-e', "my \$f = Firefox::Marionette->new($argument_string); \$f = undef; exit 0";
ok($exit_status == 0, "Firefox::Marionette doesn't alter the exit code of the parent process if it is 'undefed'");
if ($ENV{RELEASE_TESTING}) {
if ($ENV{FIREFOX_HOST}) {
Expand All @@ -5365,14 +5369,14 @@ SKIP: {
fcntl $handle, Fcntl::F_SETFD(), 0 or Carp::croak("Can't clear close-on-exec flag on temporary file:$!");
my $via = $ENV{FIREFOX_VIA} ? q[, via => "] . $ENV{FIREFOX_VIA} . q["] : q[];
my $handle_fileno = fileno $handle;
my $command = join q[ ], $^X, (map { "-I$_" } @INC), '-MFirefox::Marionette', '-e', q['open(my $fh, ">&=", ] . $handle_fileno . q[) or die "OPEN:$!"; $f = Firefox::Marionette->new( user => "] . $user . q[", host => "] . $host . q["] . $via . q[); $fh->print($f->ssh_local_directory()) or die "PRINT:$!"; close($fh) or die "CLOSE:$!";'];
my $command = join q[ ], $^X, (map { "-I$_" } @INC), '-MFirefox::Marionette', '-e', q['open(my $fh, ">&=", ] . $handle_fileno . q[) or die "OPEN:$!"; $f = Firefox::Marionette->new( user => "] . $user . q[", host => "] . $host . q["] . $via . ($argument_string ? ", $argument_string" : q[]) . q[); $fh->print($f->ssh_local_directory()) or die "PRINT:$!"; close($fh) or die "CLOSE:$!";'];
$command =~ s/([@])/\\$1/smxg;
my $output = `$command`;
$handle->seek(0,0) or die "Failed to seek on temporary file:$!";
my $result = read($handle, my $directory, 2048) or die "Failed to read from temporary file:$!";
ok(!-d $directory, "Firefox::Marionette->new() cleans up the ssh local directory at $directory");
} else {
my $command = join q[ ], $^X, (map { "-I$_" } @INC), '-MFirefox::Marionette', '-e', q['$f = Firefox::Marionette->new(); print $f->root_directory();'];
my $command = join q[ ], $^X, (map { "-I$_" } @INC), '-MFirefox::Marionette', '-e', qq['\\\$f = Firefox::Marionette->new($argument_string); print \\\$f->root_directory();'];
my $directory = `$command`;
ok(!-d $directory, "Firefox::Marionette->new() cleans up the local directory at $directory");
}
Expand Down
6 changes: 6 additions & 0 deletions t/02-taint.t
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ if ($^O eq 'MSWin32') {
if ($^O eq 'netbsd') {
$ENV{PATH} .= ":/usr/pkg/bin";
}
if ($^O eq 'openbsd') {
$ENV{PATH} .= ":/usr/X11R6/bin/";
}
if (my $pid = fork) {
waitpid $pid, 0;
if ($? == 0) {
Expand Down Expand Up @@ -56,6 +59,9 @@ if (($ENV{FIREFOX_HOST}) && ($ENV{FIREFOX_HOST} =~ /^(.*)$/smx)) {
if ($ENV{FIREFOX_DEBUG}) {
$parameters{debug} = $ENV{FIREFOX_DEBUG};
}
if ($ENV{FIREFOX_VISIBLE}) {
$parameters{visible} = $ENV{FIREFOX_VISIBLE};
}
SKIP: {
if (!$run_taint_checks) {
skip("Unable to run firefox with PATH set to $ENV{PATH}", 2);
Expand Down

0 comments on commit 8a07a91

Please sign in to comment.