Good practice in general, but especially helpful when SIGKILL'd VPP
can't write out coverage data.
Type: fix
Change-Id: I7e7261b6f2e63fd4a6b24a3832c32800c71493c2
Signed-off-by: Semir Sionek <[email protected]>
.PHONY: test-cov
test-cov: FORCE_BUILD=false
test-cov: .deps.ok .build.cov.ok wipe-lcov
- @bash ./hs_test.sh --persist=$(PERSIST) --verbose=$(VERBOSE) \
+ @bash ./hs_test.sh --coverage=true --persist=$(PERSIST) --verbose=$(VERBOSE) \
--unconfigure=$(UNCONFIGURE) --debug=$(DEBUG) --test=$(TEST-HS) --cpus=$(CPUS) \
--vppsrc=$(VPPSRC) --cpu0=$(CPU0) --dryrun=$(DRYRUN) --skip=$(SKIP) --no_color=$(NO_COLOR); \
./script/compress.sh $$?
focused_test=0
persist_set=0
dryrun_set=0
+coverage_set=0
unconfigure_set=0
debug_set=0
leak_check_set=0
persist_set=1
fi
;;
+ --coverage=*)
+ coverage="${i#*=}"
+ if [ "$coverage" = "true" ]; then
+ args="$args -coverage"
+ coverage_set=1
+ fi
+ ;;
--debug=*)
debug="${i#*=}"
if [ "$debug" = "true" ]; then
if c.VppInstance != nil && c.VppInstance.ApiStream != nil {
c.VppInstance.saveLogs()
c.VppInstance.Disconnect()
+ c.VppInstance.Stop()
}
+ timeout := 0
c.VppInstance = nil
c.saveLogs()
-
c.Suite.Log("Stopping container " + c.Name)
- timeout := 0
+ if c.Suite.CoverageRun {
+ timeout = 3
+ }
if err := c.Suite.Docker.ContainerStop(c.ctx, c.ID, containerTypes.StopOptions{Timeout: &timeout}); err != nil {
return err
}
var IsPersistent = flag.Bool("persist", false, "persists topology config")
var IsVerbose = flag.Bool("verbose", false, "verbose test output")
+var IsCoverage = flag.Bool("coverage", false, "use coverage run config")
var IsUnconfiguring = flag.Bool("unconfigure", false, "remove topology")
var IsVppDebug = flag.Bool("debug", false, "attach gdb to vpp")
var NConfiguredCpus = flag.Int("cpus", 1, "number of CPUs assigned to vpp")
Logger *log.Logger
LogFile *os.File
Docker *client.Client
+ CoverageRun bool
}
type colors struct {
Fail("failed to init cpu allocator: " + fmt.Sprint(err))
}
s.CpuCount = *NConfiguredCpus
+ s.CoverageRun = *IsCoverage
}
func (s *HstSuite) AllocateCpus(containerName string) []int {
return nil
}
+func (vpp *VppInstance) Stop() {
+ pid := strings.TrimSpace(vpp.Container.Exec(false, "pidof vpp"))
+ // Stop VPP only if it's still running
+ if len(pid) > 0 {
+ vpp.Container.Exec(false, "bash -c \"kill -15 "+pid+"\"")
+ }
+}
+
func (vpp *VppInstance) Vppctl(command string, arguments ...any) string {
vppCliCommand := fmt.Sprintf(command, arguments...)
containerExecCommand := fmt.Sprintf("docker exec --detach=false %[1]s vppctl -s %[2]s %[3]s",