summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdrian Villin <avillin@cisco.com>2024-12-12 09:16:22 +0100
committerFlorin Coras <florin.coras@gmail.com>2024-12-12 16:46:35 +0000
commitfb0cbc64e64a53e495662128457f4673b8760e03 (patch)
tree72234dce167e9cde8cda4c9e227e34dfe3d75838
parent20956385c7f5bd308f4a0f6a6fdca3a77425b300 (diff)
hs-test: fix a runtime error
- framework panicked if core_pattern was set to "core" Type: test Change-Id: I14211cc59779090a61e6e08a18d16fd7399b2bed Signed-off-by: Adrian Villin <avillin@cisco.com>
-rw-r--r--extras/hs-test/infra/container.go8
1 files changed, 6 insertions, 2 deletions
diff --git a/extras/hs-test/infra/container.go b/extras/hs-test/infra/container.go
index f6ccd88e118..6605c866939 100644
--- a/extras/hs-test/infra/container.go
+++ b/extras/hs-test/infra/container.go
@@ -331,8 +331,12 @@ func (c *Container) getVolumesAsSlice() []string {
if err == nil {
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)
+ if index == -1 {
+ c.Suite.Log("'core_pattern' isn't set to an absolute path. Core dump check will not work.")
+ } else {
+ 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))
}