summary refs log tree commit diff stats
path: root/tests/qtest/acpi-utils.c
diff options
context:
space:
mode:
authorIgor Mammedov <imammedo@redhat.com>2021-09-02 07:35:37 -0400
committerMichael S. Tsirkin <mst@redhat.com>2021-10-20 04:37:55 -0400
commit685db13a38f7599fabd353382ff65d3c244ea641 (patch)
tree1ff3131243aa6dd9820380d275de3ee99c1004bc /tests/qtest/acpi-utils.c
parent50352cce138ef3b30c1cda28a4df68fff5da3202 (diff)
downloadfocaccia-qemu-685db13a38f7599fabd353382ff65d3c244ea641.tar.gz
focaccia-qemu-685db13a38f7599fabd353382ff65d3c244ea641.zip
tests: acpi: dump table with failed checksum
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Message-Id: <20210902113551.461632-2-imammedo@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'tests/qtest/acpi-utils.c')
-rw-r--r--tests/qtest/acpi-utils.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/qtest/acpi-utils.c b/tests/qtest/acpi-utils.c
index d2a202efca..766c48e3a6 100644
--- a/tests/qtest/acpi-utils.c
+++ b/tests/qtest/acpi-utils.c
@@ -98,6 +98,20 @@ void acpi_fetch_table(QTestState *qts, uint8_t **aml, uint32_t *aml_len,
         ACPI_ASSERT_CMP(**aml, sig);
     }
     if (verify_checksum) {
+        if (acpi_calc_checksum(*aml, *aml_len)) {
+            gint fd, ret;
+            char *fname = NULL;
+            GError *error = NULL;
+
+            fprintf(stderr, "Invalid '%.4s'(%d)\n", *aml, *aml_len);
+            fd = g_file_open_tmp("malformed-XXXXXX.dat", &fname, &error);
+            g_assert_no_error(error);
+            fprintf(stderr, "Dumping invalid table into '%s'\n", fname);
+            ret = qemu_write_full(fd, *aml, *aml_len);
+            g_assert(ret == *aml_len);
+            close(fd);
+            g_free(fname);
+        }
         g_assert(!acpi_calc_checksum(*aml, *aml_len));
     }
 }