hs-test: fix core_pattern volume mounts 76/41676/2
authorFlorin Coras <[email protected]>
Fri, 4 Oct 2024 05:06:02 +0000 (01:06 -0400)
committerFlorin Coras <[email protected]>
Fri, 4 Oct 2024 05:40:15 +0000 (05:40 +0000)
If system is configured to use something like apport, avoid mounting.

Type: fix

Change-Id: I6af900bd334acba974c9c4ae30c3b2ce26d1f49b
Signed-off-by: Florin Coras <[email protected]>
extras/hs-test/infra/container.go

index 8ec9b8c..019eec4 100644 (file)
@@ -329,9 +329,13 @@ func (c *Container) getVolumesAsSlice() []string {
 
        core_pattern, err := sysctl.Read("kernel.core_pattern")
        if err == nil {
-               index := strings.LastIndex(core_pattern, "/")
-               core_pattern = core_pattern[:index]
-               volumeSlice = append(volumeSlice, c.Suite.getLogDirPath()+":"+core_pattern)
+               if len(core_pattern) > 0 && core_pattern[0] != '|' {
+                       index := strings.LastIndex(core_pattern, "/")
+                       core_pattern = core_pattern[:index]
+                       volumeSlice = append(volumeSlice, c.Suite.getLogDirPath()+":"+core_pattern)
+               } else {
+                       c.Suite.Log(fmt.Sprintf("core_pattern \"%s\" starts with pipe, ignoring", core_pattern))
+               }
        } else {
                c.Suite.Log(err)
        }