Skip to content

Commit

Permalink
tools: tc-testing: Can refer to $TESTID in test spec
Browse files Browse the repository at this point in the history
When processing the commands in the test cases, substitute
the test id for $TESTID.  This helps to make more flexible
tests.  For example, the testid can be given as a command
line argument.

As an example, if we wish to save the test output to a file
named for the test case, we can write in the test case:

"cmdUnderTest": "some test command | tee -a $TESTID.out"

Signed-off-by: Brenda J. Butler <bjb@mojatatu.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Brenda J. Butler authored and David S. Miller committed Mar 9, 2018
1 parent b19e5c1 commit 75291f3
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tools/testing/selftests/tc-testing/tdc.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,13 +177,17 @@ def prepare_env(args, pm, stage, prefix, cmdlist, output = None):
'"{}" did not complete successfully'.format(prefix))

def run_one_test(pm, args, index, tidx):
global NAMES
result = True
tresult = ""
tap = ""
if args.verbose > 0:
print("\t====================\n=====> ", end="")
print("Test " + tidx["id"] + ": " + tidx["name"])

# populate NAMES with TESTID for this test
NAMES['TESTID'] = tidx['id']

pm.call_pre_case(index, tidx['id'])
prepare_env(args, pm, 'setup', "-----> prepare stage", tidx["setup"])

Expand Down Expand Up @@ -227,6 +231,8 @@ def run_one_test(pm, args, index, tidx):

index += 1

# remove TESTID from NAMES
del(NAMES['TESTID'])
return tap

def test_runner(pm, args, filtered_tests):
Expand Down

0 comments on commit 75291f3

Please sign in to comment.