[Beignet] [PATCH] list all available utests' names

Zhigang Gong zhigang.gong at linux.intel.com
Tue Aug 20 23:54:51 PDT 2013


LGTM, pushed, thanks.

On Tue, Aug 20, 2013 at 03:01:22PM +0800, Lu Guanqun wrote:
> Signed-off-by: Lu Guanqun <guanqun.lu at intel.com>
> ---
>  utests/utest.cpp     |    9 +++++++++
>  utests/utest.hpp     |    2 ++
>  utests/utest_run.cpp |    6 ++++++
>  3 files changed, 17 insertions(+)
> 
> diff --git a/utests/utest.cpp b/utests/utest.cpp
> index fc3467e..2af08cb 100644
> --- a/utests/utest.cpp
> +++ b/utests/utest.cpp
> @@ -76,3 +76,12 @@ 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;
> +  }
> +}
> +
> diff --git a/utests/utest.hpp b/utests/utest.hpp
> index 338a4dc..93b3d87 100644
> --- a/utests/utest.hpp
> +++ b/utests/utest.hpp
> @@ -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 */
> diff --git a/utests/utest_run.cpp b/utests/utest_run.cpp
> index e577b7b..86536d7 100644
> --- a/utests/utest_run.cpp
> +++ b/utests/utest_run.cpp
> @@ -25,11 +25,17 @@
>   */
>  #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)
> -- 
> 1.7.9.5
> 
> _______________________________________________
> Beignet mailing list
> Beignet at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/beignet


More information about the Beignet mailing list