summaryrefslogtreecommitdiff
path: root/src/testpattern/run-testpattern-2.in
diff options
context:
space:
mode:
Diffstat (limited to 'src/testpattern/run-testpattern-2.in')
-rw-r--r--src/testpattern/run-testpattern-2.in85
1 files changed, 65 insertions, 20 deletions
diff --git a/src/testpattern/run-testpattern-2.in b/src/testpattern/run-testpattern-2.in
index 8df73b8..00608ff 100644
--- a/src/testpattern/run-testpattern-2.in
+++ b/src/testpattern/run-testpattern-2.in
@@ -4,6 +4,7 @@ use Getopt::Long;
Getopt::Long::Configure("bundling", "no_ignore_case", "pass_through");
use strict;
+use POSIX ":sys_wait_h";
my $valgrind = 0;
my $callgrind = 0;
@@ -66,6 +67,7 @@ my $list_printers = 0;
my $list_options = 0;
my $verbose = 0;
my $use_unused_options = 0;
+my $proc_count = 1;
my @default_options = ();
my %base_settings = ("DitherAlgorithm" => "Fast");
@@ -77,6 +79,13 @@ my %stp_float_values;
my %stp_int_values;
my %rerun_cases;
+if (defined $ENV{"STP_PARALLEL"}) {
+ $proc_count = $ENV{"STP_PARALLEL"};
+ if ($proc_count > 1) {
+ $quiet = 1;
+ }
+}
+
GetOptions("C=s" => \$csum_type,
"G=s" => \$geometry,
"H!" => \$halt_on_error,
@@ -106,7 +115,8 @@ GetOptions("C=s" => \$csum_type,
"N!" => \$use_unused_options,
"v+" => \$valgrind,
"x=s" => \@exclude_list,
- "y=s" => \@exclude_patterns);
+ "y=s" => \@exclude_patterns,
+ "t:i" => \$proc_count);
sub print_help_and_exit() {
my $options = join("\n ", sort @standard_options);
@@ -831,6 +841,9 @@ if ($list_options) {
} else {
my $valgrind_command;
my $valopts;
+ if ($gdb_attach) {
+ $proc_count = 1;
+ }
if ($callgrind) {
$valopts = '--tool=callgrind --dump-instr=yes --trace-jump=yes';
$valgrind = 4;
@@ -871,27 +884,58 @@ if ($list_options) {
}
my ($qopt) = $quiet ? "-q" : "";
my ($Hopt) = $halt_on_error ? "-H" : "";
- $testpattern_command = "$valgrind_command ./testpattern -y $suppress $qopt $Hopt";
- if ($single > 1) {
- $SIG{TERM} = sub() { stopit() };
- $SIG{HUP} = sub() { stopit() };
- $SIG{INT} = sub() { stopit() };
- foreach my $printer (@printer_list) {
- do_printer($printer, undef);
+ my (@children);
+ my ($child_no);
+ my ($kid);
+ if ($proc_count > 1) {
+ for ($child_no = 0; $child_no < $proc_count; $child_no++) {
+ $kid = fork();
+ if ($kid == 0) {
+ last;
+ } else {
+ push @children, $kid;
+ }
}
- } elsif ($single) {
- $SIG{PIPE} = sub() { restart_testpattern() };
- foreach my $printer (@printer_list) {
- restart_testpattern(1);
- do_printer($printer, $global_fh);
- $status |= close $global_fh;
- $status |= ($? & 255);
+ if ($kid == 0) {
+ my (@xprinter_list);
+ foreach my $i (0..$#printer_list) {
+ if ($i % $proc_count == $child_no) {
+ push @xprinter_list, $printer_list[$i];
+ }
+ }
+ @printer_list = @xprinter_list;
+ }
+ }
+ if ($proc_count > 1 && $kid > 0) {
+ while ($proc_count > 0 && $kid > 0) {
+ $kid = waitpid(-1, 0);
+ if ($kid > 0 && $? > 0) {
+ $error++;
+ }
}
} else {
- $SIG{PIPE} = sub() { restart_testpattern() };
- restart_testpattern(1);
- map { do_printer($_, $global_fh) } @printer_list;
- $status = close $global_fh;
+ $testpattern_command = "$valgrind_command ./testpattern -y $suppress $qopt $Hopt";
+ if ($single > 1) {
+ $SIG{TERM} = sub() { stopit() };
+ $SIG{HUP} = sub() { stopit() };
+ $SIG{INT} = sub() { stopit() };
+ foreach my $printer (@printer_list) {
+ do_printer($printer, undef);
+ }
+ } elsif ($single) {
+ $SIG{PIPE} = sub() { restart_testpattern() };
+ foreach my $printer (@printer_list) {
+ restart_testpattern(1);
+ do_printer($printer, $global_fh);
+ $status |= close $global_fh;
+ $status |= ($? & 255);
+ }
+ } else {
+ $SIG{PIPE} = sub() { restart_testpattern() };
+ restart_testpattern(1);
+ map { do_printer($_, $global_fh) } @printer_list;
+ $status = close $global_fh;
+ }
}
if ($quiet == 2) {
print STDERR "\n";
@@ -903,7 +947,8 @@ if ($list_options) {
if ($single > 1) {
print STDERR "$error cases failed\n";
} else {
- print STDERR "*** $error CRASHES NOTED***\n";
+ my ($plural) = ($error > 1 ? "ES" : "");
+ print STDERR "*** $error CRASH${plural} NOTED***\n";
}
}
exit 1;