automated/linux/ptest: Add support for -e option

The -e option works to exclude certain ptests for execution.

Change-Id: I644e45a8ab15ecc7712f04547cab3dcd61bb961f
Signed-off-by: Aníbal Limón <anibal.limon@linaro.org>
diff --git a/automated/linux/ptest/ptest.py b/automated/linux/ptest/ptest.py
index ee38876..13feb4d 100755
--- a/automated/linux/ptest/ptest.py
+++ b/automated/linux/ptest/ptest.py
@@ -61,9 +61,13 @@
     return ptests
 
 
-def filter_ptests(ptests, requested_ptests):
+def filter_ptests(ptests, requested_ptests, exclude):
     filter_ptests = []
 
+    for ptest in exclude:
+        if ptest in ptests:
+            ptests.remove(ptest)
+
     if not requested_ptests:
         return ptests
 
@@ -100,6 +104,8 @@
                                      add_help=False)
     parser.add_argument('-t', '--tests', action='store', nargs='*',
                         help='Ptests to run')
+    parser.add_argument('-e', '--exclude', action='store', nargs='*',
+                        help='Ptests to exclude')
     parser.add_argument('-d', '--ptest-dir',
                         help='Directory where ptests are stored (optional)',
                         action='store')
@@ -129,8 +135,13 @@
     if args.tests:
         tests = [x for x in args.tests if x]
 
+    # filter empty strings caused by -e ""
+    exclude = []
+    if args.exclude:
+        exclude = [e for e in args.exclude if e]
+
     required_ptests = dict.fromkeys(tests, False)
-    ptests_to_run = filter_ptests(ptests, required_ptests)
+    ptests_to_run = filter_ptests(ptests, required_ptests, exclude)
     for ptest_name in ptests_to_run:
         check_ptest(ptest_dir, ptest_name, args.output_log)