public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH 1/2] lib: Add TINFO_WARN
  2024-05-27 22:29 [LTP] [PATCH 0/2] lib: Add TINFO_WARN Petr Vorel
@ 2024-05-27 22:29 ` Petr Vorel
  0 siblings, 0 replies; 5+ messages in thread
From: Petr Vorel @ 2024-05-27 22:29 UTC (permalink / raw)
  To: ltp

When replaced tst_res(TINFO, "WARNING: ...") with tst_res(TINFO_WARN,
"..."), then:

- output message is magenta (the same as for TWARN => more visible),
- "WARNING" is printed by the library (unification),

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 include/tst_res_flags.h          |  6 +++++-
 include/tst_test.h               |  2 +-
 lib/newlib_tests/tst_res_flags.c |  1 +
 lib/tst_ansi_color.c             |  1 +
 lib/tst_res.c                    | 12 ++++++++----
 lib/tst_test.c                   |  3 +++
 6 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/include/tst_res_flags.h b/include/tst_res_flags.h
index 806940e0d..bb2f38c93 100644
--- a/include/tst_res_flags.h
+++ b/include/tst_res_flags.h
@@ -22,6 +22,9 @@
  * @TINFO: Prints an additional information, it does not change the test result
  *         counters but unlike TDEBUG the message is always displayed.
  *
+ * @TINFO_WARN: Reports a single warning, but it does not change the test result
+ *              counters like TINFO.
+ *
  * @TCONF: Reports unsupported configuration. When tests produce this result at
  *         least a subset of test was skipped, because it couldn't run. The
  *         usual reasons are, missing kernel modules or CONFIG options.
@@ -55,12 +58,13 @@ enum tst_res_flags {
 	TDEBUG = 8,
 	TINFO = 16,
 	TCONF = 32,
+	TINFO_WARN = 64,
 	TERRNO = 0x100,
 	TTERRNO = 0x200,
 	TRERRNO	= 0x400,
 };
 
 #define TTYPE_RESULT(ttype)	((ttype) & TTYPE_MASK)
-#define TTYPE_MASK 0x3f
+#define TTYPE_MASK 0x7f
 
 #endif /* TST_RES_FLAGS_H */
diff --git a/include/tst_test.h b/include/tst_test.h
index 8dc20d110..6c1f7bce1 100644
--- a/include/tst_test.h
+++ b/include/tst_test.h
@@ -69,7 +69,7 @@ void tst_res_(const char *file, const int lineno, int ttype,
 	({									\
 		TST_RES_SUPPORTS_TCONF_TDEBUG_TFAIL_TINFO_TPASS_TWARN(\
 			!((TTYPE_RESULT(ttype) ?: TCONF) & \
-			(TCONF | TDEBUG | TFAIL | TINFO | TPASS | TWARN)));				\
+			(TCONF | TDEBUG | TFAIL | TINFO | TPASS | TWARN | TINFO_WARN)));	\
 		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 a14f0df2c..7d3bc3785 100644
--- a/lib/newlib_tests/tst_res_flags.c
+++ b/lib/newlib_tests/tst_res_flags.c
@@ -20,6 +20,7 @@ static struct tcase {
 	{FLAG(TBROK)},
 	{FLAG(TCONF)},
 	{FLAG(TWARN)},
+	{FLAG(TINFO_WARN)},
 	{FLAG(TINFO)},
 	{FLAG(TDEBUG), " (printed only with -D or LTP_ENABLE_DEBUG=1)"},
 };
diff --git a/lib/tst_ansi_color.c b/lib/tst_ansi_color.c
index 98041c0af..7d1dca516 100644
--- a/lib/tst_ansi_color.c
+++ b/lib/tst_ansi_color.c
@@ -26,6 +26,7 @@ char* tst_ttype2color(int ttype)
 		return ANSI_COLOR_YELLOW;
 	break;
 	case TWARN:
+	case TINFO_WARN:
 		return ANSI_COLOR_MAGENTA;
 	break;
 	case TINFO:
diff --git a/lib/tst_res.c b/lib/tst_res.c
index 7c66d2f6c..d28c0b4f4 100644
--- a/lib/tst_res.c
+++ b/lib/tst_res.c
@@ -174,13 +174,16 @@ 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__);
+	if (ttype_result == TDEBUG || ttype_result == TINFO_WARN) {
+		printf("%s: %i: %s is not supported\n", __func__, __LINE__,
+		       strttype(ttype));
 		abort();
 	}
 
-	if (file && (ttype_result != TPASS && ttype_result != TINFO))
+	if (file && (ttype_result != TPASS && ttype_result != TINFO
+		     && ttype_result != TINFO_WARN)) {
 		len = sprintf(tmesg, "%s:%d: ", file, lineno);
+	}
 	EXPAND_VAR_ARGS(tmesg + len, arg_fmt, USERMESG - len);
 
 	/*
@@ -198,7 +201,8 @@ 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 == TINFO_WARN) {
 		tst_print(TCID, 0, ttype, tmesg);
 	} else {
 		if (tst_count < 0)
diff --git a/lib/tst_test.c b/lib/tst_test.c
index 8c212c983..ef5148c0f 100644
--- a/lib/tst_test.c
+++ b/lib/tst_test.c
@@ -225,6 +225,9 @@ static void print_result(const char *file, const int lineno, int ttype,
 	case TINFO:
 		res = "TINFO";
 	break;
+	case TINFO_WARN:
+		res = "TINFO WARNING";
+	break;
 	case TDEBUG:
 		res = "TDEBUG";
 	break;
-- 
2.43.0


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

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

* [LTP] [PATCH 0/2] lib: Add TINFO_WARN
@ 2024-05-28 12:05 Petr Vorel
  2024-05-28 12:05 ` [LTP] [PATCH 1/2] " Petr Vorel
  2024-05-28 12:05 ` [LTP] [PATCH 2/2] tree: Use TINFO_WARN Petr Vorel
  0 siblings, 2 replies; 5+ messages in thread
From: Petr Vorel @ 2024-05-28 12:05 UTC (permalink / raw)
  To: ltp

Hi,

if we found this useful, is it worth to implement it also in the shell
API?

Regardless the result, should it be TDEBUG backported to the shell API?

Kind regards,
Petr

Petr Vorel (2):
  lib: Add TINFO_WARN
  tree: Use TINFO_WARN

 include/tst_res_flags.h                         |  6 +++++-
 include/tst_test.h                              |  2 +-
 lib/newlib_tests/tst_res_flags.c                |  1 +
 lib/tst_ansi_color.c                            |  1 +
 lib/tst_res.c                                   | 12 ++++++++----
 lib/tst_supported_fs_types.c                    |  2 +-
 lib/tst_test.c                                  |  3 +++
 testcases/kernel/mem/hugetlb/lib/hugetlb.c      |  4 ++--
 testcases/kernel/syscalls/ipc/semctl/semctl08.c |  2 +-
 9 files changed, 23 insertions(+), 10 deletions(-)

-- 
2.43.0


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

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

* [LTP] [PATCH 1/2] lib: Add TINFO_WARN
  2024-05-28 12:05 [LTP] [PATCH 0/2] lib: Add TINFO_WARN Petr Vorel
@ 2024-05-28 12:05 ` Petr Vorel
  2024-05-28 12:14   ` Petr Vorel
  2024-05-28 12:05 ` [LTP] [PATCH 2/2] tree: Use TINFO_WARN Petr Vorel
  1 sibling, 1 reply; 5+ messages in thread
