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: 566685 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 12A9514032F for ; Wed, 13 Jan 2016 06:01:11 +1100 (AEDT) Received: from localhost ([::1]:33729 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aJ4Bo-0001H1-VD for incoming@patchwork.ozlabs.org; Tue, 12 Jan 2016 14:01:08 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43772) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aJ483-00028V-Gj for qemu-devel@nongnu.org; Tue, 12 Jan 2016 13:57:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aJ480-0003ZR-E0 for qemu-devel@nongnu.org; Tue, 12 Jan 2016 13:57:15 -0500 Received: from mga11.intel.com ([192.55.52.93]:21781) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aJ480-0003ZB-5A for qemu-devel@nongnu.org; Tue, 12 Jan 2016 13:57:12 -0500 Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP; 12 Jan 2016 10:57:11 -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 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> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 192.55.52.93 Cc: Xiao Guangrong , ehabkost@redhat.com, kvm@vger.kernel.org, mst@redhat.com, gleb@kernel.org, mtosatti@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com, dan.j.williams@intel.com, rth@twiddle.net Subject: [Qemu-devel] [PATCH v2 01/11] tests: acpi: test multiple SSDT tables X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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;