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:
149 def call_post_case(self, caseinfo): argument
150 for (pgn, pgn_inst) in reversed(self.plugin_instances):
155 def call_pre_execute(self, caseinfo): argument
156 for (pgn, pgn_inst) in self.plugin_instances:
161 def call_post_execute(self, caseinfo): argument
162 for (pgn, pgn_inst) in reversed(self.plugin_instances):
167 def call_add_args(self, parser): argument
168 for (pgn, pgn_inst) in self.plugin_instances:
172 def call_check_args(self, args, remaining): argument
173 for (pgn, pgn_inst) in self.plugin_instances:
176 def call_adjust_command(self, caseinfo, stage, command): argument
177 for (pgn, pgn_inst) in self.plugin_instances:
183 def set_args(self, args): argument
184 self.args = args
188 self.argparser = argparse.ArgumentParser(
224 foutput = serr.decode("utf-8", errors="ignore")
226 foutput = rawout.decode("utf-8", errors="ignore")
238 Execute the setup/teardown commands for a test case.
239 Optionally terminate test execution if the command fails.
264 print("\n{} *** Aborting test run.".format(prefix), file=sys.stderr)
289 …N value is an array, and it contains more elements than the command under test\'s output:\ncommand…
325 …N value is an array, and it contains more elements than the command under test\'s output:\ncommand…
387 print("Test " + tidx["id"] + ": " + tidx["name"])
393 res.set_errormsg('Test case designated as skipped.')
400 print('probe command for test skip')
406 res.set_errormsg('probe command: test skipped.')
411 # populate NAMES with TESTID for this test
413 NAMES['NS'] = '{}-{}'.format(NAMES['NS'], tidx['random'])
419 prepare_env(tidx, args, pm, 'setup', "-----> prepare stage", tidx["setup"])
422 print('-----> execute stage')
441 print('-----> verify stage')
464 prepare_env(tidx, args, pm, 'teardown', '-----> teardown stage', tidx['teardown'], procout)
507 teardown commands and the command under test itself. Also determines
508 success/failure based on the information in the test case and generates
523 errmsg += "physical NIC with the -d option when running tdc.\n"
524 errmsg += "Test has been skipped."
549 print('Exception {} {} (caught in test_runner, running test {} {} {} stage {})'.
551 print('---------------')
554 print('---------------')
556 print('accumulated output for this test:')
559 print('---------------')
564 # fill in the remaining tests with ok-skipped
568 for tidx in testlist[count - 1:]:
571 msg = 'skipped - previous {} failed {} {}'.format(stage,
572 index, badtest.get('id', '--Unknown--'))
588 for test in alltests:
589 if 'nsPlugin' not in test['plugins']:
590 serial.append(test)
593 if 'netdevsim/new_device' in str(test['setup']):
594 serial.append(test)
596 parallel.append(test)
656 Open the JSON file containing the test cases and return them
663 print('IGNORING test case file {}\n\tBECAUSE: {}'.format(filename, jde))
689 '--outfile', type=str,
693 '-p', '--path', type=str,
696 'selection', 'select which test cases: ' +
699 'action', 'select action to perform on selected test cases')
702 '-D', '--directory', nargs='+', metavar='DIR',
704 '(default [tc-tests])')
706 '-f', '--file', nargs='+', metavar='FILE',
709 '-c', '--category', nargs='*', metavar='CATG', default=['+c'],
713 '-e', '--execute', nargs='+', metavar='ID',
714 help='Execute the specified test cases with specified IDs')
716 '-l', '--list', action='store_true',
717 help='List all test cases, or those only within the specified category')
719 '-s', '--show', action='store_true', dest='showID',
720 help='Display the selected test cases')
722 '-i', '--id', action='store_true', dest='gen_id',
723 help='Generate ID numbers for new test cases')
725 '-v', '--verbose', action='count', default=0,
728 '--format', default='tap', const='tap', nargs='?',
730 help='Specify the format for test results. (Default: TAP)')
731 parser.add_argument('-d', '--device',
732 help='Execute test cases that use a physical device, ' +
736 '-P', '--pause', action='store_true',
737 help='Pause execution just before post-suite stage')
739 '-J', '--multiprocess', type=int, default=1, dest='mp',
767 Generate a list of all IDs in the test cases.
773 Check for duplicate test case IDs.
781 Check if a given ID already exists in the list of test cases.
789 If a test case has a blank ID field, generate a random hex ID for it
790 and then write the test cases back to disk.
856 If a test case file is specified, retrieve tests from that file.
865 testdirs = ['tc-tests']
868 # at least one file was specified - remove the default directory
917 Load the test case data and process remaining arguments to determine
927 print("No empty ID fields found in test files.")
932 print("The following test case IDs are not unique:")
970 print('Test results output suppression requested\n')
972 print('\nAll test results: \n')
982 fname = 'test-results.{}'.format(suffix)
1023 # Cleanup on Ctrl-C