From: Petr Vorel @ 2024-05-28 12:05 UTC (permalink / raw)
  To: ltp

When replaced tst_res(TINFO, "WARNING: ...") with tst_res(TINFO_WARN,
"..."), then:

- output message is magenta (the same as for TWARN => more visible),
- "WARNING" is printed by the library (unification),

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 include/tst_res_flags.h          |  6 +++++-
 include/tst_test.h               |  2 +-
 lib/newlib_tests/tst_res_flags.c |  1 +
 lib/tst_ansi_color.c             |  1 +
 lib/tst_res.c                    | 12 ++++++++----
 lib/tst_test.c                   |  3 +++
 6 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/include/tst_res_flags.h b/include/tst_res_flags.h
index 806940e0d..bb2f38c93 100644
--- a/include/tst_res_flags.h
+++ b/include/tst_res_flags.h
@@ -22,6 +22,9 @@
  * @TINFO: Prints an additional information, it does not change the test result
  *         counters but unlike TDEBUG the message is always displayed.
  *
+ * @TINFO_WARN: Reports a single warning, but it does not change the test result
+ *              counters like TINFO.
+ *
  * @TCONF: Reports unsupported configuration. When tests produce this result at
  *         least a subset of test was skipped, because it couldn't run. The
  *         usual reasons are, missing kernel modules or CONFIG options.
