From: Hangbin Liu setup() installs both the base topology and the End PSP policies. That couples general test setup with one specific flavor scenario and makes it hard to add further flavor cases cleanly. Extract the End PSP policy setup into setup_end_flv_psp() so flavor tests can set up and later tear down independently (the matching cleanup arrives in a following patch). Run the block under set -e so a setup failure is treated as an error instead of falling through into the connectivity checks. When deciding to report the run as skipped, keep any failure already recorded by a test, so a real failure is not converted into a skip. Signed-off-by: Hangbin Liu --- .../testing/selftests/net/srv6_end_flavors_test.sh | 33 ++++++++++++++++------ 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/tools/testing/selftests/net/srv6_end_flavors_test.sh b/tools/testing/selftests/net/srv6_end_flavors_test.sh index 157baa8ecb0b..250de54d8bfa 100755 --- a/tools/testing/selftests/net/srv6_end_flavors_test.sh +++ b/tools/testing/selftests/net/srv6_end_flavors_test.sh @@ -488,10 +488,15 @@ cleanup() # check whether the setup phase was completed successfully or not. In # case of an error during the setup phase of the testing environment, - # the selftest is considered as "skipped". + # the selftest is considered as "skipped", unless a test has already + # recorded a failure. if [ "${SETUP_ERR}" -ne 0 ]; then - echo "SKIP: Setting up the testing environment failed" - exit "${ksft_skip}" + if [ "$ret" -ne "$ksft_fail" ]; then + echo "SKIP: Setting up the testing environment failed" + exit "${ksft_skip}" + fi + + echo "FAIL: Setting up the testing environment failed" fi exit "${ret}" @@ -962,17 +967,25 @@ setup() setup_hs 1 1 setup_hs 2 2 - # set up the loopback addresses of the hosts used by the Policies (i.c) - # and (i.d). - setup_hs_lo_addr 1 1 "${END_CSID_PSP_FUNC}" - setup_hs_lo_addr 2 2 "${END_CSID_PSP_FUNC}" - # set up default SRv6 Endpoints (i.e. SRv6 End behavior) setup_rt_local_sids 1 "2 3 4" setup_rt_local_sids 2 "1 3 4" setup_rt_local_sids 3 "1 2 4" setup_rt_local_sids 4 "1 2 3" + # testing environment was set up successfully + SETUP_ERR=0 +} + +setup_end_flv_psp() +{ + SETUP_ERR=1 + + # set up the loopback addresses of the hosts used by the Policies (i.c) + # and (i.d). + setup_hs_lo_addr 1 1 "${END_CSID_PSP_FUNC}" + setup_hs_lo_addr 2 2 "${END_CSID_PSP_FUNC}" + # set up SRv6 policies # create a connection between hosts hs-1 and hs-2. # The path between hs-1 and hs-2 traverses SRv6 aware routers. @@ -1429,6 +1442,10 @@ set +e router_tests host2gateway_tests + +set -e +setup_end_flv_psp +set +e host_srv6_end_flv_psp_tests host_srv6_end_flv_next_csid_psp_tests host_srv6_end_flv_consumed_srh_tests -- 2.56.0