From nobody Tue Dec 16 16:35:43 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1490190290764748.5571549953355; Wed, 22 Mar 2017 06:44:50 -0700 (PDT) Received: from localhost ([::1]:51195 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cqgZF-0000Iv-8v for importer@patchew.org; Wed, 22 Mar 2017 09:44:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45568) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cqgPu-0000VJ-9X for qemu-devel@nongnu.org; Wed, 22 Mar 2017 09:35:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cqgPq-0002K5-GG for qemu-devel@nongnu.org; Wed, 22 Mar 2017 09:35:10 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34936) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cqgPm-0002HC-G4; Wed, 22 Mar 2017 09:35:02 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2498AC054C5E; Wed, 22 Mar 2017 13:35:02 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.34.112.60]) by smtp.corp.redhat.com (Postfix) with ESMTP id 69DDBA5660; Wed, 22 Mar 2017 13:34:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 2498AC054C5E Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=imammedo@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 2498AC054C5E From: Igor Mammedov To: qemu-devel@nongnu.org Date: Wed, 22 Mar 2017 14:32:48 +0100 Message-Id: <1490189568-167621-24-git-send-email-imammedo@redhat.com> In-Reply-To: <1490189568-167621-1-git-send-email-imammedo@redhat.com> References: <1490189568-167621-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 22 Mar 2017 13:35:02 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH for-2.10 23/23] tests: check -numa node, cpu=props_list usecase 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: Peter Maydell , Andrew Jones , Eduardo Habkost , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Shannon Zhao , Paolo Bonzini , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Igor Mammedov --- tests/numa-test.c | 151 ++++++++++++++++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 151 insertions(+) diff --git a/tests/numa-test.c b/tests/numa-test.c index 8326321..d371923 100644 --- a/tests/numa-test.c +++ b/tests/numa-test.c @@ -130,6 +130,144 @@ static void test_query_cpus(const void *data) g_free(cli); } =20 +static void pc_numa_cpu(const void *data) +{ + char *cli; + QDict *resp; + QList *cpus; + const QObject *e; + + cli =3D make_cli(data, "-cpu pentium -smp 8,sockets=3D2,cores=3D2,thre= ads=3D2 " + "-numa node,nodeid=3D0 -numa node,nodeid=3D1 " + "-numa cpu,node-id=3D1,socket-id=3D0 " + "-numa cpu,node-id=3D0,socket-id=3D1,core-id=3D0 " + "-numa cpu,node-id=3D0,socket-id=3D1,core-id=3D1,thread-id=3D0 " + "-numa cpu,node-id=3D1,socket-id=3D1,core-id=3D1,thread-id=3D1"); + qtest_start(cli); + cpus =3D get_cpus(&resp); + g_assert(cpus); + + while ((e =3D qlist_pop(cpus))) { + QDict *cpu, *props; + int64_t socket, core, thread, node; + + cpu =3D qobject_to_qdict(e); + g_assert(qdict_haskey(cpu, "props")); + props =3D qdict_get_qdict(cpu, "props"); + + g_assert(qdict_haskey(props, "node-id")); + node =3D qdict_get_int(props, "node-id"); + g_assert(qdict_haskey(props, "socket-id")); + socket =3D qdict_get_int(props, "socket-id"); + g_assert(qdict_haskey(props, "core-id")); + core =3D qdict_get_int(props, "core-id"); + g_assert(qdict_haskey(props, "thread-id")); + thread =3D qdict_get_int(props, "thread-id"); + + if (socket =3D=3D 0) { + g_assert_cmpint(node, =3D=3D, 1); + } else if (socket =3D=3D 1 && core =3D=3D 0) { + g_assert_cmpint(node, =3D=3D, 0); + } else if (socket =3D=3D 1 && core =3D=3D 1 && thread =3D=3D 0) { + g_assert_cmpint(node, =3D=3D, 0); + } else if (socket =3D=3D 1 && core =3D=3D 1 && thread =3D=3D 1) { + g_assert_cmpint(node, =3D=3D, 1); + } else { + g_assert(false); + } + } + + QDECREF(resp); + qtest_end(); + g_free(cli); +} + +static void spapr_numa_cpu(const void *data) +{ + char *cli; + QDict *resp; + QList *cpus; + const QObject *e; + + cli =3D make_cli(data, "-smp 4,cores=3D4 " + "-numa node,nodeid=3D0 -numa node,nodeid=3D1 " + "-numa cpu,node-id=3D0,core-id=3D0 " + "-numa cpu,node-id=3D0,core-id=3D1 " + "-numa cpu,node-id=3D0,core-id=3D2 " + "-numa cpu,node-id=3D1,core-id=3D3"); + qtest_start(cli); + cpus =3D get_cpus(&resp); + g_assert(cpus); + + while ((e =3D qlist_pop(cpus))) { + QDict *cpu, *props; + int64_t core, node; + + cpu =3D qobject_to_qdict(e); + g_assert(qdict_haskey(cpu, "props")); + props =3D qdict_get_qdict(cpu, "props"); + + g_assert(qdict_haskey(props, "node-id")); + node =3D qdict_get_int(props, "node-id"); + g_assert(qdict_haskey(props, "core-id")); + core =3D qdict_get_int(props, "core-id"); + + if (core >=3D 0 && core < 3) { + g_assert_cmpint(node, =3D=3D, 0); + } else if (core =3D=3D 3) { + g_assert_cmpint(node, =3D=3D, 1); + } else { + g_assert(false); + } + } + + QDECREF(resp); + qtest_end(); + g_free(cli); +} + +static void aarch64_numa_cpu(const void *data) +{ + char *cli; + QDict *resp; + QList *cpus; + const QObject *e; + + cli =3D make_cli(data, "-smp 2 " + "-numa node,nodeid=3D0 -numa node,nodeid=3D1 " + "-numa cpu,node-id=3D1,thread-id=3D0 " + "-numa cpu,node-id=3D0,thread-id=3D1"); + qtest_start(cli); + cpus =3D get_cpus(&resp); + g_assert(cpus); + + while ((e =3D qlist_pop(cpus))) { + QDict *cpu, *props; + int64_t thread, node; + + cpu =3D qobject_to_qdict(e); + g_assert(qdict_haskey(cpu, "props")); + props =3D qdict_get_qdict(cpu, "props"); + + g_assert(qdict_haskey(props, "node-id")); + node =3D qdict_get_int(props, "node-id"); + g_assert(qdict_haskey(props, "thread-id")); + thread =3D qdict_get_int(props, "thread-id"); + + if (thread =3D=3D 0) { + g_assert_cmpint(node, =3D=3D, 1); + } else if (thread =3D=3D 1) { + g_assert_cmpint(node, =3D=3D, 0); + } else { + g_assert(false); + } + } + + QDECREF(resp); + qtest_end(); + g_free(cli); +} + int main(int argc, char **argv) { const char *args =3D NULL; @@ -146,5 +284,18 @@ int main(int argc, char **argv) qtest_add_data_func("/numa/mon/cpus/partial", args, test_mon_partial); qtest_add_data_func("/numa/qmp/cpus/query-cpus", args, test_query_cpus= ); =20 + if (!strcmp(arch, "i386") || !strcmp(arch, "x86_64")) { + qtest_add_data_func("/numa/pc/cpu/explicit", args, pc_numa_cpu); + } + + if (!strcmp(arch, "ppc64")) { + qtest_add_data_func("/numa/spapr/cpu/explicit", args, spapr_numa_c= pu); + } + + if (!strcmp(arch, "aarch64")) { + qtest_add_data_func("/numa/aarch64/cpu/explicit", args, + aarch64_numa_cpu); + } + return g_test_run(); } --=20 2.7.4