@@ -55,12 +58,13 @@ enum tst_res_flags {
 	TDEBUG = 8,
 	TINFO = 16,
 	TCONF = 32,
+	TINFO_WARN = 64,
 	TERRNO = 0x100,
 	TTERRNO = 0x200,
 	TRERRNO	= 0x400,
 };
 
 #define TTYPE_RESULT(ttype)	((ttype) & TTYPE_MASK)
-#define TTYPE_MASK 0x3f
+#define TTYPE_MASK 0x7f
 
 #endif /* TST_RES_FLAGS_H */
diff --git a/include/tst_test.h b/include/tst_test.h
index 8dc20d110..6c1f7bce1 100644
--- a/include/tst_test.h
+++ b/include/tst_test.h
@@ -69,7 +69,7 @@ void tst_res_(const char *file, const int lineno, int ttype,
 	({									\
 		TST_RES_SUPPORTS_TCONF_TDEBUG_TFAIL_TINFO_TPASS_TWARN(\
 			!((TTYPE_RESULT(ttype) ?: TCONF) & \
-			(TCONF | TDEBUG | TFAIL | TINFO | TPASS | TWARN)));				\
+			(TCONF | TDEBUG | TFAIL | TINFO | TPASS | TWARN | TINFO_WARN)));	\
 		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 a14f0df2c..7d3bc3785 100644
--- a/lib/newlib_tests/tst_res_flags.c
+++ b/lib/newlib_tests/tst_res_flags.c
@@ -20,6 +20,7 @@ static struct tcase {
 	{FLAG(TBROK)},
 	{FLAG(TCONF)},
 	{FLAG(TWARN)},
+	{FLAG(TINFO_WARN)},
 	{FLAG(TINFO)},
 	{FLAG(TDEBUG), " (printed only with -D or LTP_ENABLE_DEBUG=1)"},
 };
diff --git a/lib/tst_ansi_color.c b/lib/tst_ansi_color.c
index 98041c0af..7d1dca516 100644
--- a/lib/tst_ansi_color.c
+++ b/lib/tst_ansi_color.c
@@ -26,6 +26,7 @@ char* tst_ttype2color(int ttype)
 		return ANSI_COLOR_YELLOW;
 	break;
 	case TWARN:
+	case TINFO_WARN:
 		return ANSI_COLOR_MAGENTA;
 	break;
 	case TINFO:
diff --git a/lib/tst_res.c b/lib/tst_res.c
index 7c66d2f6c..d28c0b4f4 100644
--- a/lib/tst_res.c
+++ b/lib/tst_res.c
@@ -174,13 +174,16 @@ 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__);
+	if (ttype_result == TDEBUG || ttype_result == TINFO_WARN) {
+		printf("%s: %i: %s is not supported\n", __func__, __LINE__,
+		       strttype(ttype));
 		abort();
 	}
 
