All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH v2 0/4] Add TDBUG tst_res() flag
@ 2023-12-07 21:27 Petr Vorel
  2023-12-07 21:27 ` [LTP] [PATCH v2 1/4] lib/tests: Add test for testing tst_res() flags Petr Vorel
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Petr Vorel @ 2023-12-07 21:27 UTC (permalink / raw)
  To: ltp

Hi all,

this started as reduce of verbose logs in
testcases/kernel/fs/fsx-linux/fsx-linux.c. I was asked to add support
for debug flags.

TODO: shell API (nfs_lib.sh uses -v for NFS version, it needs to be
renamed.

Changes v1->v2:
* all changed - v1 simply removed few logs from fsx-linux.

Kind regards,
Petr

Petr Vorel (4):
  lib/tests: Add test for testing tst_res() flags
  lib: Add support for TDBUG tst_res() flag
  fsx-linux: Reduce log output with TDBUG
  fsx-linux: Use SAFE_MSYNC()

 doc/C-Test-API.asciidoc                   |  1 +
 include/tst_ansi_color.h                  |  3 ++
 include/tst_common.h                      |  2 +-
 include/tst_res_flags.h                   |  1 +
 include/tst_test.h                        |  5 ++-
 lib/newlib_tests/tst_res_flags.c          | 47 +++++++++++++++++++++++
 lib/tst_ansi_color.c                      |  3 ++
 lib/tst_res.c                             |  9 +++--
 lib/tst_test.c                            | 12 ++++++
 testcases/kernel/fs/fsx-linux/fsx-linux.c | 37 ++++++------------
 10 files changed, 89 insertions(+), 31 deletions(-)
 create mode 100644 lib/newlib_tests/tst_res_flags.c

-- 
2.43.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [LTP] [PATCH v2 1/4] lib/tests: Add test for testing tst_res() flags
  2023-12-07 21:27 [LTP] [PATCH v2 0/4] Add TDBUG tst_res() flag Petr Vorel
@ 2023-12-07 21:27 ` Petr Vorel
  2023-12-07 21:27 ` [LTP] [PATCH v2 2/4] lib: Add support for TDBUG tst_res() flag Petr Vorel
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 10+ messages in thread
From: Petr Vorel @ 2023-12-07 21:27 UTC (permalink / raw)
  To: ltp

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 lib/newlib_tests/tst_res_flags.c | 45 ++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)
 create mode 100644 lib/newlib_tests/tst_res_flags.c

diff --git a/lib/newlib_tests/tst_res_flags.c b/lib/newlib_tests/tst_res_flags.c
new file mode 100644
index 000000000..dc8f27e74
--- /dev/null
+++ b/lib/newlib_tests/tst_res_flags.c
@@ -0,0 +1,45 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2023 Petr Vorel <pvorel@suse.cz>
+ */
+
+/*
+ * Test tst_res() flags.
+ */
+
+#include "tst_test.h"
+
+#define FLAG(x) .flag = x, .str = #x
+static struct tcase {
+	int flag;
+	const char *str;
+} tcases[] = {
+	{FLAG(TPASS)},
+	{FLAG(TFAIL)},
+	{FLAG(TBROK)},
+	{FLAG(TCONF)},
+	{FLAG(TWARN)},
+	{FLAG(TINFO)},
+};
+
+static void do_cleanup(void)
+{
+	tst_brk(TBROK, "TBROK message should be TWARN in cleanup");
+}
+
+static void do_test(unsigned int n)
+{
+	int flag = tcases[n].flag;
+	const char *str = tcases[n].str;
+
+	tst_res(flag, "%s message", str);
+
+	if (flag == TWARN || flag == TINFO)
+		tst_res(TPASS, "%s message is not a result", str);
+}
+
+static struct tst_test test = {
+	.test = do_test,
+	.tcnt = ARRAY_SIZE(tcases),
+	.cleanup = do_cleanup,
+};
-- 
2.43.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [LTP] [PATCH v2 2/4] lib: Add support for TDBUG tst_res() flag
  2023-12-07 21:27 [LTP] [PATCH v2 0/4] Add TDBUG tst_res() flag Petr Vorel
  2023-12-07 21:27 ` [LTP] [PATCH v2 1/4] lib/tests: Add test for testing tst_res() flags Petr Vorel
@ 2023-12-07 21:27 ` Petr Vorel
  2023-12-08  6:50   ` Jan Stancek
  2023-12-07 21:27 ` [LTP] [PATCH v2 3/4] fsx-linux: Reduce log output with TDBUG Petr Vorel
  2023-12-07 21:27 ` [LTP] [PATCH v2 4/4] fsx-linux: Use SAFE_MSYNC() Petr Vorel
  3 siblings, 1 reply; 10+ messages in thread
