From patchwork Tue Jan 12 18:50:00 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiao Guangrong X-Patchwork-Id: 8020191 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id A9AA8BEEED for ; Tue, 12 Jan 2016 18:57:17 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CFFCC20411 for ; Tue, 12 Jan 2016 18:57:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B98062041A for ; Tue, 12 Jan 2016 18:57:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1763336AbcALS5N (ORCPT ); Tue, 12 Jan 2016 13:57:13 -0500 Received: from mga14.intel.com ([192.55.52.115]:19771 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751121AbcALS5L (ORCPT ); Tue, 12 Jan 2016 13:57:11 -0500 Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga103.fm.intel.com with ESMTP; 12 Jan 2016 10:57:12 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.22,558,1449561600"; d="scan'208";a="891764318" Received: from xiaoreal1.sh.intel.com (HELO xiaoreal1.sh.intel.com.sh.intel.com) ([10.239.48.79]) by fmsmga002.fm.intel.com with ESMTP; 12 Jan 2016 10:57:09 -0800 From: Xiao Guangrong To: pbonzini@redhat.com, imammedo@redhat.com Cc: gleb@kernel.org, mtosatti@redhat.com, stefanha@redhat.com, mst@redhat.com, rth@twiddle.net, ehabkost@redhat.com, dan.j.williams@intel.com, kvm@vger.kernel.org, qemu-devel@nongnu.org, Xiao Guangrong Subject: [PATCH v2 01/11] tests: acpi: test multiple SSDT tables Date: Wed, 13 Jan 2016 02:50:00 +0800 Message-Id: <1452624610-46945-2-git-send-email-guangrong.xiao@linux.intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1452624610-46945-1-git-send-email-guangrong.xiao@linux.intel.com> References: <1452624610-46945-1-git-send-email-guangrong.xiao@linux.intel.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Currently, only one SSDT with default oem-table-id can be tested, this patch extents it to test all SSDT tables Other tables except the default one will be named as SSDT-$oem-table-id Signed-off-by: Xiao Guangrong --- tests/bios-tables-test.c | 43 ++++++++++++++++++++++++++++++++----------- 1 file changed, 32 insertions(+), 11 deletions(-) diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c index 75ec330..fc01cce 100644 --- a/tests/bios-tables-test.c +++ b/tests/bios-tables-test.c @@ -18,6 +18,7 @@ #include "libqtest.h" #include "qemu/compiler.h" #include "hw/acpi/acpi-defs.h" +#include "hw/acpi/aml-build.h" #include "hw/smbios/smbios.h" #include "qemu/bitmap.h" @@ -379,6 +380,33 @@ static void test_acpi_tables(test_data *data) } } +static gchar *get_sdt_aml_file_name(test_data *data, AcpiSdtTable *sdt, + bool skip_variant) +{ + gchar *aml_file, *def_oem_table_id, *oem_table_id, *sig_oem; + uint32_t signature = cpu_to_le32(sdt->header.signature); + const char *ext = data->variant && !skip_variant ? data->variant : ""; + + def_oem_table_id = g_strdup_printf("%s%s", ACPI_BUILD_APPNAME4, + (gchar *)&signature); + oem_table_id = g_strndup((char *)sdt->header.oem_table_id, + sizeof(sdt->header.oem_table_id)); + + if (strcmp(oem_table_id, def_oem_table_id)) { + sig_oem = g_strdup_printf("%.4s-%s", (gchar *)&signature, + oem_table_id); + } else { + sig_oem = g_strdup_printf("%.4s", (gchar *)&signature); + } + + aml_file = g_strdup_printf("%s/%s/%s%s", data_dir, data->machine, + sig_oem, ext); + g_free(sig_oem); + g_free(oem_table_id); + g_free(def_oem_table_id); + return aml_file; +} + static void dump_aml_files(test_data *data, bool rebuild) { AcpiSdtTable *sdt; @@ -389,14 +417,11 @@ static void dump_aml_files(test_data *data, bool rebuild) int i; for (i = 0; i < data->tables->len; ++i) { - const char *ext = data->variant ? data->variant : ""; sdt = &g_array_index(data->tables, AcpiSdtTable, i); g_assert(sdt->aml); if (rebuild) { - uint32_t signature = cpu_to_le32(sdt->header.signature); - aml_file = g_strdup_printf("%s/%s/%.4s%s", data_dir, data->machine, - (gchar *)&signature, ext); + aml_file = get_sdt_aml_file_name(data, sdt, false); fd = g_open(aml_file, O_WRONLY|O_TRUNC|O_CREAT, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH); } else { @@ -508,22 +533,18 @@ static GArray *load_expected_aml(test_data *data) GArray *exp_tables = g_array_new(false, true, sizeof(AcpiSdtTable)); for (i = 0; i < data->tables->len; ++i) { AcpiSdtTable exp_sdt; - uint32_t signature; - const char *ext = data->variant ? data->variant : ""; + bool skip_variant = false; sdt = &g_array_index(data->tables, AcpiSdtTable, i); memset(&exp_sdt, 0, sizeof(exp_sdt)); exp_sdt.header.signature = sdt->header.signature; - signature = cpu_to_le32(sdt->header.signature); - try_again: - aml_file = g_strdup_printf("%s/%s/%.4s%s", data_dir, data->machine, - (gchar *)&signature, ext); + aml_file = get_sdt_aml_file_name(data, sdt, skip_variant); if (data->variant && !g_file_test(aml_file, G_FILE_TEST_EXISTS)) { g_free(aml_file); - ext = ""; + skip_variant = true; goto try_again; } exp_sdt.aml_file = aml_file;