From 114ee601bdf7308f9957300f9204a91fd23e907c Mon Sep 17 00:00:00 2001 From: David Marchand Date: Mon, 17 Jun 2024 11:09:00 +0200 Subject: [PATCH] ci: add some basic vhost_user+virtio_user test This script is based on Thomas test-null.sh script. Quickly check that initialisation (with multiqueue) and basic forwarding are not broken between two testpmd: one testpmd polling from a vhost-user client port and the other testpmd polling one virtio_user port. Signed-off-by: David Marchand --- .ci/linux-build.sh | 8 +++++ MAINTAINERS | 1 + devtools/test-vhost.sh | 73 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 82 insertions(+) create mode 100755 devtools/test-vhost.sh diff --git a/.ci/linux-build.sh b/.ci/linux-build.sh index 15ed51e4c18..79246dea186 100755 --- a/.ci/linux-build.sh +++ b/.ci/linux-build.sh @@ -136,6 +136,14 @@ if [ -z "$cross_file" ]; then [ "$failed" != "true" ] fi +if [ -z "$cross_file" ] && [ "$MINI" != "true" ]; then + failed= + configure_coredump + devtools/test-vhost.sh || failed="true" + catch_coredump + [ "$failed" != "true" ] +fi + if [ "$ABI_CHECKS" = "true" ]; then if [ "$(cat libabigail/VERSION 2>/dev/null)" != "$LIBABIGAIL_VERSION" ]; then rm -rf libabigail diff --git a/MAINTAINERS b/MAINTAINERS index 533f707d5f7..1ccdfda7169 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -991,6 +991,7 @@ M: Maxime Coquelin M: Chenbo Xia T: git://dpdk.org/next/dpdk-next-virtio F: lib/vhost/ +F: devtools/test-vhost.sh F: doc/guides/prog_guide/vhost_lib.rst F: examples/vhost/ F: doc/guides/sample_app_ug/vhost.rst diff --git a/devtools/test-vhost.sh b/devtools/test-vhost.sh new file mode 100755 index 00000000000..1d104534f96 --- /dev/null +++ b/devtools/test-vhost.sh @@ -0,0 +1,73 @@ +#! /bin/sh -e +# SPDX-License-Identifier: BSD-3-Clause +# Copyright 2015 6WIND S.A. +# Copyright 2019 Mellanox Technologies, Ltd +# Copyright (c) 2024 Red Hat, Inc. + +# Run a quick forwarding test without hugepage, with one testpmd using +# virtio-user and another using vhost-user. + +build=${1:-build} # first argument can be the build directory +testpmd=$1 # or first argument can be the testpmd path +corelist_server=${2:-0,1,2} # default using cores 0, 1, 2 +corelist_client=${3:-0,1,3} # default using cores 0, 1, 3 +eal_options=$4 +testpmd_options=$5 + +sock=$(mktemp -t dpdk.virtio-user.XXXXXX.sock) +pid_client= +pid_server= +cleanup() { + rm -f $sock + [ "$pid_client $pid_server" != " " ] || return + if kill -0 $pid_client $pid_server >/dev/null 2>/dev/null; then + sleep 2 + fi + if kill -0 $pid_client >/dev/null 2>/dev/null ; then + echo ============================ + echo Force killing client testpmd + kill -9 $pid_client + fi + if kill -0 $pid_server >/dev/null 2>/dev/null ; then + echo ============================ + echo Force killing server testpmd + kill -9 $pid_server + fi +} + +trap cleanup EXIT + +[ -f "$testpmd" ] && build=$(dirname $(dirname $testpmd)) +[ -f "$testpmd" ] || testpmd=$build/app/dpdk-testpmd +[ -f "$testpmd" ] || testpmd=$build/app/testpmd +if [ ! -f "$testpmd" ] ; then + echo 'ERROR: testpmd cannot be found' >&2 + exit 1 +fi + +if ldd $testpmd | grep -q librte_ ; then + export LD_LIBRARY_PATH=$build/lib:$LD_LIBRARY_PATH + libs="-d $build/drivers" +else + libs= +fi + +rm -f $sock +( $testpmd -l $corelist_server --file-prefix=virtio-user --no-huge -m 1024 \ + --single-file-segments --no-pci $libs \ + --vdev net_virtio_user0,path=$sock,queues=2,server=1 $eal_options -- \ + --no-mlockall --stats-period 1 --rxq 2 --txq 2 --nb-cores=2 --tx-first -a $testpmd_options \ +>/dev/null 2>/dev/null) & +pid_server=$! + +( $testpmd -l $corelist_client --file-prefix=vhost --no-huge -m 1024 \ + --single-file-segments --no-pci $libs \ + --vdev net_vhost0,iface=$sock,queues=8,client=1 $eal_options -- \ + --no-mlockall --stats-period 1 --rxq 8 --txq 8 --nb-cores=2 --tx-first -a $testpmd_options \ +) & +pid_client=$! + +sleep 2 +kill $pid_client +sleep 1 +kill $pid_server