ACK: [PATCH][V3] fwts_acpi_object_eval: add a function to check package

ivanhu ivan.hu at canonical.com
Thu May 28 01:42:19 UTC 2020



On 5/27/20 1:36 AM, Alex Hung wrote:
> This function checks if all elements are integers in a returned package.
> This is one of common forms returned by ACPI methods.
> 
> 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     | 32 +++++++++++++++++++++++++
>  2 files changed, 33 insertions(+)
> 
> diff --git a/src/lib/include/fwts_acpi_object_eval.h b/src/lib/include/fwts_acpi_object_eval.h
> index 09f3f754..92177857 100644
> --- a/src/lib/include/fwts_acpi_object_eval.h
> +++ b/src/lib/include/fwts_acpi_object_eval.h
> @@ -128,6 +128,7 @@ void fwts_method_test_buffer_return(fwts_framework *fw, char *name, ACPI_BUFFER
>  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_package_integer_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 1e3575c9..9a7124f7 100644
> --- a/src/lib/src/fwts_acpi_object_eval.c
> +++ b/src/lib/src/fwts_acpi_object_eval.c
> @@ -881,6 +881,38 @@ void fwts_method_test_integer_max_return(
>  		fwts_passed(fw, "%s correctly returned an integer.", name);
>  }
>  
> +/*
> + *  fwts_method_test_package_integer_return
> + *	check if all integers in a returned package
> + */
> +void fwts_method_test_package_integer_return(
> +	fwts_framework *fw,
> +	char *name,
> +	ACPI_BUFFER *buf,
> +	ACPI_OBJECT *obj,
> +	void *private)
> +{
> +	char method[5];
> +	uint32_t *element_size = (uint32_t *) private;
> +
> +	if (strlen(name) < 4)
> +		return;
> +
> +	memcpy(method, name + strlen(name) - 4, 4);
> +	method[4] = '\0';
> +
> +	if (fwts_method_check_type(fw, name, buf, ACPI_TYPE_PACKAGE) != FWTS_OK)
> +		return;
> +
> +	if (fwts_method_package_count_equal(fw, name, method, obj, *element_size) != FWTS_OK)
> +		return;
> +
> +	if (fwts_method_package_elements_all_type(fw, name, method, obj, ACPI_TYPE_INTEGER) != FWTS_OK)
> +		return;
> +
> +	fwts_method_passed_sane(fw, name, "package");
> +}
> +
>  /*
>   *  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