[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20190814074704.GA2580@nanopsycho.mediaserver.passengera.com>
Date: Wed, 14 Aug 2019 09:47:04 +0200
From: Jiri Pirko <jiri@...nulli.us>
To: Jakub Kicinski <jakub.kicinski@...ronome.com>
Cc: netdev@...r.kernel.org, davem@...emloft.net, mlxsw@...lanox.com
Subject: Re: [patch net-next] selftests: netdevsim: add devlink params tests
Wed, Aug 14, 2019 at 12:41:08AM CEST, jakub.kicinski@...ronome.com wrote:
>On Tue, 13 Aug 2019 15:04:46 +0200, Jiri Pirko wrote:
>> From: Jiri Pirko <jiri@...lanox.com>
>>
>> Test recently added netdevsim devlink param implementation.
>>
>> Signed-off-by: Jiri Pirko <jiri@...lanox.com>
>
>Thanks for the test, but it doesn't pass here:
>
>TEST: fw flash test [ OK ]
>TEST: params test [FAIL]
> Failed to get test1 param value
Interesting. Fors for me correctly. When I run it manually, I get this:
bash-5.0# devlink dev param show netdevsim/netdevsim11 name test1 -j | jq -e -r '.[][][].values[] | select(.cmode == "driverinit").value'
true
bash-5.0# echo $?
0
bash-5.0# devlink dev param set netdevsim/netdevsim11 name test1 cmode driverinit value false
bash-5.0# devlink dev param show netdevsim/netdevsim11 name test1 -j | jq -e -r '.[][][].values[] | select(.cmode == "driverinit").value'
false
bash-5.0# echo $?
0
>
>> diff --git a/tools/testing/selftests/drivers/net/netdevsim/devlink.sh b/tools/testing/selftests/drivers/net/netdevsim/devlink.sh
>> index 9d8baf5d14b3..858ebdc8d8a3 100755
>> --- a/tools/testing/selftests/drivers/net/netdevsim/devlink.sh
>> +++ b/tools/testing/selftests/drivers/net/netdevsim/devlink.sh
>> @@ -3,7 +3,7 @@
>>
>> lib_dir=$(dirname $0)/../../../net/forwarding
>>
>> -ALL_TESTS="fw_flash_test"
>> +ALL_TESTS="fw_flash_test params_test"
>> NUM_NETIFS=0
>> source $lib_dir/lib.sh
>>
>> @@ -30,6 +30,66 @@ fw_flash_test()
>> log_test "fw flash test"
>> }
>>
>> +param_get()
>> +{
>> + local name=$1
>> +
>> + devlink dev param show $DL_HANDLE name $name -j | \
>> + jq -e -r '.[][][].values[] | select(.cmode == "driverinit").value'
>
> ^^
>
>The -e makes jq set exit code to 1 when test1 param is false.
>
>Quoting the man page:
>
> ยท -e / --exit-status:
>
> Sets the exit status of jq to 0 if the last output values
> was neither false nor null, 1 if the last output value was
> either false or null, or 4 if no valid result was
> ever produced. Normally jq exits with 2 if there was any
> usage problem or system error, 3 if there was a jq program
> compile error, or 0 if the jq program ran.
>
>Without the -e all is well:
Not really, for non-existent param the return value would be wrong:
bash-5.0# devlink dev param show netdevsim/netdevsim11 name test2 -j | jq -e -r '.[][][].values[] | select(.cmode == "driverinit").value'
devlink answers: Invalid argument
bash-5.0# echo $?
4
bash-5.0# devlink dev param show netdevsim/netdevsim11 name test2 -j | jq -r '.[][][].values[] | select(.cmode == "driverinit").value'
devlink answers: Invalid argument
bash-5.0# echo $?
0
The return value is 0 like everyone is fine. You probably have a
different jq version (1.6). Looks like I need to use the same
workaround I have in tools/testing/selftests/net/forwarding/tc_common.sh.
I thought that -e would avoid that.
>
># ./devlink.sh
>TEST: fw flash test [ OK ]
>TEST: params test [ OK ]
>
>> +}
>> +
Powered by blists - more mailing lists