From 5aca282bd235341c258713c7c11b20f7249333b9 Mon Sep 17 00:00:00 2001 From: Tuomas Taipale Date: Fri, 20 Sep 2024 12:40:09 +0000 Subject: [PATCH] test: l2fwd_perf: add runner script Add script for setting up a test run of `odp_l2fwd_perf` during `make check`. Script is heavily influenced by the existing `odp_l2fwd_run.sh`. Signed-off-by: Tuomas Taipale --- test/performance/Makefile.am | 1 + test/performance/odp_l2fwd_perf_run.sh | 104 +++++++++++++++++++++++++ 2 files changed, 105 insertions(+) create mode 100755 test/performance/odp_l2fwd_perf_run.sh diff --git a/test/performance/Makefile.am b/test/performance/Makefile.am index 6aaa38498a8..b652262bdd3 100644 --- a/test/performance/Makefile.am +++ b/test/performance/Makefile.am @@ -47,6 +47,7 @@ TESTSCRIPTS = odp_cpu_bench_run.sh \ odp_dma_perf_run.sh \ odp_ipsec_run.sh \ odp_l2fwd_run.sh \ + odp_l2fwd_perf_run.sh \ odp_packet_gen_run.sh \ odp_sched_latency_run.sh \ odp_sched_perf_run.sh \ diff --git a/test/performance/odp_l2fwd_perf_run.sh b/test/performance/odp_l2fwd_perf_run.sh new file mode 100755 index 00000000000..0f7422851a1 --- /dev/null +++ b/test/performance/odp_l2fwd_perf_run.sh @@ -0,0 +1,104 @@ +#!/bin/bash +# +# SPDX-License-Identifier: BSD-3-Clause +# Copyright (c) 2015-2018 Linaro Limited +# Copyright (c) 2024 Nokia +# + +# directory where test binaries have been built +TEST_DIR="${TEST_DIR:-$PWD}" +# directory where test sources are, including scripts +TEST_SRC_DIR=$(dirname $0) + +PATH=$TEST_DIR:$PATH + +# exit codes expected by automake for skipped tests +TEST_SKIPPED=77 + +VALIDATION_TESTDIR=platform/$ODP_PLATFORM/test/validation +PLATFORM_VALIDATION=${TEST_SRC_DIR}/../../$VALIDATION_TESTDIR + +# Use installed pktio env or for make check take it from platform directory +if [ -f "./pktio_env" ]; then + . ./pktio_env +elif [ "$ODP_PLATFORM" = "" ]; then + echo "$0: error: ODP_PLATFORM must be defined" + # not skipped as this should never happen via "make check" + exit 1 +elif [ -f ${PLATFORM_VALIDATION}/api/pktio/pktio_env ]; then + . ${PLATFORM_VALIDATION}/api/pktio/pktio_env +else + echo "BUG: unable to find pktio_env!" + echo "pktio_env has to be in current directory or in platform/\$ODP_PLATFORM/test." + echo "ODP_PLATFORM=\"$ODP_PLATFORM\"" + exit 1 +fi + +run_l2fwd_perf() +{ + setup_pktio_env clean # install trap to call cleanup_pktio_env + + if [ $? -ne 0 ]; then + echo "setup_pktio_env error $?" + exit $TEST_SKIPPED + fi + + type odp_packet_gen > /dev/null + + if [ $? -ne 0 ]; then + echo "odp_packet_gen not installed. Aborting." + cleanup_pktio_env + exit 1 + fi + + # Run odp_packet_gen with one tx thread + GEN_LOG=odp_packet_gen_tmp.log + (odp_packet_gen${EXEEXT} --gap 0 -i $IF0 \ + --ipv4_src 192.168.0.1 --ipv4_dst 192.168.0.2 \ + -r 0 -t 1 2>&1 > $GEN_LOG) \ + 2>&1 > $GEN_LOG & + GEN_PID=$! + LOG=odp_l2fwd_perf_tmp.log + # Max 2 workers + odp_l2fwd_perf${EXEEXT} -i $IF1,$IF2 -m 0 -t 5 -c 2 | tee $LOG + ret=${PIPESTATUS[0]} + kill -2 ${GEN_PID} + wait ${GEN_PID} + + if [ ! -f $LOG ]; then + echo "FAIL: $LOG not found" + ret=1 + elif [ $ret -eq 0 ]; then + PASS_PPS=5000 + + if [ "${TEST}" = "coverage" ]; then + PASS_PPS=10 + fi + + MAX_PPS=$(awk '/total packets per second:/ {print $5}' $LOG) + NUMREG='^[0-9]+$' + echo "PARSED PPS: $MAX_PPS" + + if ! [[ $MAX_PPS =~ $NUMREG ]]; then + echo "FAIL: cannot parse $LOG" + ret=1 + elif [ "$MAX_PPS" -lt "$PASS_PPS" ]; then + echo -e "\nodp_packet_gen" + echo "==============" + cat $GEN_LOG + echo -e "\nFAIL: pps below threshold $MAX_PPS < $PASS_PPS" + ret=1 + fi + fi + + rm -f $GEN_LOG + rm -f $LOG + cleanup_pktio_env + exit $ret +} + +case "$1" in + setup) setup_pktio_env ;; + cleanup) cleanup_pktio_env ;; + *) run_l2fwd_perf ;; +esac