diff options
author | Brenda J. Butler <bjb@mojatatu.com> | 2018-02-14 20:09:23 +0100 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2018-02-15 21:38:33 +0100 |
commit | a13fedbe56fef141aff7d584eba2a08daaf613cc (patch) | |
tree | 97bff2cb9e944aed67e134bf7af1747119d72e07 /tools/testing/selftests/tc-testing/tdc.py | |
parent | tools: tc-testing: rootPlugin (diff) | |
download | linux-a13fedbe56fef141aff7d584eba2a08daaf613cc.tar.xz linux-a13fedbe56fef141aff7d584eba2a08daaf613cc.zip |
tools: tc-testing: nsPlugin
Move the functionality of creating a namespace before the test suite
and destroying it afterwards to a plugin.
Signed-off-by: Brenda J. Butler <bjb@mojatatu.com>
Acked-by: Lucas Bates <lucasb@mojatatu.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'tools/testing/selftests/tc-testing/tdc.py')
-rwxr-xr-x | tools/testing/selftests/tc-testing/tdc.py | 45 |
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 * import TdcPlugin -USE_NS = True - class PluginMgr: def __init__(self, argparser): super().__init__() @@ -107,16 +105,13 @@ def replace_keywords(cmd): return subcmd -def exec_cmd(args, pm, stage, command, nsonly=True): +def exec_cmd(args, pm, stage, command): """ Perform any required modifications on an executable command, then run it in a subprocess and return the results. """ if len(command.strip()) == 0: return None, None - if (USE_NS and nsonly): - command = 'ip netns exec $NS ' + command - if '$' in command: command = replace_keywords(command) @@ -265,39 +260,6 @@ def test_runner(pm, args, filtered_tests): return tap - -def ns_create(args, pm): - """ - Create the network namespace in which the tests will be run and set up - the required network devices for it. - """ - if (USE_NS): - cmd = 'ip netns add $NS' - exec_cmd(args, pm, 'pre', cmd, False) - cmd = 'ip link add $DEV0 type veth peer name $DEV1' - exec_cmd(args, pm, 'pre', cmd, False) - cmd = 'ip link set $DEV1 netns $NS' - exec_cmd(args, pm, 'pre', cmd, False) - cmd = 'ip link set $DEV0 up' - exec_cmd(args, pm, 'pre', cmd, False) - cmd = 'ip -n $NS link set $DEV1 up' - exec_cmd(args, pm, 'pre', cmd, False) - cmd = 'ip link set $DEV2 netns $NS' - exec_cmd(args, pm, 'pre', cmd, False) - cmd = 'ip -n $NS link set $DEV2 up' - exec_cmd(args, pm, 'pre', cmd, False) - - -def ns_destroy(args, pm): - """ - Destroy the network namespace for testing (and any associated network - devices as well) - """ - if (USE_NS): - cmd = 'ip netns delete $NS' - exec_cmd(args, pm, 'post', cmd, False) - - def has_blank_ids(idlist): """ Search the list for empty ID fields and return true/false accordingly. @@ -579,17 +541,12 @@ def set_operation_mode(pm, args): list_test_cases(alltests) exit(0) - ns_create(args, pm) - if len(alltests): catresults = test_runner(pm, args, alltests) else: catresults = 'No tests found\n' print('All test results: \n\n{}'.format(catresults)) - ns_destroy(args, pm) - - def main(): """ Start of execution; set up argument parser and get the arguments, |