-	if (file && (ttype_result != TPASS && ttype_result != TINFO))
+	if (file && (ttype_result != TPASS && ttype_result != TINFO
+		     && ttype_result != TINFO_WARN)) {
 		len = sprintf(tmesg, "%s:%d: ", file, lineno);
+	}
 	EXPAND_VAR_ARGS(tmesg + len, arg_fmt, USERMESG - len);
 
 	/*
@@ -198,7 +201,8 @@ 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 == TINFO_WARN) {
 		tst_print(TCID, 0, ttype, tmesg);
 	} else {
 		if (tst_count < 0)
diff --git a/lib/tst_test.c b/lib/tst_test.c
index 8c212c983..ef5148c0f 100644
--- a/lib/tst_test.c
+++ b/lib/tst_test.c
@@ -225,6 +225,9 @@ static void print_result(const char *file, const int lineno, int ttype,
 	case TINFO:
 		res = "TINFO";
 	break;
+	case TINFO_WARN:
+		res = "TINFO WARNING";
+	break;
 	case TDEBUG:
 		res = "TDEBUG";
 	break;
-- 
2.43.0


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

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

* [LTP] [PATCH 2/2] tree: Use TINFO_WARN
  2024-05-28 12:05 [LTP] [PATCH 0/2] lib: Add TINFO_WARN Petr Vorel
  2024-05-28 12:05 ` [LTP] [PATCH 1/2] " Petr Vorel
@ 2024-05-28 12:05 ` Petr Vorel
  1 sibling, 0 replies; 5+ messages in thread
From: Petr Vorel @ 2024-05-28 12:05 UTC (permalink / raw)
  To: ltp

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 lib/tst_supported_fs_types.c                    | 2 +-
 testcases/kernel/mem/hugetlb/lib/hugetlb.c      | 4 ++--
 testcases/kernel/syscalls/ipc/semctl/semctl08.c | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/lib/tst_supported_fs_types.c b/lib/tst_supported_fs_types.c
index bbbb8df19..8b8cf213a 100644
--- a/lib/tst_supported_fs_types.c
+++ b/lib/tst_supported_fs_types.c
@@ -158,7 +158,7 @@ const char **tst_get_supported_fs_types(const char *const *skiplist)
 	only_fs = getenv("LTP_SINGLE_FS_TYPE");
 
 	if (only_fs) {
-		tst_res(TINFO, "WARNING: testing only %s", only_fs);
+		tst_res(TINFO_WARN, "testing only %s", only_fs);
 		if (tst_fs_is_supported(only_fs))
 			fs_types[0] = only_fs;
 		return fs_types;
diff --git a/testcases/kernel/mem/hugetlb/lib/hugetlb.c b/testcases/kernel/mem/hugetlb/lib/hugetlb.c
index 43a677ce9..c612bf2d2 100644
--- a/testcases/kernel/mem/hugetlb/lib/hugetlb.c
+++ b/testcases/kernel/mem/hugetlb/lib/hugetlb.c
@@ -106,8 +106,8 @@ void rm_shm(int shm_id)
 	 * check for # of attaches ?
 	 */
 	if (shmctl(shm_id, IPC_RMID, NULL) == -1) {
-		tst_res(TINFO, "WARNING: shared memory deletion failed.");
-		tst_res(TINFO, "This could lead to IPC resource problems.");
+		tst_res(TINFO_WARN, "shared memory deletion failed");
+		tst_res(TINFO, "This could lead to IPC resource problems");
 		tst_res(TINFO, "id = %d", shm_id);
 	}
 }
diff --git a/testcases/kernel/syscalls/ipc/semctl/semctl08.c b/testcases/kernel/syscalls/ipc/semctl/semctl08.c
index 1878bd49d..aacdcf6a5 100644
--- a/testcases/kernel/syscalls/ipc/semctl/semctl08.c
+++ b/testcases/kernel/syscalls/ipc/semctl/semctl08.c
@@ -40,7 +40,7 @@ static void run(void)
 		tst_res(TPASS, "time_high fields cleared by the kernel");
 
 	if (semctl(semid, 0, IPC_RMID, arg) == -1)
-		tst_res(TINFO, "WARNING: semaphore deletion failed.");
+		tst_res(TINFO_WARN, "semaphore deletion failed");
 }
 
 static struct tst_test test = {
-- 
2.43.0


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

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

* Re: [LTP] [PATCH 1/2] lib: Add TINFO_WARN
  2024-05-28 12:05 ` [LTP] [PATCH 1/2] " Petr Vorel
@ 2024-05-28 12:14   ` Petr Vorel
  0 siblings, 0 replies; 5+ messages in thread
From: Petr Vorel @ 2024-05-28 12:14 UTC (permalink / raw)
  To: ltp

Hi,

I'm sorry to send this patchset twice (I forget I sent it a day before).

> When replaced tst_res(TINFO, "WARNING: ...") with tst_res(TINFO_WARN,
> "..."), then:

> - output message is magenta (the same as for TWARN => more visible),
> - "WARNING" is printed by the library (unification),

Also, Andrea suggested on the first patchset:

https://lore.kernel.org/ltp/37603272-8ea2-4828-96df-4b6381cc26ad@suse.com/
I'm not sure about this. Why not enabling TINFO + TWARN combination instead?
tst_res(TINFO | TWARN, "my message");

This actually makes sense => v2 needed.

Kind regards,
Petr

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

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

end of thread, other threads:[~2024-05-28 12:15 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-28 12:05 [LTP] [PATCH 0/2] lib: Add TINFO_WARN Petr Vorel
2024-05-28 12:05 ` [LTP] [PATCH 1/2] " Petr Vorel
2024-05-28 12:14   ` Petr Vorel
2024-05-28 12:05 ` [LTP] [PATCH 2/2] tree: Use TINFO_WARN Petr Vorel
  -- strict thread matches above, loose matches on Subject: below --
2024-05-27 22:29 [LTP] [PATCH 0/2] lib: Add TINFO_WARN Petr Vorel
2024-05-27 22:29 ` [LTP] [PATCH 1/2] " Petr Vorel

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