test/e2e: fix SkipIfNotActive()
If a unit is not active the exit code from systemctl is 3. Thus this test always failed because it checked the error. Fix this by checking the exit code and remove the unnecessary output parsing. Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
parent
01d518a975
commit
525c27fe1d
|
@ -820,19 +820,14 @@ func SkipIfInContainer(reason string) {
|
|||
func SkipIfNotActive(unit string, reason string) {
|
||||
checkReason(reason)
|
||||
|
||||
var buffer bytes.Buffer
|
||||
cmd := exec.Command("systemctl", "is-active", unit)
|
||||
cmd.Stdout = &buffer
|
||||
err := cmd.Start()
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
|
||||
err = cmd.Wait()
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
if strings.TrimSpace(buffer.String()) != "active" {
|
||||
Skip(fmt.Sprintf("[systemd]: unit %s is not active: %s", unit, reason))
|
||||
cmd.Stdout = GinkgoWriter
|
||||
cmd.Stderr = GinkgoWriter
|
||||
err := cmd.Run()
|
||||
if cmd.ProcessState.ExitCode() == 0 {
|
||||
return
|
||||
}
|
||||
Skip(fmt.Sprintf("[systemd]: unit %s is not active (%v): %s", unit, err, reason))
|
||||
}
|
||||
|
||||
func SkipIfCNI(p *PodmanTestIntegration) {
|
||||
|
|
Loading…
Reference in New Issue