Skip to content

Commit

Permalink
test: dmafwd: add CI integration
Browse files Browse the repository at this point in the history
Add test script and build files to setup a test run of `odp_dmafwd`
with a few different scenarios during `make check`.

Signed-off-by: Tuomas Taipale <tuomas.taipale@nokia.com>
  • Loading branch information
TuomasTaipale committed Aug 30, 2023
1 parent e2c170b commit 7c54240
Show file tree
Hide file tree
Showing 7 changed files with 144 additions and 6 deletions.
2 changes: 2 additions & 0 deletions platform/linux-generic/m4/configure.m4
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,7 @@ AC_CONFIG_FILES([platform/linux-generic/Makefile
platform/linux-generic/test/example/switch/Makefile
platform/linux-generic/test/validation/api/shmem/Makefile
platform/linux-generic/test/validation/api/pktio/Makefile
platform/linux-generic/test/performance/Makefile
platform/linux-generic/test/performance/dmafwd/Makefile
platform/linux-generic/test/pktio_ipc/Makefile])
])
12 changes: 7 additions & 5 deletions platform/linux-generic/test/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ TESTS += validation/api/pktio/pktio_run.sh \
validation/api/pktio/pktio_run_tap.sh \
validation/api/shmem/shmem_linux$(EXEEXT)

SUBDIRS += validation/api/pktio\
validation/api/shmem\
pktio_ipc \
example
SUBDIRS += validation/api/pktio \
validation/api/shmem \
pktio_ipc \
example \
performance

if ODP_PKTIO_PCAP
TESTS += validation/api/pktio/pktio_run_pcap.sh
Expand All @@ -31,7 +32,8 @@ SUBDIRS += pktio_ipc
else
#performance tests refer to pktio_env
if test_perf
SUBDIRS += validation/api/pktio
SUBDIRS += validation/api/pktio \
performance
endif
endif

Expand Down
1 change: 1 addition & 0 deletions platform/linux-generic/test/performance/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SUBDIRS = dmafwd
18 changes: 18 additions & 0 deletions platform/linux-generic/test/performance/dmafwd/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
EXTRA_DIST = pktio_env

all-local:
if [ "x$(srcdir)" != "x$(builddir)" ]; then \
for f in $(EXTRA_DIST); do \
if [ -e $(srcdir)/$$f ]; then \
mkdir -p $(builddir)/$$(dirname $$f); \
cp -f $(srcdir)/$$f $(builddir)/$$f; \
fi \
done \
fi

clean-local:
if [ "x$(srcdir)" != "x$(builddir)" ]; then \
for f in $(EXTRA_DIST); do \
rm -f $(builddir)/$$f; \
done \
fi
46 changes: 46 additions & 0 deletions platform/linux-generic/test/performance/dmafwd/pktio_env
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/bin/sh
#
# SPDX-License-Identifier: BSD-3-Clause
# Copyright (c) 2023 Nokia

PCAP_IN=`find . ${TEST_DIR} $(dirname $0) -name udp64.pcap -print -quit`
PCAP_OUT=dmafwd_out.pcap

IF0=pcap:in=${PCAP_IN}:out=${PCAP_OUT}

if [ "$0" = "$BASH_SOURCE" ]; then
echo "ERROR: Platform specific env file has to be sourced."
fi

validate_result()
{
local VALIN=valin
local VALOUT=valout

tcpdump -r ${PCAP_IN} -t -x > ${VALIN}
tcpdump -r ${PCAP_OUT} -t -x > ${VALOUT}
diff ${VALIN} ${VALOUT}

local RET=$?

rm -f ${PCAP_OUT}
rm -f ${VALIN}
rm -f ${VALOUT}

if [ $RET -ne 0 ]; then
echo "ERROR: input and output captures do not match, exiting"
exit 1
fi

return 0
}

setup_interfaces()
{
return 0
}

cleanup_interfaces()
{
return 0
}
3 changes: 2 additions & 1 deletion test/performance/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ TESTSCRIPTS = odp_cpu_bench_run.sh \
odp_timer_perf_run.sh

if ODP_PKTIO_PCAP
TESTSCRIPTS += odp_pktio_ordered_run.sh
TESTSCRIPTS += odp_dmafwd_run.sh \
odp_pktio_ordered_run.sh
endif

TEST_EXTENSIONS = .sh
Expand Down
68 changes: 68 additions & 0 deletions test/performance/odp_dmafwd_run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#!/bin/bash
#
# SPDX-License-Identifier: BSD-3-Clause
# Copyright (c) 2023 Nokia

TEST_DIR="${TEST_DIR:-$PWD}"
TEST_SRC_DIR=$(dirname $0)
PERF_TEST_DIR=platform/${ODP_PLATFORM}/test/performance
PERF_TEST_DIR=${TEST_SRC_DIR}/../../${PERF_TEST_DIR}

BIN_NAME=odp_dmafwd
BATCH=10
TIME=2
TESTS_RUN=0

check_env()
{
if [ -f "./pktio_env" ]; then
. ./pktio_env
elif [ "${ODP_PLATFORM}" = "" ]; then
echo "$0: ERROR: ODP_PLATFORM must be defined"
exit 1
elif [ -f ${PERF_TEST_DIR}/dmafwd/pktio_env ]; then
. ${PERF_TEST_DIR}/dmafwd/pktio_env
else
echo "ERROR: 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
}

check_result()
{
if [ $1 -eq 0 ]; then
TESTS_RUN=`expr $TESTS_RUN + 1`
elif [ $1 -eq 1 ]; then
echo "Test FAILED, exiting"
exit 1
else
echo "Test SKIPPED"
return 0
fi

validate_result
}

check_exit()
{
if [ $TESTS_RUN -eq 0 ]; then
exit 77
fi

exit 0
}

check_env
setup_interfaces
echo "${BIN_NAME}: SW copy"
echo "==================="
./${BIN_NAME}${EXEEXT} -i ${IF0} -b ${BATCH} -T ${TIME} -t 0
check_result $?
echo "${BIN_NAME}: DMA copy"
echo "===================="
./${BIN_NAME}${EXEEXT} -i ${IF0} -b ${BATCH} -T ${TIME} -t 1
check_result $?
cleanup_interfaces
check_exit

0 comments on commit 7c54240

Please sign in to comment.