public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH v3 0/3] Add TDEBUG tst_res() flag
@ 2023-12-11 16:18 Petr Vorel
  2023-12-11 16:18 ` [LTP] [PATCH v3 1/3] lib/tests: Add test for testing tst_res() flags Petr Vorel
                   ` (3 more replies)
  0 siblings, 4 replies; 18+ messages in thread
From: Petr Vorel @ 2023-12-11 16:18 UTC (permalink / raw)
  To: ltp; +Cc: Richard Palethorpe

Hi,

changes v1->v2:
* %s/TDEBUG/TDEBUG/g (Cyril).
* Merged the latest patch and rebased before sending.

Kind regards,
Petr

Petr Vorel (3):
  lib/tests: Add test for testing tst_res() flags
  lib: Add support for TDEBUG tst_res() flag
  fsx-linux: Reduce log output with TDEBUG

 doc/C-Test-API.asciidoc                   |  9 +++--
 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 | 33 ++++++----------
 10 files changed, 92 insertions(+), 32 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] 18+ messages in thread

* [LTP] [PATCH v3 1/3] lib/tests: Add test for testing tst_res() flags
  2023-12-11 16:18 [LTP] [PATCH v3 0/3] Add TDEBUG tst_res() flag Petr Vorel
@ 2023-12-11 16:18 ` Petr Vorel
  2023-12-13 19:04   ` Cyril Hrubis
  2023-12-11 16:18 ` [LTP] [PATCH v3 2/3] lib: Add support for TDEBUG tst_res() flag Petr Vorel
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 18+ messages in thread
From: Petr Vorel @ 2023-12-11 16:18 UTC (permalink / raw)
  To: ltp; +Cc: Richard Palethorpe

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] 18+ messages in thread

* [LTP] [PATCH v3 2/3] lib: Add support for TDEBUG tst_res() flag
  2023-12-11 16:18 [LTP] [PATCH v3 0/3] Add TDEBUG tst_res() flag Petr Vorel
  2023-12-11 16:18 ` [LTP] [PATCH v3 1/3] lib/tests: Add test for testing tst_res() flags Petr Vorel
@ 2023-12-11 16:18 ` Petr Vorel
  2023-12-13 19:15   ` Cyril Hrubis
  2023-12-11 16:18 ` [LTP] [PATCH v3 3/3] fsx-linux: Reduce log output with TDEBUG Petr Vorel
  2023-12-11 16:27 ` [LTP] [PATCH v3 0/3] Add TDEBUG tst_res() flag Jan Stancek
  3 siblings, 1 reply; 18+ messages in thread
From: Petr Vorel @ 2023-12-11 16:18 UTC (permalink / raw)
  To: ltp; +Cc: Richard Palethorpe

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          |  9 +++++----
 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, 38 insertions(+), 12 deletions(-)

diff --git a/doc/C-Test-API.asciidoc b/doc/C-Test-API.asciidoc
index dab811564..19dcc37b7 100644
--- a/doc/C-Test-API.asciidoc
+++ b/doc/C-Test-API.asciidoc
@@ -224,10 +224,11 @@ void tst_res(int ttype, char *arg_fmt, ...);
 Printf-like function to report test result, it's mostly used with ttype:
 
 |==============================
-| 'TPASS' | Test has passed.
-| 'TFAIL' | Test has failed.
-| 'TINFO' | General message.
-| 'TWARN' | Something went wrong but we decided to continue. Mostly used in cleanup functions.
+| 'TPASS'  | Test has passed.
+| 'TFAIL'  | Test has failed.
+| 'TINFO'  | General message.
+| 'TDEBUG' | Debug message (C API only, printed with '-v').
+| 'TWARN'  | Something went wrong but we decided to continue. Mostly used in cleanup functions.
 |==============================
 
 The 'ttype' can be combined bitwise with 'TERRNO' or 'TTERRNO' to print
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..b14bbae04 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_TDEBUG_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..872352144 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 TDEBUG	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..0c3171e5b 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_TDEBUG_TFAIL_TINFO_TPASS_TWARN(\
+			!((TTYPE_RESULT(ttype) ?: TCONF) & \
+			(TCONF | TDEBUG | 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..318d0d9eb 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(TDEBUG), " (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 == TDEBUG)
 		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..98041c0af 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 TDEBUG:
+		return ANSI_COLOR_WHITE;
+	break;
 	default:
 		return "";
 	}
diff --git a/lib/tst_res.c b/lib/tst_res.c
index e0896eb05..5125001f7 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(TDEBUG)
 	};
 
 	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 != TDEBUG))
 		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 == TDEBUG) {
 		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 | TDEBUG);
 
 	if (T_exitval == TCONF && passed_cnt)
 		T_exitval &= ~TCONF;
