sub Log { say $log "@_" }
my %timings;
-my $coverage_testing = 0;
-my $valgrind = 0;
-my $strace = 0;
my $help = 0;
# Number of tests to run in parallel. Important to know how many Xdummy
# instances we need to start (unless @displays are given). Defaults to
# num_cores * 2.
my $parallel = undef;
my @displays = ();
+my %options = (
+ valgrind => 0,
+ strace => 0,
+ coverage => 0,
+ restart => 0,
+);
my $result = GetOptions(
- "coverage-testing" => \$coverage_testing,
- "valgrind" => \$valgrind,
- "strace" => \$strace,
+ "coverage-testing" => \$options{coverage},
+ "valgrind" => \$options{valgrind},
+ "strace" => \$options{strace},
"display=s" => \@displays,
"parallel=i" => \$parallel,
"help|?" => \$help,
my $numtests = scalar @testfiles;
# No displays specified, let’s start some Xdummy instances.
-@displays = start_xdummy($parallel, $numtests) if @displays == 0;
+if (@displays == 0) {
+ @displays = start_xdummy($parallel, $numtests);
+}
# 1: create an output directory for this test-run
my $outdir = "testsuite-";
# 2: keep the connection open so that i3 is not the only client. this prevents
# the X server from exiting (Xdummy will restart it, but not quick enough
# sometimes)
-my @worker;
+my @single_worker;
for my $display (@displays) {
my $screen;
my $x = X11::XCB::Connection->new(display => $display);
die "Could not connect to display $display\n";
} else {
# start a TestWorker for each display
- push @worker, worker($display, $x, $outdir);
+ push @single_worker, worker($display, $x, $outdir, \%options);
}
}
status_init(displays => \@displays, tests => $num);
-my $cv = AE::cv;
+my $single_cv = AE::cv;
# We start tests concurrently: For each display, one test gets started. Every
# test starts another test after completing.
-for (@worker) { $cv->begin; take_job($_) }
+for (@single_worker) {
+ $single_cv->begin;
+ take_job($_, $single_cv, \@testfiles);
+}
-$cv->recv;
+$single_cv->recv;
$aggregator->stop();
# triggered to finish testing.
#
sub take_job {
- my ($worker) = @_;
+ my ($worker, $cv, $tests) = @_;
- my $test = shift @testfiles
+ my $test = shift @$tests
or return $cv->end;
my $display = $worker->{display};
push @done, [ $test, $output ];
undef $w;
- take_job($worker);
+ take_job($worker, $cv, $tests);
}
);
}