diff --git a/extras/Makefile b/extras/Makefile index bbd04d92..f94192f5 100644 --- a/extras/Makefile +++ b/extras/Makefile @@ -16,5 +16,9 @@ clean: @echo "=> cleaning extras" go clean -v ./... +test-extras: extras + ## Run extras integration tests + @echo "# running extras integration tests" + VPP_REPO=$(VPP_REPO) ./test/run_integration.sh -.PHONY: build extras clean \ No newline at end of file +.PHONY: build extras clean diff --git a/extras/go.mod b/extras/go.mod index 1a929032..ddc5fc1a 100644 --- a/extras/go.mod +++ b/extras/go.mod @@ -1,14 +1,20 @@ module go.fd.io/govpp/extras -go 1.18 +go 1.22 require ( github.com/google/gopacket v1.1.17 - github.com/pkg/profile v1.6.0 - github.com/sirupsen/logrus v1.4.2 + github.com/pkg/profile v1.7.0 + github.com/sirupsen/logrus v1.9.3 + go.fd.io/govpp v0.10.0 ) require ( - github.com/konsorten/go-windows-terminal-sequences v1.0.1 // indirect - golang.org/x/sys v0.1.0 // indirect + github.com/felixge/fgprof v0.9.3 // indirect + github.com/fsnotify/fsnotify v1.7.0 // indirect + github.com/ftrvxmtrx/fd v0.0.0-20150925145434-c6d800382fff // indirect + github.com/google/pprof v0.0.0-20211214055906-6f57359322fd // indirect + github.com/lunixbochs/struc v0.0.0-20200521075829-a4cb8d33dbbe // indirect + github.com/mitchellh/go-ps v1.0.0 // indirect + golang.org/x/sys v0.16.0 // indirect ) diff --git a/extras/go.sum b/extras/go.sum index a197b63a..c5a954df 100644 --- a/extras/go.sum +++ b/extras/go.sum @@ -1,23 +1,56 @@ +github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= +github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= +github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/felixge/fgprof v0.9.3 h1:VvyZxILNuCiUCSXtPtYmmtGvb65nqXh2QFWc0Wpf2/g= +github.com/felixge/fgprof v0.9.3/go.mod h1:RdbpDgzqYVh/T9fPELJyV7EYJuHB55UTEULNun8eiPw= +github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= +github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM= +github.com/ftrvxmtrx/fd v0.0.0-20150925145434-c6d800382fff h1:zk1wwii7uXmI0znwU+lqg+wFL9G5+vm5I+9rv2let60= +github.com/ftrvxmtrx/fd v0.0.0-20150925145434-c6d800382fff/go.mod h1:yUhRXHewUVJ1k89wHKP68xfzk7kwXUx/DV1nx4EBMbw= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/gopacket v1.1.17 h1:rMrlX2ZY2UbvT+sdz3+6J+pp2z+msCq9MxTU6ymxbBY= github.com/google/gopacket v1.1.17/go.mod h1:UdDNZ1OO62aGYVnPhxT1U6aI7ukYtA/kB8vaU0diBUM= -github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk= -github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/pkg/profile v1.6.0 h1:hUDfIISABYI59DyeB3OTay/HxSRwTQ8rB/H83k6r5dM= -github.com/pkg/profile v1.6.0/go.mod h1:qBsxPvzyUincmltOk6iyRVxHYg4adc0OFOv72ZdLa18= +github.com/google/pprof v0.0.0-20211214055906-6f57359322fd h1:1FjCyPC+syAzJ5/2S8fqdZK1R22vvA0J7JZKcuOIQ7Y= +github.com/google/pprof v0.0.0-20211214055906-6f57359322fd/go.mod h1:KgnwoLYCZ8IQu3XUZ8Nc/bM9CCZFOyjUNOSygVozoDg= +github.com/ianlancetaylor/demangle v0.0.0-20210905161508-09a460cdf81d/go.mod h1:aYm2/VgdVmcIU8iMfdMvDMsRAQjcfZSKFby6HOFvi/w= +github.com/lunixbochs/struc v0.0.0-20200521075829-a4cb8d33dbbe h1:ewr1srjRCmcQogPQ/NCx6XCk6LGVmsVCc9Y3vvPZj+Y= +github.com/lunixbochs/struc v0.0.0-20200521075829-a4cb8d33dbbe/go.mod h1:vy1vK6wD6j7xX6O6hXe621WabdtNkou2h7uRtTfRMyg= +github.com/mitchellh/go-ps v1.0.0 h1:i6ampVEEF4wQFF+bkYfwYgY+F/uYJDktmvLPf7qIgjc= +github.com/mitchellh/go-ps v1.0.0/go.mod h1:J4lOc8z8yJs6vUwklHw2XEIiT4z4C40KtWVN3nvg8Pg= +github.com/onsi/gomega v1.32.0 h1:JRYU78fJ1LPxlckP6Txi/EYqJvjtMrDC04/MM5XRHPk= +github.com/onsi/gomega v1.32.0/go.mod h1:a4x4gW6Pz2yK1MAmvluYme5lvYTn61afQ2ETw/8n4Lg= +github.com/pkg/profile v1.7.0 h1:hnbDkaNWPCLMO9wGLdBFTIZvzDrDfBM2072E1S9gJkA= +github.com/pkg/profile v1.7.0/go.mod h1:8Uer0jas47ZQMJ7VD+OHknK4YDY07LPUC6dEvqDjvNo= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4= -github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= -github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w= -github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= +github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +go.fd.io/govpp v0.10.0 h1:lL93SbqOILjON2pMvazrlHRekGYTRy0Qmj57RuAkxR0= +go.fd.io/govpp v0.10.0/go.mod h1:5m3bZM9ck+2EGC2O3ASmSSJAaoouyOlVWtiwj5BdCv0= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo= +golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190405154228-4b34438f7a67/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.1.0 h1:kunALQeHf1/185U1i0GOB/fy1IPRDDpuoOOqRReG57U= -golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU= +golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= +golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/extras/gomemif/examples/icmp_responder_poll/icmp_responder_poll.go b/extras/gomemif/examples/icmp_responder_poll/icmp_responder_poll.go index 616c0d5b..fdfe77fd 100644 --- a/extras/gomemif/examples/icmp_responder_poll/icmp_responder_poll.go +++ b/extras/gomemif/examples/icmp_responder_poll/icmp_responder_poll.go @@ -85,11 +85,12 @@ func Connected(i *memif.Interface) error { fmt.Printf("pktLen: %d\n", pktLen) gopkt := gopacket.NewPacket(pkt[:pktLen], layers.LayerTypeEthernet, gopacket.NoCopy) etherLayer := gopkt.Layer(layers.LayerTypeEthernet) + tx_dstMAC := etherLayer.(*layers.Ethernet).SrcMAC if etherLayer.(*layers.Ethernet).EthernetType == layers.EthernetTypeARP { rEth := layers.Ethernet{ SrcMAC: net.HardwareAddr{0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa}, - DstMAC: net.HardwareAddr{0xff, 0xff, 0xff, 0xff, 0xff, 0xff}, + DstMAC: tx_dstMAC, EthernetType: layers.EthernetTypeARP, } rArp := layers.ARP{ @@ -100,7 +101,7 @@ func Connected(i *memif.Interface) error { Operation: layers.ARPReply, SourceHwAddress: []byte(net.HardwareAddr{0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa}), SourceProtAddress: []byte("\xc0\xa8\x01\x01"), - DstHwAddress: []byte(net.HardwareAddr{0x02, 0xfe, 0x08, 0x88, 0x45, 0x7f}), + DstHwAddress: []byte(tx_dstMAC), DstProtAddress: []byte("\xc0\xa8\x01\x02"), } buf := gopacket.NewSerializeBuffer() @@ -135,9 +136,8 @@ func Connected(i *memif.Interface) error { // Build packet layers. ethResp := layers.Ethernet{ - DstMAC: net.HardwareAddr{0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa}, - //DstMAC: net.HardwareAddr{0x02, 0xfe, 0xa8, 0x77, 0xaf, 0x20}, - SrcMAC: []byte(net.HardwareAddr{0x02, 0xfe, 0x08, 0x88, 0x45, 0x7f}), + SrcMAC: []byte(net.HardwareAddr{0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa}), + DstMAC: []byte(tx_dstMAC), EthernetType: layers.EthernetTypeIPv4, } diff --git a/extras/test/build/Dockerfile.extras b/extras/test/build/Dockerfile.extras new file mode 100644 index 00000000..b580cb3d --- /dev/null +++ b/extras/test/build/Dockerfile.extras @@ -0,0 +1,48 @@ +FROM buildpack-deps:22.04-scm + +# Install gotestsum +ARG GOTESTSUM_VERSION=1.12.0 +RUN set -eux; \ + curl -fsSL https://github.com/gotestyourself/gotestsum/releases/download/v${GOTESTSUM_VERSION}/gotestsum_${GOTESTSUM_VERSION}_linux_amd64.tar.gz -o gotestsum.tar.gz; \ + tar -xf gotestsum.tar.gz gotestsum; \ + mv gotestsum /usr/local/bin/gotestsum; \ + rm gotestsum.tar.gz; + +# Install Go +ENV GOLANG_VERSION=1.22.4 + +RUN set -eux; \ + dpkgArch="$(dpkg --print-architecture)"; \ + case "${dpkgArch##*-}" in \ + amd64) goRelArch='linux-amd64'; ;; \ + armhf) goRelArch='linux-armv6l'; ;; \ + arm64) goRelArch='linux-arm64'; ;; \ + esac; \ + wget -nv -O go.tgz "https://golang.org/dl/go${GOLANG_VERSION}.${goRelArch}.tar.gz"; \ + tar -C /usr/local -xzf go.tgz; \ + rm go.tgz; + +ENV GOPATH=/go +ENV PATH=$GOPATH/bin:/usr/local/go/bin:$PATH + +RUN set -eux; \ + mkdir -p "$GOPATH/src" "$GOPATH/bin"; \ + chmod -R 777 "$GOPATH"; + +ARG VPP_REPO=master + +# Install VPP +RUN set -eux; \ + apt-get update; \ + curl -fsSL https://packagecloud.io/install/repositories/fdio/${VPP_REPO}/script.deb.sh | bash; \ + apt-get update && apt-get install -V -y \ + vpp \ + vpp-plugin-core \ + ; \ + rm -rf /var/lib/apt/lists/* + +COPY vpp.conf /etc/vpp/vpp.conf + +WORKDIR /src + +CMD ["/usr/bin/vpp", "-c", "/etc/vpp/vpp.conf"] diff --git a/extras/test/build/vpp.conf b/extras/test/build/vpp.conf new file mode 100644 index 00000000..baac81a0 --- /dev/null +++ b/extras/test/build/vpp.conf @@ -0,0 +1,21 @@ +unix { + nodaemon + log /var/log/vpp.log + cli-listen /run/vpp/cli.sock + cli-no-pager + full-coredump + pidfile /run/vpp/vpp.pid +} +api-trace { + on +} +socksvr { + socket-name /run/vpp/api.sock +} +statseg { + socket-name /run/vpp/stats.sock + per-node-counters on +} +plugins { + plugin dpdk_plugin.so { disable } +} diff --git a/extras/test/memif/gomemif_test.go b/extras/test/memif/gomemif_test.go new file mode 100644 index 00000000..e13a1811 --- /dev/null +++ b/extras/test/memif/gomemif_test.go @@ -0,0 +1,126 @@ +// Copyright (c) 2022 Cisco and/or its affiliates. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at: +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package extras + +import ( + "bufio" + "fmt" + "os/exec" + "strconv" + "strings" + "testing" + "time" + + "go.fd.io/govpp/test/vpptesting" +) + +func TestGoMemifPoll(t *testing.T) { + test := "/icmp_responder_poll/icmp_responder_poll" + runGoMemif(t, test) +} + +func TestGoMemifCb(t *testing.T) { + test := "/icmp_responder_cb/icmp_responder_cb" + runGoMemif(t, test) +} + +func runGoMemif(t *testing.T, test string) { + _, err := exec.LookPath("go") + if err != nil { + t.Skipf("`go` command is not available, skipping test") + } + + // Start VPP + tc := vpptesting.SetupVPP(t) + + // create memif interface, assign ip address and set it up + tc.RunCli("create interface memif id 0 master") + tc.RunCli("set int ip addr memif0/0 192.168.1.2/24") + tc.RunCli("set int state memif0/0 up") + + cmd := exec.Command("./gomemif/examples" + test) + t.Logf("executing command '%v'", cmd) + + stdin, err := cmd.StdinPipe() + if err != nil { + t.Fatalf("Error creating stdin pipe: %v", err) + return + } + + stdout, err := cmd.StdoutPipe() + if err != nil { + t.Fatalf("Error creating stdout pipe: %v", err) + return + } + + // Start the command + err = cmd.Start() + if err != nil { + t.Fatalf("Error starting command: %v", err) + return + } + + // Create a scanner to read the output from the command + scanner := bufio.NewScanner(stdout) + go func() { + for scanner.Scan() { + // Print each line of output + fmt.Println(scanner.Text()) + } + }() + + // Send the "start" command to the gomemif application + _, err = stdin.Write([]byte("start\n")) + if err != nil { + t.Fatalf("Error writing to stdin: %v", err) + return + } + + time.Sleep(1 * time.Second) + // Send the "show" command to the gomemif application + _, err = stdin.Write([]byte("show\n")) + if err != nil { + t.Fatalf("Error writing to stdin: %v", err) + return + } + + vppout, err := tc.RunCli("ping 192.168.1.1") + if err != nil { + t.Fatalf("Error running ping command: %v", err) + return + } else { + ouput_split := strings.Split(vppout, "received")[0] + output_field := strings.Fields(ouput_split) + received, _ := strconv.Atoi(output_field[len(output_field)-1]) + if received < 1 { + t.Fatalf("No packets received") + return + } + } + + _, err = stdin.Write([]byte("exit\n")) + if err != nil { + t.Fatalf("Error writing to stdin: %v", err) + return + } + + err = stdin.Close() + if err != nil { + t.Fatalf("Error closing stdin: %v", err) + return + } + + t.Logf("test %s output: %s", test, stdout) +} diff --git a/extras/test/run_integration.sh b/extras/test/run_integration.sh new file mode 100755 index 00000000..ac97a238 --- /dev/null +++ b/extras/test/run_integration.sh @@ -0,0 +1,76 @@ +#!/usr/bin/env bash +# // Copyright (c) 2022 Cisco and/or its affiliates. +# // +# // Licensed under the Apache License, Version 2.0 (the "License"); +# // you may not use this file except in compliance with the License. +# // You may obtain a copy of the License at: +# // +# // http://www.apache.org/licenses/LICENSE-2.0 +# // +# // Unless required by applicable law or agreed to in writing, software +# // distributed under the License is distributed on an "AS IS" BASIS, +# // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# // See the License for the specific language governing permissions and +# // limitations under the License. + +set -euo pipefail + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd -P )" + +args=($*) + +echo "Preparing extras tests.." + +VPP_REPO=${VPP_REPO:-master} + +export CGO_ENABLED=0 +export DOCKER_BUILDKIT=1 +export GOTESTSUM_FORMAT="${GOTESTSUM_FORMAT:-testname}" + +imgtag="govpp-extras-integration" + +go test -c -o test/extras.test \ + -tags 'osusergo netgo e2e' \ + -ldflags '-w -s -extldflags "-static"' \ + -trimpath \ + "${SCRIPT_DIR}/memif" + +docker build --tag "${imgtag}" \ + -f "${SCRIPT_DIR}"/build/Dockerfile.extras \ + --build-arg VPP_REPO="${VPP_REPO}" \ + "${SCRIPT_DIR}"/build + +vppver=$(docker run --rm -i "${imgtag}" dpkg-query -f '${Version}' -W vpp) + +if [ -n "${GITHUB_STEP_SUMMARY:-}" ]; then + echo "**VPP version**: \`${vppver}\`" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY +fi + +echo "==========================================================================" +echo " GOVPP EXTRAS INTEGRATION TEST - $(date) " +echo "==========================================================================" +echo "- VPP_REPO: $VPP_REPO" +echo "- VPP version: $vppver" +echo "--------------------------------------------------------------------------" + +if docker run -i --privileged \ + -e CGO_ENABLED=0 \ + -e DEBUG_GOVPP \ + -e GOTESTSUM_FORMAT \ + -e CLICOLOR_FORCE \ + -v "$(cd "${SCRIPT_DIR}/.." && pwd)":/src \ + -w /src \ + "${imgtag}" gotestsum --raw-command -- go tool test2json -t -p extras ./test/extras.test -test.v ${args[@]:-} +then + echo >&2 "-------------------------------------------------------------" + echo >&2 -e " \e[32mPASSED\e[0m (took: ${SECONDS}s)" + echo >&2 "-------------------------------------------------------------" + exit 0 +else + res=$? + echo >&2 "-------------------------------------------------------------" + echo >&2 -e " \e[31mFAILED!\e[0m (exit code: $res)" + echo >&2 "-------------------------------------------------------------" + exit $res +fi