diff mbox

[PATCHv2] linux-generic: pktio: always test loop interface

Message ID 1440070884-4820-1-git-send-email-stuart.haslam@linaro.org
State Accepted
Commit 850bac214f056a0affe656784ebc2bedfb8f4fbc
Headers show

Commit Message

Stuart Haslam Aug. 20, 2015, 11:41 a.m. UTC
Test using the loop interface even when running as root.

Fixes bug; https://bugs.linaro.org/show_bug.cgi?id=1735

Signed-off-by: Stuart Haslam <stuart.haslam@linaro.org>
---
Change in v2 - updated comment about default interfaces

 platform/linux-generic/test/pktio/pktio_run | 25 ++++++++++++++++---------
 1 file changed, 16 insertions(+), 9 deletions(-)

Comments

Mike Holmes Aug. 20, 2015, 5:09 p.m. UTC | #1
On 20 August 2015 at 07:41, Stuart Haslam <stuart.haslam@linaro.org> wrote:
> Test using the loop interface even when running as root.
>
> Fixes bug; https://bugs.linaro.org/show_bug.cgi?id=1735
>
> Signed-off-by: Stuart Haslam <stuart.haslam@linaro.org>

Reviewed-and-tested-by: Mike Holmes <mike.holmes@linaro.org>

> ---
> Change in v2 - updated comment about default interfaces
>
>  platform/linux-generic/test/pktio/pktio_run | 25 ++++++++++++++++---------
>  1 file changed, 16 insertions(+), 9 deletions(-)
>
> diff --git a/platform/linux-generic/test/pktio/pktio_run b/platform/linux-generic/test/pktio/pktio_run
> index 76a8419..4860455 100755
> --- a/platform/linux-generic/test/pktio/pktio_run
> +++ b/platform/linux-generic/test/pktio/pktio_run
> @@ -46,9 +46,8 @@ run_test()
>  {
>         local ret=0
>
> -       # the linux-generic implementation uses environment variables to
> -       # control which socket method is used, so try each combination to
> -       # ensure decent coverage.
> +       # environment variables are used to control which socket method is
> +       # used, so try each combination to ensure decent coverage.
>         for distype in MMAP MMSG; do
>                 unset ODP_PKTIO_DISABLE_SOCKET_${distype}
>         done
> @@ -67,26 +66,34 @@ run_test()
>                 echo "!!! FAILED !!!"
>         fi
>
> -       exit $ret
> +       return $ret
>  }
>
>  run()
>  {
> -       #need to be root to set the interface: if not, run with default loopback.
> +       echo "pktio: using 'loop' device"
> +       pktio_main${EXEEXT}
> +       loop_ret=$?
> +
> +       # need to be root to run tests with real interfaces
>         if [ "$(id -u)" != "0" ]; then
> -               echo "pktio: using 'loop' device"
> -               pktio_main${EXEEXT}
> -               exit $?
> +               exit $ret
>         fi
>
>         if [ "$ODP_PKTIO_IF0" = "" ]; then
> -               # no interfaces specified on linux-generic, use defaults
> +               # no interfaces specified, use default veth interfaces
> +               # setup by the pktio_env script
>                 setup_pktio_env clean
>                 export ODP_PKTIO_IF0=$IF0
>                 export ODP_PKTIO_IF1=$IF1
>         fi
>
>         run_test
> +       ret=$?
> +
> +       [ $ret = 0 ] && ret=$loop_ret
> +
> +       exit $ret
>  }
>
>  case "$1" in
> --
> 2.1.1
>
> _______________________________________________
> lng-odp mailing list
> lng-odp@lists.linaro.org
> https://lists.linaro.org/mailman/listinfo/lng-odp
Maxim Uvarov Aug. 24, 2015, 9:34 a.m. UTC | #2
Merged,
Maxim.

