aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYujun Zhang <zhang.yujunz@zte.com.cn>2016-10-07 05:23:25 +0000
committerGerrit Code Review <gerrit@opnfv.org>2016-10-07 05:23:25 +0000
commit33d953b9c4a7ecada927af3b1666d15e3f389beb (patch)
treed42574772a29f9e22a189d5670b8988fbf690fbf
parent16385d37f66e121d0ef045e679ade1fd1aec9afc (diff)
parent441a4a29f8841dac6596ef7b278e52e29b14dcd9 (diff)
Merge "Running a single benchmark as an option for user."
-rw-r--r--func/args_handler.py4
-rw-r--r--func/cli.py20
2 files changed, 21 insertions, 3 deletions
diff --git a/func/args_handler.py b/func/args_handler.py
index 50d803eb..e27d37e7 100644
--- a/func/args_handler.py
+++ b/func/args_handler.py
@@ -38,6 +38,10 @@ def check_lab_name(lab_name):
return True if os.path.isdir('test_cases/' + lab_name) else False
+def check_benchmark_name(lab, file, benchmark):
+ return os.path.isfile('test_cases/' + lab + '/' + file + '/' + benchmark)
+
+
def _get_f_name(test_case_path):
return test_case_path.split('/')[-1]
diff --git a/func/cli.py b/func/cli.py
index f91615e2..833437d5 100644
--- a/func/cli.py
+++ b/func/cli.py
@@ -32,6 +32,9 @@ class cli:
'\n network '
'They contain all the tests that will be run. They are listed by suite.'
'Please ensure there are no empty lines')
+ parser.add_argument('-b', '--benchmark', help='Name of the benchmark.'
+ 'Can be found in test_lists/file_name')
+
return parser.parse_args(args)
def __init__(self, args=sys.argv[1:]):
@@ -50,9 +53,20 @@ class cli:
test_cases = args_handler.get_files_in_test_case(args.lab, suite)
benchmarks_list = filter(lambda x: x in test_cases, benchmarks)
- map(lambda x: args_handler.prepare_and_run_benchmark(
- os.environ['INSTALLER_TYPE'], os.environ['PWD'],
- args_handler.get_benchmark_path(args.lab.lower(), suite, x)), benchmarks_list)
+ if args.benchmark:
+ if not args_handler.check_benchmark_name(args.lab, args.file, args.benchmark):
+ print('\n\n You have specified an incorrect benchmark. Please'
+ 'enter the correct one.\n\n')
+ sys.exit(1)
+ else:
+ print("Starting with " + args.benchmark)
+ args_handler.prepare_and_run_benchmark(
+ os.environ['INSTALLER_TYPE'], os.environ['PWD'],
+ args_handler.get_benchmark_path(args.lab.lower(), args.file, args.benchmark))
+ else:
+ map(lambda x: args_handler.prepare_and_run_benchmark(
+ os.environ['INSTALLER_TYPE'], os.environ['PWD'],
+ args_handler.get_benchmark_path(args.lab.lower(), suite, x)), benchmarks_list)
print('{0} is not a Template in the Directory Enter a Valid file name.'
'or use qtip.py -h for list'.format(filter(lambda x: x not in test_cases, benchmarks)))