Skip to content

Commit

Permalink
test: l2fwd_perf: add runner script
Browse files Browse the repository at this point in the history
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 <tuomas.taipale@nokia.com>
  • Loading branch information
TuomasTaipale committed Sep 25, 2024
1 parent 1dac5dd commit 5aca282
Show file tree
Hide file tree
Showing 2 changed files with 105 additions and 0 deletions.
1 change: 1 addition & 0 deletions test/performance/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
104 changes: 104 additions & 0 deletions test/performance/odp_l2fwd_perf_run.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 5aca282

Please sign in to comment.