mirror of
https://github.com/tiagovignatti/intel-gpu-tools.git
synced 2025-06-11 09:56:22 +00:00
lib: add the ability to include a description with a test
The IGT_TEST_DESCRIPTION macro can be used to define a description for a test. v2: Remove semicolon from end of macro (Damien Lespiau) Add API documentation for the macro. Signed-off-by: Thomas Wood <thomas.wood@intel.com>
This commit is contained in:
parent
c06016798c
commit
f8b3c704af
@ -223,6 +223,7 @@ bool test_child;
|
|||||||
enum {
|
enum {
|
||||||
OPT_LIST_SUBTESTS,
|
OPT_LIST_SUBTESTS,
|
||||||
OPT_RUN_SUBTEST,
|
OPT_RUN_SUBTEST,
|
||||||
|
OPT_DESCRIPTION,
|
||||||
OPT_DEBUG,
|
OPT_DEBUG,
|
||||||
OPT_HELP = 'h'
|
OPT_HELP = 'h'
|
||||||
};
|
};
|
||||||
@ -360,6 +361,12 @@ static void common_exit_handler(int sig)
|
|||||||
assert(sig != 0 || igt_exit_called);
|
assert(sig != 0 || igt_exit_called);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void print_test_description(void)
|
||||||
|
{
|
||||||
|
if (&__igt_test_description)
|
||||||
|
printf("%s\n", __igt_test_description);
|
||||||
|
}
|
||||||
|
|
||||||
static void print_version(void)
|
static void print_version(void)
|
||||||
{
|
{
|
||||||
struct utsname uts;
|
struct utsname uts;
|
||||||
@ -380,11 +387,12 @@ static void print_usage(const char *help_str, bool output_on_stderr)
|
|||||||
{
|
{
|
||||||
FILE *f = output_on_stderr ? stderr : stdout;
|
FILE *f = output_on_stderr ? stderr : stdout;
|
||||||
|
|
||||||
fprintf(f, "Usage: %s [OPTIONS]\n"
|
fprintf(f, "Usage: %s [OPTIONS]\n", command_str);
|
||||||
" --list-subtests\n"
|
fprintf(f, " --list-subtests\n"
|
||||||
" --run-subtest <pattern>\n"
|
" --run-subtest <pattern>\n"
|
||||||
" --debug\n"
|
" --debug\n"
|
||||||
" --help\n", command_str);
|
" --help-description\n"
|
||||||
|
" --help\n");
|
||||||
if (help_str)
|
if (help_str)
|
||||||
fprintf(f, "%s\n", help_str);
|
fprintf(f, "%s\n", help_str);
|
||||||
}
|
}
|
||||||
@ -413,6 +421,7 @@ static int common_init(int argc, char **argv,
|
|||||||
static struct option long_options[] = {
|
static struct option long_options[] = {
|
||||||
{"list-subtests", 0, 0, OPT_LIST_SUBTESTS},
|
{"list-subtests", 0, 0, OPT_LIST_SUBTESTS},
|
||||||
{"run-subtest", 1, 0, OPT_RUN_SUBTEST},
|
{"run-subtest", 1, 0, OPT_RUN_SUBTEST},
|
||||||
|
{"help-description", 0, 0, OPT_DESCRIPTION},
|
||||||
{"debug", 0, 0, OPT_DEBUG},
|
{"debug", 0, 0, OPT_DEBUG},
|
||||||
{"help", 0, 0, OPT_HELP},
|
{"help", 0, 0, OPT_HELP},
|
||||||
{0, 0, 0, 0}
|
{0, 0, 0, 0}
|
||||||
@ -510,6 +519,10 @@ static int common_init(int argc, char **argv,
|
|||||||
if (!list_subtests)
|
if (!list_subtests)
|
||||||
run_single_subtest = strdup(optarg);
|
run_single_subtest = strdup(optarg);
|
||||||
break;
|
break;
|
||||||
|
case OPT_DESCRIPTION:
|
||||||
|
print_test_description();
|
||||||
|
ret = -1;
|
||||||
|
goto out;
|
||||||
case OPT_HELP:
|
case OPT_HELP:
|
||||||
print_usage(help_str, false);
|
print_usage(help_str, false);
|
||||||
ret = -1;
|
ret = -1;
|
||||||
|
@ -38,6 +38,18 @@
|
|||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
|
|
||||||
|
extern const char* __igt_test_description __attribute__((weak));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* IGT_TEST_DESCRIPTION:
|
||||||
|
* @str: description string
|
||||||
|
*
|
||||||
|
* Defines a description for a test. This is used as the output for the
|
||||||
|
* "--help-description" option and is also included in the generated
|
||||||
|
* documentation.
|
||||||
|
*/
|
||||||
|
#define IGT_TEST_DESCRIPTION(str) const char* __igt_test_description = str
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* IGT_EXIT_TIMEOUT:
|
* IGT_EXIT_TIMEOUT:
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user