Skip to content

Commit 9ffa01c

Browse files
tammeladavem330
authored andcommitted
selftests: tc-testing: drop '-N' argument from nsPlugin
This argument would bypass the net namespace creation and run the test in the root namespace, even if nsPlugin was specified. Drop it as it's the same as commenting out the nsPlugin from a test and adds additional complexity to the plugin code. Signed-off-by: Pedro Tammela <pctammela@mojatatu.com> Reviewed-by: Simon Horman <horms@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 0fbe92b commit 9ffa01c

File tree

1 file changed

+13
-36
lines changed
  • tools/testing/selftests/tc-testing/plugin-lib

1 file changed

+13
-36
lines changed

tools/testing/selftests/tc-testing/plugin-lib/nsPlugin.py

Lines changed: 13 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,7 @@ def prepare_suite(obj, test):
2828
shadow['DEV2'] = original['DEV2']
2929
obj.args.NAMES = shadow
3030

31-
if obj.args.namespace:
32-
obj._ns_create()
33-
else:
34-
obj._ports_create()
31+
obj._ns_create()
3532

3633
# Make sure the netns is visible in the fs
3734
while True:
@@ -75,10 +72,7 @@ def post_case(self):
7572
if self.args.verbose:
7673
print('{}.post_case'.format(self.sub_class))
7774

78-
if self.args.namespace:
79-
self._ns_destroy()
80-
else:
81-
self._ports_destroy()
75+
self._ns_destroy()
8276

8377
def post_suite(self, index):
8478
if self.args.verbose:
@@ -93,24 +87,11 @@ def post_suite(self, index):
9387

9488
subprocess.run(cmd, shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
9589

96-
def add_args(self, parser):
97-
super().add_args(parser)
98-
self.argparser_group = self.argparser.add_argument_group(
99-
'netns',
100-
'options for nsPlugin(run commands in net namespace)')
101-
self.argparser_group.add_argument(
102-
'-N', '--no-namespace', action='store_false', default=True,
103-
dest='namespace', help='Don\'t run commands in namespace')
104-
return self.argparser
105-
10690
def adjust_command(self, stage, command):
10791
super().adjust_command(stage, command)
10892
cmdform = 'list'
10993
cmdlist = list()
11094

111-
if not self.args.namespace:
112-
return command
113-
11495
if self.args.verbose:
11596
print('{}.adjust_command'.format(self.sub_class))
11697

@@ -144,8 +125,6 @@ def _ports_create_cmds(self):
144125
cmds.append(self._replace_keywords('link add $DEV0 type veth peer name $DEV1'))
145126
cmds.append(self._replace_keywords('link set $DEV0 up'))
146127
cmds.append(self._replace_keywords('link add $DUMMY type dummy'))
147-
if not self.args.namespace:
148-
cmds.append(self._replace_keywords('link set $DEV1 up'))
149128

150129
return cmds
151130

@@ -161,18 +140,17 @@ def _ports_destroy(self):
161140
def _ns_create_cmds(self):
162141
cmds = []
163142

164-
if self.args.namespace:
165-
ns = self.args.NAMES['NS']
143+
ns = self.args.NAMES['NS']
166144

167-
cmds.append(self._replace_keywords('netns add {}'.format(ns)))
168-
cmds.append(self._replace_keywords('link set $DEV1 netns {}'.format(ns)))
169-
cmds.append(self._replace_keywords('link set $DUMMY netns {}'.format(ns)))
170-
cmds.append(self._replace_keywords('netns exec {} $IP link set $DEV1 up'.format(ns)))
171-
cmds.append(self._replace_keywords('netns exec {} $IP link set $DUMMY up'.format(ns)))
145+
cmds.append(self._replace_keywords('netns add {}'.format(ns)))
146+
cmds.append(self._replace_keywords('link set $DEV1 netns {}'.format(ns)))
147+
cmds.append(self._replace_keywords('link set $DUMMY netns {}'.format(ns)))
148+
cmds.append(self._replace_keywords('netns exec {} $IP link set $DEV1 up'.format(ns)))
149+
cmds.append(self._replace_keywords('netns exec {} $IP link set $DUMMY up'.format(ns)))
172150

173-
if self.args.device:
174-
cmds.append(self._replace_keywords('link set $DEV2 netns {}'.format(ns)))
175-
cmds.append(self._replace_keywords('netns exec {} $IP link set $DEV2 up'.format(ns)))
151+
if self.args.device:
152+
cmds.append(self._replace_keywords('link set $DEV2 netns {}'.format(ns)))
153+
cmds.append(self._replace_keywords('netns exec {} $IP link set $DEV2 up'.format(ns)))
176154

177155
return cmds
178156

@@ -192,9 +170,8 @@ def _ns_destroy(self):
192170
Destroy the network namespace for testing (and any associated network
193171
devices as well)
194172
'''
195-
if self.args.namespace:
196-
self._exec_cmd('post', self._ns_destroy_cmd())
197-
self._ports_destroy()
173+
self._exec_cmd('post', self._ns_destroy_cmd())
174+
self._ports_destroy()
198175

199176
@cached_property
200177
def _proc(self):

0 commit comments

Comments
 (0)