On 08/20/15 20:09, Mike Holmes wrote:
> On 20 August 2015 at 07:41, Stuart Haslam <stuart.haslam@linaro.org> wrote:
>> Test using the loop interface even when running as root.
>>
>> Fixes bug; https://bugs.linaro.org/show_bug.cgi?id=1735
; -> :
>>
>> Signed-off-by: Stuart Haslam <stuart.haslam@linaro.org>
> Reviewed-and-tested-by: Mike Holmes <mike.holmes@linaro.org>
>
>> ---
>> Change in v2 - updated comment about default interfaces
>>
>>   platform/linux-generic/test/pktio/pktio_run | 25 ++++++++++++++++---------
>>   1 file changed, 16 insertions(+), 9 deletions(-)
>>
>> diff --git a/platform/linux-generic/test/pktio/pktio_run b/platform/linux-generic/test/pktio/pktio_run
>> index 76a8419..4860455 100755
>> --- a/platform/linux-generic/test/pktio/pktio_run
>> +++ b/platform/linux-generic/test/pktio/pktio_run
>> @@ -46,9 +46,8 @@ run_test()
>>   {
>>          local ret=0
>>
>> -       # the linux-generic implementation uses environment variables to
>> -       # control which socket method is used, so try each combination to
>> -       # ensure decent coverage.
>> +       # environment variables are used to control which socket method is
>> +       # used, so try each combination to ensure decent coverage.
>>          for distype in MMAP MMSG; do
>>                  unset ODP_PKTIO_DISABLE_SOCKET_${distype}
>>          done
>> @@ -67,26 +66,34 @@ run_test()
>>                  echo "!!! FAILED !!!"
>>          fi
>>
>> -       exit $ret
>> +       return $ret
>>   }
>>
>>   run()
>>   {
>> -       #need to be root to set the interface: if not, run with default loopback.
>> +       echo "pktio: using 'loop' device"
>> +       pktio_main${EXEEXT}
>> +       loop_ret=$?
>> +
>> +       # need to be root to run tests with real interfaces
>>          if [ "$(id -u)" != "0" ]; then
>> -               echo "pktio: using 'loop' device"
>> -               pktio_main${EXEEXT}
>> -               exit $?
>> +               exit $ret
>>          fi
>>
>>          if [ "$ODP_PKTIO_IF0" = "" ]; then
>> -               # no interfaces specified on linux-generic, use defaults
>> +               # no interfaces specified, use default veth interfaces
>> +               # setup by the pktio_env script
>>                  setup_pktio_env clean
>>                  export ODP_PKTIO_IF0=$IF0
>>                  export ODP_PKTIO_IF1=$IF1
>>          fi
>>
>>          run_test
>> +       ret=$?
>> +
>> +       [ $ret = 0 ] && ret=$loop_ret
>> +
>> +       exit $ret
>>   }
>>
>>   case "$1" in
>> --
>> 2.1.1
>>
>> _______________________________________________
>> lng-odp mailing list
>> lng-odp@lists.linaro.org
>> https://lists.linaro.org/mailman/listinfo/lng-odp
>
>
diff mbox

Patch

diff --git a/platform/linux-generic/test/pktio/pktio_run b/platform/linux-generic/test/pktio/pktio_run
index 76a8419..4860455 100755
--- a/platform/linux-generic/test/pktio/pktio_run
+++ b/platform/linux-generic/test/pktio/pktio_run
@@ -46,9 +46,8 @@  run_test()
 {
 	local ret=0
 
-	# the linux-generic implementation uses environment variables to
-	# control which socket method is used, so try each combination to
-	# ensure decent coverage.
+	# environment variables are used to control which socket method is
+	# used, so try each combination to ensure decent coverage.
 	for distype in MMAP MMSG; do
 		unset ODP_PKTIO_DISABLE_SOCKET_${distype}
 	done
@@ -67,26 +66,34 @@  run_test()
 		echo "!!! FAILED !!!"
 	fi
 
-	exit $ret
+	return $ret
 }
 
 run()
 {
-	#need to be root to set the interface: if not, run with default loopback.
+	echo "pktio: using 'loop' device"
+	pktio_main${EXEEXT}
+	loop_ret=$?
+
+	# need to be root to run tests with real interfaces
 	if [ "$(id -u)" != "0" ]; then
-		echo "pktio: using 'loop' device"
-		pktio_main${EXEEXT}
-		exit $?
+		exit $ret
 	fi
 
 	if [ "$ODP_PKTIO_IF0" = "" ]; then
-		# no interfaces specified on linux-generic, use defaults
+		# no interfaces specified, use default veth interfaces
+		# setup by the pktio_env script
 		setup_pktio_env clean
 		export ODP_PKTIO_IF0=$IF0
 		export ODP_PKTIO_IF1=$IF1
 	fi
 
 	run_test
+	ret=$?
+
+	[ $ret = 0 ] && ret=$loop_ret
+
+	exit $ret
 }
 
 case "$1" in