From patchwork Thu Sep 29 21:14:49 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 9357071 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B4E696077A for ; Thu, 29 Sep 2016 21:16:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A103D29C44 for ; Thu, 29 Sep 2016 21:16:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 951A729C4C; Thu, 29 Sep 2016 21:16:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2A5F929C44 for ; Thu, 29 Sep 2016 21:16:28 +0000 (UTC) Received: from localhost ([::1]:40344 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bpigt-0007il-A9 for patchwork-qemu-devel@patchwork.kernel.org; Thu, 29 Sep 2016 17:16:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40227) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bpigd-0007iJ-FY for qemu-devel@nongnu.org; Thu, 29 Sep 2016 17:16:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bpiga-0004GV-1G for qemu-devel@nongnu.org; Thu, 29 Sep 2016 17:16:11 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39510) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bpigZ-0004GO-RX for qemu-devel@nongnu.org; Thu, 29 Sep 2016 17:16:07 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 27BD619D239; Thu, 29 Sep 2016 21:16:07 +0000 (UTC) Received: from localhost (ovpn-116-132.phx2.redhat.com [10.3.116.132]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u8TLG5fj026205; Thu, 29 Sep 2016 17:16:06 -0400 From: Eduardo Habkost To: qemu-devel@nongnu.org Date: Thu, 29 Sep 2016 18:14:49 -0300 Message-Id: <1475183699-11646-2-git-send-email-ehabkost@redhat.com> In-Reply-To: <1475183699-11646-1-git-send-email-ehabkost@redhat.com> References: <1475183699-11646-1-git-send-email-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 29 Sep 2016 21:16:07 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v4 01/11] tests: Add test case for x86 feature parsing compatibility X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: libvir-list@redhat.com, Markus Armbruster , dahi@linux.vnet.ibm.com, Paolo Bonzini , Igor Mammedov , Jiri Denemark , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Add a new test case to ensure the existing behavior of the feature parsing code wlil be kept. Signed-off-by: Eduardo Habkost --- Changes series v3 -> v4: * New patch added to series --- tests/test-x86-cpuid-compat.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/tests/test-x86-cpuid-compat.c b/tests/test-x86-cpuid-compat.c index 83162a4..7cff2b5 100644 --- a/tests/test-x86-cpuid-compat.c +++ b/tests/test-x86-cpuid-compat.c @@ -3,6 +3,7 @@ #include "qapi/qmp/qlist.h" #include "qapi/qmp/qdict.h" #include "qapi/qmp/qint.h" +#include "qapi/qmp/qbool.h" #include "libqtest.h" static char *get_cpu0_qom_path(void) @@ -34,6 +35,15 @@ static QObject *qom_get(const char *path, const char *prop) return ret; } +static bool qom_get_bool(const char *path, const char *prop) +{ + QBool *value = qobject_to_qbool(qom_get(path, prop)); + bool b = qbool_get_bool(value); + + QDECREF(value); + return b; +} + typedef struct CpuidTestArgs { const char *cmdline; const char *property; @@ -66,10 +76,39 @@ static void add_cpuid_test(const char *name, const char *cmdline, qtest_add_data_func(name, args, test_cpuid_prop); } +static void test_plus_minus(void) +{ + char *path; + + /* Rules: + * "-foo" overrides "+foo" + * "[+-]foo" overrides "foo=..." + * "foo_bar" should be translated to "foo-bar" + */ + qtest_start("-cpu pentium,-fpu,+fpu,-mce,mce=on,+cx8,cx8=off,+sse4_1,sse4_2=on"); + path = get_cpu0_qom_path(); + + g_assert_false(qom_get_bool(path, "fpu")); + g_assert_false(qom_get_bool(path, "mce")); + g_assert_true(qom_get_bool(path, "cx8")); + + /* Test both the original and the alias feature names: */ + g_assert_true(qom_get_bool(path, "sse4-1")); + g_assert_true(qom_get_bool(path, "sse4.1")); + + g_assert_true(qom_get_bool(path, "sse4-2")); + g_assert_true(qom_get_bool(path, "sse4.2")); + + qtest_end(); + g_free(path); +} + int main(int argc, char **argv) { g_test_init(&argc, &argv, NULL); + qtest_add_func("x86/cpuid/parsing-plus-minus", test_plus_minus); + /* Original level values for CPU models: */ add_cpuid_test("x86/cpuid/phenom/level", "-cpu phenom", "level", 5);