list all available utests' names
authorLu Guanqun <guanqun.lu@intel.com>
Tue, 20 Aug 2013 07:01:22 +0000 (15:01 +0800)
committerZhigang Gong <zhigang.gong@linux.intel.com>
Wed, 21 Aug 2013 06:52:40 +0000 (14:52 +0800)
Signed-off-by: Lu Guanqun <guanqun.lu@intel.com>
Reviewed-by: Zhigang Gong <zhigang.gong@linux.intel.com>
utests/utest.cpp
utests/utest.hpp
utests/utest_run.cpp

index fc3467e..24045c7 100644 (file)
@@ -76,3 +76,11 @@ void UTest::runAll(void) {
   }
 }
 
+void UTest::listAll(void) {
+  if (utestList == NULL) return;
+  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;
+  }
+}
index 338a4dc..93b3d87 100644 (file)
@@ -50,6 +50,8 @@ struct UTest
   static void run(const char *name);
   /*! Run all the tests */
   static void runAll(void);
+  /*! List all the tests */
+  static void listAll(void);
 };
 
 /*! Register a new unit test */
index e577b7b..86536d7 100644 (file)
  */
 #include "utest_helper.hpp"
 #include "utest_exception.hpp"
+#include <string.h>
 #include <iostream>
 
 int main(int argc, char *argv[])
 {
   try {
+    if (argc == 2 && !strcmp(argv[1], "--list")) {
+      UTest::listAll();
+      return 0;
+    }
+
     cl_ocl_init();
     if (argc >= 2)
       for (int i = 1; i < argc; ++i)