resource_scale.sh 1.6 KB
Newer Older
1 2 3 4 5 6 7 8 9
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0

lib_dir=$(dirname $0)/../../../../net/forwarding

NUM_NETIFS=6
source $lib_dir/lib.sh
source $lib_dir/tc_common.sh
source $lib_dir/devlink_lib.sh
10
source ../mlxsw_lib.sh
11

12
mlxsw_only_on_spectrum 2+ || exit 1
13

14 15 16 17 18 19 20 21
current_test=""

cleanup()
{
	pre_cleanup
	if [ ! -z $current_test ]; then
		${current_test}_cleanup
	fi
22 23
	# Need to reload in order to avoid router abort.
	devlink_reload
24 25 26 27
}

trap cleanup EXIT

28 29 30 31 32 33 34 35
ALL_TESTS="
	router
	tc_flower
	mirror_gre
	tc_police
	port
	rif_mac_profile
	rif_counter
36
	port_range
37 38
"

39
for current_test in ${TESTS:-$ALL_TESTS}; do
40
	RET_FIN=0
41 42 43 44 45 46 47 48
	source ${current_test}_scale.sh

	num_netifs_var=${current_test^^}_NUM_NETIFS
	num_netifs=${!num_netifs_var:-$NUM_NETIFS}

	for should_fail in 0 1; do
		RET=0
		target=$(${current_test}_get_target "$should_fail")
49 50 51 52 53
		if ((target == 0)); then
			log_test_skip "'$current_test' should_fail=$should_fail test"
			continue
		fi

54 55
		${current_test}_setup_prepare
		setup_wait $num_netifs
56 57 58
		# Update target in case occupancy of a certain resource changed
		# following the test setup.
		target=$(${current_test}_get_target "$should_fail")
59 60 61
		${current_test}_test "$target" "$should_fail"
		if [[ "$should_fail" -eq 0 ]]; then
			log_test "'$current_test' $target"
62 63 64 65 66 67 68 69

			if ((!RET)); then
				tt=${current_test}_traffic_test
				if [[ $(type -t $tt) == "function" ]]; then
					$tt "$target"
					log_test "'$current_test' $target traffic test"
				fi
			fi
70 71 72
		else
			log_test "'$current_test' overflow $target"
		fi
73
		${current_test}_cleanup $target
74
		devlink_reload
75
		RET_FIN=$(( RET_FIN || RET ))
76 77 78 79
	done
done
current_test=""

80
exit "$RET_FIN"