diff options
Diffstat (limited to 'lib/tst_test.c')
-rw-r--r-- | lib/tst_test.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/lib/tst_test.c b/lib/tst_test.c index 0dec00be4..bcf2c4555 100644 --- a/lib/tst_test.c +++ b/lib/tst_test.c @@ -60,6 +60,7 @@ static pid_t main_pid, lib_pid; static int mntpoint_mounted; static int ovl_mounted; static struct timespec tst_start_time; /* valid only for test pid */ +static int tdebug; struct results { int passed; @@ -224,6 +225,9 @@ static void print_result(const char *file, const int lineno, int ttype, case TINFO: res = "TINFO"; break; + case TDEBUG: + res = "TDEBUG"; + break; default: tst_brk(TBROK, "Invalid ttype value %i", ttype); abort(); @@ -352,6 +356,9 @@ void tst_res_(const char *file, const int lineno, int ttype, { va_list va; + if (ttype == TDEBUG && !tdebug) + return; + va_start(va, fmt); tst_vres_(file, lineno, ttype, fmt, va); va_end(va); @@ -511,6 +518,7 @@ static struct option { {"h", "-h Prints this help"}, {"i:", "-i n Execute test n times"}, {"I:", "-I x Execute test for n seconds"}, + {"D", "-D Prints debug information"}, {"V", "-V Prints LTP version"}, {"C:", "-C ARG Run child process with ARG arguments (used internally)"}, }; @@ -520,7 +528,7 @@ static void print_help(void) unsigned int i; int timeout, runtime; - /* see doc/user-guide.txt, which lists also shell API variables */ + /* see doc/User-Guidelines.asciidoc, which lists also shell API variables */ fprintf(stderr, "Environment Variables\n"); fprintf(stderr, "---------------------\n"); fprintf(stderr, "KCONFIG_PATH Specify kernel config file\n"); @@ -679,6 +687,10 @@ static void parse_opts(int argc, char *argv[]) print_help(); tst_brk(TBROK, "Invalid option"); break; + case 'D': + tst_res(TINFO, "Enabling debug info"); + tdebug = 1; + break; case 'h': print_help(); print_test_tags(); @@ -1137,6 +1149,8 @@ static void do_cgroup_requires(void) static void do_setup(int argc, char *argv[]) { + char *tdebug_env = getenv("LTP_ENABLE_DEBUG"); + if (!tst_test) tst_brk(TBROK, "No tests to run"); @@ -1157,6 +1171,11 @@ static void do_setup(int argc, char *argv[]) parse_opts(argc, argv); + if (tdebug_env && (!strcmp(tdebug_env, "1") || !strcmp(tdebug_env, "y"))) { + tst_res(TINFO, "Enabling debug info"); + tdebug = 1; + } + if (tst_test->needs_kconfigs && tst_kconfig_check(tst_test->needs_kconfigs)) tst_brk(TCONF, "Aborting due to unsuitable kernel config, see above!"); |