diff mbox series

[RFC,net-next,5/5] selftests: sch_tbf_core: Use defer for stopping traffic

Message ID 7dac3bd8f776741a9816efb03c672c4887765ad4.1724324945.git.petrm@nvidia.com (mailing list archive)
State RFC
Delegated to: Netdev Maintainers
Headers show
Series selftests: forwarding: Introduce deferred commands | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 7 this patch: 7
netdev/build_tools success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers warning 2 maintainers not CCed: pabeni@redhat.com edumazet@google.com
netdev/build_clang success Errors and warnings before: 7 this patch: 7
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success net selftest script(s) already in Makefile
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 7 this patch: 7
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 17 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-08-25--21-00 (tests: 714)

Commit Message

Petr Machata Aug. 22, 2024, 1:49 p.m. UTC
Tests interrupted part-way through leave behind a running mausezahn. Use
defer to schedule a traffic stop after traffic is started.

Signed-off-by: Petr Machata <petrm@nvidia.com>
---
 tools/testing/selftests/net/forwarding/sch_tbf_core.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Ido Schimmel Aug. 26, 2024, 12:07 p.m. UTC | #1
On Thu, Aug 22, 2024 at 03:49:44PM +0200, Petr Machata wrote:
> Tests interrupted part-way through leave behind a running mausezahn. Use
> defer to schedule a traffic stop after traffic is started.

Any reason not to convert the setup part to the defer mechanism as well?

> 
> Signed-off-by: Petr Machata <petrm@nvidia.com>
> ---
>  tools/testing/selftests/net/forwarding/sch_tbf_core.sh | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/testing/selftests/net/forwarding/sch_tbf_core.sh b/tools/testing/selftests/net/forwarding/sch_tbf_core.sh
> index 9cd884d4a5de..5d58c04e055c 100644
> --- a/tools/testing/selftests/net/forwarding/sch_tbf_core.sh
> +++ b/tools/testing/selftests/net/forwarding/sch_tbf_core.sh
> @@ -213,12 +213,12 @@ do_tbf_test()
>  	local mbit=$1; shift
>  
>  	start_traffic $h1.$vlan $(ipaddr 1 $vlan) $(ipaddr 2 $vlan) $h2_mac
> +	defer stop_traffic
>  	sleep 5 # Wait for the burst to dwindle
>  
>  	local t2=$(busywait_for_counter 1000 +1 tbf_get_counter $vlan)
>  	sleep 10
>  	local t3=$(tbf_get_counter $vlan)
> -	stop_traffic
>  
>  	RET=0
>  
> @@ -231,3 +231,4 @@ do_tbf_test()
>  
>  	log_test "TC $((vlan - 10)): TBF rate ${mbit}Mbit"
>  }
> +defer_scoped_fn do_tbf_test
> -- 
> 2.45.0
>
Petr Machata Aug. 26, 2024, 2:31 p.m. UTC | #2
Ido Schimmel <idosch@nvidia.com> writes:

> On Thu, Aug 22, 2024 at 03:49:44PM +0200, Petr Machata wrote:
>> Tests interrupted part-way through leave behind a running mausezahn. Use
>> defer to schedule a traffic stop after traffic is started.
>
> Any reason not to convert the setup part to the defer mechanism as well?

No. I wanted to see if it makes sense to have an entire test use the
defer mechanism, in addition to cleanups specific to individual tests.
But I wasn't sure what people would think, so just converted the RED
tests as a sort of a demo.
diff mbox series

Patch

diff --git a/tools/testing/selftests/net/forwarding/sch_tbf_core.sh b/tools/testing/selftests/net/forwarding/sch_tbf_core.sh
index 9cd884d4a5de..5d58c04e055c 100644
--- a/tools/testing/selftests/net/forwarding/sch_tbf_core.sh
+++ b/tools/testing/selftests/net/forwarding/sch_tbf_core.sh
@@ -213,12 +213,12 @@  do_tbf_test()
 	local mbit=$1; shift
 
 	start_traffic $h1.$vlan $(ipaddr 1 $vlan) $(ipaddr 2 $vlan) $h2_mac
+	defer stop_traffic
 	sleep 5 # Wait for the burst to dwindle
 
 	local t2=$(busywait_for_counter 1000 +1 tbf_get_counter $vlan)
 	sleep 10
 	local t3=$(tbf_get_counter $vlan)
-	stop_traffic
 
 	RET=0
 
@@ -231,3 +231,4 @@  do_tbf_test()
 
 	log_test "TC $((vlan - 10)): TBF rate ${mbit}Mbit"
 }
+defer_scoped_fn do_tbf_test