netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 1/1] tc-testing: Correct compound statements for namespace execution
@ 2018-03-21 15:49 Lucas Bates
  2018-03-22 18:48 ` David Miller
  0 siblings, 1 reply; 6+ messages in thread
From: Lucas Bates @ 2018-03-21 15:49 UTC (permalink / raw)
  To: davem; +Cc: netdev, kernel, jhs, xiyou.wangcong, jiri, Lucas Bates

If tdc is executing test cases inside a namespace, only the
first command in a compound statement will be executed inside
the namespace by tdc. As a result, the subsequent commands
are not executed inside the namespace and the test will fail.

Example:

for i in {x..y}; do args="foo"; done && tc actions add $args

The namespace execution feature will prepend 'ip netns exec'
to the command:

ip netns exec tcut for i in {x..y}; do args="foo"; done && \
  tc actions add $args

So the actual tc command is not parsed by the shell as being
part of the namespace execution.

Enclosing these compound statements inside a bash invocation
with proper escape characters resolves the problem by creating
a subshell inside the namespace.

Signed-off-by: Lucas Bates <lucasb@mojatatu.com>
---
 tools/testing/selftests/tc-testing/tc-tests/actions/gact.json | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/tools/testing/selftests/tc-testing/tc-tests/actions/gact.json b/tools/testing/selftests/tc-testing/tc-tests/actions/gact.json
index ae96d03..68c9102 100644
--- a/tools/testing/selftests/tc-testing/tc-tests/actions/gact.json
+++ b/tools/testing/selftests/tc-testing/tc-tests/actions/gact.json
@@ -481,7 +481,7 @@
                 255
             ]
         ],
-        "cmdUnderTest": "for i in `seq 1 32`; do cmd=\"action pass index $i \"; args=\"$args$cmd\"; done && $TC actions add $args",
+        "cmdUnderTest": "bash -c \"for i in \\`seq 1 32\\`; do cmd=\\\"action pass index \\$i \\\"; args=\"\\$args\\$cmd\"; done && $TC actions add \\$args\"",
         "expExitCode": "0",
         "verifyCmd": "$TC actions list action gact",
         "matchPattern": "^[ \t]+index [0-9]+ ref",
@@ -505,7 +505,7 @@
                 255
             ]
         ],
-        "cmdUnderTest": "for i in `seq 1 32`; do cmd=\"action continue index $i cookie aabbccddeeff112233445566778800a1 \"; args=\"$args$cmd\"; done && $TC actions add $args",
+        "cmdUnderTest": "bash -c \"for i in \\`seq 1 32\\`; do cmd=\\\"action continue index \\$i cookie aabbccddeeff112233445566778800a1 \\\"; args=\"\\$args\\$cmd\"; done && $TC actions add \\$args\"",
         "expExitCode": "0",
         "verifyCmd": "$TC actions list action gact",
         "matchPattern": "^[ \t]+index [0-9]+ ref",
@@ -528,13 +528,13 @@
                 1,
                 255
             ],
-            "for i in `seq 1 32`; do cmd=\"action continue index $i \"; args=\"$args$cmd\"; done && $TC actions add $args"
+            "bash -c \"for i in \\`seq 1 32\\`; do cmd=\\\"action continue index \\$i \\\"; args=\\\"\\$args\\$cmd\\\"; done && $TC actions add \\$args\""
         ],
-        "cmdUnderTest": "for i in `seq 1 32`; do cmd=\"action gact index $i \"; args=\"$args$cmd\"; done && $TC actions del $args",
+        "cmdUnderTest": "bash -c \"for i in \\`seq 1 32\\`; do cmd=\\\"action gact index \\$i \\\"; args=\"\\$args\\$cmd\"; done && $TC actions del \\$args\"",
         "expExitCode": "0",
         "verifyCmd": "$TC actions list action gact",
         "matchPattern": "^[ \t]+index [0-9]+ ref",
         "matchCount": "0",
         "teardown": []
     }
-]
\ No newline at end of file
+]
--
2.7.4

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

* Re: [PATCH net-next 1/1] tc-testing: Correct compound statements for namespace execution
  2018-03-21 15:49 [PATCH net-next 1/1] tc-testing: Correct compound statements for namespace execution Lucas Bates
@ 2018-03-22 18:48 ` David Miller
  2018-03-22 19:14   ` Lucas Bates
  0 siblings, 1 reply; 6+ messages in thread
From: David Miller @ 2018-03-22 18:48 UTC (permalink / raw)
  To: lucasb; +Cc: netdev, kernel, jhs, xiyou.wangcong, jiri

From: Lucas Bates <lucasb@mojatatu.com>
Date: Wed, 21 Mar 2018 11:49:40 -0400

>      }
> -]
> \ No newline at end of file
> +]
> --
> 2.7.4

Please fix this.

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

* Re: [PATCH net-next 1/1] tc-testing: Correct compound statements for namespace execution
  2018-03-22 18:48 ` David Miller
