outreachy.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next v3] selftests: net: vrf_strict_mode_test: add support to select a test to run
@ 2022-04-28 16:48 Jaehee Park
  2022-04-28 23:02 ` Roopa Prabhu
  0 siblings, 1 reply; 3+ messages in thread
From: Jaehee Park @ 2022-04-28 16:48 UTC (permalink / raw)
  To: outreachy, Julia Denham, Roopa Prabhu, Stefano Brivio, netdev,
	jhpark1013, Roopa Prabhu, David Ahern

Add a boilerplate test loop to run all tests in
vrf_strict_mode_test.sh. Add a -t flag that allows a selected test to
run.

Signed-off-by: Jaehee Park <jhpark1013@gmail.com>
---
version 3:
- Added commented delineators to section the code for improved 
readability.
- Moved the log_section() call into the functions handling the tests.
- Removed unnecessary spaces.


 .../selftests/net/vrf_strict_mode_test.sh     | 47 +++++++++++++++++--
 1 file changed, 43 insertions(+), 4 deletions(-)

diff --git a/tools/testing/selftests/net/vrf_strict_mode_test.sh b/tools/testing/selftests/net/vrf_strict_mode_test.sh
index 865d53c1781c..423da8e08510 100755
--- a/tools/testing/selftests/net/vrf_strict_mode_test.sh
+++ b/tools/testing/selftests/net/vrf_strict_mode_test.sh
@@ -14,6 +14,8 @@ INIT_NETNS_NAME="init"
 
 PAUSE_ON_FAIL=${PAUSE_ON_FAIL:=no}
 
+TESTS="init testns mix"
+
 log_test()
 {
 	local rc=$1
@@ -262,6 +264,8 @@ cleanup()
 
 vrf_strict_mode_tests_init()
 {
+	log_section "VRF strict_mode test on init network namespace"
+
 	vrf_strict_mode_check_support init
 
 	strict_mode_check_default init
@@ -292,6 +296,8 @@ vrf_strict_mode_tests_init()
 
 vrf_strict_mode_tests_testns()
 {
+	log_section "VRF strict_mode test on testns network namespace"
+
 	vrf_strict_mode_check_support testns
 
 	strict_mode_check_default testns
@@ -318,6 +324,8 @@ vrf_strict_mode_tests_testns()
 
 vrf_strict_mode_tests_mix()
 {
+	log_section "VRF strict_mode test mixing init and testns network namespaces"
+
 	read_strict_mode_compare_and_check init 1
 
 	read_strict_mode_compare_and_check testns 0
@@ -343,16 +351,37 @@ vrf_strict_mode_tests_mix()
 
 vrf_strict_mode_tests()
 {
-	log_section "VRF strict_mode test on init network namespace"
 	vrf_strict_mode_tests_init
 
-	log_section "VRF strict_mode test on testns network namespace"
 	vrf_strict_mode_tests_testns
 
-	log_section "VRF strict_mode test mixing init and testns network namespaces"
 	vrf_strict_mode_tests_mix
 }
 
+################################################################################
+# usage
+
+usage()
+{
+	cat <<EOF
+usage: ${0##*/} OPTS
+
+	-t <test>	Test(s) to run (default: all)
+			(options: $TESTS)
+EOF
+}
+
+################################################################################
+# main
+
+while getopts ":t:h" opt; do
+	case $opt in
+		t) TESTS=$OPTARG;;
+		h) usage; exit 0;;
+		*) usage; exit 1;;
+	esac
+done
+
 vrf_strict_mode_check_support()
 {
 	local nsname=$1
@@ -391,7 +420,17 @@ fi
 cleanup &> /dev/null
 
 setup
-vrf_strict_mode_tests
+for t in $TESTS
+do
+	case $t in
+	vrf_strict_mode_tests_init|init) vrf_strict_mode_tests_init;;
+	vrf_strict_mode_tests_testns|testns) vrf_strict_mode_tests_testns;;
+	vrf_strict_mode_tests_mix|mix) vrf_strict_mode_tests_mix;;
+
+	help) echo "Test names: $TESTS"; exit 0;;
+
+	esac
+done
 cleanup
 
 print_log_test_results
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next v3] selftests: net: vrf_strict_mode_test: add support to select a test to run
  2022-04-28 16:48 [PATCH net-next v3] selftests: net: vrf_strict_mode_test: add support to select a test to run Jaehee Park
@ 2022-04-28 23:02 ` Roopa Prabhu
  2022-04-29 13:34   ` Jaehee Park
  0 siblings, 1 reply; 3+ messages in thread
From: Roopa Prabhu @ 2022-04-28 23:02 UTC (permalink / raw)
  To: Jaehee Park, outreachy, Julia Denham, Roopa Prabhu,
	Stefano Brivio, netdev, David Ahern


On 4/28/22 09:48, Jaehee Park wrote:
> Add a boilerplate test loop to run all tests in
> vrf_strict_mode_test.sh. Add a -t flag that allows a selected test to
> run.
>
> Signed-off-by: Jaehee Park <jhpark1013@gmail.com>
> ---
> version 3:
> - Added commented delineators to section the code for improved
> readability.
> - Moved the log_section() call into the functions handling the tests.
> - Removed unnecessary spaces.
>
>
>   .../selftests/net/vrf_strict_mode_test.sh     | 47 +++++++++++++++++--
>   1 file changed, 43 insertions(+), 4 deletions(-)
>
> diff --git a/tools/testing/selftests/net/vrf_strict_mode_test.sh b/tools/testing/selftests/net/vrf_strict_mode_test.sh
> index 865d53c1781c..423da8e08510 100755
> --- a/tools/testing/selftests/net/vrf_strict_mode_test.sh
> +++ b/tools/testing/selftests/net/vrf_strict_mode_test.sh
> @@ -14,6 +14,8 @@ INIT_NETNS_NAME="init"
>   
>   PAUSE_ON_FAIL=${PAUSE_ON_FAIL:=no}
>   
> +TESTS="init testns mix"
> +
>   log_test()
>   {
>   	local rc=$1
> @@ -262,6 +264,8 @@ cleanup()
>   
>   vrf_strict_mode_tests_init()
>   {
> +	log_section "VRF strict_mode test on init network namespace"
> +
>   	vrf_strict_mode_check_support init
>   
>   	strict_mode_check_default init
> @@ -292,6 +296,8 @@ vrf_strict_mode_tests_init()
>   
>   vrf_strict_mode_tests_testns()
>   {
> +	log_section "VRF strict_mode test on testns network namespace"
> +
>   	vrf_strict_mode_check_support testns
>   
>   	strict_mode_check_default testns
> @@ -318,6 +324,8 @@ vrf_strict_mode_tests_testns()
>   
>   vrf_strict_mode_tests_mix()
>   {
> +	log_section "VRF strict_mode test mixing init and testns network namespaces"
> +
>   	read_strict_mode_compare_and_check init 1
>   
>   	read_strict_mode_compare_and_check testns 0
> @@ -343,16 +351,37 @@ vrf_strict_mode_tests_mix()
>   
>   vrf_strict_mode_tests()

this func is no longer used correct ?, you can remove the function (that 
was one of the comment from david too IIRC)


>   {
> -	log_section "VRF strict_mode test on init network namespace"
>   	vrf_strict_mode_tests_init
>   
> -	log_section "VRF strict_mode test on testns network namespace"
>   	vrf_strict_mode_tests_testns
>   
> -	log_section "VRF strict_mode test mixing init and testns network namespaces"
>   	vrf_strict_mode_tests_mix
>   }
>   
> +################################################################################
> +# usage
> +
> +usage()
> +{
> +	cat <<EOF
> +usage: ${0##*/} OPTS
> +
> +	-t <test>	Test(s) to run (default: all)
> +			(options: $TESTS)
> +EOF
> +}
> +
> +################################################################################
> +# main
> +
> +while getopts ":t:h" opt; do
> +	case $opt in
> +		t) TESTS=$OPTARG;;
> +		h) usage; exit 0;;
> +		*) usage; exit 1;;
> +	esac
> +done
> +
>   vrf_strict_mode_check_support()
>   {
>   	local nsname=$1
> @@ -391,7 +420,17 @@ fi
>   cleanup &> /dev/null
>   
>   setup
> -vrf_strict_mode_tests
> +for t in $TESTS
> +do
> +	case $t in
> +	vrf_strict_mode_tests_init|init) vrf_strict_mode_tests_init;;
> +	vrf_strict_mode_tests_testns|testns) vrf_strict_mode_tests_testns;;
> +	vrf_strict_mode_tests_mix|mix) vrf_strict_mode_tests_mix;;
> +
> +	help) echo "Test names: $TESTS"; exit 0;;
> +
> +	esac
> +done
>   cleanup
>   
>   print_log_test_results

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next v3] selftests: net: vrf_strict_mode_test: add support to select a test to run
  2022-04-28 23:02 ` Roopa Prabhu
