All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eduardo Habkost <ehabkost@redhat.com>
To: qemu-devel@nongnu.org
Cc: dahi@linux.vnet.ibm.com, Paolo Bonzini <pbonzini@redhat.com>,
	Igor Mammedov <imammedo@redhat.com>,
	Jiri Denemark <jdenemar@redhat.com>,
	Markus Armbruster <armbru@redhat.com>,
	Richard Henderson <rth@twiddle.net>,
	libvir-list@redhat.com
Subject: [Qemu-devel] [PATCH v5 01/12] tests: Add test case for x86 feature parsing compatibility
Date: Fri, 30 Sep 2016 15:49:35 -0300	[thread overview]
Message-ID: <1475261386-20211-2-git-send-email-ehabkost@redhat.com> (raw)
In-Reply-To: <1475261386-20211-1-git-send-email-ehabkost@redhat.com>

Add a new test case to ensure the existing behavior of the
feature parsing code will be kept.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
Changes series v4 -> v5:
* Fix typo on commit message
  Reported-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
* Add comment noting that the "[+-]feature" compatibility mode
  will be removed soon

Changes series v3 -> v4:
* New patch added to series
---
 tests/test-x86-cpuid-compat.c | 44 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)

diff --git a/tests/test-x86-cpuid-compat.c b/tests/test-x86-cpuid-compat.c
index 83162a4..260dd27 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,44 @@ 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:
+     * 1)"-foo" overrides "+foo"
+     * 2) "[+-]foo" overrides "foo=..."
+     * 3) Old feature names with underscores (e.g. "sse4_2")
+     *    should keep working
+     *
+     * Note: rules 1 and 2 are planned to be removed soon, but we
+     * need to keep compatibility for a while until we start
+     * warning users about it.
+     */
+    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);
-- 
2.7.4

  reply	other threads:[~2016-09-30 18:50 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-30 18:49 [Qemu-devel] [PATCH v5 00/12] Add runnability info to query-cpu-definitions Eduardo Habkost
2016-09-30 18:49 ` Eduardo Habkost [this message]
2016-09-30 18:49 ` [Qemu-devel] [PATCH v5 02/12] target-i386: List CPU models using subclass list Eduardo Habkost
2016-09-30 18:49 ` [Qemu-devel] [PATCH v5 03/12] target-i386: Disable VME by default with TCG Eduardo Habkost
2016-09-30 18:49 ` [Qemu-devel] [PATCH v5 04/12] target-i386: Register aliases for feature names with underscores Eduardo Habkost
2016-09-30 19:56   ` [Qemu-devel] [libvirt] " Eric Blake
2016-09-30 20:59     ` Eduardo Habkost
2016-09-30 18:49 ` [Qemu-devel] [PATCH v5 05/12] target-i386: Make plus_features/minus_features QOM-based Eduardo Habkost
2016-11-25 14:51   ` Markus Armbruster
2016-09-30 18:49 ` [Qemu-devel] [PATCH v5 06/12] target-i386: Remove underscores from feat_names arrays Eduardo Habkost
2016-09-30 18:49 ` [Qemu-devel] [PATCH v5 07/12] target-i386: Register properties for feature aliases manually Eduardo Habkost
2016-09-30 18:49 ` [Qemu-devel] [PATCH v5 08/12] target-i386: xsave: Add FP and SSE bits to x86_ext_save_areas Eduardo Habkost
2016-09-30 18:49 ` [Qemu-devel] [PATCH v5 09/12] target-i386: Move warning code outside x86_cpu_filter_features() Eduardo Habkost
2016-09-30 18:49 ` [Qemu-devel] [PATCH v5 10/12] target-i386: x86_cpu_load_features() function Eduardo Habkost
2016-09-30 18:49 ` [Qemu-devel] [PATCH v5 11/12] qmp: Add runnability information to query-cpu-definitions Eduardo Habkost
2016-10-07 20:25   ` Eduardo Habkost
2016-09-30 18:49 ` [Qemu-devel] [PATCH v5 12/12] target-i386: Return runnability information on query-cpu-definitions Eduardo Habkost
2016-10-07 18:54 ` [Qemu-devel] [PATCH v5 00/12] Add runnability info to query-cpu-definitions Eduardo Habkost

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1475261386-20211-2-git-send-email-ehabkost@redhat.com \
    --to=ehabkost@redhat.com \
    --cc=armbru@redhat.com \
    --cc=dahi@linux.vnet.ibm.com \
    --cc=imammedo@redhat.com \
    --cc=jdenemar@redhat.com \
    --cc=libvir-list@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=rth@twiddle.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.