aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests/tc-testing/tdc.py
diff options
context:
space:
mode:
Diffstat (limited to 'tools/testing/selftests/tc-testing/tdc.py')
-rwxr-xr-xtools/testing/selftests/tc-testing/tdc.py45
1 files changed, 1 insertions, 44 deletions
diff --git a/tools/testing/selftests/tc-testing/tdc.py b/tools/testing/selftests/tc-testing/tdc.py
index a718d2b57739..b3754b9aa302 100755
--- a/tools/testing/selftests/tc-testing/tdc.py
+++ b/tools/testing/selftests/tc-testing/tdc.py
@@ -23,8 +23,6 @@ from tdc_helper import *
23 23
24import TdcPlugin 24import TdcPlugin
25 25
26USE_NS = True
27
28class PluginMgr: 26class PluginMgr:
29 def __init__(self, argparser): 27 def __init__(self, argparser):
30 super().__init__() 28 super().__init__()
@@ -107,16 +105,13 @@ def replace_keywords(cmd):
107 return subcmd 105 return subcmd
108 106
109 107
110def exec_cmd(args, pm, stage, command, nsonly=True): 108def exec_cmd(args, pm, stage, command):
111 """ 109 """
112 Perform any required modifications on an executable command, then run 110 Perform any required modifications on an executable command, then run
113 it in a subprocess and return the results. 111 it in a subprocess and return the results.
114 """ 112 """
115 if len(command.strip()) == 0: 113 if len(command.strip()) == 0:
116 return None, None 114 return None, None
117 if (USE_NS and nsonly):
118 command = 'ip netns exec $NS ' + command
119
120 if '$' in command: 115 if '$' in command:
121 command = replace_keywords(command) 116 command = replace_keywords(command)
122 117
@@ -265,39 +260,6 @@ def test_runner(pm, args, filtered_tests):
265 260
266 return tap 261 return tap
267 262
268
269def ns_create(args, pm):
270 """
271 Create the network namespace in which the tests will be run and set up
272 the required network devices for it.
273 """
274 if (USE_NS):
275 cmd = 'ip netns add $NS'
276 exec_cmd(args, pm, 'pre', cmd, False)
277 cmd = 'ip link add $DEV0 type veth peer name $DEV1'
278 exec_cmd(args, pm, 'pre', cmd, False)
279 cmd = 'ip link set $DEV1 netns $NS'
280 exec_cmd(args, pm, 'pre', cmd, False)
281 cmd = 'ip link set $DEV0 up'
282 exec_cmd(args, pm, 'pre', cmd, False)
283 cmd = 'ip -n $NS link set $DEV1 up'
284 exec_cmd(args, pm, 'pre', cmd, False)
285 cmd = 'ip link set $DEV2 netns $NS'
286 exec_cmd(args, pm, 'pre', cmd, False)
287 cmd = 'ip -n $NS link set $DEV2 up'
288 exec_cmd(args, pm, 'pre', cmd, False)
289
290
291def ns_destroy(args, pm):
292 """
293 Destroy the network namespace for testing (and any associated network
294 devices as well)
295 """
296 if (USE_NS):
297 cmd = 'ip netns delete $NS'
298 exec_cmd(args, pm, 'post', cmd, False)
299
300
301def has_blank_ids(idlist): 263def has_blank_ids(idlist):
302 """ 264 """
303 Search the list for empty ID fields and return true/false accordingly. 265 Search the list for empty ID fields and return true/false accordingly.
@@ -579,17 +541,12 @@ def set_operation_mode(pm, args):
579 list_test_cases(alltests) 541 list_test_cases(alltests)
580 exit(0) 542 exit(0)
581 543
582 ns_create(args, pm)
583
584 if len(alltests): 544 if len(alltests):
585 catresults = test_runner(pm, args, alltests) 545 catresults = test_runner(pm, args, alltests)
586 else: 546 else:
587 catresults = 'No tests found\n' 547 catresults = 'No tests found\n'
588 print('All test results: \n\n{}'.format(catresults)) 548 print('All test results: \n\n{}'.format(catresults))
589 549
590 ns_destroy(args, pm)
591
592
593def main(): 550def main():
594 """ 551 """
595 Start of execution; set up argument parser and get the arguments, 552 Start of execution; set up argument parser and get the arguments,