Skip to content

Commit c8c261b

Browse files
rh-mcermakmetan-ucw
authored andcommitted
Introduce LTP_QUIET env var
Introduce LTP_QUIET env variable. When set to 1 or y, it will suppress printing TCONF, TINFO, and TDEBUG messages. Signed-off-by: Martin Cermak <[email protected]> Reviewed-by: Cyril Hrubis <[email protected]>
1 parent 7a7cbb7 commit c8c261b

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

lib/tst_test.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ static int iterations = 1;
6868
static float duration = -1;
6969
static float timeout_mul = -1;
7070
static int reproducible_output;
71+
static int quiet_output;
7172

7273
struct context {
7374
int32_t lib_pid;
@@ -307,15 +308,21 @@ static void print_result(const char *file, const int lineno, int ttype,
307308
res = "TBROK";
308309
break;
309310
case TCONF:
311+
if (quiet_output)
312+
return;
310313
res = "TCONF";
311314
break;
312315
case TWARN:
313316
res = "TWARN";
314317
break;
315318
case TINFO:
319+
if (quiet_output)
320+
return;
316321
res = "TINFO";
317322
break;
318323
case TDEBUG:
324+
if (quiet_output)
325+
return;
319326
res = "TDEBUG";
320327
break;
321328
default:
@@ -670,6 +677,7 @@ static void print_help(void)
670677
fprintf(stderr, "LTP_DEV_FS_TYPE Filesystem used for testing (default: %s)\n", DEFAULT_FS_TYPE);
671678
fprintf(stderr, "LTP_ENABLE_DEBUG Print debug messages (set 1 or y)\n");
672679
fprintf(stderr, "LTP_REPRODUCIBLE_OUTPUT Values 1 or y discard the actual content of the messages printed by the test\n");
680+
fprintf(stderr, "LTP_QUIET Values 1 or y will suppress printing TCONF, TWARN, TINFO, and TDEBUG messages\n");
673681
fprintf(stderr, "LTP_SINGLE_FS_TYPE Specifies filesystem instead all supported (for .all_filesystems)\n");
674682
fprintf(stderr, "LTP_FORCE_SINGLE_FS_TYPE Testing only. The same as LTP_SINGLE_FS_TYPE but ignores test skiplist.\n");
675683
fprintf(stderr, "LTP_TIMEOUT_MUL Timeout multiplier (must be a number >=1)\n");
@@ -1361,6 +1369,7 @@ static void do_setup(int argc, char *argv[])
13611369
{
13621370
char *tdebug_env = getenv("LTP_ENABLE_DEBUG");
13631371
char *reproducible_env = getenv("LTP_REPRODUCIBLE_OUTPUT");
1372+
char *quiet_env = getenv("LTP_QUIET");
13641373

13651374
if (!tst_test)
13661375
tst_brk(TBROK, "No tests to run");
@@ -1391,6 +1400,10 @@ static void do_setup(int argc, char *argv[])
13911400
(!strcmp(reproducible_env, "1") || !strcmp(reproducible_env, "y")))
13921401
reproducible_output = 1;
13931402

1403+
if (quiet_env &&
1404+
(!strcmp(quiet_env, "1") || !strcmp(quiet_env, "y")))
1405+
quiet_output = 1;
1406+
13941407
assert_test_fn();
13951408

13961409
TCID = tcid = get_tcid(argv);

0 commit comments

Comments
 (0)