[PATCH][V2] fwts_acpi_object_eval: add a function to check package

Alex Hung alex.hung at canonical.com
Mon May 25 08:22:34 UTC 2020


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     | 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 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..f8d22eb4 100644
--- a/src/lib/src/fwts_acpi_object_eval.c
+++ b/src/lib/src/fwts_acpi_object_eval.c
@@ -881,6 +881,35 @@ 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;
+
+	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
-- 
2.25.1




More information about the fwts-devel mailing list