From: Petr Vorel @ 2023-12-07 21:27 UTC (permalink / raw)
  To: ltp

To print more verbose info. By default it's off, printing enabled with
-v option.

Use unused value 8 (former TRETR).
Assigned color is white.

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 doc/C-Test-API.asciidoc          |  1 +
 include/tst_ansi_color.h         |  3 +++
 include/tst_common.h             |  2 +-
 include/tst_res_flags.h          |  1 +
 include/tst_test.h               |  5 +++--
 lib/newlib_tests/tst_res_flags.c |  6 ++++--
 lib/tst_ansi_color.c             |  3 +++
 lib/tst_res.c                    |  9 ++++++---
 lib/tst_test.c                   | 12 ++++++++++++
 9 files changed, 34 insertions(+), 8 deletions(-)

diff --git a/doc/C-Test-API.asciidoc b/doc/C-Test-API.asciidoc
index dab811564..479179263 100644
--- a/doc/C-Test-API.asciidoc
+++ b/doc/C-Test-API.asciidoc
@@ -227,6 +227,7 @@ Printf-like function to report test result, it's mostly used with ttype:
 | 'TPASS' | Test has passed.
 | 'TFAIL' | Test has failed.
 | 'TINFO' | General message.
+| 'TDBUG' | Debug message (C API only, printed with '-v').
 | 'TWARN' | Something went wrong but we decided to continue. Mostly used in cleanup functions.
 |==============================
 
diff --git a/include/tst_ansi_color.h b/include/tst_ansi_color.h
index 770bf46d9..376d4ad63 100644
--- a/include/tst_ansi_color.h
+++ b/include/tst_ansi_color.h
@@ -4,14 +4,17 @@
 
 #ifndef TST_ANSI_COLOR_H__
 #define TST_ANSI_COLOR_H__
+
 /*
  * NOTE: these colors should match colors defined in tst_flag2color() in
  * testcases/lib/tst_ansi_color.sh
  */
+
 #define ANSI_COLOR_BLUE		"\033[1;34m"
 #define ANSI_COLOR_GREEN	"\033[1;32m"
 #define ANSI_COLOR_MAGENTA	"\033[1;35m"
 #define ANSI_COLOR_RED		"\033[1;31m"
+#define ANSI_COLOR_WHITE	"\033[1;37m"
 #define ANSI_COLOR_YELLOW	"\033[1;33m"
 
 #define ANSI_COLOR_RESET	"\033[0m"
diff --git a/include/tst_common.h b/include/tst_common.h
index 520cca72c..e22aa9a30 100644
--- a/include/tst_common.h
+++ b/include/tst_common.h
@@ -80,7 +80,7 @@
 #define TST_BRK_SUPPORTS_ONLY_TCONF_TBROK(condition) \
 	TST_BUILD_BUG_ON(condition)
 
-#define TST_RES_SUPPORTS_TCONF_TFAIL_TINFO_TPASS_TWARN(condition) \
+#define TST_RES_SUPPORTS_TCONF_TDBUG_TFAIL_TINFO_TPASS_TWARN(condition) \
 	TST_BUILD_BUG_ON(condition)
 
 /* stringification */
diff --git a/include/tst_res_flags.h b/include/tst_res_flags.h
index 8eda2f8b8..327b27fb3 100644
--- a/include/tst_res_flags.h
+++ b/include/tst_res_flags.h
@@ -11,6 +11,7 @@
 #define TFAIL	1	/* Test failed flag */
 #define TBROK	2	/* Test broken flag */
 #define TWARN	4	/* Test warning flag */
+#define TDBUG	8	/* Test debug information flag */
 #define TINFO	16	/* Test information flag */
 #define TCONF	32	/* Test not appropriate for configuration flag */
 #define TTYPE_RESULT(ttype)	((ttype) & TTYPE_MASK)
