Running a single benchmark as an option for user. 05/22605/2
authorlinux_geek <taseer94@gmail.com>
Fri, 30 Sep 2016 18:36:12 +0000 (23:36 +0500)
committerTaseer Ahmed <taseer94@gmail.com>
Sat, 1 Oct 2016 10:49:43 +0000 (10:49 +0000)
JIRA: QTIP-104

Change-Id: I4413d1e2670192b86af0aad62fb2752d2709fa14
Signed-off-by: Taseer Ahmed <taseer94@gmail.com>
func/args_handler.py
func/cli.py

index 50d803e..e27d37e 100644 (file)
@@ -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]
 
index 66ab227..833437d 100644 (file)
@@ -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:]):
@@ -39,20 +42,31 @@ class cli:
         args = self._parse_args(args)
         if not args_handler.check_suit_in_test_list(args.file):
             print('\n\n ERROR: Test File Does not exist in test_list/ please enter correct file \n\n')
-            sys.exit(0)
+            sys.exit(1)
 
         if not args_handler.check_lab_name(args.lab):
             print('\n\n You have specified a lab that is not present in test_cases/ please enter \
                    correct file. If unsure how to proceed, use -l default.\n\n')
-            sys.exit(0)
+            sys.exit(1)
         suite = args.file
         benchmarks = args_handler.get_files_in_test_list(suite)
         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)))