diff mbox series

[net-next,1/3] selftests: mptcp: fix a mp_fail test warning

Message ID 20220514002115.725976-2-mathew.j.martineau@linux.intel.com (mailing list archive)
State Accepted
Commit c43ce39870b3cff3cefb1faf78c577153edc2dde
Delegated to: Netdev Maintainers
Headers show
Series mptcp: Updates for net-next | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Series has a cover letter
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers warning 2 maintainers not CCed: linux-kselftest@vger.kernel.org shuah@kernel.org
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 7 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Mat Martineau May 14, 2022, 12:21 a.m. UTC
From: Geliang Tang <geliang.tang@suse.com>

Old tc versions (iproute2 5.3) show actions in multiple lines, not a
single line. Then the following unexpected MP_FAIL selftest output
occurs:

 file received by server has inverted byte at 169
 ./mptcp_join.sh: line 1277: [: [{"total acts":1},{"actions":[{"order":0 pedit ,"control_action":{"type":"pipe"}keys 1
         index 1 ref 1 bind 1,"installed":0,"last_used":0
         key #0  at 148: val ff000000 mask ffffffff
 5: integer expression expected
 001 Infinite map                      syn[ ok ] - synack[ ok ] - ack[ ok ]
                                       sum[ ok ] - csum  [ ok ]
                                       ftx[ ok ] - failrx[ ok ]
                                       rtx[ ok ] - rstrx [ ok ]
                                       itx[ ok ] - infirx[ ok ]
                                       ftx[ ok ] - failrx[ ok ] invert

This patch adds a 'grep' before 'sed' to fix this.

Fixes: b6e074e171bc ("selftests: mptcp: add infinite map testcase")
Reviewed-by: Matthieu Baerts <matthieu.baerts@tessares.net>
Signed-off-by: Geliang Tang <geliang.tang@suse.com>
Signed-off-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
---
 tools/testing/selftests/net/mptcp/mptcp_join.sh | 1 +
 1 file changed, 1 insertion(+)

Comments

Jakub Kicinski May 16, 2022, 8:13 p.m. UTC | #1
On Fri, 13 May 2022 17:21:13 -0700 Mat Martineau wrote:
>  	tc -n $ns2 -j -s action show action pedit index 100 | \
> +		grep "packets" | \
>  		sed 's/.*"packets":\([0-9]\+\),.*/\1/'

sed can do the grepping for you:

sed -n 's/.*"packets":\([0-9]\+\),.*/\1/p'

But really grepping JSON output seems weird. Why not use jq?
Matthieu Baerts May 17, 2022, 7:01 a.m. UTC | #2
Hi Jakub,

Thank you for the review and for having applied the patches!

On 16/05/2022 22:13, Jakub Kicinski wrote:
> On Fri, 13 May 2022 17:21:13 -0700 Mat Martineau wrote:
>>  	tc -n $ns2 -j -s action show action pedit index 100 | \
>> +		grep "packets" | \
>>  		sed 's/.*"packets":\([0-9]\+\),.*/\1/'
> 
> sed can do the grepping for you:
> 
> sed -n 's/.*"packets":\([0-9]\+\),.*/\1/p'

Yes, thank you, that would have been shorter!

> But really grepping JSON output seems weird. Why not use jq?

We started to use 'jq' because we originally had to extract a few values
from this command. At the end, we only needed to extract the number of
packets and we didn't want all MPTCP tests to depend on 'jq' just for that.

But because 'jq' is already needed for a few other selftests, next time
we need to parse a JSON, we should use 'jq'!

Cheers,
Matt
diff mbox series

Patch

diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh
index d1de1e7702fb..7381d1f85209 100755
--- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh
@@ -2693,6 +2693,7 @@  fastclose_tests()
 pedit_action_pkts()
 {
 	tc -n $ns2 -j -s action show action pedit index 100 | \
+		grep "packets" | \
 		sed 's/.*"packets":\([0-9]\+\),.*/\1/'
 }