ACK: [PATCH 1/2] lib: fwts_acpi_object_eval: add a function to check max returned integers
ivanhu
ivan.hu at canonical.com
Fri May 8 08:03:44 UTC 2020
On 5/8/20 4:26 AM, Alex Hung wrote:
> Signed-off-by: Alex Hung <alex.hung at canonical.com>
> ---
> src/lib/include/fwts_acpi_object_eval.h | 1 +
> src/lib/src/fwts_acpi_object_eval.c | 29 +++++++++++++++++++++++++
> 2 files changed, 30 insertions(+)
>
> diff --git a/src/lib/include/fwts_acpi_object_eval.h b/src/lib/include/fwts_acpi_object_eval.h
> index 32bba493..09f3f754 100644
> --- a/src/lib/include/fwts_acpi_object_eval.h
> +++ b/src/lib/include/fwts_acpi_object_eval.h
> @@ -127,6 +127,7 @@ void fwts_method_test_NULL_return(fwts_framework *fw, char *name, ACPI_BUFFER *b
> void fwts_method_test_buffer_return(fwts_framework *fw, char *name, ACPI_BUFFER *buf, ACPI_OBJECT *obj,void *private);
> void fwts_method_test_all_reference_package_return(fwts_framework *fw, char *name, ACPI_BUFFER *buf, ACPI_OBJECT *obj, void *private);
> void fwts_method_test_integer_reserved_bits_return(fwts_framework *fw, char *name, ACPI_BUFFER *buf, ACPI_OBJECT *obj, void *private);
> +void fwts_method_test_integer_max_return(fwts_framework *fw, char *name, ACPI_BUFFER *buf, ACPI_OBJECT *obj, void *private);
> void fwts_method_test_passed_failed_return(fwts_framework *fw, char *name, ACPI_BUFFER *buf, ACPI_OBJECT *obj, void *private);
> void fwts_method_test_polling_return( fwts_framework *fw, char *name, ACPI_BUFFER *buf, ACPI_OBJECT *obj, void *private);
>
> diff --git a/src/lib/src/fwts_acpi_object_eval.c b/src/lib/src/fwts_acpi_object_eval.c
> index d4613012..1e3575c9 100644
> --- a/src/lib/src/fwts_acpi_object_eval.c
> +++ b/src/lib/src/fwts_acpi_object_eval.c
> @@ -852,6 +852,35 @@ void fwts_method_test_integer_reserved_bits_return(
> fwts_passed(fw, "%s correctly returned an integer.", name);
> }
>
> +/*
> + * fwts_method_test_integer_max_return
> + * check if returned integer is less than a max value
> + */
> +void fwts_method_test_integer_max_return(
> + fwts_framework *fw,
> + char *name,
> + ACPI_BUFFER *buf,
> + ACPI_OBJECT *obj,
> + void *private)
> +{
> + uint64_t *max = (uint64_t *) private;
> + bool failed = false;
> +
> + if (fwts_method_check_type(fw, name, buf, ACPI_TYPE_INTEGER) != FWTS_OK)
> + return;
> +
> + if (obj->Integer.Value > *max) {
> + failed = true;
> + fwts_failed(fw, LOG_LEVEL_HIGH, "MethodOutOfRangeValue",
> + "%s returned value %" PRId64 " but range allowed "
> + "is 0..%" PRId64 " .",
> + name, (uint64_t) obj->Integer.Value, *max);
> + }
> +
> + if (!failed)
> + fwts_passed(fw, "%s correctly returned an integer.", name);
> +}
> +
> /*
> * fwts_method_test_passed_failed_return
> * check if 0 or 1 (false/true) integer is returned
>
Acked-by: Ivan Hu <ivan.hu at canonical.com>
More information about the fwts-devel
mailing list