git.iko.soy/typeable/nixpkgs
on master help sign in
test-driver: Fix "unit X is inactive and there are no pending jobs"

This was causing many random test failures.

commitad29b726866b5abeed9ad05cad52995295cf4813 authorEelco Dolstra <eelco.dolstra@logicblox.com> dateTue 24 May 2016, 16:33 (11 years ago) parent5420f7f
1 file changed+10−2
nixos/lib/test-driver/Machine.pm+10−2
nixos/lib/test-driver/Machine.pm+10−2
@@ -382,9 +382,17 @@ sub waitForUnit {
382382 my $state = $info->{ActiveState};
383383 die "unit ‘$unit’ reached state ‘$state’\n" if $state eq "failed";
384384 if ($state eq "inactive") {
385+ # If there are no pending jobs, then assume this unit
386+ # will never reach active state.
385387 my ($status, $jobs) = $self->execute("systemctl list-jobs --full 2>&1");
386− die "unit ‘$unit’ is inactive and there are no pending jobs\n"
387− if $jobs =~ /No jobs/; # FIXME: fragile
388+ if ($jobs =~ /No jobs/) { # FIXME: fragile
389+ # Handle the case where the unit may have started
390+ # between the previous getUnitInfo() and
391+ # list-jobs.
392+ my $info2 = $self->getUnitInfo($unit);
393+ die "unit ‘$unit’ is inactive and there are no pending jobs\n"
394+ if $info2->{ActiveState} eq $state;
395+ }
388396 }
389397 return 1 if $state eq "active";
390398 };