1#! /bin/bash 2# SPDX-License-Identifier: BSD-3-Clause 3 4# Usage: 5# /bin/bash <test-acl-binary> <dir-with-acl-rules-traces> <acl-alg> <burst-size> 6# Expected file-naming conventions: 7# - for rules: 'acl[0-9]v[4,6]_[0-9,a-z]+_rule' 8# - for traces: 'acl[0-9]v[4,6]_[0-9,a-z]+_trace' 9# Each rule file expects to have exactly one trace file. 10# test-acl app follows classbench file format. 11# Each line defines exactly one rule/trace. 12# rules record format: 13# '@'<src_ip_addr>'/'<masklen><space> \ 14# <dst_ipv4_addr>'/'<masklen><space> \ 15# <src_port_low><space>":"<src_port_high><space> \ 16# <dst_port_low><space>":"<dst_port_high><space> \ 17# <proto>'/'<mask> 18# trace record format: 19# <src_ip_addr><space><dst_ip_addr><space> \ 20# <src_port><space<dst_port><space><proto>...<rule_id> 21# 22# As an example: 23# /bin/bash app/test-acl/test-acl.sh build/app/dpdk-test-acl \ 24# app/test-acl/input scalar 32 25# 26# Refer to test-acl app for more information about rules/trace files format, 27# available test-acl command-line options, etc. 28 29TACL_PATH=$1 30TACL_DIR=$2 31TACL_ALG=$3 32TACL_STEP=$4 33 34if [[ ! -x ${TACL_PATH} ]]; then 35 echo "invalid TACL_PATH=${TACL_PATH}" 36 exit 127 37fi 38 39if [[ ! -d ${TACL_DIR} ]]; then 40 echo "invalid TACL_DIR=${TACL_DIR}" 41 exit 127 42fi 43 44V4F=`find ${TACL_DIR} -type f | egrep -e 'acl[0-9]v4_[0-9,a-z]+_rule$'` 45V6F=`find ${TACL_DIR} -type f | egrep -e 'acl[0-9]v6_[0-9,a-z]+_rule$'` 46 47run_test() 48{ 49 i=$1 50 n=`basename ${i}` 51 52 TRACEF=`echo ${i} | sed -e 's/_rule$/_trace/'` 53 if [[ ! -f ${TRACEF} ]]; then 54 echo "${TRACEF} not found" 55 echo "test ${n} FAILED" 56 exit 127 57 fi 58 59 OUTF=`mktemp ${n}_XXXXXX` 60 echo "start test ${n} with alg ${TACL_ALG}, burst-size ${TACL_STEP}" 61 ${TACL_PATH} -l 0 -n 4 --log-level="acl,debug" \ 62 --force-max-simd-bitwidth=0 --no-pci -- \ 63 ${XPRM} --tracenum=200000 --rulesf=${i} --tracef=${TRACEF} \ 64 --tracestep=${TACL_STEP} --alg=${TACL_ALG} \ 65 > ${OUTF} 66 grep 'result:' ${OUTF} | awk '{print $(NF);}' > ${OUTF}.out 67 sed -e '/^[[:space:]]*#/d' \ 68 -e '/^[[:space:]]*$/d' \ 69 -e 's/[[:space:]]*$//g' ${TRACEF} | \ 70 awk '{print $(NF);}' > ${OUTF}.chk 71 diff -u ${OUTF}.chk ${OUTF}.out 72 st=$? 73 if [[ $st -ne 0 ]]; then 74 echo "test ${n} FAILED" 75 echo "output files:" 76 ls ${OUTF}* 77 cat ${OUTF}* 78 exit 127 79 fi 80 rm -f ${OUTF}* 81 echo "test ${n} OK" 82} 83 84for i in ${V4F}; do 85 run_test $i 86done 87 88for i in ${V6F}; do 89 XPRM='--ipv6=4B' 90 run_test $i 91 XPRM='--ipv6=8B' 92 run_test $i 93 unset XPRM 94done 95 96echo "All tests have ended successfully" 97