diff mbox series

[v1] tst_taint: Print readable error message instead of numerical code

Message ID 20220111150028.92961-1-kushalchand@zilogic.com
State Changes Requested
Headers show
Series [v1] tst_taint: Print readable error message instead of numerical code | expand

Commit Message

Kushal Chand Jan. 11, 2022, 3 p.m. UTC
---
 lib/tst_taint.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Petr Vorel Jan. 12, 2022, 3:18 p.m. UTC | #1
Hi Kushal,

>  	if ((taint & taint_mask) != 0)
> -		tst_brk(TBROK, "Kernel is already tainted: %u", taint);
> +		tst_brk(TBROK, "Kernel is already tainted: TAINT_D (OOPS)");

Kernel can be tainted before testing with different flags than D.

If you don't like the number, how about create function to map taint flag to
char? i.e. similarly to tst_strerrno()?

Kind regards,
Petr
Kushal Chand Jan. 13, 2022, 4:09 a.m. UTC | #2
Hi Petr,

I am really sorry I forgot to mention the link to issue on LTP for which I have submitted the patch. 

Can you please check https://github.com/linux-test-project/ltp/issues/776 if you have not already? 


I just followed what the issue points out. 

If not I will follow what you have mentioned if given more references to tst_strerrno()






---- On Wed, 12 Jan 2022 20:48:50 +0530 Petr Vorel <pvorel@suse.cz> wrote ----



Hi Kushal, 
 
>      if ((taint & taint_mask) != 0) 
> -        tst_brk(TBROK, "Kernel is already tainted: %u", taint); 
> +        tst_brk(TBROK, "Kernel is already tainted: TAINT_D (OOPS)"); 
 
Kernel can be tainted before testing with different flags than D. 
 
If you don't like the number, how about create function to map taint flag to 
char? i.e. similarly to tst_strerrno()? 
 
Kind regards, 
Petr 






Regards,
Kushal
Petr Vorel Jan. 14, 2022, 12:09 p.m. UTC | #3
Hi Kushal,

> Hi Petr,

> I am really sorry I forgot to mention the link to issue on LTP for which I have submitted the patch. 

> Can you please check https://github.com/linux-test-project/ltp/issues/776 if you have not already? 

Thanks, I was not aware of this. Thank you for working on this.
Please next time add flag to git commit message:

if it's an implementation:
Implements: #776

or if it's a fix:
Fixes: #776

Cyril wanted to transform numeric value to string name - there are various taint
flags, but we print flag as number. Could you please have look at const char
*tst_strerrno(int err) in lib/errnos.h and wrote similar function for this?
i.e.:

-		tst_brk(TBROK, "Kernel is already tainted: %u", taint);
+		tst_brk(TBROK, "Kernel is already tainted: %u", tst_strtaint(taint));

const char *tst_strtaint(int err)
{
    static const struct pair taint_pairs[] = {
		STRPAIR(TST_TAINT_A, "A (ACPI table has been overwritten)")
		STRPAIR(TST_TAINT_B, "B (page-release function found bad page)")
		...
	};

    PAIR_LOOKUP(errno_pairs, err);
}

Maybe Cyril has additional comments how the string should look like.

Kind regards,
Petr


> I just followed what the issue points out. 

> If not I will follow what you have mentioned if given more references to tst_strerrno()






> ---- On Wed, 12 Jan 2022 20:48:50 +0530 Petr Vorel <pvorel@suse.cz> wrote ----



> Hi Kushal, 

> >      if ((taint & taint_mask) != 0) 
> > -        tst_brk(TBROK, "Kernel is already tainted: %u", taint); 
> > +        tst_brk(TBROK, "Kernel is already tainted: TAINT_D (OOPS)"); 

> Kernel can be tainted before testing with different flags than D. 

> If you don't like the number, how about create function to map taint flag to 
> char? i.e. similarly to tst_strerrno()? 

> Kind regards, 
> Petr 






> Regards,
> Kushal
diff mbox series

Patch

diff --git a/lib/tst_taint.c b/lib/tst_taint.c
index 49146aacb..af94656ed 100644
--- a/lib/tst_taint.c
+++ b/lib/tst_taint.c
@@ -90,7 +90,7 @@  void tst_taint_init(unsigned int mask)
 	}
 
 	if ((taint & taint_mask) != 0)
-		tst_brk(TBROK, "Kernel is already tainted: %u", taint);
+		tst_brk(TBROK, "Kernel is already tainted: TAINT_D (OOPS)");
 }