@ 2022-04-29 13:34   ` Jaehee Park
  0 siblings, 0 replies; 3+ messages in thread
From: Jaehee Park @ 2022-04-29 13:34 UTC (permalink / raw)
  To: Roopa Prabhu
  Cc: outreachy, Julia Denham, Roopa Prabhu, Stefano Brivio, netdev,
	David Ahern

On Thu, Apr 28, 2022 at 04:02:51PM -0700, Roopa Prabhu wrote:
> 
> On 4/28/22 09:48, Jaehee Park wrote:
> > Add a boilerplate test loop to run all tests in
> > vrf_strict_mode_test.sh. Add a -t flag that allows a selected test to
> > run.
> > 
> > Signed-off-by: Jaehee Park <jhpark1013@gmail.com>
> > ---
> > version 3:
> > - Added commented delineators to section the code for improved
> > readability.
> > - Moved the log_section() call into the functions handling the tests.
> > - Removed unnecessary spaces.
> > 
> > 
> >   .../selftests/net/vrf_strict_mode_test.sh     | 47 +++++++++++++++++--
> >   1 file changed, 43 insertions(+), 4 deletions(-)
> > 
> > diff --git a/tools/testing/selftests/net/vrf_strict_mode_test.sh b/tools/testing/selftests/net/vrf_strict_mode_test.sh
> > index 865d53c1781c..423da8e08510 100755
> > --- a/tools/testing/selftests/net/vrf_strict_mode_test.sh
> > +++ b/tools/testing/selftests/net/vrf_strict_mode_test.sh
> > @@ -14,6 +14,8 @@ INIT_NETNS_NAME="init"
> >   PAUSE_ON_FAIL=${PAUSE_ON_FAIL:=no}
> > +TESTS="init testns mix"
> > +
> >   log_test()
> >   {
> >   	local rc=$1
> > @@ -262,6 +264,8 @@ cleanup()
> >   vrf_strict_mode_tests_init()
> >   {
> > +	log_section "VRF strict_mode test on init network namespace"
> > +
> >   	vrf_strict_mode_check_support init
> >   	strict_mode_check_default init
> > @@ -292,6 +296,8 @@ vrf_strict_mode_tests_init()
> >   vrf_strict_mode_tests_testns()
> >   {
> > +	log_section "VRF strict_mode test on testns network namespace"
> > +
> >   	vrf_strict_mode_check_support testns
> >   	strict_mode_check_default testns
> > @@ -318,6 +324,8 @@ vrf_strict_mode_tests_testns()
> >   vrf_strict_mode_tests_mix()
> >   {
> > +	log_section "VRF strict_mode test mixing init and testns network namespaces"
> > +
> >   	read_strict_mode_compare_and_check init 1
> >   	read_strict_mode_compare_and_check testns 0
> > @@ -343,16 +351,37 @@ vrf_strict_mode_tests_mix()
> >   vrf_strict_mode_tests()
> 
> this func is no longer used correct ?, you can remove the function (that was
> one of the comment from david too IIRC)
> 

Yes! thank you for catching this -- the vrf_Strict_mode_tests is unused 
so we can remove this function. I will make that change and send in 
patch v4 soon. 

> 
> >   {
> > -	log_section "VRF strict_mode test on init network namespace"
> >   	vrf_strict_mode_tests_init
> > -	log_section "VRF strict_mode test on testns network namespace"
> >   	vrf_strict_mode_tests_testns
> > -	log_section "VRF strict_mode test mixing init and testns network namespaces"
> >   	vrf_strict_mode_tests_mix
> >   }
> > +################################################################################
> > +# usage
> > +
> > +usage()
> > +{
> > +	cat <<EOF
> > +usage: ${0##*/} OPTS
> > +
> > +	-t <test>	Test(s) to run (default: all)
> > +			(options: $TESTS)
> > +EOF
> > +}
> > +
> > +################################################################################
> > +# main
> > +
> > +while getopts ":t:h" opt; do
> > +	case $opt in
> > +		t) TESTS=$OPTARG;;
> > +		h) usage; exit 0;;
> > +		*) usage; exit 1;;
> > +	esac
> > +done
> > +
> >   vrf_strict_mode_check_support()
> >   {
> >   	local nsname=$1
> > @@ -391,7 +420,17 @@ fi
> >   cleanup &> /dev/null
> >   setup
> > -vrf_strict_mode_tests
> > +for t in $TESTS
> > +do
> > +	case $t in
> > +	vrf_strict_mode_tests_init|init) vrf_strict_mode_tests_init;;
> > +	vrf_strict_mode_tests_testns|testns) vrf_strict_mode_tests_testns;;
> > +	vrf_strict_mode_tests_mix|mix) vrf_strict_mode_tests_mix;;
> > +
> > +	help) echo "Test names: $TESTS"; exit 0;;
> > +
> > +	esac
> > +done
> >   cleanup
> >   print_log_test_results

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-04-29 13:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-28 16:48 [PATCH net-next v3] selftests: net: vrf_strict_mode_test: add support to select a test to run Jaehee Park
2022-04-28 23:02 ` Roopa Prabhu
2022-04-29 13:34   ` Jaehee Park

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).