@ 2018-03-22 19:14   ` Lucas Bates
  2018-03-25 21:08     ` David Miller
  0 siblings, 1 reply; 6+ messages in thread
From: Lucas Bates @ 2018-03-22 19:14 UTC (permalink / raw)
  To: David Miller
  Cc: Linux Kernel Network Developers, kernel, Jamal Hadi Salim,
	Cong Wang, Jiri Pirko

On Thu, Mar 22, 2018 at 2:48 PM, David Miller <davem@davemloft.net> wrote:
> From: Lucas Bates <lucasb@mojatatu.com>
> Date: Wed, 21 Mar 2018 11:49:40 -0400
>
>>      }
>> -]
>> \ No newline at end of file
>> +]
>> --
>> 2.7.4
>
> Please fix this.

This patch fixes the gact.json file that had no newline on the end.

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

* Re: [PATCH net-next 1/1] tc-testing: Correct compound statements for namespace execution
  2018-03-22 19:14   ` Lucas Bates
@ 2018-03-25 21:08     ` David Miller
  0 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2018-03-25 21:08 UTC (permalink / raw)
  To: lucasb; +Cc: netdev, kernel, jhs, xiyou.wangcong, jiri

From: Lucas Bates <lucasb@mojatatu.com>
Date: Thu, 22 Mar 2018 15:14:58 -0400

> On Thu, Mar 22, 2018 at 2:48 PM, David Miller <davem@davemloft.net> wrote:
>> From: Lucas Bates <lucasb@mojatatu.com>
>> Date: Wed, 21 Mar 2018 11:49:40 -0400
>>
>>>      }
>>> -]
>>> \ No newline at end of file
>>> +]
>>> --
>>> 2.7.4
>>
>> Please fix this.
> 
> This patch fixes the gact.json file that had no newline on the end.

Sorry about that, please repost.

Thank you.

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

* Re: [PATCH net-next 1/1] tc-testing: Correct compound statements for namespace execution
  2018-03-26 14:46 Lucas Bates
@ 2018-03-27 14:52 ` David Miller
  0 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2018-03-27 14:52 UTC (permalink / raw)
  To: lucasb; +Cc: netdev, kernel, jhs, xiyou.wangcong, jiri

From: Lucas Bates <lucasb@mojatatu.com>
Date: Mon, 26 Mar 2018 10:46:14 -0400

> If tdc is executing test cases inside a namespace, only the
> first command in a compound statement will be executed inside
> the namespace by tdc. As a result, the subsequent commands
> are not executed inside the namespace and the test will fail.
> 
> Example:
> 
> for i in {x..y}; do args="foo"; done && tc actions add $args
> 
> The namespace execution feature will prepend 'ip netns exec'
> to the command:
> 
> ip netns exec tcut for i in {x..y}; do args="foo"; done && \
>   tc actions add $args
> 
> So the actual tc command is not parsed by the shell as being
> part of the namespace execution.
> 
> Enclosing these compound statements inside a bash invocation
> with proper escape characters resolves the problem by creating
> a subshell inside the namespace.
> 
> Signed-off-by: Lucas Bates <lucasb@mojatatu.com>

Applied, thank you.

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

* [PATCH net-next 1/1] tc-testing: Correct compound statements for namespace execution
@ 2018-03-26 14:46 Lucas Bates
  2018-03-27 14:52 ` David Miller
  0 siblings, 1 reply; 6+ messages in thread