diff --git a/lib/tst_test.c b/lib/tst_test.c
index c2f8f503f..f5c87ed9e 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"},
+	{"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] 18+ messages in thread

* [LTP] [PATCH v3 3/3] fsx-linux: Reduce log output with TDEBUG
  2023-12-11 16:18 [LTP] [PATCH v3 0/3] Add TDEBUG tst_res() flag Petr Vorel
  2023-12-11 16:18 ` [LTP] [PATCH v3 1/3] lib/tests: Add test for testing tst_res() flags Petr Vorel
  2023-12-11 16:18 ` [LTP] [PATCH v3 2/3] lib: Add support for TDEBUG tst_res() flag Petr Vorel
@ 2023-12-11 16:18 ` Petr Vorel
  2023-12-12 10:08   ` Andrea Cervesato via ltp
  2023-12-11 16:27 ` [LTP] [PATCH v3 0/3] Add TDEBUG tst_res() flag Jan Stancek
  3 siblings, 1 reply; 18+ messages in thread
From: Petr Vorel @ 2023-12-11 16:18 UTC (permalink / raw)
  To: ltp; +Cc: Richard Palethorpe

Log output is very verbose thus silent with changing most verbose
TINFO messages to TDEBUG. 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 23e608189..658fc99c3 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(TDEBUG, "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(TDEBUG, "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(TDEBUG, "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(TDEBUG, "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(TDEBUG, "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(TDEBUG, "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(TDEBUG, "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] 18+ messages in thread

* Re: [LTP] [PATCH v3 0/3] Add TDEBUG tst_res() flag
  2023-12-11 16:18 [LTP] [PATCH v3 0/3] Add TDEBUG tst_res() flag Petr Vorel
                   ` (2 preceding siblings ...)
  2023-12-11 16:18 ` [LTP] [PATCH v3 3/3] fsx-linux: Reduce log output with TDEBUG Petr Vorel
@ 2023-12-11 16:27 ` Jan Stancek
  3 siblings, 0 replies; 18+ messages in thread
From: Jan Stancek @ 2023-12-11 16:27 UTC (permalink / raw)
  To: Petr Vorel; +Cc: Richard Palethorpe, ltp

On Mon, Dec 11, 2023 at 5:19 PM Petr Vorel <pvorel@suse.cz> wrote:
>
> Hi,
>
> changes v1->v2:
> * %s/TDEBUG/TDEBUG/g (Cyril).
> * Merged the latest patch and rebased before sending.

Acked-by: Jan Stancek <jstancek@redhat.com>

>
> Kind regards,
> Petr
>
> Petr Vorel (3):
>   lib/tests: Add test for testing tst_res() flags
>   lib: Add support for TDEBUG tst_res() flag
>   fsx-linux: Reduce log output with TDEBUG
>
>  doc/C-Test-API.asciidoc                   |  9 +++--
>  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 | 33 ++++++----------
>  10 files changed, 92 insertions(+), 32 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] 18+ messages in thread

* Re: [LTP] [PATCH v3 3/3] fsx-linux: Reduce log output with TDEBUG
  2023-12-11 16:18 ` [LTP] [PATCH v3 3/3] fsx-linux: Reduce log output with TDEBUG Petr Vorel
@ 2023-12-12 10:08   ` Andrea Cervesato via ltp
  2023-12-13 19:18     ` Cyril Hrubis
  0 siblings, 1 reply; 18+ messages in thread
From: Andrea Cervesato via ltp @ 2023-12-12 10:08 UTC (permalink / raw)
  To: ltp

Hi!

Acked-by: Andrea Cervesato <andrea.cervesato@suse.com>

Andrea

On 12/11/23 17:18, Petr Vorel wrote:
> Log output is very verbose thus silent with changing most verbose
> TINFO messages to TDEBUG. 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 23e608189..658fc99c3 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(TDEBUG, "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(TDEBUG, "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(TDEBUG, "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(TDEBUG, "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(TDEBUG, "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(TDEBUG, "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(TDEBUG, "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';



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

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

* Re: [LTP] [PATCH v3 1/3] lib/tests: Add test for testing tst_res() flags
  2023-12-11 16:18 ` [LTP] [PATCH v3 1/3] lib/tests: Add test for testing tst_res() flags Petr Vorel
