[PATCH 19/20] fwts_clog.c: add fwts_clog_available

Marcello Sylvester Bauer info at marcellobauer.com
Tue Jun 26 13:10:53 UTC 2018


Add a function to test the accessibility of coreboot logs.
If this is not the case, the clog test will be skipped.

Signed-off-by: Marcello Sylvester Bauer <info at marcellobauer.com>
---
 src/coreboot/clog/clog.c    |  5 +++++
 src/lib/include/fwts_clog.h |  1 +
 src/lib/src/fwts_clog.c     | 22 ++++++++++++++++++++++
 3 files changed, 28 insertions(+)

diff --git a/src/coreboot/clog/clog.c b/src/coreboot/clog/clog.c
index caf0fecf..5feca313 100644
--- a/src/coreboot/clog/clog.c
+++ b/src/coreboot/clog/clog.c
@@ -29,6 +29,11 @@ static fwts_list *clog;
 
 static int clog_init(fwts_framework *fw)
 {
+	if (!fwts_clog_available(fw)) {
+		fwts_log_info(fw, "coreboot log not available, skipping test");
+		return FWTS_SKIP;
+	}
+
 	clog = fwts_clog_read(fw);
 
 	if (clog == NULL) {
diff --git a/src/lib/include/fwts_clog.h b/src/lib/include/fwts_clog.h
index 6f3bab6c..0981717e 100644
--- a/src/lib/include/fwts_clog.h
+++ b/src/lib/include/fwts_clog.h
@@ -27,6 +27,7 @@ typedef void (*fwts_clog_progress_func)(fwts_framework *fw, int percent);
 typedef void (*fwts_clog_scan_func)(fwts_framework *fw, char *line, int repeated, char *prevline, void *private, int *errors);
 
 void       fwts_clog_free(fwts_list *list);
+bool       fwts_clog_available(fwts_framework *fw);
 fwts_list *fwts_clog_read(fwts_framework *fw);
 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);
diff --git a/src/lib/src/fwts_clog.c b/src/lib/src/fwts_clog.c
index 80576bd6..91e4bd49 100644
--- a/src/lib/src/fwts_clog.c
+++ b/src/lib/src/fwts_clog.c
@@ -36,6 +36,11 @@
 */
 #define UNIQUE_CLOG_LABEL       "Clog"
 
+/*
+ *  coreboot dmi entry
+ */
+#define COREBOOT_BIOS_VENDOR	"coreboot"
+
 /*
  *  free coreboot log list
  */
@@ -44,6 +49,23 @@ void fwts_clog_free(fwts_list *clog)
         fwts_log_free(clog);
 }
 
+bool fwts_clog_available(fwts_framework *fw)
+{
+    bool coreboot_tag = false;
+    char *vendor = fwts_get("/sys/class/dmi/id/bios_vendor");
+
+    if (vendor) {
+        if (strstr(vendor, COREBOOT_BIOS_VENDOR))
+            coreboot_tag = true;
+        free(vendor);
+    }
+
+    if (fw->clog || coreboot_tag)
+        return true;
+
+   return false;
+}
+
 /*
  *  read coreboot log and return as list of lines
  *  TODO: find coreboot log in /dev/mem
-- 
2.16.4




More information about the fwts-devel mailing list