#!/bin/sh # # Copyright (c) 2015, Linaro Limited # All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause # # TEST_DIR is set by Makefile, when we add a rule to Makefile for odp_l2fwd_run # we can use TEST_DIR the same way odp_pktio_run uses it now. # If TEST_DIR is not set it means we are not running with make, and in this case # there are two situations: # 1. user build ODP in the same dir as the source (most likely) # here the user can simply call odp_l2fwd_run # 2. user may have built ODP in a separate build dir (like bitbake usually does) # here the user has to do something like $ODP/test/performance/odp_l2fwd_run # # In both situations the script assumes that the user is in the directory where # odp_l2fwd exists. If that's not true, then the user has to specify the path # to it and run: # TEST_DIR=$builddir $ODP/test/performance/odp_l2fwd_run # 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:$TEST_DIR/../../example/generator:$PATH # exit codes expected by automake for skipped tests TEST_SKIPPED=77 # 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 ${TEST_SRC_DIR}/../../platform/$ODP_PLATFORM/test/pktio/pktio_env ]; then . ${TEST_SRC_DIR}/../../platform/$ODP_PLATFORM/test/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() { setup_pktio_env if [ $? -ne 0 ]; then echo "setup_pktio_env error $?" exit $TEST_SKIPPED fi #@todo: limit odp_generator to cores #https://bugs.linaro.org/show_bug.cgi?id=1398 (odp_generator${EXEEXT} -I $IF0 \ --srcip 192.168.0.1 --dstip 192.168.0.2 -m u 2>&1 > /dev/null) \ 2>&1 > /dev/null & GEN_PID=$! echo "Run odp_l2fwd -i $IF1,$IF2 -m 0 -t 30 -c 2" odp_l2fwd${EXEEXT} -i $IF1,$IF2 -m 0 -t 30 -c 2 ret=$? kill ${GEN_PID} cleanup_pktio_env if [ $? -ne 0 ]; then echo "cleanup_pktio_env error $?" exit $TEST_SKIPPED fi exit $ret } case "$1" in setup) setup_pktio_env ;; cleanup) cleanup_pktio_env ;; *) run_l2fwd ;; esac