Antwort: [PATCH v2 19/39] acpi: Move acpi_fill_header() to generic code

Wolfgang Wallner wolfgang.wallner at br-automation.com
Wed Mar 11 10:04:27 CET 2020


Hi Simon,

looking at this patch some more I have another question, see below.

-----"Simon Glass" <sjg at chromium.org> schrieb: -----
> 
> This function needs to be used by sandbox for tests. Move it into the
> generic directory.
> 
> Signed-off-by: Simon Glass <sjg at chromium.org>
> Reviewed-by: Bin Meng <bmeng.cn at gmail.com>
> ---

[snip] 

> @@ -81,3 +82,30 @@ static int dm_test_acpi_create_dmar(struct unit_test_state *uts)
>  	return 0;
>  }
>  DM_TEST(dm_test_acpi_create_dmar, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
> +
> +/* Test acpi_fill_header() */
> +static int dm_test_acpi_fill_header(struct unit_test_state *uts)
> +{
> +	struct acpi_table_header hdr;
> +
> +	/* Make sure these 5 fields are not changed */
> +	hdr.length = 0x11;
> +	hdr.revision = 0x22;
> +	hdr.checksum = 0x33;
> +	hdr.aslc_revision = 0x44;
> +	acpi_fill_header(&hdr, "ABCD");
> +
> +	ut_assertok(memcmp("ABCD", hdr.signature, sizeof(hdr.signature)));

Could ut_asserteq_mem() be used here?
The output would be a little more verbose.

With ut_assertok(memcmp()):
 test/dm/acpi.c:104, dm_test_acpi_fill_header(): 0 == memcmp("ABCD", hdr.signature, sizeof(hdr.signature)): Expected 0x0 (0), got 0x13 (19)

With ut_assertmem_eq():
 test/dm/acpi.c:103, dm_test_acpi_fill_header(): "ABCD" = hdr.signature: Expected "41424344", got "41424331"

> +	ut_asserteq(0x11, hdr.length);
> +	ut_asserteq(0x22, hdr.revision);
> +	ut_asserteq(0x33, hdr.checksum);
> +	ut_assertok(memcmp(OEM_ID, hdr.oem_id, sizeof(hdr.oem_id)));
> +	ut_assertok(memcmp(OEM_TABLE_ID, hdr.oem_table_id,
> +			   sizeof(hdr.oem_table_id)));
> +	ut_asserteq(U_BOOT_BUILD_DATE, hdr.oem_revision);
> +	ut_assertok(memcmp(ASLC_ID, hdr.aslc_id, sizeof(hdr.aslc_id)));
> +	ut_asserteq(0x44, hdr.aslc_revision);
> +
> +	return 0;
> +}
> +DM_TEST(dm_test_acpi_fill_header, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
> -- 
> 2.25.1.481.gfbce0eb801-goog

regards, Wolfgang


More information about the U-Boot mailing list