1#!/bin/bash
2# SPDX-License-Identifier: GPL-2.0
3
4lib_dir=$(dirname $0)/../../../../net/forwarding
5
6NUM_NETIFS=6
7source $lib_dir/lib.sh
8source $lib_dir/tc_common.sh
9source $lib_dir/devlink_lib.sh
10source ../mlxsw_lib.sh
11
12mlxsw_only_on_spectrum 2+ || exit 1
13
14current_test=""
15
16cleanup()
17{
18	pre_cleanup
19	if [ ! -z $current_test ]; then
20		${current_test}_cleanup
21	fi
22	# Need to reload in order to avoid router abort.
23	devlink_reload
24}
25
26trap cleanup EXIT
27
28ALL_TESTS="router tc_flower mirror_gre tc_police port rif_mac_profile"
29for current_test in ${TESTS:-$ALL_TESTS}; do
30	RET_FIN=0
31	source ${current_test}_scale.sh
32
33	num_netifs_var=${current_test^^}_NUM_NETIFS
34	num_netifs=${!num_netifs_var:-$NUM_NETIFS}
35
36	for should_fail in 0 1; do
37		RET=0
38		target=$(${current_test}_get_target "$should_fail")
39		${current_test}_setup_prepare
40		setup_wait $num_netifs
41		${current_test}_test "$target" "$should_fail"
42		${current_test}_cleanup
43		devlink_reload
44		if [[ "$should_fail" -eq 0 ]]; then
45			log_test "'$current_test' $target"
46		else
47			log_test "'$current_test' overflow $target"
48		fi
49		RET_FIN=$(( RET_FIN || RET ))
50	done
51done
52current_test=""
53
54exit "$RET_FIN"
55