Message ID | 20180620121446.31470-20-info@marcellobauer.com |
---|---|
State | Superseded |
Headers | show |
Series | coreboot test intergration | expand |
On 20/06/18 13:14, Marcello Sylvester Bauer wrote: > 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@marcellobauer.com> > --- > src/coreboot/clog/clog.c | 5 +++++ > src/lib/include/fwts_clog.h | 1 + > src/lib/src/fwts_clog.c | 15 +++++++++++++++ > 3 files changed, 21 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..32c21b61 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,16 @@ void fwts_clog_free(fwts_list *clog) > fwts_log_free(clog); > } > > +bool fwts_clog_available(fwts_framework *fw) > +{ > + char *vendor = fwts_get("/sys/class/dmi/id/bios_vendor"); A C string is returned from fwts_get... and should be null checked for a failed allocation. > + > + if (fw->clog || (vendor && strstr(vendor, COREBOOT_BIOS_VENDOR))) > + return true; ..and leaked here, a free(vendor) is required > + > + return false ..and also leaked here too. > +} > + > /* > * read coreboot log and return as list of lines > * TODO: find coreboot log in /dev/mem >
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..32c21b61 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,16 @@ void fwts_clog_free(fwts_list *clog) fwts_log_free(clog); } +bool fwts_clog_available(fwts_framework *fw) +{ + char *vendor = fwts_get("/sys/class/dmi/id/bios_vendor"); + + if (fw->clog || (vendor && strstr(vendor, COREBOOT_BIOS_VENDOR))) + return true; + + return false; +} + /* * read coreboot log and return as list of lines * TODO: find coreboot log in /dev/mem
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@marcellobauer.com> --- src/coreboot/clog/clog.c | 5 +++++ src/lib/include/fwts_clog.h | 1 + src/lib/src/fwts_clog.c | 15 +++++++++++++++ 3 files changed, 21 insertions(+)