hs-test: fix envoy test
[vpp.git] / extras / hs-test / vppinstance.go
index 29b86d5..c6771f6 100644 (file)
@@ -2,11 +2,15 @@ package main
 
 import (
        "fmt"
-       "github.com/edwarnicke/exechelper"
+       "os"
        "os/exec"
+       "os/signal"
        "strings"
+       "syscall"
        "time"
 
+       "github.com/edwarnicke/exechelper"
+
        "go.fd.io/govpp"
        "go.fd.io/govpp/api"
        "go.fd.io/govpp/binapi/af_packet"
@@ -113,8 +117,26 @@ 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
+                       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
@@ -160,15 +182,16 @@ func (vpp *VppInstance) vppctl(command string, arguments ...any) string {
        return string(output)
 }
 
-func (vpp *VppInstance) waitForApp(appName string, timeout int) error {
+func (vpp *VppInstance) waitForApp(appName string, timeout int) {
        for i := 0; i < timeout; i++ {
                o := vpp.vppctl("show app")
                if strings.Contains(o, appName) {
-                       return nil
+                       return
                }
                time.Sleep(1 * time.Second)
        }
-       return fmt.Errorf("timeout while waiting for app '%s'", appName)
+       vpp.Suite().assertNil(1, "Timeout while waiting for app '%s'", appName)
+       return
 }
 
 func (vpp *VppInstance) createAfPacket(
@@ -253,9 +276,13 @@ func (vpp *VppInstance) addAppNamespace(
 }
 
 func (vpp *VppInstance) createTap(
-       id uint32,
        tap *NetInterface,
+       tapId ...uint32,
 ) error {
+       var id uint32 = 1
+       if len(tapId) > 0 {
+               id = tapId[0]
+       }
        createTapReq := &tapv2.TapCreateV2{
                ID:               id,
                HostIfNameSet:    true,