diff options
Diffstat (limited to 'tools/testing/selftests/tc-testing/tdc.py')
-rwxr-xr-x | tools/testing/selftests/tc-testing/tdc.py | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/tools/testing/selftests/tc-testing/tdc.py b/tools/testing/selftests/tc-testing/tdc.py index cd61b7844c0d..5f11f5d7456e 100755 --- a/tools/testing/selftests/tc-testing/tdc.py +++ b/tools/testing/selftests/tc-testing/tdc.py | |||
@@ -88,7 +88,7 @@ def prepare_env(cmdlist): | |||
88 | exit(1) | 88 | exit(1) |
89 | 89 | ||
90 | 90 | ||
91 | def test_runner(filtered_tests): | 91 | def test_runner(filtered_tests, args): |
92 | """ | 92 | """ |
93 | Driver function for the unit tests. | 93 | Driver function for the unit tests. |
94 | 94 | ||
@@ -105,6 +105,8 @@ def test_runner(filtered_tests): | |||
105 | for tidx in testlist: | 105 | for tidx in testlist: |
106 | result = True | 106 | result = True |
107 | tresult = "" | 107 | tresult = "" |
108 | if "flower" in tidx["category"] and args.device == None: | ||
109 | continue | ||
108 | print("Test " + tidx["id"] + ": " + tidx["name"]) | 110 | print("Test " + tidx["id"] + ": " + tidx["name"]) |
109 | prepare_env(tidx["setup"]) | 111 | prepare_env(tidx["setup"]) |
110 | (p, procout) = exec_cmd(tidx["cmdUnderTest"]) | 112 | (p, procout) = exec_cmd(tidx["cmdUnderTest"]) |
@@ -152,6 +154,10 @@ def ns_create(): | |||
152 | exec_cmd(cmd, False) | 154 | exec_cmd(cmd, False) |
153 | cmd = 'ip -s $NS link set $DEV1 up' | 155 | cmd = 'ip -s $NS link set $DEV1 up' |
154 | exec_cmd(cmd, False) | 156 | exec_cmd(cmd, False) |
157 | cmd = 'ip link set $DEV2 netns $NS' | ||
158 | exec_cmd(cmd, False) | ||
159 | cmd = 'ip -s $NS link set $DEV2 up' | ||
160 | exec_cmd(cmd, False) | ||
155 | 161 | ||
156 | 162 | ||
157 | def ns_destroy(): | 163 | def ns_destroy(): |
@@ -211,7 +217,8 @@ def set_args(parser): | |||
211 | help='Execute the single test case with specified ID') | 217 | help='Execute the single test case with specified ID') |
212 | parser.add_argument('-i', '--id', action='store_true', dest='gen_id', | 218 | parser.add_argument('-i', '--id', action='store_true', dest='gen_id', |
213 | help='Generate ID numbers for new test cases') | 219 | help='Generate ID numbers for new test cases') |
214 | return parser | 220 | parser.add_argument('-d', '--device', |
221 | help='Execute the test case in flower category') | ||
215 | return parser | 222 | return parser |
216 | 223 | ||
217 | 224 | ||
@@ -225,6 +232,8 @@ def check_default_settings(args): | |||
225 | 232 | ||
226 | if args.path != None: | 233 | if args.path != None: |
227 | NAMES['TC'] = args.path | 234 | NAMES['TC'] = args.path |
235 | if args.device != None: | ||
236 | NAMES['DEV2'] = args.device | ||
228 | if not os.path.isfile(NAMES['TC']): | 237 | if not os.path.isfile(NAMES['TC']): |
229 | print("The specified tc path " + NAMES['TC'] + " does not exist.") | 238 | print("The specified tc path " + NAMES['TC'] + " does not exist.") |
230 | exit(1) | 239 | exit(1) |
@@ -381,14 +390,17 @@ def set_operation_mode(args): | |||
381 | if (len(alltests) == 0): | 390 | if (len(alltests) == 0): |
382 | print("Cannot find a test case with ID matching " + target_id) | 391 | print("Cannot find a test case with ID matching " + target_id) |
383 | exit(1) | 392 | exit(1) |
384 | catresults = test_runner(alltests) | 393 | catresults = test_runner(alltests, args) |
385 | print("All test results: " + "\n\n" + catresults) | 394 | print("All test results: " + "\n\n" + catresults) |
386 | elif (len(target_category) > 0): | 395 | elif (len(target_category) > 0): |
396 | if (target_category == "flower") and args.device == None: | ||
397 | print("Please specify a NIC device (-d) to run category flower") | ||
398 | exit(1) | ||
387 | if (target_category not in ucat): | 399 | if (target_category not in ucat): |
388 | print("Specified category is not present in this file.") | 400 | print("Specified category is not present in this file.") |
389 | exit(1) | 401 | exit(1) |
390 | else: | 402 | else: |
391 | catresults = test_runner(testcases[target_category]) | 403 | catresults = test_runner(testcases[target_category], args) |
392 | print("Category " + target_category + "\n\n" + catresults) | 404 | print("Category " + target_category + "\n\n" + catresults) |
393 | 405 | ||
394 | ns_destroy() | 406 | ns_destroy() |