diff mbox series

[16/20] fwts_clog: add fwts_clog_firmware_check

Message ID 20180620121446.31470-17-info@marcellobauer.com
State Accepted
Headers show
Series coreboot test intergration | expand

Commit Message

Marcello Sylvester Bauer June 20, 2018, 12:14 p.m. UTC
Signed-off-by: Marcello Sylvester Bauer <info@marcellobauer.com>
---
 src/lib/include/fwts_clog.h |  1 +
 src/lib/src/fwts_clog.c     | 30 ++++++++++++++++++++++++++++++
 2 files changed, 31 insertions(+)

Comments

Colin Ian King June 21, 2018, 3:55 p.m. UTC | #1
On 20/06/18 13:14, Marcello Sylvester Bauer wrote:
> Signed-off-by: Marcello Sylvester Bauer <info@marcellobauer.com>
> ---
>  src/lib/include/fwts_clog.h |  1 +
>  src/lib/src/fwts_clog.c     | 30 ++++++++++++++++++++++++++++++
>  2 files changed, 31 insertions(+)
> 
> diff --git a/src/lib/include/fwts_clog.h b/src/lib/include/fwts_clog.h
> index 89cfc350..96b7557c 100644
> --- a/src/lib/include/fwts_clog.h
> +++ b/src/lib/include/fwts_clog.h
> @@ -30,5 +30,6 @@ void       fwts_clog_free(fwts_list *list);
>  fwts_list *fwts_clog_read(void);
>  int        fwts_clog_scan(fwts_framework *fw, fwts_list *clog, fwts_clog_scan_func callback, fwts_clog_progress_func progress, void *private, int *errors);
>  void       fwts_clog_scan_patterns(fwts_framework *fw, char *line, int repeated, char *prevline, void *private, int *errors);
> +int        fwts_clog_firmware_check(fwts_framework *fw, fwts_clog_progress_func progress, fwts_list *clog, int *errors);
>  
>  #endif
> diff --git a/src/lib/src/fwts_clog.c b/src/lib/src/fwts_clog.c
> index d5babb31..3257d55b 100644
> --- a/src/lib/src/fwts_clog.c
> +++ b/src/lib/src/fwts_clog.c
> @@ -26,6 +26,16 @@
>   */
>  #define GOOGLE_MEMCONSOLE_COREBOOT_PATH	"/sys/firmware/log"
>  
> +/*
> + *  clog pattern matching strings data file, data stored in json format
> + */
> +#define CLOG_DATA_JSON_FILE     "clog.json"
> +
> +/*
> + *  match unique strings in the coreboot log
> +*/
> +#define UNIQUE_CLOG_LABEL       "Clog"
> +
>  /*
>   *  free coreboot log list
>   */
> @@ -71,3 +81,23 @@ void fwts_clog_scan_patterns(fwts_framework *fw,
>          "firmware test suite has no diagnostic advice for this particular problem.";
>      fwts_log_scan_patterns(fw, line, repeated, prevline, private, errors, "coreboot", advice);
>  }
> +
> +static int fwts_clog_check(fwts_framework *fw,
> +        const char *table,
> +        fwts_clog_progress_func progress,
> +        fwts_list *clog,
> +        int *errors)
> +{
> +        char json_data_path[PATH_MAX];
> +
> +        snprintf(json_data_path, sizeof(json_data_path), "%s/%s", fw->json_data_path, CLOG_DATA_JSON_FILE);
> +
> +        return fwts_log_check(fw, table, fwts_clog_scan_patterns, progress, clog, errors, json_data_path, UNIQUE_CLOG_LABEL, true);
> +}
> +
> +int fwts_clog_firmware_check(fwts_framework *fw, fwts_clog_progress_func progress,
> +        fwts_list *clog, int *errors)
> +{
> +        return fwts_clog_check(fw, "firmware_error_warning_patterns",
> +                progress, clog, errors);
> +}
> 
Acked-by: Colin Ian King <colin.king@canonical.com>
Alex Hung June 27, 2018, 10:58 p.m. UTC | #2
On 2018-06-20 05:14 AM, Marcello Sylvester Bauer wrote:
> Signed-off-by: Marcello Sylvester Bauer <info@marcellobauer.com>
> ---
>   src/lib/include/fwts_clog.h |  1 +
>   src/lib/src/fwts_clog.c     | 30 ++++++++++++++++++++++++++++++
>   2 files changed, 31 insertions(+)
> 
> diff --git a/src/lib/include/fwts_clog.h b/src/lib/include/fwts_clog.h
> index 89cfc350..96b7557c 100644
> --- a/src/lib/include/fwts_clog.h
> +++ b/src/lib/include/fwts_clog.h
> @@ -30,5 +30,6 @@ void       fwts_clog_free(fwts_list *list);
>   fwts_list *fwts_clog_read(void);
>   int        fwts_clog_scan(fwts_framework *fw, fwts_list *clog, fwts_clog_scan_func callback, fwts_clog_progress_func progress, void *private, int *errors);
>   void       fwts_clog_scan_patterns(fwts_framework *fw, char *line, int repeated, char *prevline, void *private, int *errors);
> +int        fwts_clog_firmware_check(fwts_framework *fw, fwts_clog_progress_func progress, fwts_list *clog, int *errors);
>   
>   #endif
> diff --git a/src/lib/src/fwts_clog.c b/src/lib/src/fwts_clog.c
> index d5babb31..3257d55b 100644
> --- a/src/lib/src/fwts_clog.c
> +++ b/src/lib/src/fwts_clog.c
> @@ -26,6 +26,16 @@
>    */
>   #define GOOGLE_MEMCONSOLE_COREBOOT_PATH	"/sys/firmware/log"
>   
> +/*
> + *  clog pattern matching strings data file, data stored in json format
> + */
> +#define CLOG_DATA_JSON_FILE     "clog.json"
> +
> +/*
> + *  match unique strings in the coreboot log
> +*/
> +#define UNIQUE_CLOG_LABEL       "Clog"
> +
>   /*
>    *  free coreboot log list
>    */
> @@ -71,3 +81,23 @@ void fwts_clog_scan_patterns(fwts_framework *fw,
>           "firmware test suite has no diagnostic advice for this particular problem.";
>       fwts_log_scan_patterns(fw, line, repeated, prevline, private, errors, "coreboot", advice);
>   }
> +
> +static int fwts_clog_check(fwts_framework *fw,
> +        const char *table,
> +        fwts_clog_progress_func progress,
> +        fwts_list *clog,
> +        int *errors)
> +{
> +        char json_data_path[PATH_MAX];
> +
> +        snprintf(json_data_path, sizeof(json_data_path), "%s/%s", fw->json_data_path, CLOG_DATA_JSON_FILE);
> +
> +        return fwts_log_check(fw, table, fwts_clog_scan_patterns, progress, clog, errors, json_data_path, UNIQUE_CLOG_LABEL, true);
> +}
> +
> +int fwts_clog_firmware_check(fwts_framework *fw, fwts_clog_progress_func progress,
> +        fwts_list *clog, int *errors)
> +{
> +        return fwts_clog_check(fw, "firmware_error_warning_patterns",
> +                progress, clog, errors);
> +}
> 


