Lines Matching +full:self +full:- +full:test
2 # SPDX-License-Identifier: GPL-2.0
5 tdc.py - Linux tc (Traffic Control) unit test driver
29 def __init__(self, missing_pg): argument
30 self.missing_pg = missing_pg
33 def __init__(self, stage, output, message): argument
34 self.stage = stage
35 self.output = output
36 self.message = message
39 def __init__(self, argparser): argument
41 self.plugins = {}
42 self.plugin_instances = []
43 self.failed_plugins = {}
44 self.argparser = argparser
54 mn = fn[0:-3]
56 self.plugins[mn] = foo
57 self.plugin_instances.append(foo.SubPlugin())
59 def load_plugin(self, pgdir, pgname): argument
60 pgname = pgname[0:-3]
62 self.plugins[pgname] = foo
63 self.plugin_instances.append(foo.SubPlugin())
64 self.plugin_instances[-1].check_args(self.args, None)
66 def get_required_plugins(self, testlist): argument
68 Get all required plugins from the list of test cases and return
84 def load_required_plugins(self, reqs, parser, args, remaining): argument
86 Get all required plugins from the list of test cases and load any plugin
89 pgd = ['plugin-lib', 'plugin-lib-custom']
93 if r not in self.plugins:
109 self.load_plugin(pgdir, fname)
113 parser = self.call_add_args(parser)
117 def call_pre_suite(self, testcount, testidlist): argument
118 for pgn_inst in self.plugin_instances:
121 def call_post_suite(self, index): argument
122 for pgn_inst in reversed(self.plugin_instances):
125 def call_pre_case(self, caseinfo, *, test_skip=False): argument
126 for pgn_inst in self.plugin_instances:
136 def call_post_case(self): argument
137 for pgn_inst in reversed(self.plugin_instances):
140 def call_pre_execute(self): argument
141 for pgn_inst in self.plugin_instances:
144 def call_post_execute(self): argument
145 for pgn_inst in reversed(self.plugin_instances):
148 def call_add_args(self, parser): argument
149 for pgn_inst in self.plugin_instances:
153 def call_check_args(self, args, remaining): argument
154 for pgn_inst in self.plugin_instances:
157 def call_adjust_command(self, stage, command): argument
158 for pgn_inst in self.plugin_instances:
162 def set_args(self, args): argument
163 self.args = args
167 self.argparser = argparse.ArgumentParser(
202 foutput = serr.decode("utf-8", errors="ignore")
204 foutput = rawout.decode("utf-8", errors="ignore")
216 Execute the setup/teardown commands for a test case.
217 Optionally terminate test execution if the command fails.
242 print("\n{} *** Aborting test run.".format(prefix), file=sys.stderr)
257 print("Test " + tidx["id"] + ": " + tidx["name"])
263 res.set_errormsg('Test case designated as skipped.')
268 # populate NAMES with TESTID for this test
272 prepare_env(args, pm, 'setup', "-----> prepare stage", tidx["setup"])
275 print('-----> execute stage')
294 print('-----> verify stage')
311 prepare_env(args, pm, 'teardown', '-----> teardown stage', tidx['teardown'], procout)
325 teardown commands and the command under test itself. Also determines
326 success/failure based on the information in the test case and generates
349 stage = 'pre-SUITE'
355 print('give test rig 2 seconds to stabilize')
360 errmsg += "physical NIC with the -d option when running tdc.\n"
361 errmsg += "Test has been skipped."
385 print('Exception {} {} (caught in test_runner, running test {} {} {} stage {})'.
387 print('---------------')
390 print('---------------')
392 print('accumulated output for this test:')
395 print('---------------')
400 # fill in the remaining tests with ok-skipped
404 for tidx in testlist[count - 1:]:
407 msg = 'skipped - previous {} failed {} {}'.format(stage,
408 index, badtest.get('id', '--Unknown--'))
431 Open the JSON file containing the test cases and return them
438 print('IGNORING test case file {}\n\tBECAUSE: {}'.format(filename, jde))
461 '--outfile', type=str,
465 '-p', '--path', type=str,
468 'selection', 'select which test cases: ' +
471 'action', 'select action to perform on selected test cases')
474 '-D', '--directory', nargs='+', metavar='DIR',
476 '(default [tc-tests])')
478 '-f', '--file', nargs='+', metavar='FILE',
481 '-c', '--category', nargs='*', metavar='CATG', default=['+c'],
485 '-e', '--execute', nargs='+', metavar='ID',
486 help='Execute the specified test cases with specified IDs')
488 '-l', '--list', action='store_true',
489 help='List all test cases, or those only within the specified category')
491 '-s', '--show', action='store_true', dest='showID',
492 help='Display the selected test cases')
494 '-i', '--id', action='store_true', dest='gen_id',
495 help='Generate ID numbers for new test cases')
497 '-v', '--verbose', action='count', default=0,
500 '--format', default='tap', const='tap', nargs='?',
502 help='Specify the format for test results. (Default: TAP)')
503 parser.add_argument('-d', '--device',
504 help='Execute test cases that use a physical device, ' +
508 '-P', '--pause', action='store_true',
509 help='Pause execution just before post-suite stage')
536 Generate a list of all IDs in the test cases.
543 Check for duplicate test case IDs.
551 Check if a given ID already exists in the list of test cases.
559 If a test case has a blank ID field, generate a random hex ID for it
560 and then write the test cases back to disk.
624 If a test case file is specified, retrieve tests from that file.
633 testdirs = ['tc-tests']
636 # at least one file was specified - remove the default directory
685 Load the test case data and process remaining arguments to determine
695 print("No empty ID fields found in test files.")
700 print("The following test case IDs are not unique:")
728 print('Test results output suppression requested\n')
730 print('\nAll test results: \n')
740 fname = 'test-results.{}'.format(suffix)