hs-test: fix logs once again 06/41206/3
authorAdrian Villin <[email protected]>
Wed, 24 Jul 2024 15:46:53 +0000 (17:46 +0200)
committerDave Wallace <[email protected]>
Wed, 24 Jul 2024 21:16:21 +0000 (21:16 +0000)
- "/dev/null" and "tail: ..." messages should now be
  removed properly

Type: test

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

index 44f141a..46cee97 100644 (file)
@@ -468,12 +468,12 @@ func (c *Container) log(maxLines int) (string, error) {
        stdout := stdoutBuf.String()
        stderr := stderrBuf.String()
 
-       if strings.Contains(stdout, "==> /dev/null <==") {
-               stdout = ""
-       }
-       if strings.Contains(stderr, "tail: cannot open") {
-               stderr = ""
-       }
+       stdout = strings.Join(strings.Split(stdout, "==> /dev/null <=="), "")
+       stderr = strings.Join(strings.Split(stderr, "tail: cannot open '' for reading: No such file or directory"), "")
+
+       // remove empty lines after deleting the above-mentioned messages
+       stdout = strings.TrimSpace(stdout)
+       stderr = strings.TrimSpace(stderr)
 
        return stdout + stderr, err
 }