[Beignet] [PATCH 2/2] Utest: Refine utest_run -l option

Xiuli Pan xiuli.pan at intel.com
Fri Aug 12 08:53:37 UTC 2016


From: Pan Xiuli <xiuli.pan at intel.com>

Refine old -l to test cases that can run
-la for all test cases
-li for test cases with issue

Signed-off-by: Pan Xiuli <xiuli.pan at intel.com>
---
 utests/utest.cpp     | 29 +++++++++++++++++++++++++----
 utests/utest.hpp     |  4 ++++
 utests/utest_run.cpp | 18 ++++++++++++++----
 3 files changed, 43 insertions(+), 8 deletions(-)

diff --git a/utests/utest.cpp b/utests/utest.cpp
index dac6c28..336fe67 100644
--- a/utests/utest.cpp
+++ b/utests/utest.cpp
@@ -248,9 +248,30 @@ void UTest::runAllBenchMark(void) {
 void UTest::listAllCases()
 {
   if (utestList == NULL) return;
-    for (size_t i = 0; i < utestList->size(); ++i) {
-      const UTest &utest = (*utestList)[i];
-      if (utest.fn == NULL) continue;
+  for (size_t i = 0; i < utestList->size(); ++i) {
+    const UTest &utest = (*utestList)[i];
+    if (utest.fn == NULL)
+      continue;
     std::cout << utest.name << std::endl;
- }
+  }
+}
+void UTest::listCasesCanRun()
+{
+  if (utestList == NULL) return;
+  for (size_t i = 0; i < utestList->size(); ++i) {
+    const UTest &utest = (*utestList)[i];
+    if (utest.fn == NULL || utest.haveIssue || utest.isBenchMark)
+      continue;
+    std::cout << utest.name << std::endl;
+  }
+}
+void UTest::listCasesWithIssue()
+{
+  if (utestList == NULL) return;
+  for (size_t i = 0; i < utestList->size(); ++i) {
+    const UTest &utest = (*utestList)[i];
+    if (utest.fn == NULL || !utest.haveIssue || utest.isBenchMark)
+      continue;
+    std::cout << utest.name << std::endl;
+  }
 }
diff --git a/utests/utest.hpp b/utests/utest.hpp
index 3e9f077..ca233aa 100644
--- a/utests/utest.hpp
+++ b/utests/utest.hpp
@@ -76,6 +76,10 @@ struct UTest
   static void runAll(void);
   /*! List all test cases */
   static void listAllCases(void);
+  /*! List test cases that can run*/
+  static void listCasesCanRun(void);
+  /*! List test cases with issue*/
+  static void listCasesWithIssue(void);
   /*! Statistics struct */
   static RStatistics retStatistics;
   /*! Do run a test case actually */
diff --git a/utests/utest_run.cpp b/utests/utest_run.cpp
index 380d738..1866d9a 100644
--- a/utests/utest_run.cpp
+++ b/utests/utest_run.cpp
@@ -26,13 +26,14 @@
 #include "utest_helper.hpp"
 #include "utest_exception.hpp"
 #include <iostream>
+#include <string.h>
 #include <getopt.h>
 
-static const char *shortopts = "c:j:lanh";
+static const char *shortopts = "c:j:l::anh";
 struct option longopts[] = {
 {"casename", required_argument, NULL, 'c'},
 {"jobs", required_argument, NULL, 'j'},
-{"list", no_argument, NULL, 'l'},
+{"list", optional_argument, NULL, 'l'},
 {"all", no_argument, NULL, 'a'},
 {"allnoissue", no_argument, NULL, 'n'},
 {"help", no_argument, NULL, 'h'},
@@ -48,7 +49,7 @@ Usage:\n\
   option:\n\
     -c <casename>: run sub-case named 'casename'\n\
     -j <number>  : specifies the 'number' of jobs (multi-thread)\n\
-    -l           : list all the available case name\n\
+    -l <a/i>     : list case name that can run(a for all case, i for case with issue)\n\
     -a           : run all test cases\n\
     -n           : run all test cases without known issue (default option)\n\
     -h           : display this usage\n\
@@ -103,7 +104,16 @@ int main(int argc, char *argv[])
         break;
 
       case 'l':
-        UTest::listAllCases();
+        if (optarg == NULL)
+          UTest::listCasesCanRun();
+        else if (strcmp(optarg,"a") == 0)
+          UTest::listAllCases();
+        else if (strcmp(optarg,"i") == 0)
+          UTest::listCasesWithIssue();
+        else {
+          usage();
+          exit(1);
+        }
         break;
 
       case 'a':
-- 
2.7.4



More information about the Beignet mailing list