hs-test: fix docker log output when logs are empty 02/41202/2
authorAdrian Villin <[email protected]>
Thu, 18 Jul 2024 06:33:59 +0000 (08:33 +0200)
committerDave Wallace <[email protected]>
Fri, 19 Jul 2024 14:08:19 +0000 (14:08 +0000)
- removed "==> /dev/null <==" and "tail: cannot open..." lines
  when docker logs are empty

Type: test

Change-Id: Ia51f7aa41d2c6c04c0adcb82142abfd45fbe2728
Signed-off-by: Adrian Villin <[email protected]>
extras/hs-test/infra/container.go

index d71761b..5093398 100644 (file)
@@ -463,7 +463,14 @@ func (c *Container) log(maxLines int) (string, error) {
        stdout := stdoutBuf.String()
        stderr := stderrBuf.String()
 
-       return stdout + " " + stderr, err
+       if strings.Contains(stdout, "==> /dev/null <==") {
+               stdout = ""
+       }
+       if strings.Contains(stderr, "tail: cannot open") {
+               stderr = ""
+       }
+
+       return stdout + stderr, err
 }
 
 func (c *Container) stop() error {