@ 2023-12-13 19:04   ` Cyril Hrubis
  2023-12-13 23:40     ` Petr Vorel
  0 siblings, 1 reply; 18+ messages in thread
From: Cyril Hrubis @ 2023-12-13 19:04 UTC (permalink / raw)
  To: Petr Vorel; +Cc: Richard Palethorpe, ltp

Hi!
> +#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);

Maybe it would make sense the loop over the flags here instead, so that
we don't have to produce second TPASS message.

> +}
> +
> +static struct tst_test test = {
> +	.test = do_test,
> +	.tcnt = ARRAY_SIZE(tcases),
> +	.cleanup = do_cleanup,
> +};
> -- 
> 2.43.0
> 

-- 
Cyril Hrubis
chrubis@suse.cz

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

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

* Re: [LTP] [PATCH v3 2/3] lib: Add support for TDEBUG tst_res() flag
  2023-12-11 16:18 ` [LTP] [PATCH v3 2/3] lib: Add support for TDEBUG tst_res() flag Petr Vorel
@ 2023-12-13 19:15   ` Cyril Hrubis
  2023-12-13 23:11     ` Petr Vorel
  2023-12-13 23:48     ` Petr Vorel
  0 siblings, 2 replies; 18+ messages in thread
From: Cyril Hrubis @ 2023-12-13 19:15 UTC (permalink / raw)
  To: Petr Vorel; +Cc: Richard Palethorpe, ltp

Hi!
> diff --git a/lib/tst_res.c b/lib/tst_res.c
> index e0896eb05..5125001f7 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(TDEBUG)
>  	};
>  
>  	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 != TDEBUG))
>  		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 == TDEBUG) {
>  		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 | TDEBUG);
>  
>  	if (T_exitval == TCONF && passed_cnt)
>  		T_exitval &= ~TCONF;

I woudln't add it to the old library. None of the old tests uses it so
there is no reason to export it there.

I suppose that we just abort if we get this flag in old library:

diff --git a/lib/tst_res.c b/lib/tst_res.c
index e0896eb05..e87918ed1 100644
--- a/lib/tst_res.c
+++ b/lib/tst_res.c
@@ -174,6 +174,11 @@ static void tst_res__(const char *file, const int lineno, int ttype,
        int len = 0;
        int ttype_result = TTYPE_RESULT(ttype);

+       if (ttype_result == TDEBUG) {
+               printf("%s: %i: TDEBUG is not supported\n", __func__, __LINE__);
+               abort();
+       }
+

What do you think?

> diff --git a/lib/tst_test.c b/lib/tst_test.c
> index c2f8f503f..f5c87ed9e 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"},
> +	{"v",  "-v       Prints debug information"},

Maybe thi should now be called -d since we call it TDEBUG and that will
avoid having a bit confusing parameters with both -v and -V used.

>  	{"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");
                                           ^
					   Maybe just "Enabling debug info"
> +		break;
>  		case 'V':
>  			fprintf(stderr, "LTP version: " LTP_VERSION "\n");
>  			exit(0);
> -- 
> 2.43.0
> 

-- 
Cyril Hrubis
chrubis@suse.cz

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

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

* Re: [LTP] [PATCH v3 3/3] fsx-linux: Reduce log output with TDEBUG
  2023-12-12 10:08   ` Andrea Cervesato via ltp
@ 2023-12-13 19:18     ` Cyril Hrubis
  0 siblings, 0 replies; 18+ messages in thread
From: Cyril Hrubis @ 2023-12-13 19:18 UTC (permalink / raw)
  To: Andrea Cervesato; +Cc: ltp

Hi!
Reviewed-by: Cyril Hrubis <chrubis@suse.cz>

-- 
Cyril Hrubis
chrubis@suse.cz

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

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

* Re: [LTP] [PATCH v3 2/3] lib: Add support for TDEBUG tst_res() flag
  2023-12-13 19:15   ` Cyril Hrubis
@ 2023-12-13 23:11     ` Petr Vorel
  2023-12-14  9:41       ` Cyril Hrubis
  2023-12-13 23:48     ` Petr Vorel
  1 sibling, 1 reply; 18+ messages in thread
From: Petr Vorel @ 2023-12-13 23:11 UTC (permalink / raw)
  To: Cyril Hrubis; +Cc: Richard Palethorpe, ltp

> Hi!
> > diff --git a/lib/tst_res.c b/lib/tst_res.c
> > index e0896eb05..5125001f7 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(TDEBUG)
> >  	};

