1#!/usr/bin/ksh 2# 3# This file and its contents are supplied under the terms of the 4# Common Development and Distribution License ("CDDL"), version 1.0. 5# You may only use this file in accordance with the terms of version 6# 1.0 of the CDDL. 7# 8# A full copy of the text of the CDDL should have accompanied this 9# source. A copy of the CDDL is also available via the Internet at 10# http://www.illumos.org/license/CDDL. 11 12# 13# Copyright 2019 Joyent, Inc. 14# 15 16# 17# Run the IP forwarding test suite. 18# 19# Usage 20# 21# ip_fwd_suite [-n <name>] [-a <args>] 22# 23# To run all tests: 24# 25# NET_TESTS=/opt/net-tests ip_fwd_suite 26# 27# To run one test: 28# 29# NET_TESTS=/opt/net-tests ip_fwd_suite -n 001 30# 31# To run one test with additional arguments passed to 'ip_forwarding': 32# 33# NET_TESTS=/opt/net-tests ip_fwd_suite -n 001 -a n 34# 35 36if [[ -z $NET_TESTS ]]; then 37 echo "NET_TESTS not set" >&2 38 exit 1 39fi 40 41. $NET_TESTS/tests/net_common 42. $NET_TESTS/config/ip_forwarding.config 43 44if [[ -z "$NT_CLIENT" ]]; then 45 fail "NT_CLIENT must be set" 46fi 47 48if [[ -z "$NT_ROUTER" ]]; then 49 fail "NT_ROUTER must be set" 50fi 51 52if [[ -z "$NT_SERVER" ]]; then 53 fail "NT_SERVER must be set" 54fi 55 56while getopts "a:n:" opt; do 57 case $opt in 58 a) 59 nt_args=$OPTARG 60 ;; 61 n) 62 nt_name=$OPTARG 63 ;; 64 esac 65done 66 67shift $((OPTIND - 1)) 68 69nt_script=$NET_TESTS/tests/forwarding/ip_forwarding 70 71# 72# See the "Test Matrix" section of the README for a description of 73# each test. 74# 75typeset -A nt_name_args 76nt_name_args["001"]="uv" 77nt_name_args["002"]="puv" 78nt_name_args["003"]="lpuv" 79nt_name_args["004"]="fuv" 80nt_name_args["005"]="fluv" 81nt_name_args["006"]="ruv" 82nt_name_args["007"]="pruv" 83nt_name_args["008"]="lpruv" 84nt_name_args["009"]="fruv" 85nt_name_args["010"]="flruv" 86 87nt_name_args["011"]="buv" 88nt_name_args["012"]="bpuv" 89nt_name_args["013"]="blpuv" 90nt_name_args["014"]="bfuv" 91nt_name_args["015"]="bfluv" 92nt_name_args["016"]="bruv" 93nt_name_args["017"]="bpruv" 94nt_name_args["018"]="blpruv" 95nt_name_args["019"]="bfruv" 96nt_name_args["020"]="bflruv" 97 98if [[ -n $nt_name ]]; then 99 if [[ -z ${nt_name_args[$nt_name]} ]]; then 100 fail "invalid test name: $nt_name" 101 fi 102 103 export NT_TNAME="ip_fwd_$nt_name" 104 nt_args="-${nt_name_args[$nt_name]}${nt_args}" 105 $nt_script $nt_args $NT_CLIENT $NT_ROUTER $NT_SERVER 106 exit $? 107fi 108 109for nt_name in ${!nt_name_args[@]}; do 110 export NT_TNAME="ip_fwd_$nt_name" 111 nt_args="-${nt_name_args[$nt_name]}${nt_args}" 112 $nt_script $nt_args $NT_CLIENT $NT_ROUTER $NT_SERVER || exit $? 113done 114 115exit 0 116