* [patch net-next v2 0/2] selftests: netdevsim: add devlink paramstests
@ 2019-08-14 15:26 Jiri Pirko
2019-08-14 15:26 ` [patch net-next v2 1/2] selftests: net: push jq workaround into separate helper Jiri Pirko
2019-08-14 15:26 ` [patch net-next v2 2/2] selftests: netdevsim: add devlink params tests Jiri Pirko
0 siblings, 2 replies; 8+ messages in thread
From: Jiri Pirko @ 2019-08-14 15:26 UTC (permalink / raw)
To: netdev; +Cc: davem, jakub.kicinski, mlxsw
From: Jiri Pirko <jiri@mellanox.com>
The first patch is just a helper addition as a dependency of the actual
test in patch number two.
Jiri Pirko (2):
selftests: net: push jq workaround into separate helper
selftests: netdevsim: add devlink params tests
.../drivers/net/netdevsim/devlink.sh | 62 ++++++++++++++++++-
tools/testing/selftests/net/forwarding/lib.sh | 16 +++++
.../selftests/net/forwarding/tc_common.sh | 17 ++---
3 files changed, 81 insertions(+), 14 deletions(-)
--
2.21.0
^ permalink raw reply [flat|nested] 8+ messages in thread
* [patch net-next v2 1/2] selftests: net: push jq workaround into separate helper
2019-08-14 15:26 [patch net-next v2 0/2] selftests: netdevsim: add devlink paramstests Jiri Pirko
@ 2019-08-14 15:26 ` Jiri Pirko
2019-08-14 15:26 ` [patch net-next v2 2/2] selftests: netdevsim: add devlink params tests Jiri Pirko
1 sibling, 0 replies; 8+ messages in thread
From: Jiri Pirko @ 2019-08-14 15:26 UTC (permalink / raw)
To: netdev; +Cc: davem, jakub.kicinski, mlxsw
From: Jiri Pirko <jiri@mellanox.com>
Push the jq return value workaround code into a separate helper so it
could be used by the rest of the code.
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
---
v1->v2:
-new patch
---
tools/testing/selftests/net/forwarding/lib.sh | 16 ++++++++++++++++
.../selftests/net/forwarding/tc_common.sh | 17 ++++-------------
2 files changed, 20 insertions(+), 13 deletions(-)
diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/selftests/net/forwarding/lib.sh
index 9385dc971269..9d78841efef6 100644
--- a/tools/testing/selftests/net/forwarding/lib.sh
+++ b/tools/testing/selftests/net/forwarding/lib.sh
@@ -250,6 +250,22 @@ setup_wait()
sleep $WAIT_TIME
}
+cmd_jq()
+{
+ local cmd=$1
+ local jq_exp=$2
+ local ret
+ local output
+
+ output="$($cmd)"
+ # workaround the jq bug which causes jq to return 0 in case input is ""
+ ret=$?
+ if [[ $ret -ne 0 ]]; then
+ return $ret
+ fi
+ echo $output | jq -r -e "$jq_exp"
+}
+
lldpad_app_wait_set()
{
local dev=$1; shift
diff --git a/tools/testing/selftests/net/forwarding/tc_common.sh b/tools/testing/selftests/net/forwarding/tc_common.sh
index 9d3b64a2a264..315e934358d4 100644
--- a/tools/testing/selftests/net/forwarding/tc_common.sh
+++ b/tools/testing/selftests/net/forwarding/tc_common.sh
@@ -8,18 +8,9 @@ tc_check_packets()
local id=$1
local handle=$2
local count=$3
- local ret
- output="$(tc -j -s filter show $id)"
- # workaround the jq bug which causes jq to return 0 in case input is ""
- ret=$?
- if [[ $ret -ne 0 ]]; then
- return $ret
- fi
- echo $output | \
- jq -e ".[] \
- | select(.options.handle == $handle) \
- | select(.options.actions[0].stats.packets == $count)" \
- &> /dev/null
- return $?
+ cmd_jq "tc -j -s filter show $id" \
+ ".[] | select(.options.handle == $handle) | \
+ select(.options.actions[0].stats.packets == $count)" \
+ &> /dev/null
}
--
2.21.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [patch net-next v2 2/2] selftests: netdevsim: add devlink params tests
2019-08-14 15:26 [patch net-next v2 0/2] selftests: netdevsim: add devlink paramstests Jiri Pirko
2019-08-14 15:26 ` [patch net-next v2 1/2] selftests: net: push jq workaround into separate helper Jiri Pirko
@ 2019-08-14 15:26 ` Jiri Pirko
2019-08-15 1:09 ` Jakub Kicinski
1 sibling, 1 reply; 8+ messages in thread
From: Jiri Pirko @ 2019-08-14 15:26 UTC (permalink / raw)
To: netdev; +Cc: davem, jakub.kicinski, mlxsw
From: Jiri Pirko <jiri@mellanox.com>
Test recently added netdevsim devlink param implementation.
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
---
v1->v2:
-using cmd_jq helper
---
.../drivers/net/netdevsim/devlink.sh | 62 ++++++++++++++++++-
1 file changed, 61 insertions(+), 1 deletion(-)
diff --git a/tools/testing/selftests/drivers/net/netdevsim/devlink.sh b/tools/testing/selftests/drivers/net/netdevsim/devlink.sh
index 9d8baf5d14b3..6828e9404460 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
+
+ cmd_jq "devlink dev param show $DL_HANDLE name $name -j" \
+ '.[][][].values[] | select(.cmode == "driverinit").value'
+}
+
+param_set()
+{
+ local name=$1
+ local value=$2
+
+ devlink dev param set $DL_HANDLE name $name cmode driverinit value $value
+}
+
+check_value()
+{
+ local name=$1
+ local phase_name=$2
+ local expected_param_value=$3
+ local expected_debugfs_value=$4
+ local value
+
+ value=$(param_get $name)
+ check_err $? "Failed to get $name param value"
+ [ "$value" == "$expected_param_value" ]
+ check_err $? "Unexpected $phase_name $name param value"
+ value=$(<$DEBUGFS_DIR/$name)
+ check_err $? "Failed to get $name debugfs value"
+ [ "$value" == "$expected_debugfs_value" ]
+ check_err $? "Unexpected $phase_name $name debugfs value"
+}
+
+params_test()
+{
+ RET=0
+
+ local max_macs
+ local test1
+
+ check_value max_macs initial 32 32
+ check_value test1 initial true Y
+
+ param_set max_macs 16
+ check_err $? "Failed to set max_macs param value"
+ param_set test1 false
+ check_err $? "Failed to set test1 param value"
+
+ check_value max_macs post-set 16 32
+ check_value test1 post-set false Y
+
+ devlink dev reload $DL_HANDLE
+
+ check_value max_macs post-reload 16 16
+ check_value test1 post-reload false N
+
+ log_test "params test"
+}
+
setup_prepare()
{
modprobe netdevsim
--
2.21.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [patch net-next v2 2/2] selftests: netdevsim: add devlink params tests
2019-08-14 15:26 ` [patch net-next v2 2/2] selftests: netdevsim: add devlink params tests Jiri Pirko
@ 2019-08-15 1:09 ` Jakub Kicinski
2019-08-15 5:58 ` Jiri Pirko
2019-08-15 8:45 ` Jiri Pirko
0 siblings, 2 replies; 8+ messages in thread
From: Jakub Kicinski @ 2019-08-15 1:09 UTC (permalink / raw)
To: Jiri Pirko; +Cc: netdev, davem, mlxsw
On Wed, 14 Aug 2019 17:26:04 +0200, Jiri Pirko wrote:
> From: Jiri Pirko <jiri@mellanox.com>
>
> Test recently added netdevsim devlink param implementation.
>
> Signed-off-by: Jiri Pirko <jiri@mellanox.com>
> ---
> v1->v2:
> -using cmd_jq helper
Still failing here :(
# ./devlink.sh
TEST: fw flash test [ OK ]
TEST: params test [FAIL]
Failed to get test1 param value
TEST: regions test [ OK ]
# jq --version
jq-1.5-1-a5b5cbe
# echo '{ "a" : false }' | jq -e -r '.[]'
false
# echo $?
1
On another machine:
$ echo '{ "a" : false }' | jq -e -r '.[]'
false
$ echo $?
1
Did you mean to drop the -e ?
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [patch net-next v2 2/2] selftests: netdevsim: add devlink params tests
2019-08-15 1:09 ` Jakub Kicinski
@ 2019-08-15 5:58 ` Jiri Pirko
2019-08-15 8:45 ` Jiri Pirko
1 sibling, 0 replies; 8+ messages in thread
From: Jiri Pirko @ 2019-08-15 5:58 UTC (permalink / raw)
To: Jakub Kicinski; +Cc: netdev, davem, mlxsw
Thu, Aug 15, 2019 at 03:09:00AM CEST, jakub.kicinski@netronome.com wrote:
>On Wed, 14 Aug 2019 17:26:04 +0200, Jiri Pirko wrote:
>> From: Jiri Pirko <jiri@mellanox.com>
>>
>> Test recently added netdevsim devlink param implementation.
>>
>> Signed-off-by: Jiri Pirko <jiri@mellanox.com>
>> ---
>> v1->v2:
>> -using cmd_jq helper
>
>Still failing here :(
Ugh :/
>
># ./devlink.sh
>TEST: fw flash test [ OK ]
>TEST: params test [FAIL]
> Failed to get test1 param value
>TEST: regions test [ OK ]
>
># jq --version
>jq-1.5-1-a5b5cbe
># echo '{ "a" : false }' | jq -e -r '.[]'
>false
># echo $?
>1
>
>On another machine:
>
>$ echo '{ "a" : false }' | jq -e -r '.[]'
>false
>$ echo $?
>1
>
>Did you mean to drop the -e ?
No. -e is needed in order to jq return error in case there is no output.
Looks like a bug in jq 1.6 fixed. How about I add a check for jq >= 1.6?
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [patch net-next v2 2/2] selftests: netdevsim: add devlink params tests
2019-08-15 1:09 ` Jakub Kicinski
2019-08-15 5:58 ` Jiri Pirko
@ 2019-08-15 8:45 ` Jiri Pirko
2019-08-15 8:52 ` Jiri Pirko
1 sibling, 1 reply; 8+ messages in thread
From: Jiri Pirko @ 2019-08-15 8:45 UTC (permalink / raw)
To: Jakub Kicinski; +Cc: netdev, davem, mlxsw
Thu, Aug 15, 2019 at 03:09:00AM CEST, jakub.kicinski@netronome.com wrote:
>On Wed, 14 Aug 2019 17:26:04 +0200, Jiri Pirko wrote:
>> From: Jiri Pirko <jiri@mellanox.com>
>>
>> Test recently added netdevsim devlink param implementation.
>>
>> Signed-off-by: Jiri Pirko <jiri@mellanox.com>
>> ---
>> v1->v2:
>> -using cmd_jq helper
>
>Still failing here :(
>
># ./devlink.sh
>TEST: fw flash test [ OK ]
>TEST: params test [FAIL]
> Failed to get test1 param value
>TEST: regions test [ OK ]
>
># jq --version
>jq-1.5-1-a5b5cbe
># echo '{ "a" : false }' | jq -e -r '.[]'
>false
># echo $?
>1
Odd, could you please try:
$ jq --version
jq-1.5
$ echo '{"param":{"netdevsim/netdevsim11":[{"name":"test1","type":"driver-specific","values":[{"cmode":"driverinit","value":"false"}]}]}}' | jq -e -r '.[][][].values[] | select(.cmode == "driverinit").value'
false
$ echo $?
0
>
>On another machine:
>
>$ echo '{ "a" : false }' | jq -e -r '.[]'
>false
>$ echo $?
>1
>
>Did you mean to drop the -e ?
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [patch net-next v2 2/2] selftests: netdevsim: add devlink params tests
2019-08-15 8:45 ` Jiri Pirko
@ 2019-08-15 8:52 ` Jiri Pirko
2019-08-15 17:12 ` Jakub Kicinski
0 siblings, 1 reply; 8+ messages in thread
From: Jiri Pirko @ 2019-08-15 8:52 UTC (permalink / raw)
To: Jakub Kicinski; +Cc: netdev, davem, mlxsw
Thu, Aug 15, 2019 at 10:45:45AM CEST, jiri@resnulli.us wrote:
>Thu, Aug 15, 2019 at 03:09:00AM CEST, jakub.kicinski@netronome.com wrote:
>>On Wed, 14 Aug 2019 17:26:04 +0200, Jiri Pirko wrote:
>>> From: Jiri Pirko <jiri@mellanox.com>
>>>
>>> Test recently added netdevsim devlink param implementation.
>>>
>>> Signed-off-by: Jiri Pirko <jiri@mellanox.com>
>>> ---
>>> v1->v2:
>>> -using cmd_jq helper
>>
>>Still failing here :(
>>
>># ./devlink.sh
>>TEST: fw flash test [ OK ]
>>TEST: params test [FAIL]
>> Failed to get test1 param value
>>TEST: regions test [ OK ]
>>
>># jq --version
>>jq-1.5-1-a5b5cbe
>># echo '{ "a" : false }' | jq -e -r '.[]'
>>false
>># echo $?
>>1
>
>Odd, could you please try:
>$ jq --version
>jq-1.5
>$ echo '{"param":{"netdevsim/netdevsim11":[{"name":"test1","type":"driver-specific","values":[{"cmode":"driverinit","value":"false"}]}]}}' | jq -e -r '.[][][].values[] | select(.cmode == "driverinit").value'
>false
>$ echo $?
>0
Ah, it is not the jq version, it is the iproute2 version:
8257e6c49cca9847e01262f6e749c6e88e2ddb72
I'll think about how to fix this.
>
>
>>
>>On another machine:
>>
>>$ echo '{ "a" : false }' | jq -e -r '.[]'
>>false
>>$ echo $?
>>1
>>
>>Did you mean to drop the -e ?
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [patch net-next v2 2/2] selftests: netdevsim: add devlink params tests
2019-08-15 8:52 ` Jiri Pirko
@ 2019-08-15 17:12 ` Jakub Kicinski
0 siblings, 0 replies; 8+ messages in thread
From: Jakub Kicinski @ 2019-08-15 17:12 UTC (permalink / raw)
To: Jiri Pirko; +Cc: netdev, davem, mlxsw
On Thu, 15 Aug 2019 10:52:14 +0200, Jiri Pirko wrote:
> Thu, Aug 15, 2019 at 10:45:45AM CEST, jiri@resnulli.us wrote:
> >Thu, Aug 15, 2019 at 03:09:00AM CEST, jakub.kicinski@netronome.com wrote:
> >>On Wed, 14 Aug 2019 17:26:04 +0200, Jiri Pirko wrote:
> >>> From: Jiri Pirko <jiri@mellanox.com>
> >>>
> >>> Test recently added netdevsim devlink param implementation.
> >>>
> >>> Signed-off-by: Jiri Pirko <jiri@mellanox.com>
> >>> ---
> >>> v1->v2:
> >>> -using cmd_jq helper
> >>
> >>Still failing here :(
> >>
> >># ./devlink.sh
> >>TEST: fw flash test [ OK ]
> >>TEST: params test [FAIL]
> >> Failed to get test1 param value
> >>TEST: regions test [ OK ]
> >>
> >># jq --version
> >>jq-1.5-1-a5b5cbe
> >># echo '{ "a" : false }' | jq -e -r '.[]'
> >>false
> >># echo $?
> >>1
> >
> >Odd, could you please try:
> >$ jq --version
> >jq-1.5
> >$ echo '{"param":{"netdevsim/netdevsim11":[{"name":"test1","type":"driver-specific","values":[{"cmode":"driverinit","value":"false"}]}]}}' | jq -e -r '.[][][].values[] | select(.cmode == "driverinit").value'
> >false
> >$ echo $?
> >0
>
> Ah, it is not the jq version, it is the iproute2 version:
> 8257e6c49cca9847e01262f6e749c6e88e2ddb72
>
> I'll think about how to fix this.
Ah, wow, you're right! Old iproute2 works fine here, too!
> >>
> >>On another machine:
> >>
> >>$ echo '{ "a" : false }' | jq -e -r '.[]'
> >>false
> >>$ echo $?
> >>1
> >>
> >>Did you mean to drop the -e ?
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2019-08-15 17:12 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-14 15:26 [patch net-next v2 0/2] selftests: netdevsim: add devlink paramstests Jiri Pirko
2019-08-14 15:26 ` [patch net-next v2 1/2] selftests: net: push jq workaround into separate helper Jiri Pirko
2019-08-14 15:26 ` [patch net-next v2 2/2] selftests: netdevsim: add devlink params tests Jiri Pirko
2019-08-15 1:09 ` Jakub Kicinski
2019-08-15 5:58 ` Jiri Pirko
2019-08-15 8:45 ` Jiri Pirko
2019-08-15 8:52 ` Jiri Pirko
2019-08-15 17:12 ` Jakub Kicinski
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).