On 03/18/14 15:48, Michael S. Tsirkin wrote:
> acpi table signature is really an ASCII string.
> Treat it as such in tests.
> 
> Signed-off-by: Michael S. Tsirkin <m...@redhat.com>
> ---
>  tests/acpi-test.c | 48 +++++++++++++++++++++++++++++++++---------------
>  1 file changed, 33 insertions(+), 15 deletions(-)
> 
> diff --git a/tests/acpi-test.c b/tests/acpi-test.c
> index 185309a..249fe03 100644
> --- a/tests/acpi-test.c
> +++ b/tests/acpi-test.c
> @@ -23,7 +23,6 @@
>  #define MACHINE_Q35 "q35"
>  
>  #define ACPI_REBUILD_EXPECTED_AML "TEST_ACPI_REBUILD_AML"
> -#define ACPI_SSDT_SIGNATURE 0x54445353 /* SSDT */
>  
>  /* DSDT and SSDTs format */
>  typedef struct {
> @@ -101,6 +100,20 @@ typedef struct {
>          ACPI_READ_FIELD((table)->asl_compiler_revision, addr);   \
>      } while (0);
>  
> +#define ACPI_ASSERT_CMP(actual, expected) do { \
> +    uint32_t ACPI_ASSERT_CMP_le = cpu_to_le32(actual); \
> +    char ACPI_ASSERT_CMP_str[5] = {}; \
> +    memcpy(ACPI_ASSERT_CMP_str, &ACPI_ASSERT_CMP_le, 4); \
> +    g_assert_cmpstr(ACPI_ASSERT_CMP_str, ==, expected); \
> +} while (0)
> +
> +#define ACPI_ASSERT_CMP64(actual, expected) do { \
> +    uint64_t ACPI_ASSERT_CMP_le = cpu_to_le64(actual); \
> +    char ACPI_ASSERT_CMP_str[9] = {}; \
> +    memcpy(ACPI_ASSERT_CMP_str, &ACPI_ASSERT_CMP_le, 8); \
> +    g_assert_cmpstr(ACPI_ASSERT_CMP_str, ==, expected); \
> +} while (0)
> +

The {} initializers are GNUisms, { 0 } is the standard way to write them.

(For strings where you specify the size explicitly, = "" would work too
(in C99 explicitly, in C89 a bit more navel gazing would be required to
derive that).)

The patch seems reasonable to me.

Reviewed-by: Laszlo Ersek <ler...@redhat.com>

Reply via email to