From b8ccb7a4c180c6aece63fe6bbba7e242bdbf220d Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Sun, 10 Mar 2019 12:14:58 -0400 Subject: [PATCH] Fix maintainer test when no Parallel::Forker, msg2630. --- Changes | 2 ++ test_regress/driver.pl | 20 +++++++++++++++----- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/Changes b/Changes index f0f87919f..0d51fb2fe 100644 --- a/Changes +++ b/Changes @@ -16,6 +16,8 @@ The contributors that suggested a given feature are shown in []. Thanks! **** Fix MSVC compile error, bug1406. [Benjamin Gartner] +**** Fix maintainer test when no Parallel::Forker, msg2630. [Enzo Chi] + * Verilator 4.010 2019-01-27 diff --git a/test_regress/driver.pl b/test_regress/driver.pl index 3b6fc7e07..95611699a 100755 --- a/test_regress/driver.pl +++ b/test_regress/driver.pl @@ -136,6 +136,9 @@ if ($#opt_tests<0) { if ($#opt_tests>=2 && $opt_jobs>=2) { # Without this tests such as t_debug_sigsegv_bt_bad.pl will occasionally # block on input and cause a SIGSTOP, then a "fg" was needed to resume testing. + if (!$::Have_Forker) { + print STDERR "driver.pl: NO_FORKER: For faster testing 'sudo cpan install Parallel::Forker'\n"; + } print STDERR "== Many jobs; redirecting STDIN\n"; open(STDIN, "+>/dev/null"); } @@ -173,9 +176,10 @@ sub one_test { # Don't put anything other than _exit after _read, # as may call _exit via another path $test->_exit; - }, - run_on_finish => sub { - my $test = VTest->new(@params); + }, + run_on_finish => sub { + # RUnning in context of parent + my $test = VTest->new(@params); $test->_read_status; if ($test->ok) { $OkCnt++; @@ -1814,8 +1818,14 @@ sub new { sub schedule { my $self = shift; my %params = (@_); - &{$params{run_on_start}}(); - &{$params{run_on_finish}}(); + + if (my $pid = fork()) { # Parent + waitpid($pid, 0); + } else { # Child + $params{run_on_start}->($self); + exit(0); # Don't close anything + } + $params{run_on_finish}->($self); return $self; } sub max_proc {}