> >  	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 != TDEBUG))
> >  		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 == TDEBUG) {
> >  		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 | TDEBUG);

> >  	if (T_exitval == TCONF && passed_cnt)
> >  		T_exitval &= ~TCONF;

> I woudln't add it to the old library. None of the old tests uses it so
> there is no reason to export it there.

> I suppose that we just abort if we get this flag in old library:

> diff --git a/lib/tst_res.c b/lib/tst_res.c
> index e0896eb05..e87918ed1 100644
> --- a/lib/tst_res.c
> +++ b/lib/tst_res.c
> @@ -174,6 +174,11 @@ static void tst_res__(const char *file, const int lineno, int ttype,
>         int len = 0;
>         int ttype_result = TTYPE_RESULT(ttype);

> +       if (ttype_result == TDEBUG) {
> +               printf("%s: %i: TDEBUG is not supported\n", __func__, __LINE__);
> +               abort();
> +       }
> +

> What do you think?

Makes sense, thanks!

> > diff --git a/lib/tst_test.c b/lib/tst_test.c
> > index c2f8f503f..f5c87ed9e 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"},
> > +	{"v",  "-v       Prints debug information"},

> Maybe this should now be called -d since we call it TDEBUG and that will
> avoid having a bit confusing parameters with both -v and -V used.

Yes, I didn't like the flag name does not correspond to the option.
I previously wrote that more tests use -d for something else:

$ git grep '"d:"' $(git grep -l tst_option)
testcases/kernel/fs/read_all/read_all.c:                {"d:", &root_dir,
testcases/kernel/io/ltp-aiodio/aio-stress.c:            { "d:", &str_depth, "Number of pending aio requests for each file (default 64)" },
testcases/network/netstress/netstress.c:                {"d:", &rpath, "Path to file where result is saved"},
testcases/network/nfs/nfs_stress/nfs05_make_tree.c:     {"d:", &d_arg, "Number of subdirs to generate, default: 100"},
testcases/network/stress/route/route-change-netlink.c:          {"d:", &d_opt, "Interface to work on (mandatory)"},

Hopefully all could be changed to -D in separate commits.

$ git grep '"d"' $(git grep -l tst_option)
Also some other tests already use it as debug, this will be trivial to convert
to delete it and use TDEBUG (will have to be in the same commit which introduces
the flag or I would have to remove the debug and print always in commit before
introducing the flag):

testcases/kernel/mem/mmapstress/mmapstress01.c:         {"d", &debug, "Enable debug output"},
testcases/kernel/security/integrity/ima/src/ima_boot_aggregate.c:       {"d", &debug, "Enable debug"},
testcases/kernel/syscalls/mq_notify/mq_notify01.c:              {"d", &str_debug, "Print debug messages"},

Also, shell API uses -d

$ git grep "TST_OPTS=.*d"
testcases/network/virt/geneve01.sh:TST_OPTS="hi:d:"
testcases/network/virt/geneve02.sh:TST_OPTS="hi:d:"
testcases/network/virt/vxlan01.sh:TST_OPTS="hi:d:"
testcases/network/virt/vxlan02.sh:TST_OPTS="hi:d:"
testcases/network/virt/vxlan03.sh:TST_OPTS="hi:d:"
testcases/network/virt/vxlan04.sh:TST_OPTS="hi:d:"

=> all for VxLAN destination address in testcases/network/virt/virt_lib.sh
Again, it could be changed to -D in separate commits.

Alternative to all this work would be to have TVERBOSE. But I'm ok to do the job
if you like TDEBUG.

> >  	{"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");
>                                            ^
> 					   Maybe just "Enabling debug info"

+1

If none objects, I hopefully send patch this week.

Kind regards,
Petr

> > +		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] 18+ messages in thread

* Re: [LTP] [PATCH v3 1/3] lib/tests: Add test for testing tst_res() flags
  2023-12-13 19:04   ` Cyril Hrubis
@ 2023-12-13 23:40     ` Petr Vorel
  2023-12-14  9:09       ` Cyril Hrubis
  0 siblings, 1 reply; 18+ messages in thread
From: Petr Vorel @ 2023-12-13 23:40 UTC (permalink / raw)
  To: Cyril Hrubis; +Cc: Richard Palethorpe, ltp

> Hi!
> > +#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);

> Maybe it would make sense the loop over the flags here instead, so that
> we don't have to produce second TPASS message.

I'm not sure if I follow you. I wanted to use the flag in tst_res(),
but for these two there would be tst_brk(TBROK) due missing result.

Kind regards,
Petr

> > +}
> > +
> > +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	[flat|nested] 18+ messages in thread

* Re: [LTP] [PATCH v3 2/3] lib: Add support for TDEBUG tst_res() flag
  2023-12-13 19:15   ` Cyril Hrubis
  2023-12-13 23:11     ` Petr Vorel
@ 2023-12-13 23:48     ` Petr Vorel
  2023-12-14  9:39       ` Cyril Hrubis
  1 sibling, 1 reply; 18+ messages in thread
From: Petr Vorel @ 2023-12-13 23:48 UTC (permalink / raw)
  To: Cyril Hrubis; +Cc: Richard Palethorpe, ltp

Hi all,

...
> > +	{"v",  "-v       Prints debug information"},

> Maybe this should now be called -d since we call it TDEBUG and that will
> avoid having a bit confusing parameters with both -v and -V used.

Also, I have forgotten, I would prefer to enable TDEBUG messages also via
environment variable (e.g. TST_ENABLE_DEBUG). This will be easier for openQA and
possibly other testing frameworks to rerun runtest with debug info (-d is enough
to run locally, but it would require to change runtest to add it to particular
test, but exporting variable will work on unmodified sources).

Kind regards,
Petr


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

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

* Re: [LTP] [PATCH v3 1/3] lib/tests: Add test for testing tst_res() flags
  2023-12-13 23:40     ` Petr Vorel
@ 2023-12-14  9:09       ` Cyril Hrubis
  2023-12-14 12:19         ` Petr Vorel
  0 siblings, 1 reply; 18+ messages in thread
From: Cyril Hrubis @ 2023-12-14  9:09 UTC (permalink / raw)
  To: Petr Vorel; +Cc: Richard Palethorpe, ltp

Hi!
> > Maybe it would make sense the loop over the flags here instead, so that
> > we don't have to produce second TPASS message.
> 
> I'm not sure if I follow you. I wanted to use the flag in tst_res(),
> but for these two there would be tst_brk(TBROK) due missing result.

I mean that if we put TBROK last in the array we can do:

	for (i = 0; i < ARRAY_SIZE(...); i++)
		tst_res(....);

I.e. loop over all the flags in a single call of the function, which
would mean that we do not have to add artificial TPASS at the end.

-- 
Cyril Hrubis
chrubis@suse.cz

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

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

* Re: [LTP] [PATCH v3 2/3] lib: Add support for TDEBUG tst_res() flag
  2023-12-13 23:48     ` Petr Vorel
@ 2023-12-14  9:39       ` Cyril Hrubis
  0 siblings, 0 replies; 18+ messages in thread
From: Cyril Hrubis @ 2023-12-14  9:39 UTC (permalink / raw)
  To: Petr Vorel; +Cc: Richard Palethorpe, ltp

Hi!
> > Maybe this should now be called -d since we call it TDEBUG and that will
> > avoid having a bit confusing parameters with both -v and -V used.
> 
> Also, I have forgotten, I would prefer to enable TDEBUG messages also via
> environment variable (e.g. TST_ENABLE_DEBUG). This will be easier for openQA and
> possibly other testing frameworks to rerun runtest with debug info (-d is enough
> to run locally, but it would require to change runtest to add it to particular
> test, but exporting variable will work on unmodified sources).

Sure.

-- 
Cyril Hrubis
chrubis@suse.cz

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

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

* Re: [LTP] [PATCH v3 2/3] lib: Add support for TDEBUG tst_res() flag
  2023-12-13 23:11     ` Petr Vorel
@ 2023-12-14  9:41       ` Cyril Hrubis
  2023-12-14 12:08         ` Petr Vorel
  0 siblings, 1 reply; 18+ messages in thread
From: Cyril Hrubis @ 2023-12-14  9:41 UTC (permalink / raw)
  To: Petr Vorel; +Cc: Richard Palethorpe, ltp

Hi!
> > > diff --git a/lib/tst_test.c b/lib/tst_test.c
> > > index c2f8f503f..f5c87ed9e 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"},
> > > +	{"v",  "-v       Prints debug information"},
> 
> > Maybe this should now be called -d since we call it TDEBUG and that will
> > avoid having a bit confusing parameters with both -v and -V used.
> 
> Yes, I didn't like the flag name does not correspond to the option.
> I previously wrote that more tests use -d for something else:
> 
> $ git grep '"d:"' $(git grep -l tst_option)
> testcases/kernel/fs/read_all/read_all.c:                {"d:", &root_dir,
> testcases/kernel/io/ltp-aiodio/aio-stress.c:            { "d:", &str_depth, "Number of pending aio requests for each file (default 64)" },
> testcases/network/netstress/netstress.c:                {"d:", &rpath, "Path to file where result is saved"},
> testcases/network/nfs/nfs_stress/nfs05_make_tree.c:     {"d:", &d_arg, "Number of subdirs to generate, default: 100"},
> testcases/network/stress/route/route-change-netlink.c:          {"d:", &d_opt, "Interface to work on (mandatory)"},
> 
> Hopefully all could be changed to -D in separate commits.

Or we can use -D for TDEBUG. I suppose that we use -V for version for
the same reason.

-- 
Cyril Hrubis
chrubis@suse.cz

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

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

* Re: [LTP] [PATCH v3 2/3] lib: Add support for TDEBUG tst_res() flag
  2023-12-14  9:41       ` Cyril Hrubis
@ 2023-12-14 12:08         ` Petr Vorel
  0 siblings, 0 replies; 18+ messages in thread
From: Petr Vorel @ 2023-12-14 12:08 UTC (permalink / raw)
  To: Cyril Hrubis; +Cc: Richard Palethorpe, ltp

Hi Cyril,

...
> > > >  	{"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"},

> > > Maybe this should now be called -d since we call it TDEBUG and that will
> > > avoid having a bit confusing parameters with both -v and -V used.

> > Yes, I didn't like the flag name does not correspond to the option.
> > I previously wrote that more tests use -d for something else:

> > $ git grep '"d:"' $(git grep -l tst_option)
> > testcases/kernel/fs/read_all/read_all.c:                {"d:", &root_dir,
> > testcases/kernel/io/ltp-aiodio/aio-stress.c:            { "d:", &str_depth, "Number of pending aio requests for each file (default 64)" },
> > testcases/network/netstress/netstress.c:                {"d:", &rpath, "Path to file where result is saved"},
> > testcases/network/nfs/nfs_stress/nfs05_make_tree.c:     {"d:", &d_arg, "Number of subdirs to generate, default: 100"},
> > testcases/network/stress/route/route-change-netlink.c:          {"d:", &d_opt, "Interface to work on (mandatory)"},

> > Hopefully all could be changed to -D in separate commits.

> Or we can use -D for TDEBUG. I suppose that we use -V for version for
> the same reason.

Good point, thanks! -D is still used, but in less C tests.

$ git grep '"D:"' $(git grep -l tst_option)
testcases/kernel/syscalls/ioctl/ioctl02.c:              {"D:", &device, "Tty device. For example, /dev/tty[0-9]"},
testcases/network/can/filter-tests/can_filter.c:                {"D:", &can_dev_name, "CAN device name"},
testcases/network/can/filter-tests/can_rcv_own_msgs.c:          {"D:", &can_dev_name, "CAN device name"},
testcases/network/netstress/netstress.c:                {"D:", &dev, "Bind to device x"},

But at least -D is not used in shell.
$ git grep "TST_OPTS=.*D"

Kind regards,
Petr

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

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

* Re: [LTP] [PATCH v3 1/3] lib/tests: Add test for testing tst_res() flags
  2023-12-14  9:09       ` Cyril Hrubis
@ 2023-12-14 12:19         ` Petr Vorel
  2023-12-14 12:26           ` Petr Vorel
  0 siblings, 1 reply; 18+ messages in thread
From: Petr Vorel @ 2023-12-14 12:19 UTC (permalink / raw)
  To: Cyril Hrubis; +Cc: Richard Palethorpe, ltp

> Hi!
> > > Maybe it would make sense the loop over the flags here instead, so that
> > > we don't have to produce second TPASS message.

> > I'm not sure if I follow you. I wanted to use the flag in tst_res(),
> > but for these two there would be tst_brk(TBROK) due missing result.

> I mean that if we put TBROK last in the array we can do:

> 	for (i = 0; i < ARRAY_SIZE(...); i++)
> 		tst_res(....);

Yeah, I realized that later (it was too late already when I wrote the question).
My motivation was that extra TPASS also test functionality, we test, that TINFO
and TDEBUG are not results. But this is probably not important, thus I'll just
loop over array. And sure, I'll put TBROK to the end.

Kind regards,
Petr

> I.e. loop over all the flags in a single call of the function, which
> would mean that we do not have to add artificial TPASS at the end.


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

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

* Re: [LTP] [PATCH v3 1/3] lib/tests: Add test for testing tst_res() flags
  2023-12-14 12:19         ` Petr Vorel
@ 2023-12-14 12:26           ` Petr Vorel
  0 siblings, 0 replies; 18+ messages in thread
From: Petr Vorel @ 2023-12-14 12:26 UTC (permalink / raw)
  To: Cyril Hrubis, ltp, Li Wang, Richard Palethorpe, Jan Stancek,
	Xiao Yang, Yang Xu

> > Hi!
> > > > Maybe it would make sense the loop over the flags here instead, so that
> > > > we don't have to produce second TPASS message.

> > > I'm not sure if I follow you. I wanted to use the flag in tst_res(),
> > > but for these two there would be tst_brk(TBROK) due missing result.

> > I mean that if we put TBROK last in the array we can do:

> > 	for (i = 0; i < ARRAY_SIZE(...); i++)
FYI TBROK can stay, because we test tst_res().

I add also add similar test in shell API (IMHO there still can be bugs in shell
API implementation).

Kind regards,
Petr

> > 		tst_res(....);

> Yeah, I realized that later (it was too late already when I wrote the question).
> My motivation was that extra TPASS also test functionality, we test, that TINFO
> and TDEBUG are not results. But this is probably not important, thus I'll just
> loop over array. And sure, I'll put TBROK to the end.

> Kind regards,
> Petr

> > I.e. loop over all the flags in a single call of the function, which
> > would mean that we do not have to add artificial TPASS at the end.


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

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

end of thread, other threads:[~2023-12-14 12:27 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-11 16:18 [LTP] [PATCH v3 0/3] Add TDEBUG tst_res() flag Petr Vorel
2023-12-11 16:18 ` [LTP] [PATCH v3 1/3] lib/tests: Add test for testing tst_res() flags Petr Vorel
2023-12-13 19:04   ` Cyril Hrubis
2023-12-13 23:40     ` Petr Vorel
2023-12-14  9:09       ` Cyril Hrubis
2023-12-14 12:19         ` Petr Vorel
2023-12-14 12:26           ` Petr Vorel
2023-12-11 16:18 ` [LTP] [PATCH v3 2/3] lib: Add support for TDEBUG tst_res() flag Petr Vorel
2023-12-13 19:15   ` Cyril Hrubis
2023-12-13 23:11     ` Petr Vorel
2023-12-14  9:41       ` Cyril Hrubis
2023-12-14 12:08         ` Petr Vorel
2023-12-13 23:48     ` Petr Vorel
2023-12-14  9:39       ` Cyril Hrubis
2023-12-11 16:18 ` [LTP] [PATCH v3 3/3] fsx-linux: Reduce log output with TDEBUG Petr Vorel
2023-12-12 10:08   ` Andrea Cervesato via ltp
2023-12-13 19:18     ` Cyril Hrubis
2023-12-11 16:27 ` [LTP] [PATCH v3 0/3] Add TDEBUG tst_res() flag Jan Stancek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox