hs-test: add support for running vpp in gdb
Type: test Signed-off-by: Filip Tehlar <ftehlar@cisco.com> Change-Id: I6e03b88ca013cafd73f424ea63f706f105bebe6b
This commit is contained in:

committed by
Florin Coras

parent
2da99e5072
commit
ec5c40b83a
@ -15,6 +15,10 @@ ifeq ($(TEST),)
|
||||
TEST=all
|
||||
endif
|
||||
|
||||
ifeq ($(DEBUG),)
|
||||
DEBUG=false
|
||||
endif
|
||||
|
||||
list_tests = @(grep -r ') Test' *_test.go | cut -d '*' -f2 | cut -d '(' -f1 | \
|
||||
tr -d ' ' | tr ')' '/' | sed 's/Suite//')
|
||||
|
||||
@ -33,6 +37,7 @@ help:
|
||||
@echo " PERSIST=[true|false] - whether clean up topology and dockers after test"
|
||||
@echo " VERBOSE=[true|false] - verbose output"
|
||||
@echo " UNCONFIGURE=[true|false] - unconfigure selected test"
|
||||
@echo " DEBUG=[true|false] - attach VPP to GDB"
|
||||
@echo " TEST=[test-name] - specific test to run"
|
||||
@echo
|
||||
@echo "List of all tests:"
|
||||
@ -51,7 +56,7 @@ build-vpp-debug:
|
||||
.PHONY: test
|
||||
test: .deps.ok .build.vpp
|
||||
@bash ./test --persist=$(PERSIST) --verbose=$(VERBOSE) \
|
||||
--unconfigure=$(UNCONFIGURE) --test=$(TEST)
|
||||
--unconfigure=$(UNCONFIGURE) --debug=$(DEBUG) --test=$(TEST)
|
||||
|
||||
build-go:
|
||||
go build ./tools/http_server
|
||||
|
@ -20,6 +20,7 @@ const (
|
||||
var IsPersistent = flag.Bool("persist", false, "persists topology config")
|
||||
var IsVerbose = flag.Bool("verbose", false, "verbose test output")
|
||||
var IsUnconfiguring = flag.Bool("unconfigure", false, "remove topology")
|
||||
var IsVppDebug = flag.Bool("debug", false, "attach gdb to vpp")
|
||||
|
||||
type HstSuite struct {
|
||||
suite.Suite
|
||||
|
@ -6,6 +6,7 @@ args=
|
||||
single_test=0
|
||||
persist_set=0
|
||||
unconfigure_set=0
|
||||
debug_set=0
|
||||
|
||||
for i in "$@"
|
||||
do
|
||||
@ -17,6 +18,13 @@ case "${i}" in
|
||||
persist_set=1
|
||||
fi
|
||||
;;
|
||||
--debug=*)
|
||||
debug="${i#*=}"
|
||||
if [ $debug = "true" ]; then
|
||||
args="$args -debug"
|
||||
debug_set=1
|
||||
fi
|
||||
;;
|
||||
--verbose=*)
|
||||
verbose="${i#*=}"
|
||||
if [ $verbose = "true" ]; then
|
||||
@ -54,4 +62,9 @@ if [ $persist_set -eq 1 ] && [ $unconfigure_set -eq 1 ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ $single_test -eq 0 ] && [ $debug_set -eq 1 ]; then
|
||||
echo "VPP debug flag is not supperted while running all tests!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
sudo -E go test -buildvcs=false -v $args
|
||||
|
@ -3,8 +3,11 @@ package main
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/edwarnicke/exechelper"
|
||||
"os"
|
||||
"os/exec"
|
||||
"os/signal"
|
||||
"strings"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"go.fd.io/govpp"
|
||||
@ -113,8 +116,27 @@ func (vpp *VppInstance) start() error {
|
||||
startupFileName := vpp.getEtcDir() + "/startup.conf"
|
||||
vpp.container.createFile(startupFileName, configContent)
|
||||
|
||||
// Start VPP
|
||||
vpp.container.execServer("su -c \"vpp -c " + startupFileName + " &> /proc/1/fd/1\"")
|
||||
if *IsVppDebug {
|
||||
sig := make(chan os.Signal, 1)
|
||||
signal.Notify(sig, syscall.SIGINT)
|
||||
cont := make(chan bool, 1)
|
||||
go func() {
|
||||
sig := <-sig
|
||||
fmt.Println(sig)
|
||||
cont <- true
|
||||
}()
|
||||
|
||||
// Start VPP in GDB and wait for user to attach it
|
||||
vpp.container.execServer("su -c \"gdb -ex run --args vpp -c " + startupFileName + " &> /proc/1/fd/1\"")
|
||||
fmt.Println("run following command in different terminal:")
|
||||
fmt.Println("docker exec -it " + vpp.container.name + " gdb -ex \"attach $(docker exec " + vpp.container.name + " pidof gdb)\"")
|
||||
fmt.Println("Afterwards press CTRL+C to continue")
|
||||
<-cont
|
||||
fmt.Println("continuing...")
|
||||
} else {
|
||||
// Start VPP
|
||||
vpp.container.execServer("su -c \"vpp -c " + startupFileName + " &> /proc/1/fd/1\"")
|
||||
}
|
||||
|
||||
// Connect to VPP and store the connection
|
||||
sockAddress := vpp.container.GetHostWorkDir() + defaultApiSocketFilePath
|
||||
|
Reference in New Issue
Block a user