···372 return $info;
373}
37400000000000375376# Wait for a systemd unit to reach the "active" state.
377sub waitForUnit {
···372 return $info;
373}
374375+# Fail if the given systemd unit is not in the "active" state.
376+sub requireActiveUnit {
377+ my ($self, $unit) = @_;
378+ $self->nest("checking if unit ‘$unit’ has reached state 'active'", sub {
379+ my $info = $self->getUnitInfo($unit);
380+ my $state = $info->{ActiveState};
381+ if ($state ne "active") {
382+ die "Expected unit ‘$unit’ to to be in state 'active' but it is in state ‘$state’\n";
383+ };
384+ });
385+}
386387# Wait for a systemd unit to reach the "active" state.
388sub waitForUnit {