Acked-by: Alex Hung <alex.hung@canonical.com>
diff mbox series

Patch

diff --git a/src/lib/include/fwts_clog.h b/src/lib/include/fwts_clog.h
index 89cfc350..96b7557c 100644
--- a/src/lib/include/fwts_clog.h
+++ b/src/lib/include/fwts_clog.h
@@ -30,5 +30,6 @@  void       fwts_clog_free(fwts_list *list);
 fwts_list *fwts_clog_read(void);
 int        fwts_clog_scan(fwts_framework *fw, fwts_list *clog, fwts_clog_scan_func callback, fwts_clog_progress_func progress, void *private, int *errors);
 void       fwts_clog_scan_patterns(fwts_framework *fw, char *line, int repeated, char *prevline, void *private, int *errors);
+int        fwts_clog_firmware_check(fwts_framework *fw, fwts_clog_progress_func progress, fwts_list *clog, int *errors);
 
 #endif
diff --git a/src/lib/src/fwts_clog.c b/src/lib/src/fwts_clog.c
index d5babb31..3257d55b 100644
--- a/src/lib/src/fwts_clog.c
+++ b/src/lib/src/fwts_clog.c
@@ -26,6 +26,16 @@ 
  */
 #define GOOGLE_MEMCONSOLE_COREBOOT_PATH	"/sys/firmware/log"
 
+/*
+ *  clog pattern matching strings data file, data stored in json format
+ */
+#define CLOG_DATA_JSON_FILE     "clog.json"
+
+/*
+ *  match unique strings in the coreboot log
+*/
+#define UNIQUE_CLOG_LABEL       "Clog"
+
 /*
  *  free coreboot log list
  */
@@ -71,3 +81,23 @@  void fwts_clog_scan_patterns(fwts_framework *fw,
         "firmware test suite has no diagnostic advice for this particular problem.";
     fwts_log_scan_patterns(fw, line, repeated, prevline, private, errors, "coreboot", advice);
 }
+
+static int fwts_clog_check(fwts_framework *fw,
+        const char *table,
+        fwts_clog_progress_func progress,
+        fwts_list *clog,
+        int *errors)
+{
+        char json_data_path[PATH_MAX];
+
+        snprintf(json_data_path, sizeof(json_data_path), "%s/%s", fw->json_data_path, CLOG_DATA_JSON_FILE);
+
+        return fwts_log_check(fw, table, fwts_clog_scan_patterns, progress, clog, errors, json_data_path, UNIQUE_CLOG_LABEL, true);
+}
+
+int fwts_clog_firmware_check(fwts_framework *fw, fwts_clog_progress_func progress,
+        fwts_list *clog, int *errors)
+{
+        return fwts_clog_check(fw, "firmware_error_warning_patterns",
+                progress, clog, errors);
+}