summaryrefslogtreecommitdiffstats
path: root/vsperf
diff options
context:
space:
mode:
authorBilly O'Mahony <billy.o.mahony@intel.com>2015-08-28 16:09:07 +0100
committerMaryam Tahhan <maryam.tahhan@intel.com>2015-09-08 12:57:31 +0000
commit3954f35080b8a2b63a66c96a92128cc9b3c6c3a2 (patch)
treec54275095e266467f323c29117195c4864bf557a /vsperf
parentdcb66fe7b184080d521e341ac4f73c165abacc37 (diff)
bugfix: Allow exact test names
The current --tests option can make it hard to specify a single test to run. This patch allows specification of tests using exact names. JIRA: VSPERF-58 Signed-off-by: Billy O'Mahony<billy.o.mahony@intel.com> Reviewed-by: Maryam Tahhan <maryam.tahhan@intel.com> Reviewed-by: Martin Klozik <martinx.klozik@intel.com> Reviewed-by: Radek Zetik <radekx.zetik@intel.com> Reviewed-by: Dino Madarang <dino.simeonx.madarang@intel.com> Reviewed-by: Brian Castelli <brian.castelli@spirent.com> Change-Id: Ib820bdae96d6257d785f4e310a3b3d1fbfa1b575
Diffstat (limited to 'vsperf')
-rwxr-xr-xvsperf33
1 files changed, 26 insertions, 7 deletions
diff --git a/vsperf b/vsperf
index d5086ac4..7c9f0187 100755
--- a/vsperf
+++ b/vsperf
@@ -126,7 +126,10 @@ def parse_arguments():
help='list all system vnfs and exit')
parser.add_argument('--list-settings', action='store_true',
help='list effective settings configuration and exit')
- parser.add_argument('test', nargs='*', help='test specification(s)')
+ parser.add_argument('exact_test_name', nargs='*', help='Exact names of\
+ tests to run. E.g "vsperf phy2phy_tput phy2phy_cont"\
+ runs only the two tests with those exact names.\
+ To run all tests omit both positional args and --tests arg.')
group = parser.add_argument_group('test selection options')
group.add_argument('-f', '--test-spec', help='test specification file')
@@ -353,9 +356,6 @@ def main():
cfg.get('Name', '<Name not set>'))
raise
- # TODO(BOM) Apply filter to select requested tests
- all_tests = apply_filter(all_tests, args['tests'])
-
# if required, handle list-* operations
if args['list']:
@@ -385,15 +385,34 @@ def main():
print(str(settings))
exit()
+ # select requested tests
+ if args['exact_test_name'] and args['tests']:
+ logger.error("Cannot specify tests with both positional args and --test.")
+ sys.exit(1)
+
+ if args['exact_test_name']:
+ exact_names = args['exact_test_name']
+ # positional args => exact matches only
+ selected_tests = [test for test in all_tests if test.name in exact_names]
+ elif args['tests']:
+ # --tests => apply filter to select requested tests
+ selected_tests = apply_filter(all_tests, args['tests'])
+ else:
+ # Default - run all tests
+ selected_tests = all_tests
+
+ if not selected_tests:
+ logger.error("No tests matched --test option or positional args. Done.")
+ sys.exit(1)
+
# create results directory
if not os.path.exists(results_path):
logger.info("Creating result directory: " + results_path)
os.makedirs(results_path)
- suite = unittest.TestSuite()
-
# run tests
- for test in all_tests:
+ suite = unittest.TestSuite()
+ for test in selected_tests:
try:
test.run()
suite.addTest(MockTestCase('', True, test.name))