diff options
author | Stuart Haslam <stuart.haslam@linaro.org> | 2016-01-29 18:17:33 +0000 |
---|---|---|
committer | Stuart Haslam <stuart.haslam@linaro.org> | 2016-01-29 18:19:33 +0000 |
commit | d1be00969de9f3a39695a536db77b3fd69247112 (patch) | |
tree | 1c0ee94024867ab6484d670ca46b27ac7fcf0ec9 | |
parent | fa85c7807890f1999e29ad18902106980687482d (diff) |
linux-generic: example: add examples to make checkexamples-check
Add the IPsec and classifier examples to "make check".
Signed-off-by: Stuart Haslam <stuart.haslam@linaro.org>
26 files changed, 208 insertions, 149 deletions
diff --git a/example/ipsec/Makefile.am b/example/ipsec/Makefile.am index c82ea0a7..779040ee 100644 --- a/example/ipsec/Makefile.am +++ b/example/ipsec/Makefile.am @@ -14,17 +14,6 @@ noinst_HEADERS = \ $(top_srcdir)/example/ipsec/odp_ipsec_stream.h \ $(top_srcdir)/example/example_debug.h -dist_bin_SCRIPTS = \ - $(srcdir)/run_ah_in \ - $(srcdir)/run_ah_out \ - $(srcdir)/run_both_in \ - $(srcdir)/run_both_out \ - $(srcdir)/run_esp_in \ - $(srcdir)/run_esp_out \ - $(srcdir)/run_live \ - $(srcdir)/run_router \ - $(srcdir)/run_simple - dist_odp_ipsec_SOURCES = odp_ipsec.c \ odp_ipsec_sa_db.c \ odp_ipsec_sp_db.c \ diff --git a/example/ipsec/run_ah_in b/example/ipsec/run_ah_in deleted file mode 100755 index 252f44bf..00000000 --- a/example/ipsec/run_ah_in +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash -# -# Test input AH -# - 2 loop interfaces -# - 10 packets -# - Specify API mode on command line -odp_ipsec -i loop1,loop2 \ --r 192.168.111.2/32:loop1:08.00.27.76.B5.E0 \ --p 192.168.222.0/24:192.168.111.0/24:in:ah \ --a 192.168.222.2:192.168.111.2:md5:300:27f6d123d7077b361662fc6e451f65d8 \ --s 192.168.222.2:192.168.111.2:loop2:loop1:10:100 \ --c 2 -m $1 diff --git a/example/ipsec/run_ah_out b/example/ipsec/run_ah_out deleted file mode 100755 index 9256c072..00000000 --- a/example/ipsec/run_ah_out +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash -# -# Test output AH -# - 2 loop interfaces -# - 10 packets -# - Specify API mode on command line -odp_ipsec -i loop1,loop2 \ --r 192.168.222.2/32:loop2:08.00.27.F5.8B.DB \ --p 192.168.111.0/24:192.168.222.0/24:out:ah \ --a 192.168.111.2:192.168.222.2:md5:200:a731649644c5dee92cbd9c2e7e188ee6 \ --s 192.168.111.2:192.168.222.2:loop1:loop2:10:100 \ --c 2 -m $1 diff --git a/example/ipsec/run_both_in b/example/ipsec/run_both_in deleted file mode 100755 index c3f169ce..00000000 --- a/example/ipsec/run_both_in +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash -# -# Test AH and ESP input -# - 2 loop interfaces -# - 10 packets -# - Specify API mode on command line -odp_ipsec -i loop1,loop2 \ --r 192.168.111.2/32:loop1:08.00.27.76.B5.E0 \ --p 192.168.222.0/24:192.168.111.0/24:in:both \ --a 192.168.222.2:192.168.111.2:md5:300:27f6d123d7077b361662fc6e451f65d8 \ --e 192.168.222.2:192.168.111.2:\ -3des:301:c966199f24d095f3990a320d749056401e82b26570320292 \ --s 192.168.222.2:192.168.111.2:loop2:loop1:10:100 \ --c 2 -m $1 diff --git a/example/ipsec/run_both_out b/example/ipsec/run_both_out deleted file mode 100755 index 8ba06722..00000000 --- a/example/ipsec/run_both_out +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash -# -# Test AH and ESP output -# - 2 loop interfaces -# - 10 packets -# - Specify API mode on command line -odp_ipsec -i loop1,loop2 \ --r 192.168.222.2/32:loop2:08.00.27.F5.8B.DB \ --p 192.168.111.0/24:192.168.222.0/24:out:both \ --e 192.168.111.2:192.168.222.2:\ -3des:201:656c8523255ccc23a66c1917aa0cf30991fce83532a4b224 \ --a 192.168.111.2:192.168.222.2:md5:200:a731649644c5dee92cbd9c2e7e188ee6 \ --s 192.168.111.2:192.168.222.2:loop1:loop2:10:100 \ --c 2 -m $1 diff --git a/example/ipsec/run_esp_in b/example/ipsec/run_esp_in deleted file mode 100755 index 12fdae69..00000000 --- a/example/ipsec/run_esp_in +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash -# -# Test input ESP -# - 2 loop interfaces -# - 10 packets -# - Specify API mode on command line -odp_ipsec -i loop1,loop2 \ --r 192.168.111.2/32:loop1:08.00.27.76.B5.E0 \ --p 192.168.222.0/24:192.168.111.0/24:in:esp \ --e 192.168.222.2:192.168.111.2:\ -3des:301:c966199f24d095f3990a320d749056401e82b26570320292 \ --s 192.168.222.2:192.168.111.2:loop2:loop1:10:100 \ --c 2 -m $1 diff --git a/example/ipsec/run_esp_out b/example/ipsec/run_esp_out deleted file mode 100755 index 73c4ff0e..00000000 --- a/example/ipsec/run_esp_out +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash -# -# Test output ESP -# - 2 loop interfaces -# - 10 packets -# - Specify API mode on command line -odp_ipsec -i loop1,loop2 \ --r 192.168.222.2/32:loop2:08.00.27.F5.8B.DB \ --p 192.168.111.0/24:192.168.222.0/24:out:esp \ --e 192.168.111.2:192.168.222.2:\ -3des:201:656c8523255ccc23a66c1917aa0cf30991fce83532a4b224 \ --s 192.168.111.2:192.168.222.2:loop1:loop2:10:100 \ --c 2 -m $1 diff --git a/example/ipsec/run_live b/example/ipsec/run_live deleted file mode 100755 index 90947ad7..00000000 --- a/example/ipsec/run_live +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash -# -# Live router test -# - 2 interfaces interfaces -# - Specify API mode on command line -sudo odp_ipsec -i p7p1,p8p1 \ --r 192.168.111.2/32:p7p1:08.00.27.76.B5.E0 \ --r 192.168.222.2/32:p8p1:08.00.27.F5.8B.DB \ --p 192.168.111.0/24:192.168.222.0/24:out:both \ --e 192.168.111.2:192.168.222.2:\ -3des:201:656c8523255ccc23a66c1917aa0cf30991fce83532a4b224 \ --a 192.168.111.2:192.168.222.2:md5:200:a731649644c5dee92cbd9c2e7e188ee6 \ --p 192.168.222.0/24:192.168.111.0/24:in:both \ --e 192.168.222.2:192.168.111.2:\ -3des:301:c966199f24d095f3990a320d749056401e82b26570320292 \ --a 192.168.222.2:192.168.111.2:md5:300:27f6d123d7077b361662fc6e451f65d8 \ --c 2 -m $1 diff --git a/example/ipsec/run_router b/example/ipsec/run_router deleted file mode 100755 index 36302973..00000000 --- a/example/ipsec/run_router +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash -# -# Live router test -# - 2 interfaces interfaces -# - Specify API mode on command line -sudo odp_ipsec -i p7p1,p8p1 \ --r 192.168.111.2/32:p7p1:08.00.27.76.B5.E0 \ --r 192.168.222.2/32:p8p1:08.00.27.F5.8B.DB \ --c 1 -m $1 diff --git a/example/ipsec/run_simple b/example/ipsec/run_simple deleted file mode 100755 index 12115838..00000000 --- a/example/ipsec/run_simple +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash -# -# Simple router test -# - 2 loop interfaces -# - 10 packets -# - Specify API mode on command line -odp_ipsec -i loop1,loop2 \ --r 192.168.222.2/32:loop2:08.00.27.F5.8B.DB \ --s 192.168.111.2:192.168.222.2:loop1:loop2:10:100 \ --c 2 -m $1 diff --git a/platform/linux-generic/m4/configure.m4 b/platform/linux-generic/m4/configure.m4 index df6dc640..e4ace0c1 100644 --- a/platform/linux-generic/m4/configure.m4 +++ b/platform/linux-generic/m4/configure.m4 @@ -23,4 +23,8 @@ m4_include([platform/linux-generic/m4/odp_pcap.m4]) AC_CONFIG_FILES([platform/linux-generic/Makefile platform/linux-generic/test/Makefile - platform/linux-generic/test/pktio/Makefile]) + platform/linux-generic/test/validation/Makefile + platform/linux-generic/test/validation/pktio/Makefile + platform/linux-generic/test/example/Makefile + platform/linux-generic/test/example/classifier/Makefile + platform/linux-generic/test/example/ipsec/Makefile]) diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c index db85b5e5..aa4e8b98 100644 --- a/platform/linux-generic/odp_packet.c +++ b/platform/linux-generic/odp_packet.c @@ -97,22 +97,11 @@ odp_packet_t packet_alloc(odp_pool_t pool_hdl, uint32_t len, int parse) return ODP_PACKET_INVALID; /* Handle special case for zero-length packets */ - if (len == 0) { - len = pool->s.params.buf.size; + uint32_t buf_len = (len == 0) ? pool->s.params.buf.size : len; - pkt = (odp_packet_t)buffer_alloc(pool_hdl, len); - - if (pkt == ODP_PACKET_INVALID) - return ODP_PACKET_INVALID; - - pull_tail(odp_packet_hdr(pkt), len); - - } else { - pkt = (odp_packet_t)buffer_alloc(pool_hdl, len); - - if (pkt == ODP_PACKET_INVALID) - return ODP_PACKET_INVALID; - } + pkt = (odp_packet_t)buffer_alloc(pool_hdl, buf_len); + if (pkt == ODP_PACKET_INVALID) + return ODP_PACKET_INVALID; pkt_hdr = odp_packet_hdr(pkt); diff --git a/platform/linux-generic/test/Makefile.am b/platform/linux-generic/test/Makefile.am index e6298729..5d43b473 100644 --- a/platform/linux-generic/test/Makefile.am +++ b/platform/linux-generic/test/Makefile.am @@ -1,11 +1,11 @@ include $(top_srcdir)/test/Makefile.inc TESTS_ENVIRONMENT += TEST_DIR=${top_builddir}/test/validation -ODP_MODULES = pktio +TESTS = if test_vald -TESTS = pktio/pktio_run \ - pktio/pktio_run_tap \ +TESTS += validation/pktio/pktio_run \ + validation/pktio/pktio_run_tap \ ${top_builddir}/test/validation/buffer/buffer_main$(EXEEXT) \ ${top_builddir}/test/validation/classification/classification_main$(EXEEXT) \ ${top_builddir}/test/validation/config/config_main$(EXEEXT) \ @@ -29,13 +29,18 @@ TESTS = pktio/pktio_run \ ${top_builddir}/test/validation/shmem/shmem_main$(EXEEXT) \ ${top_builddir}/test/validation/system/system_main$(EXEEXT) -SUBDIRS = $(ODP_MODULES) +SUBDIRS = validation example if HAVE_PCAP -TESTS += pktio/pktio_run_pcap +TESTS += validation/pktio/pktio_run_pcap endif endif +#if test_example +TESTS += example/ipsec/ipsec_run \ + example/classifier/classifier_run +#endif + dist_check_SCRIPTS = run-test tests-validation.env $(LOG_COMPILER) test_SCRIPTS = $(dist_check_SCRIPTS) @@ -52,5 +57,5 @@ endif #performance tests refer to pktio_env if test_perf -SUBDIRS = pktio +SUBDIRS = validation/pktio endif diff --git a/platform/linux-generic/test/example/Makefile.am b/platform/linux-generic/test/example/Makefile.am new file mode 100644 index 00000000..b586f1f3 --- /dev/null +++ b/platform/linux-generic/test/example/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = classifier ipsec diff --git a/platform/linux-generic/test/example/classifier/Makefile.am b/platform/linux-generic/test/example/classifier/Makefile.am new file mode 100644 index 00000000..6b32335d --- /dev/null +++ b/platform/linux-generic/test/example/classifier/Makefile.am @@ -0,0 +1,3 @@ +dist_check_SCRIPTS = classifier_run + +test_SCRIPTS = $(dist_check_SCRIPTS) diff --git a/platform/linux-generic/test/example/classifier/classifier_run b/platform/linux-generic/test/example/classifier/classifier_run new file mode 100755 index 00000000..f1b10c23 --- /dev/null +++ b/platform/linux-generic/test/example/classifier/classifier_run @@ -0,0 +1,14 @@ +# +# +# +# +PATH=${TEST_DIR}/pktio:$PATH +PATH=$(dirname $0):$PATH +PATH=$(dirname $0)/../../../../example/classifier/:$PATH +PATH=.:$PATH + +ESP_PCAP=esp.pcap + +odp_classifier${EXEEXT} -m 0 -ipcap:in=${ESP_PCAP} \ + -p "ODP_PMR_SIP_ADDR:192.168.111.2:FFFFFFFF:queue1" \ + -t 5 -c 1 | tee bleh.log diff --git a/platform/linux-generic/test/example/ipsec/Makefile.am b/platform/linux-generic/test/example/ipsec/Makefile.am new file mode 100644 index 00000000..84116dd1 --- /dev/null +++ b/platform/linux-generic/test/example/ipsec/Makefile.am @@ -0,0 +1,3 @@ +dist_check_SCRIPTS = ipsec_run + +test_SCRIPTS = $(dist_check_SCRIPTS) diff --git a/platform/linux-generic/test/example/ipsec/ipsec_run b/platform/linux-generic/test/example/ipsec/ipsec_run new file mode 100755 index 00000000..167d02ab --- /dev/null +++ b/platform/linux-generic/test/example/ipsec/ipsec_run @@ -0,0 +1,152 @@ +#!/bin/sh +# +# Copyright (c) 2015, Linaro Limited +# All rights reserved. +# +# SPDX-License-Identifier: BSD-3-Clause +# +NUM_CORES=${IPSEC_NUM_CORES:-2} +MODE=${IPSEC_MODE:-0} +IFACE1=${IPSEC_IFACE1:-loop1} +IFACE2=${IPSEC_IFACE2:-loop2} +INTERFACES=${IFACE1},${IFACE2} +NUM_PACKETS=${IPSEC_NUM_PACKETS:-10} +IP1=192.168.111.2 +MASK1=192.168.222.0/24 +IP2=192.168.222.2 +MASK2=192.168.111.0/24 +TUNIP1=192.168.100.1 +TUNIP2=192.168.100.2 + +R1=$IP1/32:$IFACE1:08.00.27.76.B5.E0 +R2=$IP2/32:$IFACE2:08.00.27.F5.8B.DB +P1=$MASK1:$MASK2 +P2=$MASK2:$MASK1 + +# Streams +S1=$IP2:$IP1:$IFACE2:$IFACE1:$NUM_PACKETS:100 +S2=$IP1:$IP2:$IFACE1:$IFACE2:$NUM_PACKETS:100 +# AH SPD entries +A1=$IP2:$IP1:md5:300:27f6d123d7077b361662fc6e451f65d8 +A2=$IP1:$IP2:md5:200:a731649644c5dee92cbd9c2e7e188ee6 +# ESP SPD entries +E1=$IP2:$IP1:3des:301:c966199f24d095f3990a320d749056401e82b26570320292 +E2=$IP1:$IP2:3des:201:656c8523255ccc23a66c1917aa0cf30991fce83532a4b224 +# Tunnels +T1=$IP2:$IP1:$TUNIP2:$TUNIP1 +T2=$IP1:$IP2:$TUNIP1:$TUNIP2 + +usage() +{ + echo "USAGE: odp_ipsec_run MODE" + echo + echo "Where MODE is one of:" + echo + echo " all Run each of the loopback modes below in sequence" + echo " simple Simple router test, no encryption or authentication" + echo " ah_in Test input AH" + echo " ah_in_tun Test input AH, tunnel mode" + echo " ah_out Test output AH" + echo " ah_out_tun Test output AH, tunnel_mode" + echo " esp_in Test input ESP" + echo " esp_in_tun Test input ESP, tunnel mode" + echo " esp_out Test output ESP" + echo " esp_out_tun Test output ESP, tunnel mode" + echo " both_in Test AH and ESP" + echo " both_in_tun Test AH and ESP, tunnel mode" + echo " both_out Test AH and ESP" + echo " both_out_tun Test AH and ESP, tunnel mode" + echo " router Live router test, no AH or ESP" + echo " live Live router test, with AH and ESP" +} + +set_args() +{ + TUN= + + case $1 in + simple) + # Simple router test, no encryption or authentication + IPSEC_ARGS="-r $R2 -s $S2";; + ah_in) + # Test input AH using loop interfaces + IPSEC_ARGS="-r $R1 -p $P1:in:ah -a $A1 -s $S1";; + ah_in_tun) + # Test input AH using loop interfaces, tunnel mode + IPSEC_ARGS="-r $R1 -p $P1:in:ah -a $A1 -s $S1 -t $T1";; + ah_out) + # Test output AH using loop interfaces + IPSEC_ARGS="-r $R2 -p $P2:out:ah -a $A2 -s $S2";; + ah_out_tun) + # Test output AH using loop interfaces, tunnel mode + IPSEC_ARGS="-r $R2 -p $P2:out:ah -a $A2 -s $S2 -t $T2";; + esp_in) + # Test input ESP using loop interfaces + IPSEC_ARGS="-r $R1 -p $P1:in:esp -e $E1 -s $S1";; + esp_in_tun) + # Test input ESP using loop interfaces, tunnel mode + IPSEC_ARGS="-r $R1 -p $P1:in:esp -e $E1 -s $S1 -t $T1";; + esp_out) + # Test output ESP using loop interfaces + IPSEC_ARGS="-r $R2 -p $P2:out:esp -e $E2 -s $S2";; + esp_out_tun) + # Test output ESP using loop interfaces, tunnel mode + IPSEC_ARGS="-r $R2 -p $P2:out:esp -e $E2 -s $S2 -t $T2";; + both_in) + # Test AH and ESP input using loop interfaces + IPSEC_ARGS="-r $R1 -p $P1:in:both -a $A1 -e $E1 -s $S1";; + both_in_tun) + # Test AH and ESP input using loop interfaces, tunnel mode + IPSEC_ARGS="-r $R1 -p $P1:in:both -a $A1 -e $E1 -s $S1 -t $T1";; + both_out) + # Test AH and ESP output using loop interfaces + IPSEC_ARGS="-r $R2 -p $P2:out:both -e $E2 -a $A2 -s $S2";; + both_out_tun) + # Test AH and ESP output using loop interfaces, tunnel mode + IPSEC_ARGS="-r $R2 -p $P2:out:both -e $E2 -a $A2 -s $S2 -t $T2";; + router) + # Live router test, no encryption or authentication + IPSEC_ARGS="-r $R1 -r $R2";; + live) + # Live router test, with encryption and authentication + IPSEC_ARGS="-r $R1 -r $R2 -p $P2:out:both -e $E2 -a $A2 \ + -p $P1:in:both -e $E1 -a $A1";; + *) + usage + exit 1 + ;; + esac +} + +if [ "$1" = "all" -o "$1" = "" ]; then + # special case for running all automated tests + AUTO_TESTS="simple ah_in ah_in_tun ah_out ah_out_tun \ + esp_in esp_in_tun esp_out esp_out_tun both_in \ + both_in_tun both_out both_out_tun" + PASS=0 + FAIL=0 + for t in $AUTO_TESTS; do + set_args $t + cmd="timeout --foreground 20 ./example/ipsec/odp_ipsec -i $INTERFACES \ + -c $NUM_CORES -m $MODE $IPSEC_ARGS" + + if [ "$V" = "0" ]; then + $cmd > /dev/null 2>&1 + else + $cmd + fi + if [ $? = 0 ]; then + let PASS=$PASS+1 + echo "PASS: $t" + else + let FAIL=$FAIL+1 + echo "FAIL: $t" + fi + done + echo "$PASS tests passed, $FAIL failed." + [ $FAIL = 0 ] && exit 0 || exit 1 +else + set_args $1 + gdb --args ./example/ipsec/odp_ipsec -i $INTERFACES -c $NUM_CORES -m $MODE $IPSEC_ARGS + exit $? +fi diff --git a/platform/linux-generic/test/validation/Makefile.am b/platform/linux-generic/test/validation/Makefile.am new file mode 100644 index 00000000..23212b2e --- /dev/null +++ b/platform/linux-generic/test/validation/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = pktio diff --git a/platform/linux-generic/test/pktio/.gitignore b/platform/linux-generic/test/validation/pktio/.gitignore index 7e563b8b..7e563b8b 100644 --- a/platform/linux-generic/test/pktio/.gitignore +++ b/platform/linux-generic/test/validation/pktio/.gitignore diff --git a/platform/linux-generic/test/pktio/Makefile.am b/platform/linux-generic/test/validation/pktio/Makefile.am index ea0ad87a..ea0ad87a 100644 --- a/platform/linux-generic/test/pktio/Makefile.am +++ b/platform/linux-generic/test/validation/pktio/Makefile.am diff --git a/platform/linux-generic/test/validation/pktio/pktio.c b/platform/linux-generic/test/validation/pktio/pktio.c new file mode 100644 index 00000000..dca041c7 --- /dev/null +++ b/platform/linux-generic/test/validation/pktio/pktio.c @@ -0,0 +1,12 @@ +/* Copyright (c) 2015, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include "pktio.h" + +int main(void) +{ + return pktio_main(); +} diff --git a/platform/linux-generic/test/pktio/pktio_env b/platform/linux-generic/test/validation/pktio/pktio_env index 345b5bd5..345b5bd5 100644 --- a/platform/linux-generic/test/pktio/pktio_env +++ b/platform/linux-generic/test/validation/pktio/pktio_env diff --git a/platform/linux-generic/test/pktio/pktio_run b/platform/linux-generic/test/validation/pktio/pktio_run index 7029ab20..b378145c 100755 --- a/platform/linux-generic/test/pktio/pktio_run +++ b/platform/linux-generic/test/validation/pktio/pktio_run @@ -12,9 +12,9 @@ # -in the validation when running standalone (./pktio_run) intree. # -in the current directory. # running stand alone out of tree requires setting PATH -PATH=${TEST_DIR}/pktio:$PATH +PATH=${TEST_DIR}/validation/pktio:$PATH PATH=$(dirname $0):$PATH -PATH=$(dirname $0)/../../../../test/validation/pktio:$PATH +PATH=$(dirname $0)/../../../../../test/validation/pktio:$PATH PATH=.:$PATH pktio_main_path=$(which pktio_main${EXEEXT}) diff --git a/platform/linux-generic/test/pktio/pktio_run_pcap b/platform/linux-generic/test/validation/pktio/pktio_run_pcap index c130417c..c130417c 100755 --- a/platform/linux-generic/test/pktio/pktio_run_pcap +++ b/platform/linux-generic/test/validation/pktio/pktio_run_pcap diff --git a/platform/linux-generic/test/pktio/pktio_run_tap b/platform/linux-generic/test/validation/pktio/pktio_run_tap index 975da81b..975da81b 100755 --- a/platform/linux-generic/test/pktio/pktio_run_tap +++ b/platform/linux-generic/test/validation/pktio/pktio_run_tap |