diff --git a/include/tst_test.h b/include/tst_test.h
index 75c2109b9..e54601285 100644
--- a/include/tst_test.h
+++ b/include/tst_test.h
@@ -54,8 +54,9 @@ void tst_res_(const char *file, const int lineno, int ttype,
 
 #define tst_res(ttype, arg_fmt, ...) \
 	({									\
-		TST_RES_SUPPORTS_TCONF_TFAIL_TINFO_TPASS_TWARN(!((TTYPE_RESULT(ttype) ?: TCONF) & \
-			(TCONF | TFAIL | TINFO | TPASS | TWARN))); 				\
+		TST_RES_SUPPORTS_TCONF_TDBUG_TFAIL_TINFO_TPASS_TWARN(\
+			!((TTYPE_RESULT(ttype) ?: TCONF) & \
+			(TCONF | TDBUG | TFAIL | TINFO | TPASS | TWARN))); 				\
 		tst_res_(__FILE__, __LINE__, (ttype), (arg_fmt), ##__VA_ARGS__);\
 	})
 
diff --git a/lib/newlib_tests/tst_res_flags.c b/lib/newlib_tests/tst_res_flags.c
index dc8f27e74..331f1ae1c 100644
--- a/lib/newlib_tests/tst_res_flags.c
+++ b/lib/newlib_tests/tst_res_flags.c
@@ -13,6 +13,7 @@
 static struct tcase {
 	int flag;
 	const char *str;
+	const char *note;
 } tcases[] = {
 	{FLAG(TPASS)},
 	{FLAG(TFAIL)},
@@ -20,6 +21,7 @@ static struct tcase {
 	{FLAG(TCONF)},
 	{FLAG(TWARN)},
 	{FLAG(TINFO)},
+	{FLAG(TDBUG), " (printed only with -v)"},
 };
 
 static void do_cleanup(void)
@@ -32,9 +34,9 @@ static void do_test(unsigned int n)
 	int flag = tcases[n].flag;
 	const char *str = tcases[n].str;
 
-	tst_res(flag, "%s message", str);
+	tst_res(flag, "%s message%s", str, tcases[n].note ?: "");
 
-	if (flag == TWARN || flag == TINFO)
+	if (flag == TWARN || flag == TINFO || flag == TDBUG)
 		tst_res(TPASS, "%s message is not a result", str);
 }
 
diff --git a/lib/tst_ansi_color.c b/lib/tst_ansi_color.c
index 1c29268f2..9598cafc9 100644
--- a/lib/tst_ansi_color.c
+++ b/lib/tst_ansi_color.c
@@ -31,6 +31,9 @@ char* tst_ttype2color(int ttype)
 	case TINFO:
 		return ANSI_COLOR_BLUE;
 	break;
+	case TDBUG:
+		return ANSI_COLOR_WHITE;
+	break;
 	default:
 		return "";
 	}
diff --git a/lib/tst_res.c b/lib/tst_res.c
index e0896eb05..2e6606088 100644
--- a/lib/tst_res.c
+++ b/lib/tst_res.c
@@ -157,6 +157,7 @@ const char *strttype(int ttype)
 		PAIR(TCONF)
 		PAIR(TWARN)
 		PAIR(TINFO)
+		PAIR(TDBUG)
 	};
 
 	PAIR_LOOKUP(ttype_pairs, TTYPE_RESULT(ttype));