From: Lucas Bates @ 2018-03-26 14:46 UTC (permalink / raw)
  To: davem; +Cc: netdev, kernel, jhs, xiyou.wangcong, jiri, Lucas Bates

If tdc is executing test cases inside a namespace, only the
first command in a compound statement will be executed inside
the namespace by tdc. As a result, the subsequent commands
are not executed inside the namespace and the test will fail.

Example:

for i in {x..y}; do args="foo"; done && tc actions add $args

The namespace execution feature will prepend 'ip netns exec'
to the command:

ip netns exec tcut for i in {x..y}; do args="foo"; done && \
  tc actions add $args

So the actual tc command is not parsed by the shell as being
part of the namespace execution.

Enclosing these compound statements inside a bash invocation
with proper escape characters resolves the problem by creating
a subshell inside the namespace.

Signed-off-by: Lucas Bates <lucasb@mojatatu.com>
---
 tools/testing/selftests/tc-testing/tc-tests/actions/gact.json | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/tools/testing/selftests/tc-testing/tc-tests/actions/gact.json b/tools/testing/selftests/tc-testing/tc-tests/actions/gact.json
index ae96d03..68c9102 100644
--- a/tools/testing/selftests/tc-testing/tc-tests/actions/gact.json
+++ b/tools/testing/selftests/tc-testing/tc-tests/actions/gact.json
@@ -481,7 +481,7 @@
                 255
             ]
         ],
-        "cmdUnderTest": "for i in `seq 1 32`; do cmd=\"action pass index $i \"; args=\"$args$cmd\"; done && $TC actions add $args",
+        "cmdUnderTest": "bash -c \"for i in \\`seq 1 32\\`; do cmd=\\\"action pass index \\$i \\\"; args=\"\\$args\\$cmd\"; done && $TC actions add \\$args\"",
         "expExitCode": "0",
         "verifyCmd": "$TC actions list action gact",
         "matchPattern": "^[ \t]+index [0-9]+ ref",
@@ -505,7 +505,7 @@
                 255
             ]
         ],
-        "cmdUnderTest": "for i in `seq 1 32`; do cmd=\"action continue index $i cookie aabbccddeeff112233445566778800a1 \"; args=\"$args$cmd\"; done && $TC actions add $args",
+        "cmdUnderTest": "bash -c \"for i in \\`seq 1 32\\`; do cmd=\\\"action continue index \\$i cookie aabbccddeeff112233445566778800a1 \\\"; args=\"\\$args\\$cmd\"; done && $TC actions add \\$args\"",
         "expExitCode": "0",
         "verifyCmd": "$TC actions list action gact",
         "matchPattern": "^[ \t]+index [0-9]+ ref",
@@ -528,13 +528,13 @@
                 1,
                 255
             ],
-            "for i in `seq 1 32`; do cmd=\"action continue index $i \"; args=\"$args$cmd\"; done && $TC actions add $args"
+            "bash -c \"for i in \\`seq 1 32\\`; do cmd=\\\"action continue index \\$i \\\"; args=\\\"\\$args\\$cmd\\\"; done && $TC actions add \\$args\""
         ],
-        "cmdUnderTest": "for i in `seq 1 32`; do cmd=\"action gact index $i \"; args=\"$args$cmd\"; done && $TC actions del $args",
+        "cmdUnderTest": "bash -c \"for i in \\`seq 1 32\\`; do cmd=\\\"action gact index \\$i \\\"; args=\"\\$args\\$cmd\"; done && $TC actions del \\$args\"",
         "expExitCode": "0",
         "verifyCmd": "$TC actions list action gact",
         "matchPattern": "^[ \t]+index [0-9]+ ref",
         "matchCount": "0",
         "teardown": []
     }
-]
\ No newline at end of file
+]

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

end of thread, other threads:[~2018-03-27 14:52 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-21 15:49 [PATCH net-next 1/1] tc-testing: Correct compound statements for namespace execution Lucas Bates
2018-03-22 18:48 ` David Miller
2018-03-22 19:14   ` Lucas Bates
2018-03-25 21:08     ` David Miller
2018-03-26 14:46 Lucas Bates
2018-03-27 14:52 ` David Miller

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).