ACK: [PATCH 17/20] coreboot/clog/clog.c: add clog test

Colin Ian King colin.king at canonical.com
Thu Jun 21 15:56:11 UTC 2018


On 20/06/18 13:14, Marcello Sylvester Bauer wrote:
> Add coreboot log error and warning scanning test
> 
> Signed-off-by: Marcello Sylvester Bauer <info at marcellobauer.com>
> ---
>  data/clog.json           | 12 +++++++
>  src/Makefile.am          |  1 +
>  src/coreboot/clog/clog.c | 87 ++++++++++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 100 insertions(+)
>  create mode 100644 data/clog.json
>  create mode 100644 src/coreboot/clog/clog.c
> 
> diff --git a/data/clog.json b/data/clog.json
> new file mode 100644
> index 00000000..f2594bcc
> --- /dev/null
> +++ b/data/clog.json
> @@ -0,0 +1,12 @@
> +{
> + "firmware_error_warning_patterns":
> + [
> +  {
> +    "compare_mode": "string",
> +    "log_level": "LOG_LEVEL_LOW",
> +    "pattern": "magic pattern string which will definitely not appear in the logs",
> +    "advice": "This is only a template.",
> +    "label": "template"
> +  }
> + ]
> +}
> diff --git a/src/Makefile.am b/src/Makefile.am
> index 4daa9e8f..b2ea8830 100644
> --- a/src/Makefile.am
> +++ b/src/Makefile.am
> @@ -154,6 +154,7 @@ fwts_SOURCES = main.c 				\
>  	bios/pnp/pnp.c 				\
>  	bios/romdump/romdump.c 			\
>  	cmos/cmosdump/cmosdump.c 		\
> +	coreboot/clog/clog.c			\
>  	cpu/virt/virt.c 			\
>  	cpu/virt/virt_svm.c 			\
>  	cpu/virt/virt_vmx.c			\
> diff --git a/src/coreboot/clog/clog.c b/src/coreboot/clog/clog.c
> new file mode 100644
> index 00000000..adb8aa83
> --- /dev/null
> +++ b/src/coreboot/clog/clog.c
> @@ -0,0 +1,87 @@
> +/*
> + * Copyright (C) 2010-2018 Canonical
> + * Copyright (C) 2018 9elements Cyber Security
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License
> + * as published by the Free Software Foundation; either version 2
> + * of the License, or (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
> + *
> + */
> +#include "fwts.h"
> +
> +#include <stdlib.h>
> +#include <stdio.h>
> +#include <sys/types.h>
> +#include <sys/stat.h>
> +#include <unistd.h>
> +
> +static fwts_list *clog;
> +
> +static int clog_init(fwts_framework *fw)
> +{
> +	clog = fwts_clog_read();
> +
> +	if (clog == NULL) {
> +		fwts_log_error(fw, "Cannot read coreboot log.");
> +		return FWTS_ERROR;
> +	}
> +	return FWTS_OK;
> +}
> +
> +static int clog_deinit(fwts_framework *fw)
> +{
> +	FWTS_UNUSED(fw);
> +
> +	fwts_clog_free(clog);
> +
> +	return FWTS_OK;
> +}
> +
> +static void clog_progress(fwts_framework *fw, int progress)
> +{
> +	fwts_progress(fw, progress);
> +}
> +
> +static int clog_test1(fwts_framework *fw)
> +{
> +	int errors = 0;
> +
> +	if (fwts_clog_firmware_check(fw, clog_progress, clog, &errors)) {
> +		fwts_log_error(fw, "Error parsing coreboot log.");
> +		return FWTS_ERROR;
> +	}
> +
> +	if (errors > 0)
> +		/* Checks will log errors as failures automatically */
> +		fwts_log_info(fw, "Found %d unique errors in coreboot log.",
> +			errors);
> +	else
> +		fwts_passed(fw, "Found no errors in coreboot log.");
> +
> +	return FWTS_OK;
> +}
> +
> +static fwts_framework_minor_test clog_tests[] = {
> +	{ clog_test1, "coreboot log error check." },
> +	{ NULL, NULL }
> +};
> +
> +static fwts_framework_ops clog_ops = {
> +	.description = "Scan coreboot log for errors and warnings.",
> +	.init        = clog_init,
> +	.deinit      = clog_deinit,
> +	.minor_tests = clog_tests
> +};
> +
> +FWTS_REGISTER("clog", &clog_ops, FWTS_TEST_EARLY, FWTS_FLAG_BATCH)
> +
> 
Acked-by: Colin Ian King <colin.king at canonical.com>



More information about the fwts-devel mailing list