Patchwork [1/4] lib: fwts_oops: check for WARN_ON messages as well as oopses

login
register
mail settings
Submitter Colin King
Date Nov. 15, 2012, 12:05 p.m.
Message ID <1352981144-3586-2-git-send-email-colin.king@canonical.com>
Download mbox | patch
Permalink /patch/199262/
State Accepted
Headers show

Comments

Colin King - Nov. 15, 2012, 12:05 p.m.
From: Colin Ian King <colin.king@canonical.com>

It is also useful to check for WARN_ON messages as well as oopses
in the oops check.  We add a new counter to count WARN_ONs too.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 src/lib/include/fwts_oops.h |    2 +-
 src/lib/src/fwts_oops.c     |   63 ++++++++++++++++++++++++++++++-------------
 2 files changed, 45 insertions(+), 20 deletions(-)
Alex Hung - Nov. 22, 2012, 2:26 a.m.
On 11/15/2012 08:05 PM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> It is also useful to check for WARN_ON messages as well as oopses
> in the oops check.  We add a new counter to count WARN_ONs too.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>   src/lib/include/fwts_oops.h |    2 +-
>   src/lib/src/fwts_oops.c     |   63 ++++++++++++++++++++++++++++++-------------
>   2 files changed, 45 insertions(+), 20 deletions(-)
>
> diff --git a/src/lib/include/fwts_oops.h b/src/lib/include/fwts_oops.h
> index 556b1c5..e09e5e3 100644
> --- a/src/lib/include/fwts_oops.h
> +++ b/src/lib/include/fwts_oops.h
> @@ -22,6 +22,6 @@
>
>   #include <sys/types.h>
>
> -int fwts_oops_check(fwts_framework *fw, fwts_list *klog, int *oopses);
> +int fwts_oops_check(fwts_framework *fw, fwts_list *klog, int *oopses, int *warn_ons);
>
>   #endif
> diff --git a/src/lib/src/fwts_oops.c b/src/lib/src/fwts_oops.c
> index fe557e5..4eaad1f 100644
> --- a/src/lib/src/fwts_oops.c
> +++ b/src/lib/src/fwts_oops.c
> @@ -25,33 +25,40 @@
>   #include "fwts.h"
>
>   #define FWTS_OOPS_GOT_OOPS		(0x0001)
> -#define FWTS_OOPS_GOT_STACK		(0x0002)
> -#define FWTS_OOPS_GOT_CALL_TRACE	(0x0004)
> -#define FWTS_OOPS_GOT_END_TRACE		(0x0008)
> +#define FWTS_OOPS_GOT_CALL_TRACE	(0x0002)
> +#define FWTS_OOPS_GOT_END_TRACE		(0x0004)
> +#define FWTS_OOPS_GOT_WARN_ON		(0x0008)
>
>   #define FWTS_OOPS_DUMPABLE		\
> -	(FWTS_OOPS_GOT_OOPS | FWTS_OOPS_GOT_STACK | FWTS_OOPS_GOT_CALL_TRACE | FWTS_OOPS_GOT_END_TRACE)
> +	(FWTS_OOPS_GOT_OOPS | FWTS_OOPS_GOT_CALL_TRACE | FWTS_OOPS_GOT_END_TRACE)
>
> +#define FWTS_WARN_ON_DUMPABLE		\
> +	(FWTS_OOPS_GOT_WARN_ON | FWTS_OOPS_GOT_CALL_TRACE | FWTS_OOPS_GOT_END_TRACE)
>
>   /*
> - *  fwts_oops_dump()
> - *	for a given item in a kernel log list, scan for an oops message and
> - *	if we find an oops message increment 'oopses' and dump out the oops
> - *	message to the fwts log
> + *  fwts_klog_stack_dump()
> + *	for a given item in a kernel log list, scan for an oops or WARN_ON message.
> + *	Increment oopses or warn_ons depending on what we find and dump out the stack
> + *	trace to the fwts log
>    */
> -void fwts_oops_dump(fwts_framework *fw, fwts_list_link *bug_item, int *oopses)
> +static void fwts_klog_stack_dump(
> +	fwts_framework *fw,
> +	fwts_list_link *bug_item,
> +	int *oopses,
> +	int *warn_ons)
>   {
>   	fwts_list_link *item = bug_item;
>   	int lines = 0;
>   	int dumpable = 0;
> +	bool dumpstack = false;
>
>   	fwts_list_foreach_continue(item) {
>   		char *line = fwts_klog_remove_timestamp(fwts_list_data(char *, item));
>
>   		if (strstr(line, "Oops:"))
>   			dumpable |= FWTS_OOPS_GOT_OOPS;
> -		if (strstr(line, "Stack:"))
> -			dumpable |= FWTS_OOPS_GOT_STACK;
> +		if (strstr(line, "WARNING: at"))
> +			dumpable |= FWTS_OOPS_GOT_WARN_ON;
>   		if (strstr(line, "Call Trace:"))
>   			dumpable |= FWTS_OOPS_GOT_CALL_TRACE;
>   		if (strstr(line, "--[ end trace")) {
> @@ -60,8 +67,12 @@ void fwts_oops_dump(fwts_framework *fw, fwts_list_link *bug_item, int *oopses)
>   		}
>   		lines++;
>
> -		/* We are looking for an Oops message within 5 lines of a "BUG:" */
> -		if ((lines > 5) && (!(dumpable & FWTS_OOPS_GOT_OOPS)))
> +		/*
> +		 * We are looking for an Oops message within 5 lines of a "BUG:"
> +		 * or we've got a WARN_ON then, OK, otherwise abort.
> +		 */
> +		if ((lines > 5) &&
> +		    (!(dumpable & (FWTS_OOPS_GOT_OOPS | FWTS_OOPS_GOT_WARN_ON))))
>   			return;
>
>   	}
> @@ -73,12 +84,21 @@ void fwts_oops_dump(fwts_framework *fw, fwts_list_link *bug_item, int *oopses)
>   	if (item == NULL)
>   		return;
>
> -
>   	/* Found all the features that indicate an oops, so dump it */
> -	if (dumpable & FWTS_OOPS_DUMPABLE) {
> +	if ((dumpable & FWTS_OOPS_DUMPABLE) == FWTS_OOPS_DUMPABLE) {
>   		(*oopses)++;
>   		fwts_log_info(fw, "Found OOPS (%d):", *oopses);
> +		dumpstack = true;
> +	}
>
> +	/* Found all the features that indicate a WARN_ON, so dump it */
> +	if ((dumpable & FWTS_WARN_ON_DUMPABLE) == FWTS_WARN_ON_DUMPABLE) {
> +		(*warn_ons)++;
> +		fwts_log_info(fw, "Found WARNING (%d):", *warn_ons);
> +		dumpstack = true;
> +	}
> +
> +	if (dumpstack) {
>   		while (bug_item != NULL && bug_item != item) {
>   			fwts_log_info_verbatum(fw, "  %s",
>   				fwts_klog_remove_timestamp(fwts_list_data(char *, bug_item)));
> @@ -94,17 +114,22 @@ void fwts_oops_dump(fwts_framework *fw, fwts_list_link *bug_item, int *oopses)
>    *	messages found is returned in 'oopses'.  Oops messages are logged to the
>    *	fwts log.
>    */
> -int fwts_oops_check(fwts_framework *fw, fwts_list *klog, int *oopses)
> +int fwts_oops_check(fwts_framework *fw, fwts_list *klog, int *oopses, int *warn_ons)
>   {
>   	fwts_list_link *item;
>   	*oopses = 0;
> +	*warn_ons = 0;
>
> -	if ((fw == NULL) || (oopses == NULL) || (klog == NULL))
> +	/* Sanity check */
> +	if ((fw == NULL) || (oopses == NULL) ||
> +	    (warn_ons == NULL) || (klog == NULL))
>   		return FWTS_ERROR;
>
>   	fwts_list_foreach(item, klog) {
> -		if (strncmp("BUG:", fwts_klog_remove_timestamp(fwts_list_data(char *, item)), 4) == 0)
> -			fwts_oops_dump(fw, item, oopses);
> +		char *line = fwts_klog_remove_timestamp(fwts_list_data(char *, item));
> +		if ((strncmp("BUG:", line, 4) == 0) ||
> +		    (strncmp("WARNING:", line, 8) == 0))
> +			fwts_klog_stack_dump(fw, item, oopses, warn_ons);
>   	}
>
>   	return FWTS_OK;
>
Acked-by: Alex Hung <alex.hung@canonical.com>
Keng-Yu Lin - Nov. 22, 2012, 5:55 a.m.
On Thu, Nov 15, 2012 at 8:05 PM, Colin King <colin.king@canonical.com> wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> It is also useful to check for WARN_ON messages as well as oopses
> in the oops check.  We add a new counter to count WARN_ONs too.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  src/lib/include/fwts_oops.h |    2 +-
>  src/lib/src/fwts_oops.c     |   63 ++++++++++++++++++++++++++++++-------------
>  2 files changed, 45 insertions(+), 20 deletions(-)
>
> diff --git a/src/lib/include/fwts_oops.h b/src/lib/include/fwts_oops.h
> index 556b1c5..e09e5e3 100644
> --- a/src/lib/include/fwts_oops.h
> +++ b/src/lib/include/fwts_oops.h
> @@ -22,6 +22,6 @@
>
>  #include <sys/types.h>
>
> -int fwts_oops_check(fwts_framework *fw, fwts_list *klog, int *oopses);
> +int fwts_oops_check(fwts_framework *fw, fwts_list *klog, int *oopses, int *warn_ons);
>
>  #endif
> diff --git a/src/lib/src/fwts_oops.c b/src/lib/src/fwts_oops.c
> index fe557e5..4eaad1f 100644
> --- a/src/lib/src/fwts_oops.c
> +++ b/src/lib/src/fwts_oops.c
> @@ -25,33 +25,40 @@
>  #include "fwts.h"
>
>  #define FWTS_OOPS_GOT_OOPS             (0x0001)
> -#define FWTS_OOPS_GOT_STACK            (0x0002)
> -#define FWTS_OOPS_GOT_CALL_TRACE       (0x0004)
> -#define FWTS_OOPS_GOT_END_TRACE                (0x0008)
> +#define FWTS_OOPS_GOT_CALL_TRACE       (0x0002)
> +#define FWTS_OOPS_GOT_END_TRACE                (0x0004)
> +#define FWTS_OOPS_GOT_WARN_ON          (0x0008)
>
>  #define FWTS_OOPS_DUMPABLE             \
> -       (FWTS_OOPS_GOT_OOPS | FWTS_OOPS_GOT_STACK | FWTS_OOPS_GOT_CALL_TRACE | FWTS_OOPS_GOT_END_TRACE)
> +       (FWTS_OOPS_GOT_OOPS | FWTS_OOPS_GOT_CALL_TRACE | FWTS_OOPS_GOT_END_TRACE)
>
> +#define FWTS_WARN_ON_DUMPABLE          \
> +       (FWTS_OOPS_GOT_WARN_ON | FWTS_OOPS_GOT_CALL_TRACE | FWTS_OOPS_GOT_END_TRACE)
>
>  /*
> - *  fwts_oops_dump()
> - *     for a given item in a kernel log list, scan for an oops message and
> - *     if we find an oops message increment 'oopses' and dump out the oops
> - *     message to the fwts log
> + *  fwts_klog_stack_dump()
> + *     for a given item in a kernel log list, scan for an oops or WARN_ON message.
> + *     Increment oopses or warn_ons depending on what we find and dump out the stack
> + *     trace to the fwts log
>   */
> -void fwts_oops_dump(fwts_framework *fw, fwts_list_link *bug_item, int *oopses)
> +static void fwts_klog_stack_dump(
> +       fwts_framework *fw,
> +       fwts_list_link *bug_item,
> +       int *oopses,
> +       int *warn_ons)
>  {
>         fwts_list_link *item = bug_item;
>         int lines = 0;
>         int dumpable = 0;
> +       bool dumpstack = false;
>
>         fwts_list_foreach_continue(item) {
>                 char *line = fwts_klog_remove_timestamp(fwts_list_data(char *, item));
>
>                 if (strstr(line, "Oops:"))
>                         dumpable |= FWTS_OOPS_GOT_OOPS;
> -               if (strstr(line, "Stack:"))
> -                       dumpable |= FWTS_OOPS_GOT_STACK;
> +               if (strstr(line, "WARNING: at"))
> +                       dumpable |= FWTS_OOPS_GOT_WARN_ON;
>                 if (strstr(line, "Call Trace:"))
>                         dumpable |= FWTS_OOPS_GOT_CALL_TRACE;
>                 if (strstr(line, "--[ end trace")) {
> @@ -60,8 +67,12 @@ void fwts_oops_dump(fwts_framework *fw, fwts_list_link *bug_item, int *oopses)
>                 }
>                 lines++;
>
> -               /* We are looking for an Oops message within 5 lines of a "BUG:" */
> -               if ((lines > 5) && (!(dumpable & FWTS_OOPS_GOT_OOPS)))
> +               /*
> +                * We are looking for an Oops message within 5 lines of a "BUG:"
> +                * or we've got a WARN_ON then, OK, otherwise abort.
> +                */
> +               if ((lines > 5) &&
> +                   (!(dumpable & (FWTS_OOPS_GOT_OOPS | FWTS_OOPS_GOT_WARN_ON))))
>                         return;
>
>         }
> @@ -73,12 +84,21 @@ void fwts_oops_dump(fwts_framework *fw, fwts_list_link *bug_item, int *oopses)
>         if (item == NULL)
>                 return;
>
> -
>         /* Found all the features that indicate an oops, so dump it */
> -       if (dumpable & FWTS_OOPS_DUMPABLE) {
> +       if ((dumpable & FWTS_OOPS_DUMPABLE) == FWTS_OOPS_DUMPABLE) {
>                 (*oopses)++;
>                 fwts_log_info(fw, "Found OOPS (%d):", *oopses);
> +               dumpstack = true;
> +       }
>
> +       /* Found all the features that indicate a WARN_ON, so dump it */
> +       if ((dumpable & FWTS_WARN_ON_DUMPABLE) == FWTS_WARN_ON_DUMPABLE) {
> +               (*warn_ons)++;
> +               fwts_log_info(fw, "Found WARNING (%d):", *warn_ons);
> +               dumpstack = true;
> +       }
> +
> +       if (dumpstack) {
>                 while (bug_item != NULL && bug_item != item) {
>                         fwts_log_info_verbatum(fw, "  %s",
>                                 fwts_klog_remove_timestamp(fwts_list_data(char *, bug_item)));
> @@ -94,17 +114,22 @@ void fwts_oops_dump(fwts_framework *fw, fwts_list_link *bug_item, int *oopses)
>   *     messages found is returned in 'oopses'.  Oops messages are logged to the
>   *     fwts log.
>   */
> -int fwts_oops_check(fwts_framework *fw, fwts_list *klog, int *oopses)
> +int fwts_oops_check(fwts_framework *fw, fwts_list *klog, int *oopses, int *warn_ons)
>  {
>         fwts_list_link *item;
>         *oopses = 0;
> +       *warn_ons = 0;
>
> -       if ((fw == NULL) || (oopses == NULL) || (klog == NULL))
> +       /* Sanity check */
> +       if ((fw == NULL) || (oopses == NULL) ||
> +           (warn_ons == NULL) || (klog == NULL))
>                 return FWTS_ERROR;
>
>         fwts_list_foreach(item, klog) {
> -               if (strncmp("BUG:", fwts_klog_remove_timestamp(fwts_list_data(char *, item)), 4) == 0)
> -                       fwts_oops_dump(fw, item, oopses);
> +               char *line = fwts_klog_remove_timestamp(fwts_list_data(char *, item));
> +               if ((strncmp("BUG:", line, 4) == 0) ||
> +                   (strncmp("WARNING:", line, 8) == 0))
> +                       fwts_klog_stack_dump(fw, item, oopses, warn_ons);
>         }
>
>         return FWTS_OK;
> --
> 1.7.10.4
>
Acked-by: Keng-Yu Lin <kengyu@canonical.com>

Patch

diff --git a/src/lib/include/fwts_oops.h b/src/lib/include/fwts_oops.h
index 556b1c5..e09e5e3 100644
--- a/src/lib/include/fwts_oops.h
+++ b/src/lib/include/fwts_oops.h
@@ -22,6 +22,6 @@ 
 
 #include <sys/types.h>
 
-int fwts_oops_check(fwts_framework *fw, fwts_list *klog, int *oopses);
+int fwts_oops_check(fwts_framework *fw, fwts_list *klog, int *oopses, int *warn_ons);
 
 #endif
diff --git a/src/lib/src/fwts_oops.c b/src/lib/src/fwts_oops.c
index fe557e5..4eaad1f 100644
--- a/src/lib/src/fwts_oops.c
+++ b/src/lib/src/fwts_oops.c
@@ -25,33 +25,40 @@ 
 #include "fwts.h"
 
 #define FWTS_OOPS_GOT_OOPS		(0x0001)
-#define FWTS_OOPS_GOT_STACK		(0x0002)
-#define FWTS_OOPS_GOT_CALL_TRACE	(0x0004)
-#define FWTS_OOPS_GOT_END_TRACE		(0x0008)
+#define FWTS_OOPS_GOT_CALL_TRACE	(0x0002)
+#define FWTS_OOPS_GOT_END_TRACE		(0x0004)
+#define FWTS_OOPS_GOT_WARN_ON		(0x0008)
 
 #define FWTS_OOPS_DUMPABLE		\
-	(FWTS_OOPS_GOT_OOPS | FWTS_OOPS_GOT_STACK | FWTS_OOPS_GOT_CALL_TRACE | FWTS_OOPS_GOT_END_TRACE)
+	(FWTS_OOPS_GOT_OOPS | FWTS_OOPS_GOT_CALL_TRACE | FWTS_OOPS_GOT_END_TRACE)
 
+#define FWTS_WARN_ON_DUMPABLE		\
+	(FWTS_OOPS_GOT_WARN_ON | FWTS_OOPS_GOT_CALL_TRACE | FWTS_OOPS_GOT_END_TRACE)
 
 /*
- *  fwts_oops_dump()
- *	for a given item in a kernel log list, scan for an oops message and
- *	if we find an oops message increment 'oopses' and dump out the oops
- *	message to the fwts log
+ *  fwts_klog_stack_dump()
+ *	for a given item in a kernel log list, scan for an oops or WARN_ON message.
+ *	Increment oopses or warn_ons depending on what we find and dump out the stack
+ *	trace to the fwts log
  */
-void fwts_oops_dump(fwts_framework *fw, fwts_list_link *bug_item, int *oopses)
+static void fwts_klog_stack_dump(
+	fwts_framework *fw,
+	fwts_list_link *bug_item,
+	int *oopses,
+	int *warn_ons)
 {
 	fwts_list_link *item = bug_item;
 	int lines = 0;
 	int dumpable = 0;
+	bool dumpstack = false;
 
 	fwts_list_foreach_continue(item) {
 		char *line = fwts_klog_remove_timestamp(fwts_list_data(char *, item));
 
 		if (strstr(line, "Oops:"))
 			dumpable |= FWTS_OOPS_GOT_OOPS;
-		if (strstr(line, "Stack:"))
-			dumpable |= FWTS_OOPS_GOT_STACK;
+		if (strstr(line, "WARNING: at"))
+			dumpable |= FWTS_OOPS_GOT_WARN_ON;
 		if (strstr(line, "Call Trace:"))
 			dumpable |= FWTS_OOPS_GOT_CALL_TRACE;
 		if (strstr(line, "--[ end trace")) {
@@ -60,8 +67,12 @@  void fwts_oops_dump(fwts_framework *fw, fwts_list_link *bug_item, int *oopses)
 		}
 		lines++;
 
-		/* We are looking for an Oops message within 5 lines of a "BUG:" */
-		if ((lines > 5) && (!(dumpable & FWTS_OOPS_GOT_OOPS)))
+		/*
+		 * We are looking for an Oops message within 5 lines of a "BUG:"
+		 * or we've got a WARN_ON then, OK, otherwise abort.
+		 */
+		if ((lines > 5) && 
+		    (!(dumpable & (FWTS_OOPS_GOT_OOPS | FWTS_OOPS_GOT_WARN_ON))))
 			return;
 
 	}
@@ -73,12 +84,21 @@  void fwts_oops_dump(fwts_framework *fw, fwts_list_link *bug_item, int *oopses)
 	if (item == NULL)
 		return;
 
-
 	/* Found all the features that indicate an oops, so dump it */
-	if (dumpable & FWTS_OOPS_DUMPABLE) {
+	if ((dumpable & FWTS_OOPS_DUMPABLE) == FWTS_OOPS_DUMPABLE) {
 		(*oopses)++;
 		fwts_log_info(fw, "Found OOPS (%d):", *oopses);
+		dumpstack = true;
+	}
 
+	/* Found all the features that indicate a WARN_ON, so dump it */
+	if ((dumpable & FWTS_WARN_ON_DUMPABLE) == FWTS_WARN_ON_DUMPABLE) {
+		(*warn_ons)++;
+		fwts_log_info(fw, "Found WARNING (%d):", *warn_ons);
+		dumpstack = true;
+	}
+
+	if (dumpstack) {
 		while (bug_item != NULL && bug_item != item) {
 			fwts_log_info_verbatum(fw, "  %s",
 				fwts_klog_remove_timestamp(fwts_list_data(char *, bug_item)));
@@ -94,17 +114,22 @@  void fwts_oops_dump(fwts_framework *fw, fwts_list_link *bug_item, int *oopses)
  *	messages found is returned in 'oopses'.  Oops messages are logged to the
  *	fwts log.
  */
-int fwts_oops_check(fwts_framework *fw, fwts_list *klog, int *oopses)
+int fwts_oops_check(fwts_framework *fw, fwts_list *klog, int *oopses, int *warn_ons)
 {
 	fwts_list_link *item;
 	*oopses = 0;
+	*warn_ons = 0;
 
-	if ((fw == NULL) || (oopses == NULL) || (klog == NULL))
+	/* Sanity check */
+	if ((fw == NULL) || (oopses == NULL) ||
+	    (warn_ons == NULL) || (klog == NULL))
 		return FWTS_ERROR;
 
 	fwts_list_foreach(item, klog) {
-		if (strncmp("BUG:", fwts_klog_remove_timestamp(fwts_list_data(char *, item)), 4) == 0)
-			fwts_oops_dump(fw, item, oopses);
+		char *line = fwts_klog_remove_timestamp(fwts_list_data(char *, item));
+		if ((strncmp("BUG:", line, 4) == 0) ||
+		    (strncmp("WARNING:", line, 8) == 0))
+			fwts_klog_stack_dump(fw, item, oopses, warn_ons);
 	}
 
 	return FWTS_OK;