Linux Test Project
 help / color / mirror / Atom feed
* [LTP] [PATCH v4] tst_taint: print readable error message instead of numerical codes
@ 2022-01-26  5:05 Kushal Chand
  2022-01-28 12:12 ` Petr Vorel
  0 siblings, 1 reply; 2+ messages in thread
From: Kushal Chand @ 2022-01-26  5:05 UTC (permalink / raw)
  To: ltp; +Cc: Kushal Chand

Fixes: #776

I have did the necessary changes as discussed in our communication.
Now we print each taint flag using tst_res(TINFO, ...) and a final
tst_brk(TBROK, ...) which informs the kernel is tainted.

Regards,
Kushal

---
 lib/tst_taint.c | 31 +++++++++++++++++++++++++++++--
 1 file changed, 29 insertions(+), 2 deletions(-)

diff --git a/lib/tst_taint.c b/lib/tst_taint.c
index 49146aacb..49929b11c 100644
--- a/lib/tst_taint.c
+++ b/lib/tst_taint.c
@@ -8,6 +8,27 @@

 static unsigned int taint_mask = -1;

+static const char *const taint_strings[] = {
+	"G (Propriety module loaded)",
+	"F (Module force loaded)",
+	"S (Running on out of spec system)",
+	"R (Module force unloaded)",
+	"M (Machine check exception)",
+	"B (Bad page reference)",
+	"U (User request)",
+	"D (OOPS/BUG)",
+	"A (ACPI table overridden)",
+	"W (Warning)",
+	"C (Staging driver loaded)",
+	"I (Workaround BIOS/FW bug)",
+	"O (Out of tree module loaded)",
+	"E (Unsigned module loaded)",
+	"L (Soft lock up occured)",
+	"K (Live patched)",
+	"X (Auxilary)",
+	"T (Built with struct randomization)",
+};
+
 static unsigned int tst_taint_read(void)
 {
 	unsigned int val;
@@ -74,6 +95,7 @@ static int tst_taint_check_kver(unsigned int mask)
 void tst_taint_init(unsigned int mask)
 {
 	unsigned int taint = -1;
+	unsigned long i;

 	if (mask == 0)
 		tst_brk(TBROK, "mask is not allowed to be 0");
@@ -89,8 +111,13 @@ void tst_taint_init(unsigned int mask)
 		taint_mask &= ~TST_TAINT_W;
 	}

-	if ((taint & taint_mask) != 0)
-		tst_brk(TBROK, "Kernel is already tainted: %u", taint);
+	if ((taint & taint_mask) != 0) {
+		for (i = 0; i < ARRAY_SIZE(taint_strings); i++) {
+			if (taint & (1 << i))
+				tst_res(TINFO, "%s", taint_strings[i]);
+		}
+		tst_brk(TBROK, "Kernel is already tainted");
+	}
 }


--
2.25.1

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

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

* Re: [LTP] [PATCH v4] tst_taint: print readable error message instead of numerical codes
  2022-01-26  5:05 [LTP] [PATCH v4] tst_taint: print readable error message instead of numerical codes Kushal Chand
@ 2022-01-28 12:12 ` Petr Vorel
  0 siblings, 0 replies; 2+ messages in thread
From: Petr Vorel @ 2022-01-28 12:12 UTC (permalink / raw)
  To: Kushal Chand; +Cc: ltp

Hi Kushal,

> Fixes: #776

> I have did the necessary changes as discussed in our communication.
> Now we print each taint flag using tst_res(TINFO, ...) and a final
> tst_brk(TBROK, ...) which informs the kernel is tainted.

> Regards,
> Kushal
FYI this test above should be ...

> ---
... here after '---'. Because everything after '---' does not go to the git
commit message (designed for notes which should not be preserved in the commit
message).

Anyway, added text "tainted: " and merged. Thanks!

Kind regards,
Petr

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

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

end of thread, other threads:[~2022-01-28 12:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-01-26  5:05 [LTP] [PATCH v4] tst_taint: print readable error message instead of numerical codes Kushal Chand
2022-01-28 12:12 ` Petr Vorel

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