aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--extras/hs-test/Makefile7
-rw-r--r--extras/hs-test/hst_suite.go1
-rwxr-xr-xextras/hs-test/test13
-rw-r--r--extras/hs-test/vppinstance.go26
4 files changed, 44 insertions, 3 deletions
diff --git a/extras/hs-test/Makefile b/extras/hs-test/Makefile
index 268a518b7ca..29cbd0ea01e 100644
--- a/extras/hs-test/Makefile
+++ b/extras/hs-test/Makefile
@@ -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
diff --git a/extras/hs-test/hst_suite.go b/extras/hs-test/hst_suite.go
index 8e52cc4e851..4e4b7d20b61 100644
--- a/extras/hs-test/hst_suite.go
+++ b/extras/hs-test/hst_suite.go
@@ -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
diff --git a/extras/hs-test/test b/extras/hs-test/test
index f02c1596681..a8866524b58 100755
--- a/extras/hs-test/test
+++ b/extras/hs-test/test
@@ -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
diff --git a/extras/hs-test/vppinstance.go b/extras/hs-test/vppinstance.go
index 4092d35cfd6..1c28ec920b7 100644
--- a/extras/hs-test/vppinstance.go
+++ b/extras/hs-test/vppinstance.go
@@ -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