hs-test: skip vppctl assert on teardown
- core dump check would get skipped if vpp crashed and vppctl was called on teardown Type: test Change-Id: I9dda7036042158332c8ec815f6eb4bb3c2f7000f Signed-off-by: Adrian Villin <avillin@cisco.com>
This commit is contained in:
Adrian Villin
committed by
Florin Coras
parent
499a9dd875
commit
1c2f0f22d9
@ -9,6 +9,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
|
"runtime"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"syscall"
|
"syscall"
|
||||||
@ -244,7 +245,23 @@ func (vpp *VppInstance) Vppctl(command string, arguments ...any) string {
|
|||||||
vpp.Container.Name, vpp.getCliSocket(), vppCliCommand)
|
vpp.Container.Name, vpp.getCliSocket(), vppCliCommand)
|
||||||
vpp.getSuite().Log(containerExecCommand)
|
vpp.getSuite().Log(containerExecCommand)
|
||||||
output, err := exechelper.CombinedOutput(containerExecCommand)
|
output, err := exechelper.CombinedOutput(containerExecCommand)
|
||||||
|
|
||||||
|
// If an error occurs, retrieve the caller function's name.
|
||||||
|
// If retrieving the caller name fails, perform a regular assert.
|
||||||
|
// If the caller is 'teardown', only log the error instead of asserting.
|
||||||
|
if err != nil {
|
||||||
|
pc, _, _, ok := runtime.Caller(1)
|
||||||
|
if !ok {
|
||||||
vpp.getSuite().AssertNil(err)
|
vpp.getSuite().AssertNil(err)
|
||||||
|
} else {
|
||||||
|
fn := runtime.FuncForPC(pc)
|
||||||
|
if fn != nil && strings.Contains(fn.Name(), "TearDownTest") {
|
||||||
|
vpp.getSuite().Log("vppctl failed in test teardown (skipping assert): %v", err)
|
||||||
|
} else {
|
||||||
|
vpp.getSuite().AssertNil(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return string(output)
|
return string(output)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user