@@ -174,8 +175,10 @@ static void tst_res__(const char *file, const int lineno, int ttype,
 	int len = 0;
 	int ttype_result = TTYPE_RESULT(ttype);
 
-	if (file && (ttype_result != TPASS && ttype_result != TINFO))
+	if (file && (ttype_result != TPASS && ttype_result != TINFO &&
+		     ttype_result != TDBUG))
 		len = sprintf(tmesg, "%s:%d: ", file, lineno);
+
 	EXPAND_VAR_ARGS(tmesg + len, arg_fmt, USERMESG - len);
 
 	/*
@@ -193,7 +196,7 @@ static void tst_res__(const char *file, const int lineno, int ttype,
 	 * Set the test case number and print the results, depending on the
 	 * display type.
 	 */
-	if (ttype_result == TWARN || ttype_result == TINFO) {
+	if (ttype_result == TWARN || ttype_result == TINFO || ttype_result == TDBUG) {
 		tst_print(TCID, 0, ttype, tmesg);
 	} else {
 		if (tst_count < 0)
@@ -411,7 +414,7 @@ void tst_exit(void)
 
 	tst_old_flush();
 
-	T_exitval &= ~TINFO;
+	T_exitval &= ~(TINFO | TDBUG);
 
 	if (T_exitval == TCONF && passed_cnt)
 		T_exitval &= ~TCONF;
diff --git a/lib/tst_test.c b/lib/tst_test.c
index c2f8f503f..04be736ab 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 TDBUG:
+		res = "TDBUG";
+	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 == TDBUG && !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"},
+	{"v",  "-v       Prints debug information"},
 	{"V",  "-V       Prints LTP version"},
 	{"C:", "-C ARG   Run child process with ARG arguments (used internally)"},
 };
@@ -692,6 +700,10 @@ static void parse_opts(int argc, char *argv[])
 			else
 				duration = SAFE_STRTOF(optarg, 0.1, HUGE_VALF);
 		break;
+		case 'v':
+			tdebug = 1;
+			tst_res(TINFO, "Run with -v, printing debug info");
+		break;
 		case 'V':
 			fprintf(stderr, "LTP version: " LTP_VERSION "\n");
 			exit(0);
-- 
2.43.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [LTP] [PATCH v2 3/4] fsx-linux: Reduce log output with TDBUG
  2023-12-07 21:27 [LTP] [PATCH v2 0/4] Add TDBUG tst_res() flag Petr Vorel
  2023-12-07 21:27 ` [LTP] [PATCH v2 1/4] lib/tests: Add test for testing tst_res() flags Petr Vorel
  2023-12-07 21:27 ` [LTP] [PATCH v2 2/4] lib: Add support for TDBUG tst_res() flag Petr Vorel
@ 2023-12-07 21:27 ` Petr Vorel
  2023-12-07 21:27 ` [LTP] [PATCH v2 4/4] fsx-linux: Use SAFE_MSYNC() Petr Vorel
  3 siblings, 0 replies; 10+ messages in thread
From: Petr Vorel @ 2023-12-07 21:27 UTC (permalink / raw)
  To: ltp

Log output is very verbose thus silent with changing most verbose
TINFO messages to TDBUG. Given how many times the test tries it's a
significant time spent for printing output. This change also helps to
run on slower SUT without need to set LTP_TIMEOUT_MUL environment
variable.

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 testcases/kernel/fs/fsx-linux/fsx-linux.c | 33 ++++++++---------------
 1 file changed, 11 insertions(+), 22 deletions(-)

diff --git a/testcases/kernel/fs/fsx-linux/fsx-linux.c b/testcases/kernel/fs/fsx-linux/fsx-linux.c
index 112c21f85..5b099c8a0 100644
--- a/testcases/kernel/fs/fsx-linux/fsx-linux.c
+++ b/testcases/kernel/fs/fsx-linux/fsx-linux.c
@@ -98,8 +98,7 @@ static void update_file_size(struct file_pos_t const *pos)
 {
 	if (pos->offset + pos->size > file_size) {
 		file_size = pos->offset + pos->size;
-
-		tst_res(TINFO, "File size changed: %llu", file_size);
+		tst_res(TDBUG, "File size changed: %llu", file_size);
 	}
 }
 
@@ -114,8 +113,7 @@ static int memory_compare(
 	for (long long i = 0; i < size; i++) {
 		diff = a[i] - b[i];
 		if (diff) {
-			tst_res(TINFO,
-				"File memory differs at offset=%llu ('%c' != '%c')",
+			tst_res(TDBUG, "File memory differs at offset=%llu ('%c' != '%c')",
 				offset + i, a[i], b[i]);
 			break;
 		}
@@ -135,10 +133,8 @@ static int op_read(void)
 
 	op_file_position(file_size, op_read_align, &pos);
 
-	tst_res(TINFO,
-		"Reading at offset=%llu, size=%llu",
-		pos.offset,
-		pos.size);
+	tst_res(TDBUG, "Reading at offset=%llu, size=%llu",
+		pos.offset, pos.size);
 
 	memset(temp_buff, 0, file_max_size);
 
@@ -176,10 +172,8 @@ static int op_write(void)
 		temp_buff[i] = data;
 	}
 
-	tst_res(TINFO,
-		"Writing at offset=%llu, size=%llu",
-		pos.offset,
-		pos.size);
+	tst_res(TDBUG, "Writing at offset=%llu, size=%llu",
+		pos.offset, pos.size);
 
 	SAFE_LSEEK(file_desc, (off_t)pos.offset, SEEK_SET);
 	SAFE_WRITE(SAFE_WRITE_ALL, file_desc, temp_buff, pos.size);
@@ -194,10 +188,9 @@ static int op_truncate(void)
 	struct file_pos_t pos;
 
 	op_file_position(file_max_size, op_trunc_align, &pos);
-
 	file_size = pos.offset + pos.size;
 
-	tst_res(TINFO, "Truncating to %llu", file_size);
+	tst_res(TDBUG, "Truncating to %llu", file_size);
 
 	SAFE_FTRUNCATE(file_desc, file_size);
 	memset(file_buff + file_size, 0, file_max_size - file_size);
@@ -218,10 +211,8 @@ static int op_map_read(void)
 	op_file_position(file_size, op_read_align, &pos);
 	op_align_pages(&pos);
 
-	tst_res(TINFO,
-		"Map reading at offset=%llu, size=%llu",
-		pos.offset,
-		pos.size);
+	tst_res(TDBUG, "Map reading at offset=%llu, size=%llu",
+		pos.offset, pos.size);
 
 	addr = SAFE_MMAP(
 		0, pos.size,
@@ -261,10 +252,8 @@ static int op_map_write(void)
 	if (file_size < pos.offset + pos.size)
 		SAFE_FTRUNCATE(file_desc, pos.offset + pos.size);
 
-	tst_res(TINFO,
-		"Map writing at offset=%llu, size=%llu",
-		pos.offset,
-		pos.size);
+	tst_res(TDBUG, "Map writing at offset=%llu, size=%llu",
+		pos.offset, pos.size);
 
 	for (long long i = 0; i < pos.size; i++)
 		file_buff[pos.offset + i] = random() % 10 + 'l';
-- 
2.43.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [LTP] [PATCH v2 4/4] fsx-linux: Use SAFE_MSYNC()
  2023-12-07 21:27 [LTP] [PATCH v2 0/4] Add TDBUG tst_res() flag Petr Vorel
                   ` (2 preceding siblings ...)
  2023-12-07 21:27 ` [LTP] [PATCH v2 3/4] fsx-linux: Reduce log output with TDBUG Petr Vorel
@ 2023-12-07 21:27 ` Petr Vorel
  3 siblings, 0 replies; 10+ messages in thread
From: Petr Vorel @ 2023-12-07 21:27 UTC (permalink / raw)
  To: ltp

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 testcases/kernel/fs/fsx-linux/fsx-linux.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/testcases/kernel/fs/fsx-linux/fsx-linux.c b/testcases/kernel/fs/fsx-linux/fsx-linux.c
index 5b099c8a0..fed79f956 100644
--- a/testcases/kernel/fs/fsx-linux/fsx-linux.c
+++ b/testcases/kernel/fs/fsx-linux/fsx-linux.c
@@ -266,10 +266,8 @@ static int op_map_write(void)
 		(off_t)pos.offset);
 
 	memcpy(addr, file_buff + pos.offset, pos.size);
-	msync(addr, pos.size, MS_SYNC);
-
+	SAFE_MSYNC(addr, pos.size, MS_SYNC);
 	SAFE_MUNMAP(addr, pos.size);
-
 	update_file_size(&pos);
 
 	return 1;
-- 
2.43.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [LTP] [PATCH v2 2/4] lib: Add support for TDBUG tst_res() flag
  2023-12-07 21:27 ` [LTP] [PATCH v2 2/4] lib: Add support for TDBUG tst_res() flag Petr Vorel
@ 2023-12-08  6:50   ` Jan Stancek
  2023-12-08  7:43     ` Petr Vorel
  2023-12-08  8:17     ` Cyril Hrubis
  0 siblings, 2 replies; 10+ messages in thread
From: Jan Stancek @ 2023-12-08  6:50 UTC (permalink / raw)
  To: Petr Vorel; +Cc: ltp

On Thu, Dec 7, 2023 at 10:27 PM Petr Vorel <pvorel@suse.cz> wrote:
>
> To print more verbose info. By default it's off, printing enabled with
> -v option.
>
> Use unused value 8 (former TRETR).
> Assigned color is white.
>
> Signed-off-by: Petr Vorel <pvorel@suse.cz>
> ---
>  doc/C-Test-API.asciidoc          |  1 +
>  include/tst_ansi_color.h         |  3 +++
>  include/tst_common.h             |  2 +-
>  include/tst_res_flags.h          |  1 +
>  include/tst_test.h               |  5 +++--
>  lib/newlib_tests/tst_res_flags.c |  6 ++++--
>  lib/tst_ansi_color.c             |  3 +++
>  lib/tst_res.c                    |  9 ++++++---
>  lib/tst_test.c                   | 12 ++++++++++++
>  9 files changed, 34 insertions(+), 8 deletions(-)
>
> diff --git a/doc/C-Test-API.asciidoc b/doc/C-Test-API.asciidoc
> index dab811564..479179263 100644
> --- a/doc/C-Test-API.asciidoc
> +++ b/doc/C-Test-API.asciidoc
> @@ -227,6 +227,7 @@ Printf-like function to report test result, it's mostly used with ttype:
>  | 'TPASS' | Test has passed.
>  | 'TFAIL' | Test has failed.
>  | 'TINFO' | General message.
> +| 'TDBUG' | Debug message (C API only, printed with '-v').

My first impression was it's some kind of new BUG type :-)
I'd suggest making it TDEBUG or TDBG.

>  | 'TWARN' | Something went wrong but we decided to continue. Mostly used in cleanup functions.
>  |==============================
>
> diff --git a/include/tst_ansi_color.h b/include/tst_ansi_color.h
> index 770bf46d9..376d4ad63 100644
> --- a/include/tst_ansi_color.h
> +++ b/include/tst_ansi_color.h
> @@ -4,14 +4,17 @@
>
>  #ifndef TST_ANSI_COLOR_H__
>  #define TST_ANSI_COLOR_H__
> +
>  /*
>   * NOTE: these colors should match colors defined in tst_flag2color() in
>   * testcases/lib/tst_ansi_color.sh
>   */
> +
>  #define ANSI_COLOR_BLUE                "\033[1;34m"
>  #define ANSI_COLOR_GREEN       "\033[1;32m"
>  #define ANSI_COLOR_MAGENTA     "\033[1;35m"
>  #define ANSI_COLOR_RED         "\033[1;31m"
> +#define ANSI_COLOR_WHITE       "\033[1;37m"
>  #define ANSI_COLOR_YELLOW      "\033[1;33m"
>
>  #define ANSI_COLOR_RESET       "\033[0m"
> diff --git a/include/tst_common.h b/include/tst_common.h
> index 520cca72c..e22aa9a30 100644
> --- a/include/tst_common.h
> +++ b/include/tst_common.h
> @@ -80,7 +80,7 @@
>  #define TST_BRK_SUPPORTS_ONLY_TCONF_TBROK(condition) \
>         TST_BUILD_BUG_ON(condition)
>
> -#define TST_RES_SUPPORTS_TCONF_TFAIL_TINFO_TPASS_TWARN(condition) \
> +#define TST_RES_SUPPORTS_TCONF_TDBUG_TFAIL_TINFO_TPASS_TWARN(condition) \
>         TST_BUILD_BUG_ON(condition)
>
>  /* stringification */
> diff --git a/include/tst_res_flags.h b/include/tst_res_flags.h
> index 8eda2f8b8..327b27fb3 100644
> --- a/include/tst_res_flags.h
> +++ b/include/tst_res_flags.h
> @@ -11,6 +11,7 @@
>  #define TFAIL  1       /* Test failed flag */
>  #define TBROK  2       /* Test broken flag */
>  #define TWARN  4       /* Test warning flag */
> +#define TDBUG  8       /* Test debug information flag */
>  #define TINFO  16      /* Test information flag */
>  #define TCONF  32      /* Test not appropriate for configuration flag */
>  #define TTYPE_RESULT(ttype)    ((ttype) & TTYPE_MASK)
> diff --git a/include/tst_test.h b/include/tst_test.h
> index 75c2109b9..e54601285 100644
> --- a/include/tst_test.h
> +++ b/include/tst_test.h
> @@ -54,8 +54,9 @@ void tst_res_(const char *file, const int lineno, int ttype,
>
>  #define tst_res(ttype, arg_fmt, ...) \
>         ({                                                                      \
> -               TST_RES_SUPPORTS_TCONF_TFAIL_TINFO_TPASS_TWARN(!((TTYPE_RESULT(ttype) ?: TCONF) & \
> -                       (TCONF | TFAIL | TINFO | TPASS | TWARN)));                              \
> +               TST_RES_SUPPORTS_TCONF_TDBUG_TFAIL_TINFO_TPASS_TWARN(\
> +                       !((TTYPE_RESULT(ttype) ?: TCONF) & \
> +                       (TCONF | TDBUG | TFAIL | TINFO | TPASS | TWARN)));                              \
>                 tst_res_(__FILE__, __LINE__, (ttype), (arg_fmt), ##__VA_ARGS__);\
>         })
>
> diff --git a/lib/newlib_tests/tst_res_flags.c b/lib/newlib_tests/tst_res_flags.c
> index dc8f27e74..331f1ae1c 100644
> --- a/lib/newlib_tests/tst_res_flags.c
> +++ b/lib/newlib_tests/tst_res_flags.c
> @@ -13,6 +13,7 @@
>  static struct tcase {
>         int flag;
>         const char *str;
> +       const char *note;
>  } tcases[] = {
>         {FLAG(TPASS)},
>         {FLAG(TFAIL)},
> @@ -20,6 +21,7 @@ static struct tcase {
>         {FLAG(TCONF)},
>         {FLAG(TWARN)},
>         {FLAG(TINFO)},
> +       {FLAG(TDBUG), " (printed only with -v)"},
>  };
>
>  static void do_cleanup(void)
> @@ -32,9 +34,9 @@ static void do_test(unsigned int n)
>         int flag = tcases[n].flag;
>         const char *str = tcases[n].str;
>
> -       tst_res(flag, "%s message", str);
> +       tst_res(flag, "%s message%s", str, tcases[n].note ?: "");
>
> -       if (flag == TWARN || flag == TINFO)
> +       if (flag == TWARN || flag == TINFO || flag == TDBUG)
>                 tst_res(TPASS, "%s message is not a result", str);
>  }
>
> diff --git a/lib/tst_ansi_color.c b/lib/tst_ansi_color.c
> index 1c29268f2..9598cafc9 100644
> --- a/lib/tst_ansi_color.c
> +++ b/lib/tst_ansi_color.c
> @@ -31,6 +31,9 @@ char* tst_ttype2color(int ttype)
>         case TINFO:
>                 return ANSI_COLOR_BLUE;
>         break;
> +       case TDBUG:
> +               return ANSI_COLOR_WHITE;
> +       break;
>         default:
>                 return "";
>         }
> diff --git a/lib/tst_res.c b/lib/tst_res.c
> index e0896eb05..2e6606088 100644
> --- a/lib/tst_res.c
> +++ b/lib/tst_res.c
> @@ -157,6 +157,7 @@ const char *strttype(int ttype)
>                 PAIR(TCONF)
>                 PAIR(TWARN)
>                 PAIR(TINFO)
> +               PAIR(TDBUG)
>         };
>
>         PAIR_LOOKUP(ttype_pairs, TTYPE_RESULT(ttype));
> @@ -174,8 +175,10 @@ static void tst_res__(const char *file, const int lineno, int ttype,
>         int len = 0;
>         int ttype_result = TTYPE_RESULT(ttype);
>
> -       if (file && (ttype_result != TPASS && ttype_result != TINFO))
> +       if (file && (ttype_result != TPASS && ttype_result != TINFO &&
> +                    ttype_result != TDBUG))
>                 len = sprintf(tmesg, "%s:%d: ", file, lineno);
> +
>         EXPAND_VAR_ARGS(tmesg + len, arg_fmt, USERMESG - len);
>
>         /*
> @@ -193,7 +196,7 @@ static void tst_res__(const char *file, const int lineno, int ttype,
>          * Set the test case number and print the results, depending on the
>          * display type.
>          */
> -       if (ttype_result == TWARN || ttype_result == TINFO) {
> +       if (ttype_result == TWARN || ttype_result == TINFO || ttype_result == TDBUG) {
>                 tst_print(TCID, 0, ttype, tmesg);
>         } else {
>                 if (tst_count < 0)
> @@ -411,7 +414,7 @@ void tst_exit(void)
>
>         tst_old_flush();
>
> -       T_exitval &= ~TINFO;
> +       T_exitval &= ~(TINFO | TDBUG);
>
>         if (T_exitval == TCONF && passed_cnt)
>                 T_exitval &= ~TCONF;
> diff --git a/lib/tst_test.c b/lib/tst_test.c
> index c2f8f503f..04be736ab 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 TDBUG:
> +               res = "TDBUG";
> +       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 == TDBUG && !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"},
> +       {"v",  "-v       Prints debug information"},
>         {"V",  "-V       Prints LTP version"},
>         {"C:", "-C ARG   Run child process with ARG arguments (used internally)"},
>  };
> @@ -692,6 +700,10 @@ static void parse_opts(int argc, char *argv[])
>                         else
>                                 duration = SAFE_STRTOF(optarg, 0.1, HUGE_VALF);
>                 break;
> +               case 'v':
> +                       tdebug = 1;
> +                       tst_res(TINFO, "Run with -v, printing debug info");
> +               break;
>                 case 'V':
>                         fprintf(stderr, "LTP version: " LTP_VERSION "\n");
>                         exit(0);
> --
> 2.43.0
>


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [LTP] [PATCH v2 2/4] lib: Add support for TDBUG tst_res() flag
  2023-12-08  6:50   ` Jan Stancek
@ 2023-12-08  7:43     ` Petr Vorel
  2023-12-08  8:17     ` Cyril Hrubis
  1 sibling, 0 replies; 10+ messages in thread
From: Petr Vorel @ 2023-12-08  7:43 UTC (permalink / raw)
  To: Jan Stancek; +Cc: ltp

Hi Jan, all,

> > diff --git a/doc/C-Test-API.asciidoc b/doc/C-Test-API.asciidoc
> > index dab811564..479179263 100644
> > --- a/doc/C-Test-API.asciidoc
> > +++ b/doc/C-Test-API.asciidoc
> > @@ -227,6 +227,7 @@ Printf-like function to report test result, it's mostly used with ttype:
> >  | 'TPASS' | Test has passed.
> >  | 'TFAIL' | Test has failed.
> >  | 'TINFO' | General message.
> > +| 'TDBUG' | Debug message (C API only, printed with '-v').

> My first impression was it's some kind of new BUG type :-)
> I'd suggest making it TDEBUG or TDBG.

Agree it looks strange. We wanted to keep 5 letters.
Therefore maybe TVERB (in discussion from v1).

If we agree to use more, TDEBUG or TVERBOSE would be better.

Kind regards,
Petr

> >  | 'TWARN' | Something went wrong but we decided to continue. Mostly used in cleanup functions.
> >  |==============================

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [LTP] [PATCH v2 2/4] lib: Add support for TDBUG tst_res() flag
  2023-12-08  6:50   ` Jan Stancek
  2023-12-08  7:43     ` Petr Vorel
@ 2023-12-08  8:17     ` Cyril Hrubis
  2023-12-08 13:53       ` Petr Vorel
  1 sibling, 1 reply; 10+ messages in thread
From: Cyril Hrubis @ 2023-12-08  8:17 UTC (permalink / raw)
  To: Jan Stancek; +Cc: ltp

Hi!
> My first impression was it's some kind of new BUG type :-)
> I'd suggest making it TDEBUG or TDBG.

Naming things is hard, I suppose that the least confusing is probably
the full spelling, i.e. TDEBUG. I suppose that having it one letter
longer is not a big deal.

-- 
Cyril Hrubis
chrubis@suse.cz

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [LTP] [PATCH v2 2/4] lib: Add support for TDBUG tst_res() flag
  2023-12-08  8:17     ` Cyril Hrubis
@ 2023-12-08 13:53       ` Petr Vorel
  2023-12-08 13:54         ` Andrea Cervesato via ltp
  0 siblings, 1 reply; 10+ messages in thread
From: Petr Vorel @ 2023-12-08 13:53 UTC (permalink / raw)
  To: Cyril Hrubis; +Cc: ltp

Hi Cyril, all,

> Hi!
> > My first impression was it's some kind of new BUG type :-)
> > I'd suggest making it TDEBUG or TDBG.

> Naming things is hard, I suppose that the least confusing is probably
> the full spelling, i.e. TDEBUG. I suppose that having it one letter
> longer is not a big deal.

OK, I'll wait for other feedback before sending v3 with
s/TDBUG/TDEBUG/

Kind regards,
Petr

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [LTP] [PATCH v2 2/4] lib: Add support for TDBUG tst_res() flag
  2023-12-08 13:53       ` Petr Vorel
@ 2023-12-08 13:54         ` Andrea Cervesato via ltp
  0 siblings, 0 replies; 10+ messages in thread
From: Andrea Cervesato via ltp @ 2023-12-08 13:54 UTC (permalink / raw)
  To: Petr Vorel, Cyril Hrubis; +Cc: ltp

Hi!

On 12/8/23 14:53, Petr Vorel wrote:
> Hi Cyril, all,
>
>> Hi!
>>> My first impression was it's some kind of new BUG type :-)
>>> I'd suggest making it TDEBUG or TDBG.
>> Naming things is hard, I suppose that the least confusing is probably
>> the full spelling, i.e. TDEBUG. I suppose that having it one letter
>> longer is not a big deal.
> OK, I'll wait for other feedback before sending v3 with
> s/TDBUG/TDEBUG/
>
> Kind regards,
> Petr

TDEBUG sounds good to me. Also TVERB was not so bad, but I prefer the 
TDEBUG notation.

Andrea


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2023-12-08 13:54 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-07 21:27 [LTP] [PATCH v2 0/4] Add TDBUG tst_res() flag Petr Vorel
2023-12-07 21:27 ` [LTP] [PATCH v2 1/4] lib/tests: Add test for testing tst_res() flags Petr Vorel
2023-12-07 21:27 ` [LTP] [PATCH v2 2/4] lib: Add support for TDBUG tst_res() flag Petr Vorel
2023-12-08  6:50   ` Jan Stancek
2023-12-08  7:43     ` Petr Vorel
2023-12-08  8:17     ` Cyril Hrubis
2023-12-08 13:53       ` Petr Vorel
2023-12-08 13:54         ` Andrea Cervesato via ltp
2023-12-07 21:27 ` [LTP] [PATCH v2 3/4] fsx-linux: Reduce log output with TDBUG Petr Vorel
2023-12-07 21:27 ` [LTP] [PATCH v2 4/4] fsx-linux: Use SAFE_MSYNC() Petr Vorel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.