Lines Matching +full:self +full:- +full:test

2 # SPDX-License-Identifier: GPL-2.0
5 tdc.py - Linux tc (Traffic Control) unit test driver
31 def __init__(self, missing_pg): argument
32 self.missing_pg = missing_pg
35 def __init__(self, stage, output, message): argument
36 self.stage = stage
37 self.output = output
38 self.message = message
41 def __init__(self, argparser): argument
43 self.plugins = set()
44 self.plugin_instances = []
45 self.failed_plugins = {}
46 self.argparser = argparser
55 mn = fn[0:-3]
57 self.plugins.add(mn)
58 self.plugin_instances[mn] = foo.SubPlugin()
60 def load_plugin(self, pgdir, pgname): argument
61 pgname = pgname[0:-3]
62 self.plugins.add(pgname)
68 self.plugin_instances.insert(0, (pgname, foo.SubPlugin()))
69 self.plugin_instances[0][1].check_args(self.args, None)
71 self.plugin_instances.append((pgname, foo.SubPlugin()))
72 self.plugin_instances[-1][1].check_args(self.args, None)
74 def get_required_plugins(self, testlist): argument
76 Get all required plugins from the list of test cases and return
96 def load_required_plugins(self, reqs, parser, args, remaining): argument
98 Get all required plugins from the list of test cases and load any plugin
101 pgd = ['plugin-lib', 'plugin-lib-custom']
105 if r not in self.plugins:
121 self.load_plugin(pgdir, fname)
125 parser = self.call_add_args(parser)
129 def call_pre_suite(self, testcount, testidlist): argument
130 for (_, pgn_inst) in self.plugin_instances:
133 def call_post_suite(self, index): argument
134 for (_, pgn_inst) in reversed(self.plugin_instances):
137 def call_pre_case(self, caseinfo, *, test_skip=False): argument
138 for (pgn, pgn_inst) in self.plugin_instances:
150 def call_post_case(self, caseinfo): argument
151 for (pgn, pgn_inst) in reversed(self.plugin_instances):
156 def call_pre_execute(self, caseinfo): argument
157 for (pgn, pgn_inst) in self.plugin_instances:
162 def call_post_execute(self, caseinfo): argument
163 for (pgn, pgn_inst) in reversed(self.plugin_instances):
168 def call_add_args(self, parser): argument
169 for (pgn, pgn_inst) in self.plugin_instances:
173 def call_check_args(self, args, remaining): argument
174 for (pgn, pgn_inst) in self.plugin_instances:
177 def call_adjust_command(self, caseinfo, stage, command): argument
178 for (pgn, pgn_inst) in self.plugin_instances:
184 def set_args(self, args): argument
185 self.args = args
189 self.argparser = argparse.ArgumentParser(
225 foutput = serr.decode("utf-8", errors="ignore")
227 foutput = rawout.decode("utf-8", errors="ignore")
239 Execute the setup/teardown commands for a test case.
240 Optionally terminate test execution if the command fails.
265 print("\n{} *** Aborting test run.".format(prefix), file=sys.stderr)
290 …N value is an array, and it contains more elements than the command under test\'s output:\ncommand…
326 …N value is an array, and it contains more elements than the command under test\'s output:\ncommand…
388 print("Test " + tidx["id"] + ": " + tidx["name"])
394 res.set_errormsg('Test case designated as skipped.')
401 print('probe command for test skip')
407 res.set_errormsg('probe command: test skipped.')
412 # populate NAMES with TESTID for this test
414 NAMES['NS'] = '{}-{}'.format(NAMES['NS'], tidx['random'])
420 prepare_env(tidx, args, pm, 'setup', "-----> prepare stage", tidx["setup"])
423 print('-----> execute stage')
442 print('-----> verify stage')
465 prepare_env(tidx, args, pm, 'teardown', '-----> teardown stage', tidx['teardown'], procout)
508 teardown commands and the command under test itself. Also determines
509 success/failure based on the information in the test case and generates
524 errmsg += "physical NIC with the -d option when running tdc.\n"
525 errmsg += "Test has been skipped."
550 print('Exception {} {} (caught in test_runner, running test {} {} {} stage {})'.
552 print('---------------')
555 print('---------------')
557 print('accumulated output for this test:')
560 print('---------------')
565 # fill in the remaining tests with ok-skipped
569 for tidx in testlist[count - 1:]:
572 msg = 'skipped - previous {} failed {} {}'.format(stage,
573 index, badtest.get('id', '--Unknown--'))
589 for test in alltests:
590 if 'nsPlugin' not in test['plugins']:
591 serial.append(test)
594 if 'netdevsim/new_device' in str(test['setup']):
595 serial.append(test)
597 parallel.append(test)
657 Open the JSON file containing the test cases and return them
664 print('IGNORING test case file {}\n\tBECAUSE: {}'.format(filename, jde))
690 '--outfile', type=str,
694 '-p', '--path', type=str,
697 'selection', 'select which test cases: ' +
700 'action', 'select action to perform on selected test cases')
703 '-D', '--directory', nargs='+', metavar='DIR',
705 '(default [tc-tests])')
707 '-f', '--file', nargs='+', metavar='FILE',
710 '-c', '--category', nargs='*', metavar='CATG', default=['+c'],
714 '-e', '--execute', nargs='+', metavar='ID',
715 help='Execute the specified test cases with specified IDs')
717 '-l', '--list', action='store_true',
718 help='List all test cases, or those only within the specified category')
720 '-s', '--show', action='store_true', dest='showID',
721 help='Display the selected test cases')
723 '-i', '--id', action='store_true', dest='gen_id',
724 help='Generate ID numbers for new test cases')
726 '-v', '--verbose', action='count', default=0,
729 '--format', default='tap', const='tap', nargs='?',
731 help='Specify the format for test results. (Default: TAP)')
732 parser.add_argument('-d', '--device',
733 help='Execute test cases that use a physical device, ' +
737 '-P', '--pause', action='store_true',
738 help='Pause execution just before post-suite stage')
740 '-J', '--multiprocess', type=int, default=1, dest='mp',
768 Generate a list of all IDs in the test cases.
774 Check for duplicate test case IDs.
782 Check if a given ID already exists in the list of test cases.
790 If a test case has a blank ID field, generate a random hex ID for it
791 and then write the test cases back to disk.
857 If a test case file is specified, retrieve tests from that file.
866 testdirs = ['tc-tests']
869 # at least one file was specified - remove the default directory
918 Load the test case data and process remaining arguments to determine
928 print("No empty ID fields found in test files.")
933 print("The following test case IDs are not unique:")
971 print('Test results output suppression requested\n')
973 print('\nAll test results: \n')
983 fname = 'test-results.{}'.format(suffix)
1024 # Cleanup on Ctrl-C