gro.sh (2101B)
1#!/bin/bash 2# SPDX-License-Identifier: GPL-2.0 3 4readonly SERVER_MAC="aa:00:00:00:00:02" 5readonly CLIENT_MAC="aa:00:00:00:00:01" 6readonly TESTS=("data" "ack" "flags" "tcp" "ip" "large") 7readonly PROTOS=("ipv4" "ipv6") 8dev="" 9test="all" 10proto="ipv4" 11 12run_test() { 13 local server_pid=0 14 local exit_code=0 15 local protocol=$1 16 local test=$2 17 local ARGS=( "--${protocol}" "--dmac" "${SERVER_MAC}" \ 18 "--smac" "${CLIENT_MAC}" "--test" "${test}" "--verbose" ) 19 20 setup_ns 21 # Each test is run 3 times to deflake, because given the receive timing, 22 # not all packets that should coalesce will be considered in the same flow 23 # on every try. 24 for tries in {1..3}; do 25 # Actual test starts here 26 ip netns exec server_ns ./gro "${ARGS[@]}" "--rx" "--iface" "server" \ 27 1>>log.txt & 28 server_pid=$! 29 sleep 0.5 # to allow for socket init 30 ip netns exec client_ns ./gro "${ARGS[@]}" "--iface" "client" \ 31 1>>log.txt 32 wait "${server_pid}" 33 exit_code=$? 34 if [[ "${exit_code}" -eq 0 ]]; then 35 break; 36 fi 37 done 38 cleanup_ns 39 echo ${exit_code} 40} 41 42run_all_tests() { 43 local failed_tests=() 44 for proto in "${PROTOS[@]}"; do 45 for test in "${TESTS[@]}"; do 46 echo "running test ${proto} ${test}" >&2 47 exit_code=$(run_test $proto $test) 48 if [[ "${exit_code}" -ne 0 ]]; then 49 failed_tests+=("${proto}_${test}") 50 fi; 51 done; 52 done 53 if [[ ${#failed_tests[@]} -ne 0 ]]; then 54 echo "failed tests: ${failed_tests[*]}. \ 55 Please see log.txt for more logs" 56 exit 1 57 else 58 echo "All Tests Succeeded!" 59 fi; 60} 61 62usage() { 63 echo "Usage: $0 \ 64 [-i <DEV>] \ 65 [-t data|ack|flags|tcp|ip|large] \ 66 [-p <ipv4|ipv6>]" 1>&2; 67 exit 1; 68} 69 70while getopts "i:t:p:" opt; do 71 case "${opt}" in 72 i) 73 dev="${OPTARG}" 74 ;; 75 t) 76 test="${OPTARG}" 77 ;; 78 p) 79 proto="${OPTARG}" 80 ;; 81 *) 82 usage 83 ;; 84 esac 85done 86 87if [ -n "$dev" ]; then 88 source setup_loopback.sh 89else 90 source setup_veth.sh 91fi 92 93setup 94trap cleanup EXIT 95if [[ "${test}" == "all" ]]; then 96 run_all_tests 97else 98 run_test "${proto}" "${test}" 99fi;