From nobody Mon Feb 9 03:31:34 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1636988349; cv=none; d=zohomail.com; s=zohoarc; b=OO1ii5kF8WS1eb9B721Fn2q+Ft5eYK8w4NViOp5ZMimeh7DZ3eS85jfAJ1QhppqZP2W94DWxG3jE4BijavvscZ50J/LbLs0lziXi5QjwY7G/GzzDQPy+tX4pgYzoya3tjXuy9tgIEOhkwbS8fZQY9AbWXhJXaF7LqXwAzReJ+4k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1636988349; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=caAjapNdQ6O6O98D29tR+rRlgePlecp/3vyOxlktzrU=; b=jW/d9ZvVZ3AeSu/4SK4QjxMTiw8Vaev4o3Z0XGSKUI8jMMwfVOIgfmpOZFM8TrY2JRjGG1ixjeZvb9yqTuFPiESLRTNLnPauxwuezEEnzvhO3jBO66ZYNkaZq0dZv68pMVuI9TDliBbq5o5PxjhgILbHaansZNGOhBEdlbBqfpQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1636988349343131.7057396895534; Mon, 15 Nov 2021 06:59:09 -0800 (PST) Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-224-PPLqIy76OKSLGsU0__P99Q-1; Mon, 15 Nov 2021 09:59:07 -0500 Received: by mail-wm1-f72.google.com with SMTP id 201-20020a1c04d2000000b003335bf8075fso5445921wme.0 for ; Mon, 15 Nov 2021 06:59:07 -0800 (PST) Return-Path: Return-Path: Received: from x1w.redhat.com (62.red-83-57-168.dynamicip.rima-tde.net. [83.57.168.62]) by smtp.gmail.com with ESMTPSA id f7sm16700545wri.74.2021.11.15.06.59.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Nov 2021 06:59:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636988348; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=caAjapNdQ6O6O98D29tR+rRlgePlecp/3vyOxlktzrU=; b=VBiE+P32t719oMDwsu2Mf8buyyWvtpQib+Ojzy1EZHfUTUQahiqkuhAi/K2EabAupiCpSE BhJaeNPyNcAEPQSqNdKTbF99A9ezxOwxA3O8o9ET9S4JMUIlGeBW5Phx2wytA1ROPCJbR1 +WElj9FbIRBDDDbMy38XInvDMYNX/YM= X-MC-Unique: PPLqIy76OKSLGsU0__P99Q-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=caAjapNdQ6O6O98D29tR+rRlgePlecp/3vyOxlktzrU=; b=u79p2HfOEy7ddRx3X8uXiwfPh4qfj8Da/YLCEsk6Nxy8L0XVe7ugumlgzGsU2aWW0X f2HWQGXfmWIpo1qEj2PrNRShfVeWjKpV4QZw0z2dkbC6AVhiTu2BnYZ1PfI1a3sZ9HTJ 7wy04cYfA9b+vnP7Ch1I4m9fvPq0+lEp9zHLp9PG+dKtEG5LRfnXyB10o/w4XYxh1FqO fUQv85gCFDe01st4ZYTEWa8JopAxXL+G2yk6y2oRVy2Rb/gD/TZinyXe/D6LP8a3wTcV JVrHTLTmakdvggoy9Hy/daxESctr17A7WyQYJcaMshV3JlZao0g/XDiBorTmoExa68FO ULDg== X-Gm-Message-State: AOAM5317Cdzu0GffxWJx9lObkr2xn9i4bkBJZINAzBCJzWF09NtsFMvm cGd/DYhsUCkpmkxV2x9A8d8XJseXY3R+i2tXV1zRyuIF2uxVETWPRf4dMgunoIZUyU1kxPEVa7Y AAJlObpS5S6GzYA== X-Received: by 2002:a1c:1b15:: with SMTP id b21mr42113577wmb.174.1636988346152; Mon, 15 Nov 2021 06:59:06 -0800 (PST) X-Google-Smtp-Source: ABdhPJz0oa/CpUTWaggeGCmCOAqU5B8Z8RhJ/2ib4uzilsK0l/Wf4C9bHkOkX2oqAZOGufh4YElNHw== X-Received: by 2002:a1c:1b15:: with SMTP id b21mr42113554wmb.174.1636988346010; Mon, 15 Nov 2021 06:59:06 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Markus Armbruster , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Yanan Wang , Andrew Jones , Eduardo Habkost , Thomas Huth , Marcel Apfelbaum , Richard Henderson Subject: [PATCH-for-6.2 v4 01/11] tests/unit/test-smp-parse: Restore MachineClass fields after modifying Date: Mon, 15 Nov 2021 15:58:50 +0100 Message-Id: <20211115145900.2531865-2-philmd@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211115145900.2531865-1-philmd@redhat.com> References: <20211115145900.2531865-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1636988350502100001 There is a single MachineClass object, registered with type_register_static(&smp_machine_info). Since the same object is used multiple times (an MachineState object is instantiated in both test_generic and test_with_dies), we should restore its internal state after modifying for the test purpose. Reviewed-by: Andrew Jones Reviewed-by: Richard Henderson Reviewed-by: Yanan Wang Tested-by: Yanan Wang Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- tests/unit/test-smp-parse.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/unit/test-smp-parse.c b/tests/unit/test-smp-parse.c index cbe0c990494..47774c1ee2a 100644 --- a/tests/unit/test-smp-parse.c +++ b/tests/unit/test-smp-parse.c @@ -512,7 +512,7 @@ static void test_generic(void) smp_parse_test(ms, data, true); } =20 - /* Reset the supported min CPUs and max CPUs */ + /* Force invalid min CPUs and max CPUs */ mc->min_cpus =3D 2; mc->max_cpus =3D 511; =20 @@ -523,6 +523,10 @@ static void test_generic(void) smp_parse_test(ms, data, false); } =20 + /* Reset the supported min CPUs and max CPUs */ + mc->min_cpus =3D MIN_CPUS; + mc->max_cpus =3D MAX_CPUS; + object_unref(obj); } =20 @@ -536,6 +540,7 @@ static void test_with_dies(void) int i; =20 smp_machine_class_init(mc); + /* Force the SMP compat properties */ mc->smp_props.dies_supported =3D true; =20 for (i =3D 0; i < ARRAY_SIZE(data_generic_valid); i++) { @@ -575,6 +580,9 @@ static void test_with_dies(void) smp_parse_test(ms, data, false); } =20 + /* Restore the SMP compat properties */ + mc->smp_props.dies_supported =3D false; + object_unref(obj); } =20 --=20 2.31.1 From nobody Mon Feb 9 03:31:34 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1636988353; cv=none; d=zohomail.com; s=zohoarc; b=DfzYwuoNk6Yl8J2Au1Y5wk7LQGIqm4Vi8Wd0ANKTwaatAAYSGzblPjknw2j0wTwTRjkqzYy7EMr9PbD1LNO1XbIn3DwwPatw0z1wU3oaKM56t0B7nAQl3lABi36U1Qj8mjNEYUQ2BoeS+LHRTCGZHjLRIQDynGresY11vksdIuU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1636988353; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=5aBWgeT8dX8n5hQ5ktoKDC7N22O1xIWSsGNqfC8T6cI=; b=khsRQgvHGd5UxO822aNzxXtN8qs1GUgpIKSvAt5tH5ixqF5uthC1ICSC4JxVp7b1qS81N07AOtZYwuG6L+h/beaSWMl1hCRoPJfAs2GA55WgeV3OWmNpXp6z+OTVVVm8nU5Fyi3NN07m6qcHKwsi4VGSjrk8Dt0ieIQZnarLQBE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1636988353959844.1281943452993; Mon, 15 Nov 2021 06:59:13 -0800 (PST) Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-274-oBqBc3iYMISZEwoPYUocVw-1; Mon, 15 Nov 2021 09:59:11 -0500 Received: by mail-wm1-f71.google.com with SMTP id r6-20020a1c4406000000b0033119c22fdbso6319623wma.4 for ; Mon, 15 Nov 2021 06:59:11 -0800 (PST) Return-Path: Return-Path: Received: from x1w.redhat.com (62.red-83-57-168.dynamicip.rima-tde.net. [83.57.168.62]) by smtp.gmail.com with ESMTPSA id l5sm13007464wml.20.2021.11.15.06.59.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Nov 2021 06:59:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636988353; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5aBWgeT8dX8n5hQ5ktoKDC7N22O1xIWSsGNqfC8T6cI=; b=FgZeXsQzy0dboNcELF4SMmz8l6U7qe7hgBzu36c5A1cKuhBDwysdJ94XYVXWegN9s5zvcd jnRvzRZIXB0W3ERNUzt6wwspUkdIypb8pPpO6kI2tUWIhOqSOhRiWXXzp0I/9uLQt7YgML uXrfWapT10kiW7bRAkdIqkR2phtAzPw= X-MC-Unique: oBqBc3iYMISZEwoPYUocVw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=5aBWgeT8dX8n5hQ5ktoKDC7N22O1xIWSsGNqfC8T6cI=; b=xb21sV2guwxKj9aJx8VYrN5wMeIccC8KoKKskBFrbsyOG/B8FkrsxS6zHq0ykxV06i PQHDBBkdjiRt4ABAeltsIW0GnPV9NpQ/g59uG83oiGh4/EaMzadt1ddVy0/KQOEcLRKG HTpiqTQtWglPn4mqGbVHnrgPB2H+S0IPxspMBOEUtOcEmLPEY2oP3C2Sx9Dj6V4Ou4dg ISbJwzympv1qru83jyrQjN3vne498N61V9QrZ8vq2CHCgRmhilKd72PsTb59soOxIWDP KOzaeUTysCd6DxiTx0bWQx4Wl65oecPcn7UwLlNoP5IP+34JSCrxblbwqC8Wa6wsmt+S pSmQ== X-Gm-Message-State: AOAM531W6e84tO7fHoz+wK3+zIEUwkV4TofjeTIcYBvDtCBiiABZlJ2z fVQgeOszW+9jS0vT+zGj7isHPNvpcuwEfbCgBWS6vEVIWLaoNL3rM/q6iKggCsP//NaAEH1sOqE MFWw8HOclNvU8aQ== X-Received: by 2002:a5d:4704:: with SMTP id y4mr46850737wrq.85.1636988350575; Mon, 15 Nov 2021 06:59:10 -0800 (PST) X-Google-Smtp-Source: ABdhPJy5Sfp5AM6+xO0tVEMe/4po5R+MIwLeW8l/RmHHIhz5RGCmDJZPaa/VBr0hQVulmXgq8Vrr/A== X-Received: by 2002:a5d:4704:: with SMTP id y4mr46850721wrq.85.1636988350453; Mon, 15 Nov 2021 06:59:10 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Markus Armbruster , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Yanan Wang , Andrew Jones , Eduardo Habkost , Thomas Huth , Marcel Apfelbaum , Richard Henderson Subject: [PATCH-for-6.2 v4 02/11] tests/unit/test-smp-parse: QOM'ify smp_machine_class_init() Date: Mon, 15 Nov 2021 15:58:51 +0100 Message-Id: <20211115145900.2531865-3-philmd@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211115145900.2531865-1-philmd@redhat.com> References: <20211115145900.2531865-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1636988355477100001 smp_machine_class_init() is the actual TypeInfo::class_init(). Declare it as such in smp_machine_info, and avoid to call it manually in each test. Move smp_machine_info definition just before we register the type to avoid a forward declaration. Reviewed-by: Andrew Jones Reviewed-by: Richard Henderson Reviewed-by: Yanan Wang Tested-by: Yanan Wang Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- tests/unit/test-smp-parse.c | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/tests/unit/test-smp-parse.c b/tests/unit/test-smp-parse.c index 47774c1ee2a..3fff2af4e27 100644 --- a/tests/unit/test-smp-parse.c +++ b/tests/unit/test-smp-parse.c @@ -75,14 +75,6 @@ typedef struct SMPTestData { const char *expect_error; } SMPTestData; =20 -/* Type info of the tested machine */ -static const TypeInfo smp_machine_info =3D { - .name =3D TYPE_MACHINE, - .parent =3D TYPE_OBJECT, - .class_size =3D sizeof(MachineClass), - .instance_size =3D sizeof(MachineState), -}; - /* * List all the possible valid sub-collections of the generic 5 * topology parameters (i.e. cpus/maxcpus/sockets/cores/threads), @@ -480,9 +472,10 @@ static void unsupported_params_init(MachineClass *mc, = SMPTestData *data) } } =20 -/* Reset the related machine properties before each sub-test */ -static void smp_machine_class_init(MachineClass *mc) +static void machine_base_class_init(ObjectClass *oc, void *data) { + MachineClass *mc =3D MACHINE_CLASS(oc); + mc->min_cpus =3D MIN_CPUS; mc->max_cpus =3D MAX_CPUS; =20 @@ -498,8 +491,6 @@ static void test_generic(void) SMPTestData *data =3D &(SMPTestData){{ }}; int i; =20 - smp_machine_class_init(mc); - for (i =3D 0; i < ARRAY_SIZE(data_generic_valid); i++) { *data =3D data_generic_valid[i]; unsupported_params_init(mc, data); @@ -539,7 +530,6 @@ static void test_with_dies(void) unsigned int num_dies =3D 2; int i; =20 - smp_machine_class_init(mc); /* Force the SMP compat properties */ mc->smp_props.dies_supported =3D true; =20 @@ -586,12 +576,24 @@ static void test_with_dies(void) object_unref(obj); } =20 +/* Type info of the tested machine */ +static const TypeInfo smp_machine_types[] =3D { + { + .name =3D TYPE_MACHINE, + .parent =3D TYPE_OBJECT, + .class_init =3D machine_base_class_init, + .class_size =3D sizeof(MachineClass), + .instance_size =3D sizeof(MachineState), + } +}; + +DEFINE_TYPES(smp_machine_types) + int main(int argc, char *argv[]) { - g_test_init(&argc, &argv, NULL); - module_call_init(MODULE_INIT_QOM); - type_register_static(&smp_machine_info); + + g_test_init(&argc, &argv, NULL); =20 g_test_add_func("/test-smp-parse/generic", test_generic); g_test_add_func("/test-smp-parse/with_dies", test_with_dies); --=20 2.31.1 From nobody Mon Feb 9 03:31:34 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1636988358; cv=none; d=zohomail.com; s=zohoarc; b=B9C+3NbD7u38tUfDiz7CcCTSfCljSn6Ioebe8U3lm5kWeYnzVl3wrYqMNOYCTtCs3GGyuqr3e5uCb0gPtboMh6tN0JfnIio10/IbeGZLTiH8/TASorxsdS0zsCVSRKaS134B98cqGgJ78/CHqaCW2RJ+IJueIcxXkGH8HxYrl/U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1636988358; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=4KAeBrUilj/ve6Ofp+Ew6cDhrRd6+8AxOgCMLHgLOxQ=; b=hDKHyGLEV5Zfw5t7yhs8o5G5WeiZ3DE2um/NEXvWvDPhISwfWinD9ZnPPv5SXGGaoxkp2mcpoEabezQuvNmIj6PDeHWIFyrRw+F9fVt6hPwcM9rI5xfvcYqr6zC/k8Rgyuxx4ssFVwqsXOcfLi6SMYatkiqMi0PBhOLF8H8lPTE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1636988358584787.3929652692188; Mon, 15 Nov 2021 06:59:18 -0800 (PST) Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-542-udW3y36UMBWMX8X8hHg8QA-1; Mon, 15 Nov 2021 09:59:16 -0500 Received: by mail-wm1-f71.google.com with SMTP id j25-20020a05600c1c1900b00332372c252dso23199wms.1 for ; Mon, 15 Nov 2021 06:59:16 -0800 (PST) Return-Path: Return-Path: Received: from x1w.redhat.com (62.red-83-57-168.dynamicip.rima-tde.net. [83.57.168.62]) by smtp.gmail.com with ESMTPSA id k37sm15906619wms.21.2021.11.15.06.59.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Nov 2021 06:59:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636988357; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4KAeBrUilj/ve6Ofp+Ew6cDhrRd6+8AxOgCMLHgLOxQ=; b=WB3tu6iLh5AUt6QpaK5oIxrK3pnsOlbP+21Mzk64KSJ0ueQOMwzQAjCbsN9EocL1MmvoaX DGGdWpf7WFlufjKp4Md0dRv100bjHwMo9fIZgnBXU+XDxorEhtHdwCAPjCLAfdkPwb2GGM xog8vHmDUMhMVKnxksK/gfNspnTI3e0= X-MC-Unique: udW3y36UMBWMX8X8hHg8QA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=4KAeBrUilj/ve6Ofp+Ew6cDhrRd6+8AxOgCMLHgLOxQ=; b=KVUUpF5WYlRWRk3HegI/hKBkNyFABrqRq6UMKKSRI6/DC5+m7owRVZwcgiVgS+f5GB pmUyEX/pufmWsqfDHiSZuCzlpww9Ewkp70SC3lPCnadCk/rfpz8z8yGc2FW2a0sqoXxC n7rOn9ulcPVQp4DJx3NAgVSBpsITZgpk3Osttr1N3uERXMju0aqi0nP5UmPh6QtsCxOK 2eP8NBtLx1JMk4pzzxLmDt2fJbPr5JsdM2hi1KCh/EH3sOX+I2aeQBK2v/FYh7ndFc5p iG+NvVucaXx0KEyJh6x+kvBx1RwGvxKa4HuO/7OZPj6Rykc/rxzJpxuHccgbFhot7lOF nCAQ== X-Gm-Message-State: AOAM532KMGywlh5U5Ou2TkRf41nU/2P4BZirv5lcg4V4zohUwXMGpyFw glsxaHTXusBdTYU5CqpyYlO/5tjRGna6nP2lbddJ48Hgtpu8cPw8cIl/Z2YDcjML66m0Vsk2z0q IydnQGQizTtlqJw== X-Received: by 2002:a5d:6e8c:: with SMTP id k12mr47514685wrz.401.1636988355053; Mon, 15 Nov 2021 06:59:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJyCMKRZjDDT6BXi0z8cGLwmCLsGou+twN0aKM1cAra2VHjcM269z3ycWuB/R3sbQ2VfrV4Wog== X-Received: by 2002:a5d:6e8c:: with SMTP id k12mr47514660wrz.401.1636988354923; Mon, 15 Nov 2021 06:59:14 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Markus Armbruster , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Yanan Wang , Andrew Jones , Eduardo Habkost , Thomas Huth , Marcel Apfelbaum , Richard Henderson Subject: [PATCH-for-6.2 v4 03/11] tests/unit/test-smp-parse: Explicit MachineClass name Date: Mon, 15 Nov 2021 15:58:52 +0100 Message-Id: <20211115145900.2531865-4-philmd@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211115145900.2531865-1-philmd@redhat.com> References: <20211115145900.2531865-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1636988359193100001 If the MachineClass::name pointer is not explicitly set, it is NULL. Per the C standard, passing a NULL pointer to printf "%s" format is undefined. Some implementations display it as 'NULL', other as 'null'. Since we are comparing the formatted output, we need a stable value. The easiest is to explicit a machine name string. Reviewed-by: Andrew Jones Reviewed-by: Richard Henderson Reviewed-by: Yanan Wang Tested-by: Yanan Wang Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- tests/unit/test-smp-parse.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/unit/test-smp-parse.c b/tests/unit/test-smp-parse.c index 3fff2af4e27..b02450e25a3 100644 --- a/tests/unit/test-smp-parse.c +++ b/tests/unit/test-smp-parse.c @@ -23,6 +23,8 @@ #define MIN_CPUS 1 /* set the min CPUs supported by the machine as 1 */ #define MAX_CPUS 512 /* set the max CPUs supported by the machine as 512 */ =20 +#define SMP_MACHINE_NAME "TEST-SMP" + /* * Used to define the generic 3-level CPU topology hierarchy * -sockets/cores/threads @@ -307,13 +309,13 @@ static struct SMPTestData data_generic_invalid[] =3D { * should tweak the supported min CPUs to 2 for testing */ .config =3D SMP_CONFIG_GENERIC(T, 1, F, 0, F, 0, F, 0, F, 0), .expect_error =3D "Invalid SMP CPUs 1. The min CPUs supported " - "by machine '(null)' is 2", + "by machine '" SMP_MACHINE_NAME "' is 2", }, { /* config: -smp 512 * should tweak the supported max CPUs to 511 for testing */ .config =3D SMP_CONFIG_GENERIC(T, 512, F, 0, F, 0, F, 0, F, 0), .expect_error =3D "Invalid SMP CPUs 512. The max CPUs supported " - "by machine '(null)' is 511", + "by machine '" SMP_MACHINE_NAME "' is 511", }, }; =20 @@ -481,6 +483,8 @@ static void machine_base_class_init(ObjectClass *oc, vo= id *data) =20 mc->smp_props.prefer_sockets =3D true; mc->smp_props.dies_supported =3D false; + + mc->name =3D g_strdup(SMP_MACHINE_NAME); } =20 static void test_generic(void) --=20 2.31.1 From nobody Mon Feb 9 03:31:34 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1636988405; cv=none; d=zohomail.com; s=zohoarc; b=K13cShDPcWZ0EwSgnI5Hiqi0QWqMin2bSUGU2RBEXV6FYY2z0o+Hkfb7Sd0Rur45FxROoVlbfaJHrUPiixeoNaCl5lZ8jMszzrTaEe8JVRRVWZf/KmOHBSERQcegbQ8tMuBwiJO+znaaUjQsiGV954qb+9nM0hJxAwzbnK60Ujo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1636988405; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=BZpI0ahGf4kduGjb9YumMUGF6LmoFzxgBcNi4uwMZn8=; b=MEhONr/HJtMg/RpHIryDJ174ySyBsqfU312RbgKkvSW2GU/k9L7cqkw6l3uBY4noIU3uJlWgthtfAbwlKYzIK6Ro9zwRItQhXnJvLxOKf7TFx3oyUo4Ag0CoswaMSutc2rG+6kuIifSBb6L/6PHMIFqoSBCqHWMKXbmnBTkDAes= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1636988405456416.1273355116057; Mon, 15 Nov 2021 07:00:05 -0800 (PST) Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-411-6DR8SbBSO9CyCp4dSnU5bQ-1; Mon, 15 Nov 2021 09:59:20 -0500 Received: by mail-wm1-f71.google.com with SMTP id l4-20020a05600c1d0400b00332f47a0fa3so2119wms.8 for ; Mon, 15 Nov 2021 06:59:20 -0800 (PST) Return-Path: Return-Path: Received: from x1w.redhat.com (62.red-83-57-168.dynamicip.rima-tde.net. [83.57.168.62]) by smtp.gmail.com with ESMTPSA id h15sm14551985wml.9.2021.11.15.06.59.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Nov 2021 06:59:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636988404; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BZpI0ahGf4kduGjb9YumMUGF6LmoFzxgBcNi4uwMZn8=; b=JCerl6pt8iYl6uMla7DlOYoZ1NJJAMGK4jFLeHE6ZW6c0j+jNQ02ncI/G2TelQUmXxxeU0 NCLA0R2rrI5cIE3ogOv6nI6K9D0ffSSlV9S5MXc2MkITeNJ4Brxl+8jhS+4fCM8xF+on1i NcIJHd/3OIpHyaG702rsUFDa0NBcrZI= X-MC-Unique: 6DR8SbBSO9CyCp4dSnU5bQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=BZpI0ahGf4kduGjb9YumMUGF6LmoFzxgBcNi4uwMZn8=; b=iXd3sWdIfC5eo2ccm/q36A1RZilSTG4rwllqSrGEDGJB78+DxS6QQwLCgEonO2DSbS DS4H5NzWq9NUClUjGTKsFMhcbdH61hALx9QHHSC+XYwRFxJR/paXCsPFl01yiVD5vVfI d8QSJQloXmKlUOz8PodE7vYX7lLQUK1k6rwcaYMUVtO69YdOH0HxqlOE0/ZAUmlZeZow T2o3eO+Ivr7J18MkodxylVZpFB+PQGscwBE2nzRMZVmxTl60AZzto1GLpHbBc/vWar3O 78GwHRNDUfOB9bPaT+Eq4w+r1L+Lx/C6tgvMgMUbFPVsKgsY63iONk+EmDjOSNvxGwM3 /waA== X-Gm-Message-State: AOAM530vadE3fTFaSHsOm/oK43T1OXN8Ntsp184JRETLWjA0ZRAnOZx5 KJtdY9wp5L1kp1ck+mjdsU0dj+OeJjdFPJA78/D3P399ez/l9PgAs6DmsylBCxsU1IaX7kxV7c8 JPwN29ZcUbsKDWw== X-Received: by 2002:a7b:ce16:: with SMTP id m22mr42101232wmc.39.1636988359516; Mon, 15 Nov 2021 06:59:19 -0800 (PST) X-Google-Smtp-Source: ABdhPJwmV7M5DT5RuonHLIfQoQVMZNVgK795Dk22eQTXVP5DyttGto4TohsnhEW3oETy41PCeUw0HA== X-Received: by 2002:a7b:ce16:: with SMTP id m22mr42101213wmc.39.1636988359392; Mon, 15 Nov 2021 06:59:19 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Markus Armbruster , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Yanan Wang , Andrew Jones , Eduardo Habkost , Thomas Huth , Marcel Apfelbaum Subject: [PATCH-for-7.0 v4 04/11] tests/unit/test-smp-parse: Pass machine type as argument to tests Date: Mon, 15 Nov 2021 15:58:53 +0100 Message-Id: <20211115145900.2531865-5-philmd@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211115145900.2531865-1-philmd@redhat.com> References: <20211115145900.2531865-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1636988410734100001 Use g_test_add_data_func() instead of g_test_add_func() so we can pass the machine type to the tests (we will soon have different machine types). Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson Reviewed-by: Yanan Wang --- tests/unit/test-smp-parse.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/tests/unit/test-smp-parse.c b/tests/unit/test-smp-parse.c index b02450e25a3..37c6b4981db 100644 --- a/tests/unit/test-smp-parse.c +++ b/tests/unit/test-smp-parse.c @@ -487,9 +487,10 @@ static void machine_base_class_init(ObjectClass *oc, v= oid *data) mc->name =3D g_strdup(SMP_MACHINE_NAME); } =20 -static void test_generic(void) +static void test_generic(const void *opaque) { - Object *obj =3D object_new(TYPE_MACHINE); + const char *machine_type =3D opaque; + Object *obj =3D object_new(machine_type); MachineState *ms =3D MACHINE(obj); MachineClass *mc =3D MACHINE_GET_CLASS(obj); SMPTestData *data =3D &(SMPTestData){{ }}; @@ -525,9 +526,10 @@ static void test_generic(void) object_unref(obj); } =20 -static void test_with_dies(void) +static void test_with_dies(const void *opaque) { - Object *obj =3D object_new(TYPE_MACHINE); + const char *machine_type =3D opaque; + Object *obj =3D object_new(machine_type); MachineState *ms =3D MACHINE(obj); MachineClass *mc =3D MACHINE_GET_CLASS(obj); SMPTestData *data =3D &(SMPTestData){{ }}; @@ -599,8 +601,12 @@ int main(int argc, char *argv[]) =20 g_test_init(&argc, &argv, NULL); =20 - g_test_add_func("/test-smp-parse/generic", test_generic); - g_test_add_func("/test-smp-parse/with_dies", test_with_dies); + g_test_add_data_func("/test-smp-parse/generic", + TYPE_MACHINE, + test_generic); + g_test_add_data_func("/test-smp-parse/with_dies", + TYPE_MACHINE, + test_with_dies); =20 g_test_run(); =20 --=20 2.31.1 From nobody Mon Feb 9 03:31:34 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1636988367; cv=none; d=zohomail.com; s=zohoarc; b=hhxsR32N+PDfSNo4X6yKZCTAwwE6gTSxOTAwtC3b3j+Z/T7IITlrGluzIO8/oc3D5YXBd3VLb9xwUGdgfftKNwya9fNgi+qCanxwWxFuVpU/4T6MJGXjCKLIA4Pa7ZImPsGJmOtYHa173UcGfbWYv15y2EMIl553JVpAhSbVIgg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1636988367; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=gF1s0KbAL9b83AB6/JlbAHqywgqU7lOR4NhlFP3KFgg=; b=fSzECkyrw6DqduOKyQvAycCa4Frekkl/5p3Cf5UbDlqiHlcWFIcstT0XnudHXW5OLYkymYaqhZiy1tTbEEInCCe4LpwjefBylYYFY7xitfhTsWSExKun7MXyK1BS+wqtnCCxu7pytXp39Ey/Q5ggM036RjiwGarhWWAuxqBgD1M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1636988367772540.7144922830369; Mon, 15 Nov 2021 06:59:27 -0800 (PST) Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-210-H5i-IobHPg-dS6_zG3FH4w-1; Mon, 15 Nov 2021 09:59:25 -0500 Received: by mail-wm1-f70.google.com with SMTP id 144-20020a1c0496000000b003305ac0e03aso9740820wme.8 for ; Mon, 15 Nov 2021 06:59:24 -0800 (PST) Return-Path: Return-Path: Received: from x1w.redhat.com (62.red-83-57-168.dynamicip.rima-tde.net. [83.57.168.62]) by smtp.gmail.com with ESMTPSA id d15sm20289354wri.50.2021.11.15.06.59.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Nov 2021 06:59:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636988366; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gF1s0KbAL9b83AB6/JlbAHqywgqU7lOR4NhlFP3KFgg=; b=cy2OEnuTRuwnbJtQVSpL1cS2O8A8lJEdoXNuCVUaBHP65zobighyd7hhx1BtbVO3azEgyV 2EqfxHMd55gN0IZhuPDZUrEpuPyhNEuL27bX8B8Fvu/yequjb2XocaP9QMnSX3G7S2JKcR U5ZA2Bdjkv666n6Jp2f1RutAvPVsEd4= X-MC-Unique: H5i-IobHPg-dS6_zG3FH4w-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gF1s0KbAL9b83AB6/JlbAHqywgqU7lOR4NhlFP3KFgg=; b=DgGbyybxazPAOUGWJpQ29qV0w4j2aDXk2HxO0hqa5aXuLTxHngAkOyB698HFUmK+QA lRj6s8Z0fzryA7N4cc+jCHGdKACr6Qw2GCF12FVF3Kc+YILJTiHurGvXRILMXb71K+wz zP3DadWtuTSmDzly9ZOJoH2DiaK/oNx+YGscMWbTc/GJEazftde4KQYfegkRrnMu7wTz CaKhUuWqpO3n6/lLKhqKDmpy9fTnE5gtJBxfdeNx4EmejenlanHf9pBbx5dY9Z5gDNwE 63cDckwj8Kt3pLxFnN3r07Chn0S4y6mNwihYwYWvtK+mzIl8rpPfc3sBremFCMvDRW0d a5Yw== X-Gm-Message-State: AOAM533husrfgV1lzqJPf7xhci9B3vHIoJafn5YM/NT6j5mSmUKENpfm ksfbY8J6R0Nv8qcNxhjIoJfGj1cjHRM05Us4oYTB74pDorfFTS7KMYDOgr7oX7RiHLO/5b8hjkf OxPEPiU94d7YOEg== X-Received: by 2002:a05:600c:3553:: with SMTP id i19mr59753373wmq.97.1636988364003; Mon, 15 Nov 2021 06:59:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJyBiHO29Vm+h+jU24GT/dqqfeksL0Vw9veynBbFRs2Rn1r5bPrUU8uyakzy04flTYbN4S4oew== X-Received: by 2002:a05:600c:3553:: with SMTP id i19mr59753356wmq.97.1636988363875; Mon, 15 Nov 2021 06:59:23 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Markus Armbruster , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Yanan Wang , Andrew Jones , Eduardo Habkost , Thomas Huth , Marcel Apfelbaum Subject: [PATCH-for-7.0 v4 05/11] tests/unit/test-smp-parse: Split the 'generic' test in valid / invalid Date: Mon, 15 Nov 2021 15:58:54 +0100 Message-Id: <20211115145900.2531865-6-philmd@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211115145900.2531865-1-philmd@redhat.com> References: <20211115145900.2531865-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1636988368713100001 Split the 'generic' test in two tests: 'valid' and 'invalid'. This will allow us to remove the hack which modifies the MachineClass internal state. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson Reviewed-by: Yanan Wang --- tests/unit/test-smp-parse.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/tests/unit/test-smp-parse.c b/tests/unit/test-smp-parse.c index 37c6b4981db..e27aedad354 100644 --- a/tests/unit/test-smp-parse.c +++ b/tests/unit/test-smp-parse.c @@ -487,7 +487,7 @@ static void machine_base_class_init(ObjectClass *oc, vo= id *data) mc->name =3D g_strdup(SMP_MACHINE_NAME); } =20 -static void test_generic(const void *opaque) +static void test_generic_valid(const void *opaque) { const char *machine_type =3D opaque; Object *obj =3D object_new(machine_type); @@ -508,6 +508,19 @@ static void test_generic(const void *opaque) smp_parse_test(ms, data, true); } =20 + object_unref(obj); +} + +static void test_generic_invalid(const void *opaque) +{ + const char *machine_type =3D opaque; + Object *obj =3D object_new(machine_type); + MachineState *ms =3D MACHINE(obj); + MachineClass *mc =3D MACHINE_GET_CLASS(obj); + SMPTestData *data =3D &(SMPTestData){}; + int i; + + /* Force invalid min CPUs and max CPUs */ mc->min_cpus =3D 2; mc->max_cpus =3D 511; @@ -601,9 +614,12 @@ int main(int argc, char *argv[]) =20 g_test_init(&argc, &argv, NULL); =20 - g_test_add_data_func("/test-smp-parse/generic", + g_test_add_data_func("/test-smp-parse/generic/valid", TYPE_MACHINE, - test_generic); + test_generic_valid); + g_test_add_data_func("/test-smp-parse/generic/invalid", + TYPE_MACHINE, + test_generic_invalid); g_test_add_data_func("/test-smp-parse/with_dies", TYPE_MACHINE, test_with_dies); --=20 2.31.1 From nobody Mon Feb 9 03:31:34 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1636988373; cv=none; d=zohomail.com; s=zohoarc; b=HUJ4xgnQNiwWUrHbtIV9f/SMWU7lbnxyb6cd2vKB8y4GYqEETKdYNv7/uOgrDvNAJ3Fz2bur8vYHUjAu9tjkJmG0o6ug2xRCH18NMaJZUS6M9o+0fgKMxrosNe8MaUECT7SqluXKOhIMHQXuJI3zCfQis65GqkCr3b7bVEOo9UA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1636988373; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=4xRdiXmpdnfeTUGpX5NMgs94Fe642FxHpeJMvGfGSJQ=; b=OYEUm6C2lkKjYShq8CeWJ3VCnEYBY0qqbeZO8WwtEgXi2wk7AG5meiEboyDHzRK10dOxWWv0TUqLcZohUVogKfJoXK3VrMkE7d5FX5N1g8t9KalwHkLEs3ZKfOxCz3eqloCcICaxZPxNq9OrdeQNyFirk5DNlkYSZGe4WB5h0f4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1636988373583407.7310614481928; Mon, 15 Nov 2021 06:59:33 -0800 (PST) Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-353-h9OoLUHwOeOTZ51j7NPMEQ-1; Mon, 15 Nov 2021 09:59:29 -0500 Received: by mail-wm1-f69.google.com with SMTP id z138-20020a1c7e90000000b003319c5f9164so9748933wmc.7 for ; Mon, 15 Nov 2021 06:59:29 -0800 (PST) Return-Path: Return-Path: Received: from x1w.redhat.com (62.red-83-57-168.dynamicip.rima-tde.net. [83.57.168.62]) by smtp.gmail.com with ESMTPSA id w17sm15203043wrp.79.2021.11.15.06.59.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Nov 2021 06:59:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636988372; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4xRdiXmpdnfeTUGpX5NMgs94Fe642FxHpeJMvGfGSJQ=; b=IwhWZx9rE0xgCa2yfDgW4vGOEq/0uz/d3muIz0d3iBvHuhbAFu/MjWdcMFZODRXZc+G4L7 jbiLWeDds55YSjwthhUQZQkqXLGjpois1KUEEYDvoE5zCozuGpXEDKZHdWfKxdgBOQmmpq Ob/yBrK1pwTqW4oYlcYE8fnKNQ/zqFk= X-MC-Unique: h9OoLUHwOeOTZ51j7NPMEQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=4xRdiXmpdnfeTUGpX5NMgs94Fe642FxHpeJMvGfGSJQ=; b=O6iPkg6wBiYHWHEV6Pkk8vgp36pzz5VNYMToN6LN/dZKSbGvmTNTEUsalJJs9/d9Or LPrSsIUi6XFKYxQT0MuALhGpXlE+CDveeI5PDwGWA4xalrhU+bZPBRBcRb6LnfN6YUV5 OXrrofpJYw2E/p4cyl2noT3ZI+f8jMstL15V5V20WcVgLaJs/axJzGTbYjAs/AZ87C3c p/nJqerJsAmK5qu5BObkMrsvG567x6OAD0OBDtFZd+fBHon5GSdK04E3N3IfyoElj+QQ hJu5/ehWakpu1MJEr3o3IVdbndd8zNauSbBS7xwGEvWyoM9AIPExd5sh6a2UkW7yJCjk zkgg== X-Gm-Message-State: AOAM532oLMPAAb9iM2u7JfGnnO5ekooJf80+TrFevD3CkM1OwkKDtm9T cGDh4/dVvBr5zswiUwV3uo5P00XWjbCoQEA65DjiPPZxB8Hh7v8kbiovZ9NDznbnMZVwJM0aOYM ZxMLjsofxiTXSqA== X-Received: by 2002:a05:600c:3227:: with SMTP id r39mr64451042wmp.120.1636988368408; Mon, 15 Nov 2021 06:59:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJwk/zqiwkSztF//4rF24BcxpTmpw66DybNwLZPSvoC8yRbT5o1dKrbJxPMDTtIEOmfTezfvmA== X-Received: by 2002:a05:600c:3227:: with SMTP id r39mr64451019wmp.120.1636988368289; Mon, 15 Nov 2021 06:59:28 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Markus Armbruster , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Yanan Wang , Andrew Jones , Eduardo Habkost , Thomas Huth , Marcel Apfelbaum Subject: [PATCH-for-7.0 v4 06/11] tests/unit/test-smp-parse: Add 'smp-with-dies' machine type Date: Mon, 15 Nov 2021 15:58:55 +0100 Message-Id: <20211115145900.2531865-7-philmd@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211115145900.2531865-1-philmd@redhat.com> References: <20211115145900.2531865-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1636988374516100001 Avoid modifying the MachineClass internals by adding the 'smp-with-dies' machine, which inherits from TYPE_MACHINE. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson Reviewed-by: Yanan Wang Tested-by: Yanan Wang --- tests/unit/test-smp-parse.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/tests/unit/test-smp-parse.c b/tests/unit/test-smp-parse.c index e27aedad354..ff61da06e3d 100644 --- a/tests/unit/test-smp-parse.c +++ b/tests/unit/test-smp-parse.c @@ -487,6 +487,16 @@ static void machine_base_class_init(ObjectClass *oc, v= oid *data) mc->name =3D g_strdup(SMP_MACHINE_NAME); } =20 +static void machine_with_dies_class_init(ObjectClass *oc, void *data) +{ + MachineClass *mc =3D MACHINE_CLASS(oc); + + mc->min_cpus =3D MIN_CPUS; + mc->max_cpus =3D MAX_CPUS; + + mc->smp_props.dies_supported =3D true; +} + static void test_generic_valid(const void *opaque) { const char *machine_type =3D opaque; @@ -549,9 +559,6 @@ static void test_with_dies(const void *opaque) unsigned int num_dies =3D 2; int i; =20 - /* Force the SMP compat properties */ - mc->smp_props.dies_supported =3D true; - for (i =3D 0; i < ARRAY_SIZE(data_generic_valid); i++) { *data =3D data_generic_valid[i]; unsupported_params_init(mc, data); @@ -589,9 +596,6 @@ static void test_with_dies(const void *opaque) smp_parse_test(ms, data, false); } =20 - /* Restore the SMP compat properties */ - mc->smp_props.dies_supported =3D false; - object_unref(obj); } =20 @@ -603,6 +607,10 @@ static const TypeInfo smp_machine_types[] =3D { .class_init =3D machine_base_class_init, .class_size =3D sizeof(MachineClass), .instance_size =3D sizeof(MachineState), + }, { + .name =3D MACHINE_TYPE_NAME("smp-with-dies"), + .parent =3D TYPE_MACHINE, + .class_init =3D machine_with_dies_class_init, } }; =20 @@ -621,7 +629,7 @@ int main(int argc, char *argv[]) TYPE_MACHINE, test_generic_invalid); g_test_add_data_func("/test-smp-parse/with_dies", - TYPE_MACHINE, + MACHINE_TYPE_NAME("smp-with-dies"), test_with_dies); =20 g_test_run(); --=20 2.31.1 From nobody Mon Feb 9 03:31:34 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1636988376; cv=none; d=zohomail.com; s=zohoarc; b=bxvVXPP72AWUzA2FVx4Vs5iwFm0b8b9R6/pPAjXt09avYmyOMWMxG7xSkxSTDjnOlzC+6fRwvfbZd1VUO4uYkfAvzPCc6pFW2N2R04aUEJ1q5lo2SRJ/8yXbFjS4qpnd7pEI0ItbNlaWnoJz8ettUeoNYysMRvlzz6c4n5l8BbY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1636988376; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=2CcO+Z0iBapQD7/VeLORTYFY1zV22osrIJAVn0P+5js=; b=J8Zw1AKXWDKv3SfYyz02mjWnL4WbFKAzm97IPtcYOkkzGXiSrEny80H06hM+gO7yyQdcgQ/ojgCL9nPXTxj9Zggh4tU3Y84ykujdmJcF/zaSesEuSUCJk1YQ2UYF8yj9j8p64mVvnNK7nF9VraGA3orKPYohz6UxuWPt4cyQNWk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1636988376467922.0701145162911; Mon, 15 Nov 2021 06:59:36 -0800 (PST) Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-285-m5v-iIuOMKmm0Wx52g4dQA-1; Mon, 15 Nov 2021 09:59:34 -0500 Received: by mail-wm1-f71.google.com with SMTP id g81-20020a1c9d54000000b003330e488323so25479wme.0 for ; Mon, 15 Nov 2021 06:59:33 -0800 (PST) Return-Path: Return-Path: Received: from x1w.redhat.com (62.red-83-57-168.dynamicip.rima-tde.net. [83.57.168.62]) by smtp.gmail.com with ESMTPSA id o8sm14256154wrm.67.2021.11.15.06.59.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Nov 2021 06:59:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636988375; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2CcO+Z0iBapQD7/VeLORTYFY1zV22osrIJAVn0P+5js=; b=IWdQiMCQzRW2LM+ZoZlVGM9GqhybUJOKCU8Jr8hzvGBd9c54yaJdH/q9HNRCx5cGTYc3/2 KCOQbHwNkOml/W/OHDGasdDGvejCr7cUdpgTmjtuHnOfGfrJY+ixdyPXMy/xpquDGlbZyZ nhsnS/wenYg2vCvDaFFHYHx36wIHWIA= X-MC-Unique: m5v-iIuOMKmm0Wx52g4dQA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2CcO+Z0iBapQD7/VeLORTYFY1zV22osrIJAVn0P+5js=; b=talbX5zksqpL1ckaN03VeO0vbEAUWtMj0GbE9VBOSN7Im6fnPKNRc55spHUgVDb+5X apsjfdBSPjB1Wv7Y2oeDfsHq8RmEVjRuph3c4WSUbE1z0qGB2YHwsiFe1EpBFXI5bfOw 0laO4PHK7i5y6sw8W69nOLWQygUuXSXQHyIczH+aKYfvmaGGwW49+8RBJgvEqImg0R0t mvSiJScf1JfGW14FNrm7M4mJQ4CA6S61Suoq6eyN4BJOy0T9NnrYqWzP55KXbC8bWFVi AJ45al8XeaxeLjvctGv6axs4L+G2OEe/2kptVGB9cuO5I6WgJdWy79AtEPHwP5FZ7js5 KsFQ== X-Gm-Message-State: AOAM532hcyH+sMnI+aPNOA0dHFImpRIHCnjiE2j2l8/Q+mNFKFbUFQEW OMiuHlCc+cobrKQV9qJbRaAwtVQHunvTqvRf92JaDv8tu6ylTTqE5oJjIK9Vd9efTpuo0Xcm1qN gXExI8DwMVF4YEg== X-Received: by 2002:adf:d1e2:: with SMTP id g2mr49312393wrd.346.1636988372998; Mon, 15 Nov 2021 06:59:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJx6CciOegvif+34GnCt0hD/64UuEDugB7rW9G76m3FCy6yAO30mqJbwBDxaNwN/j5jZNdoVtw== X-Received: by 2002:adf:d1e2:: with SMTP id g2mr49312366wrd.346.1636988372860; Mon, 15 Nov 2021 06:59:32 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Markus Armbruster , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Yanan Wang , Andrew Jones , Eduardo Habkost , Thomas Huth , Marcel Apfelbaum Subject: [PATCH-for-7.0 v4 07/11] tests/unit/test-smp-parse: Add 'smp-without-dies-invalid' machine type Date: Mon, 15 Nov 2021 15:58:56 +0100 Message-Id: <20211115145900.2531865-8-philmd@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211115145900.2531865-1-philmd@redhat.com> References: <20211115145900.2531865-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1636988377114100001 Avoid modifying the MachineClass internals by adding the 'smp-without-dies-invalid' machine, which inherits from TYPE_MACHINE. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- tests/unit/test-smp-parse.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/tests/unit/test-smp-parse.c b/tests/unit/test-smp-parse.c index ff61da06e3d..dfe7f1313b0 100644 --- a/tests/unit/test-smp-parse.c +++ b/tests/unit/test-smp-parse.c @@ -487,6 +487,17 @@ static void machine_base_class_init(ObjectClass *oc, v= oid *data) mc->name =3D g_strdup(SMP_MACHINE_NAME); } =20 +static void machine_without_dies_invalid_class_init(ObjectClass *oc, void = *data) +{ + MachineClass *mc =3D MACHINE_CLASS(oc); + + /* Force invalid min CPUs and max CPUs */ + mc->min_cpus =3D 2; + mc->max_cpus =3D 511; + + mc->smp_props.dies_supported =3D false; +} + static void machine_with_dies_class_init(ObjectClass *oc, void *data) { MachineClass *mc =3D MACHINE_CLASS(oc); @@ -530,11 +541,6 @@ static void test_generic_invalid(const void *opaque) SMPTestData *data =3D &(SMPTestData){}; int i; =20 - - /* Force invalid min CPUs and max CPUs */ - mc->min_cpus =3D 2; - mc->max_cpus =3D 511; - for (i =3D 0; i < ARRAY_SIZE(data_generic_invalid); i++) { *data =3D data_generic_invalid[i]; unsupported_params_init(mc, data); @@ -542,10 +548,6 @@ static void test_generic_invalid(const void *opaque) smp_parse_test(ms, data, false); } =20 - /* Reset the supported min CPUs and max CPUs */ - mc->min_cpus =3D MIN_CPUS; - mc->max_cpus =3D MAX_CPUS; - object_unref(obj); } =20 @@ -607,6 +609,10 @@ static const TypeInfo smp_machine_types[] =3D { .class_init =3D machine_base_class_init, .class_size =3D sizeof(MachineClass), .instance_size =3D sizeof(MachineState), + }, { + .name =3D MACHINE_TYPE_NAME("smp-without-dies-invalid"), + .parent =3D TYPE_MACHINE, + .class_init =3D machine_without_dies_invalid_class_init, }, { .name =3D MACHINE_TYPE_NAME("smp-with-dies"), .parent =3D TYPE_MACHINE, @@ -626,7 +632,7 @@ int main(int argc, char *argv[]) TYPE_MACHINE, test_generic_valid); g_test_add_data_func("/test-smp-parse/generic/invalid", - TYPE_MACHINE, + MACHINE_TYPE_NAME("smp-without-dies-invalid"), test_generic_invalid); g_test_add_data_func("/test-smp-parse/with_dies", MACHINE_TYPE_NAME("smp-with-dies"), --=20 2.31.1 From nobody Mon Feb 9 03:31:34 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1636988380; cv=none; d=zohomail.com; s=zohoarc; b=B9ADrd+tCgHFjrz+uN+mpyXvucHvWDGpfqM1lMJnOOBWLZ5QiPUi58eIhaX78VRQgWvGZZNmlSVgrnDBnq0bdgZdejRebnClj7/TqLiphfuK1RHjD32uIcjWsKw3bmcjMzlnDERhNNHdyJQqBXdddcv69FP7mzPzgl6NZAfcEp0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1636988380; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=k7Mfm0kJ9oi+go9Fu+Y6UDaHOPdntdv19UcC7ZtAoHg=; b=K6yAM8PFRp0dMuotknD4LkyQSrcQGX+fJd3bZdM048cfVRqzUJfyOpf7zqslCq5NukLCwJy8xiIJsw6/cFMYCKfkN74BGJrKZh99BMAwgpQ5zgDQMKpubibFRV+XmphxoN+WI1Tjd+T9WDvKPxJS39QwGbM4+qA8vTIMQYGfwqk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1636988380861665.3750546277129; Mon, 15 Nov 2021 06:59:40 -0800 (PST) Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-234-x3TDmittP6KDhxwdJPZyYQ-1; Mon, 15 Nov 2021 09:59:38 -0500 Received: by mail-wm1-f71.google.com with SMTP id o22-20020a1c7516000000b0030d6f9c7f5fso6325601wmc.1 for ; Mon, 15 Nov 2021 06:59:38 -0800 (PST) Return-Path: Return-Path: Received: from x1w.redhat.com (62.red-83-57-168.dynamicip.rima-tde.net. [83.57.168.62]) by smtp.gmail.com with ESMTPSA id b188sm14043968wmd.45.2021.11.15.06.59.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Nov 2021 06:59:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636988379; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=k7Mfm0kJ9oi+go9Fu+Y6UDaHOPdntdv19UcC7ZtAoHg=; b=YRTrzlR9DxEvInLYZziRiau8yEHpiHSUSgOITFs3bzdzgo0mbQp5fvQfPMm3gDzT1TOBg9 hnluReZAcwNfkNwKwi+8dtL9HlsOGGoaortNmylO+e4GNSsVULlBB2Sc2pWpFvBxox9ROu ksUfUIT73OxbwvaLSEqI9165vCuF/Xg= X-MC-Unique: x3TDmittP6KDhxwdJPZyYQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=k7Mfm0kJ9oi+go9Fu+Y6UDaHOPdntdv19UcC7ZtAoHg=; b=SVSRGIKG7iuxbEC+hlaQflbRR0qK1wcbBNYsgNEyCKucotRwnm+T/HTIPV37oTuGJ0 hiwOf7UKt73lqpD+msoT7SSz7KYJdhrlZ43hkQDNnavU95z3LdDMuZGP5zE2ZvQMf4mk cKUuURdH2UXpfmyq2EBbfEDGoXOmsgyQXkOYPnKpemk1DenGvhzH0GHvf+bkjXcZGEtE Gty3YCip0Pddy7rkyoWJRDzh3eUKKWbSnqE9tsj7okiHJGvYqIBycvIoTJnMyhanaJtY CO3gTPLSwO+Gn48V68tQVG79rr3FrisAtyUW9QxBF1Bf9gfJI3Jc/3wrBtJZAsV1TEkN WB7g== X-Gm-Message-State: AOAM533BSmN9mDyyf/T9eGToNw3/8Z5wXnI1ZYqBJ//I4B+8m8glwY/r 7a1lGpmnqNP3wYWlcNfWGeD+zeQZflks4dW1Yo88GSwFCAgpjgEc7c2fYlob6RKIdwrdH5aPOcg Wvy2BG7j1rYTzTA== X-Received: by 2002:a5d:464c:: with SMTP id j12mr47415611wrs.150.1636988377355; Mon, 15 Nov 2021 06:59:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJxZcmTp4r0jzDzTwRnun/HIV1bv/UO4CRlPVTREiare+KSKukQl/Vr0NsBwexNnIWCObYijcg== X-Received: by 2002:a5d:464c:: with SMTP id j12mr47415595wrs.150.1636988377243; Mon, 15 Nov 2021 06:59:37 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Markus Armbruster , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Yanan Wang , Andrew Jones , Eduardo Habkost , Thomas Huth , Marcel Apfelbaum Subject: [PATCH-for-7.0 v4 08/11] tests/unit/test-smp-parse: Add 'smp-without-dies-valid' machine type Date: Mon, 15 Nov 2021 15:58:57 +0100 Message-Id: <20211115145900.2531865-9-philmd@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211115145900.2531865-1-philmd@redhat.com> References: <20211115145900.2531865-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1636988381542100001 Keep the common TYPE_MACHINE class initialization in machine_base_class_init(), make it abstract, and move the non-common code to a new class: "smp-without-dies-valid". Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- tests/unit/test-smp-parse.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/tests/unit/test-smp-parse.c b/tests/unit/test-smp-parse.c index dfe7f1313b0..90a249fe8c8 100644 --- a/tests/unit/test-smp-parse.c +++ b/tests/unit/test-smp-parse.c @@ -478,13 +478,19 @@ static void machine_base_class_init(ObjectClass *oc, = void *data) { MachineClass *mc =3D MACHINE_CLASS(oc); =20 + mc->smp_props.prefer_sockets =3D true; + + mc->name =3D g_strdup(SMP_MACHINE_NAME); +} + +static void machine_without_dies_valid_class_init(ObjectClass *oc, void *d= ata) +{ + MachineClass *mc =3D MACHINE_CLASS(oc); + mc->min_cpus =3D MIN_CPUS; mc->max_cpus =3D MAX_CPUS; =20 - mc->smp_props.prefer_sockets =3D true; mc->smp_props.dies_supported =3D false; - - mc->name =3D g_strdup(SMP_MACHINE_NAME); } =20 static void machine_without_dies_invalid_class_init(ObjectClass *oc, void = *data) @@ -606,9 +612,14 @@ static const TypeInfo smp_machine_types[] =3D { { .name =3D TYPE_MACHINE, .parent =3D TYPE_OBJECT, + .abstract =3D true, .class_init =3D machine_base_class_init, .class_size =3D sizeof(MachineClass), .instance_size =3D sizeof(MachineState), + }, { + .name =3D MACHINE_TYPE_NAME("smp-without-dies-valid"), + .parent =3D TYPE_MACHINE, + .class_init =3D machine_without_dies_valid_class_init, }, { .name =3D MACHINE_TYPE_NAME("smp-without-dies-invalid"), .parent =3D TYPE_MACHINE, @@ -629,7 +640,7 @@ int main(int argc, char *argv[]) g_test_init(&argc, &argv, NULL); =20 g_test_add_data_func("/test-smp-parse/generic/valid", - TYPE_MACHINE, + MACHINE_TYPE_NAME("smp-without-dies-valid"), test_generic_valid); g_test_add_data_func("/test-smp-parse/generic/invalid", MACHINE_TYPE_NAME("smp-without-dies-invalid"), --=20 2.31.1 From nobody Mon Feb 9 03:31:34 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1636988385; cv=none; d=zohomail.com; s=zohoarc; b=k6i4A7SyBqF8YYSFt9CrwHMIuYVDZByHKzEOX9goOqg5PsDPwjPCZKUvhwRhnJMcBHOv9+6x5XJgDptxVRP93NqYACbBoSjY0qbLQarrYv5vV8czcyxt1TDlrEcKco1CzXt1+xpCWyT4TIykSXzMKRDmUmU6+OUbnhEJbvLEbA8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1636988385; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=7qrzT/vnokZ3nh9S7J+fR3Ca5gL/K7rOLc2Ix6PJKjc=; b=LBxW56b6koaeyIp+u29wzzyrgO4ZCbkKcGfX68NM5LBQyr8YrKnfN5E9HOpoNRa+ypy/ai6dtsTLe5KCJh3FMmQeTHfEekm/hg+RSZvcDvZ7PNyQrwSDzy2bP8WB7kaA7jkFkZTk1l4o5uSnewYPiZygC9HXP3OeiIIjh+P/d1k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1636988385221597.3139324674852; Mon, 15 Nov 2021 06:59:45 -0800 (PST) Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-170-tyskG9FxN3amEbNGyavMiw-1; Mon, 15 Nov 2021 09:59:43 -0500 Received: by mail-wr1-f71.google.com with SMTP id q5-20020a5d5745000000b00178abb72486so3657660wrw.9 for ; Mon, 15 Nov 2021 06:59:42 -0800 (PST) Return-Path: Return-Path: Received: from x1w.redhat.com (62.red-83-57-168.dynamicip.rima-tde.net. [83.57.168.62]) by smtp.gmail.com with ESMTPSA id 4sm18966325wrz.90.2021.11.15.06.59.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Nov 2021 06:59:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636988384; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7qrzT/vnokZ3nh9S7J+fR3Ca5gL/K7rOLc2Ix6PJKjc=; b=RxosOmOMseojs0qHhCh55Np6+gCbfo1uCJM4Ygk+/Iyt+8K4vcSHL+VebQokvYZqu6qljd NIIxkAVJP4Q4YysgWODv38fMdDdbC+L1vGVDspcpj/vGwrDrdSihzr0OdJIQ0Uqa1OAtms 3K4CkSIPGTljRWRvnOsh2fOEle/1oBQ= X-MC-Unique: tyskG9FxN3amEbNGyavMiw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=7qrzT/vnokZ3nh9S7J+fR3Ca5gL/K7rOLc2Ix6PJKjc=; b=oxV6vHaJ/SQbf9gw9e5w6ijebVoCZ0QMqd8TL+yBD0Unk8d2y/GqLfCOXd1fQP7P/3 1L43L5NG6p7ppARfjCbjWJpbb29whOo/ljWbEF1Fnb6EruyFMpQQGrf5XeczhNnqrR6U 5HNW5MbD/GIPert3SdMbjrph90ZRZByJoV62Yi0795kEOS1IFRyDd+iGEOHtSSSmUGJz ElhYqR/4FhDeTz4th6iWlItT9g5WSkGBUG+4+/LfoIvKCFgGXfFA0705nUOtJhAex5pa 4oPqZxaQXBoC+sUkyjaDtylxc91ppgLY02Cv8Go7Xbfm63ZkSnadhHk1p1B5gXP3D8Qi DXCA== X-Gm-Message-State: AOAM53074MgHNB9czuXpmfwtQGH8E0LPi72cdImi0vwhpFbzhat0YZQc KNMtwirVsDsYaThhru37RRE+cbBFDwR+JkIk4JJKEM059IJZsiMlIrL1Y0kasMSEVKL7FjLSJ05 lMYZbsnXYxKVIug== X-Received: by 2002:a1c:448b:: with SMTP id r133mr60991497wma.85.1636988381864; Mon, 15 Nov 2021 06:59:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJykDunek8iQ6DRO/1a7gbv8dm/sXnTEje1uFEdMxUcwqTlr0/Y4tcY1g6TJ2uU2BGzyKxPDvA== X-Received: by 2002:a1c:448b:: with SMTP id r133mr60991475wma.85.1636988381663; Mon, 15 Nov 2021 06:59:41 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Markus Armbruster , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Yanan Wang , Andrew Jones , Eduardo Habkost , Thomas Huth , Marcel Apfelbaum , Richard Henderson Subject: [PATCH-for-7.0 v4 09/11] tests/unit/test-smp-parse: Simplify pointer to compound literal use Date: Mon, 15 Nov 2021 15:58:58 +0100 Message-Id: <20211115145900.2531865-10-philmd@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211115145900.2531865-1-philmd@redhat.com> References: <20211115145900.2531865-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1636988387269100001 We can simply use a local variable (and pass its pointer) instead of a pointer to a compound literal. Reviewed-by: Andrew Jones Reviewed-by: Richard Henderson Reviewed-by: Yanan Wang Tested-by: Yanan Wang Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- tests/unit/test-smp-parse.c | 66 ++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/tests/unit/test-smp-parse.c b/tests/unit/test-smp-parse.c index 90a249fe8c8..2f3bcf198a5 100644 --- a/tests/unit/test-smp-parse.c +++ b/tests/unit/test-smp-parse.c @@ -520,19 +520,19 @@ static void test_generic_valid(const void *opaque) Object *obj =3D object_new(machine_type); MachineState *ms =3D MACHINE(obj); MachineClass *mc =3D MACHINE_GET_CLASS(obj); - SMPTestData *data =3D &(SMPTestData){{ }}; + SMPTestData data =3D {}; int i; =20 for (i =3D 0; i < ARRAY_SIZE(data_generic_valid); i++) { - *data =3D data_generic_valid[i]; - unsupported_params_init(mc, data); + data =3D data_generic_valid[i]; + unsupported_params_init(mc, &data); =20 - smp_parse_test(ms, data, true); + smp_parse_test(ms, &data, true); =20 /* Unsupported parameters can be provided with their values as 1 */ - data->config.has_dies =3D true; - data->config.dies =3D 1; - smp_parse_test(ms, data, true); + data.config.has_dies =3D true; + data.config.dies =3D 1; + smp_parse_test(ms, &data, true); } =20 object_unref(obj); @@ -544,14 +544,14 @@ static void test_generic_invalid(const void *opaque) Object *obj =3D object_new(machine_type); MachineState *ms =3D MACHINE(obj); MachineClass *mc =3D MACHINE_GET_CLASS(obj); - SMPTestData *data =3D &(SMPTestData){}; + SMPTestData data =3D {}; int i; =20 for (i =3D 0; i < ARRAY_SIZE(data_generic_invalid); i++) { - *data =3D data_generic_invalid[i]; - unsupported_params_init(mc, data); + data =3D data_generic_invalid[i]; + unsupported_params_init(mc, &data); =20 - smp_parse_test(ms, data, false); + smp_parse_test(ms, &data, false); } =20 object_unref(obj); @@ -563,45 +563,45 @@ static void test_with_dies(const void *opaque) Object *obj =3D object_new(machine_type); MachineState *ms =3D MACHINE(obj); MachineClass *mc =3D MACHINE_GET_CLASS(obj); - SMPTestData *data =3D &(SMPTestData){{ }}; + SMPTestData data =3D {}; unsigned int num_dies =3D 2; int i; =20 for (i =3D 0; i < ARRAY_SIZE(data_generic_valid); i++) { - *data =3D data_generic_valid[i]; - unsupported_params_init(mc, data); + data =3D data_generic_valid[i]; + unsupported_params_init(mc, &data); =20 /* when dies parameter is omitted, it will be set as 1 */ - data->expect_prefer_sockets.dies =3D 1; - data->expect_prefer_cores.dies =3D 1; + data.expect_prefer_sockets.dies =3D 1; + data.expect_prefer_cores.dies =3D 1; =20 - smp_parse_test(ms, data, true); + smp_parse_test(ms, &data, true); =20 /* when dies parameter is specified */ - data->config.has_dies =3D true; - data->config.dies =3D num_dies; - if (data->config.has_cpus) { - data->config.cpus *=3D num_dies; + data.config.has_dies =3D true; + data.config.dies =3D num_dies; + if (data.config.has_cpus) { + data.config.cpus *=3D num_dies; } - if (data->config.has_maxcpus) { - data->config.maxcpus *=3D num_dies; + if (data.config.has_maxcpus) { + data.config.maxcpus *=3D num_dies; } =20 - data->expect_prefer_sockets.dies =3D num_dies; - data->expect_prefer_sockets.cpus *=3D num_dies; - data->expect_prefer_sockets.max_cpus *=3D num_dies; - data->expect_prefer_cores.dies =3D num_dies; - data->expect_prefer_cores.cpus *=3D num_dies; - data->expect_prefer_cores.max_cpus *=3D num_dies; + data.expect_prefer_sockets.dies =3D num_dies; + data.expect_prefer_sockets.cpus *=3D num_dies; + data.expect_prefer_sockets.max_cpus *=3D num_dies; + data.expect_prefer_cores.dies =3D num_dies; + data.expect_prefer_cores.cpus *=3D num_dies; + data.expect_prefer_cores.max_cpus *=3D num_dies; =20 - smp_parse_test(ms, data, true); + smp_parse_test(ms, &data, true); } =20 for (i =3D 0; i < ARRAY_SIZE(data_with_dies_invalid); i++) { - *data =3D data_with_dies_invalid[i]; - unsupported_params_init(mc, data); + data =3D data_with_dies_invalid[i]; + unsupported_params_init(mc, &data); =20 - smp_parse_test(ms, data, false); + smp_parse_test(ms, &data, false); } =20 object_unref(obj); --=20 2.31.1 From nobody Mon Feb 9 03:31:34 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1636988389; cv=none; d=zohomail.com; s=zohoarc; b=a6Wp1RKIof04kpBVIBvuW2vOm0MNhJey4PYrletdyZEnxUAPPDdyFjWTdrt4FIJcSxzlrDJ7PS5DFlBsaYnZoPKRx3P+/SNxpWBPmjmsRPPNJlV0w4JajVZ47dnZVJUrpB1ul37MH58C3/TeLjrQEuiXmC3/OV9D7Kv6TTwIdPQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1636988389; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=1cgRYAqM41Px2LriKtMbCkqWrzppnp4Wtl8WLrPbt8g=; b=hRMY0FMZlywnh1lkz9opeqYtEXNXM0OhJ40UWX/2a5E2v6E9g3HYYHCyWQWxsR86VQY/+elR6rowLCB7tc/0B46ZmG8v8JrqnKOn1swUY88r4nlj0WtMM/DXT3CKenv3bfYrJdoRi9TUug3UlcIuf4n115p49Y98G8rx4dis9wM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1636988389844290.6288569079371; Mon, 15 Nov 2021 06:59:49 -0800 (PST) Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-81-LpSBrbi1OKiVIwbOGvcWhw-1; Mon, 15 Nov 2021 09:59:47 -0500 Received: by mail-wr1-f72.google.com with SMTP id q17-20020adfcd91000000b0017bcb12ad4fso3657235wrj.12 for ; Mon, 15 Nov 2021 06:59:47 -0800 (PST) Return-Path: Return-Path: Received: from x1w.redhat.com (62.red-83-57-168.dynamicip.rima-tde.net. [83.57.168.62]) by smtp.gmail.com with ESMTPSA id j40sm16105149wms.16.2021.11.15.06.59.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Nov 2021 06:59:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636988388; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1cgRYAqM41Px2LriKtMbCkqWrzppnp4Wtl8WLrPbt8g=; b=ELVEEsGBdZJNFe0Z3pDomqG7jffBYS/zMOvVStCaB+wGlAj8qLkCgiTTgbWkEBv80MAvGY 4LqrVDdj6e8UMoPZIZtNrjxvYFXypegYRuIFEhzbzooKzCpGFFGxpz3HjigD9PYdMKk/TZ CrjmiOgOtblTnJj5L7eecV1XtJvJ9l4= X-MC-Unique: LpSBrbi1OKiVIwbOGvcWhw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=1cgRYAqM41Px2LriKtMbCkqWrzppnp4Wtl8WLrPbt8g=; b=BC+6NbaoP0605VJB8FtEv3cf3kn1ZTjNZUiACqxPZKY5DS6joA0E778FH7a21BFE3h sdd+uj0wQwKHpaw2wPVdVeVEOuZk6jYa4Sj3waRoOliCcx/6vU1TFGlfK1OsLbpqt6pb KYvKVQYPT9W8vxYFi+45RfuWSj1NiPgDxThlKBE35BEFj8gK58cHwOH4shv0MhKSrYTB SiMw+cnClMT0lK8XgYwFv279wH812+JQwCIJQLoNpRGYd0GgtY7qapuKgrh/tNRBHBrm iBNeHWtfq5Cf5BGbopppUTcd4Tu++fn3f9Z0jel7JCmeBBeH9iYKGLMgbHK737Xpb88k mZ/g== X-Gm-Message-State: AOAM5336SqmCeBInghfU8a+eS1YthNS+zQs1qqLQOqtRUDcB4wRaETN+ 8zIh4ULM2KQeFkv6V2TwJifrKwyDXsirfef3iR6wX79jTuWO+TVWtAZmASj3OAAJ5YzJOFaMjEN qHGO5Y90QOWX7KA== X-Received: by 2002:a1c:cc09:: with SMTP id h9mr45141872wmb.191.1636988386225; Mon, 15 Nov 2021 06:59:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJyMNNqFIDTgepRxco8S6Zh8Jux7IOmBRfYU39T36RKkzsyRIdT1//measUpR5efmESqGx+hwg== X-Received: by 2002:a1c:cc09:: with SMTP id h9mr45141838wmb.191.1636988386025; Mon, 15 Nov 2021 06:59:46 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Markus Armbruster , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Yanan Wang , Andrew Jones , Eduardo Habkost , Thomas Huth , Marcel Apfelbaum , Richard Henderson Subject: [PATCH-for-7.0 v4 10/11] tests/unit/test-smp-parse: Constify some pointer/struct Date: Mon, 15 Nov 2021 15:58:59 +0100 Message-Id: <20211115145900.2531865-11-philmd@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211115145900.2531865-1-philmd@redhat.com> References: <20211115145900.2531865-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1636988391334100001 Declare structures const when we don't need to modify them at runtime. Reviewed-by: Andrew Jones Reviewed-by: Richard Henderson Reviewed-by: Yanan Wang Tested-by: Yanan Wang Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- tests/unit/test-smp-parse.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/unit/test-smp-parse.c b/tests/unit/test-smp-parse.c index 2f3bcf198a5..8f47a2e65f6 100644 --- a/tests/unit/test-smp-parse.c +++ b/tests/unit/test-smp-parse.c @@ -83,7 +83,7 @@ typedef struct SMPTestData { * then test the automatic calculation algorithm of the missing * values in the parser. */ -static struct SMPTestData data_generic_valid[] =3D { +static const struct SMPTestData data_generic_valid[] =3D { { /* config: no configuration provided * expect: cpus=3D1,sockets=3D1,cores=3D1,threads=3D1,maxcpus=3D1 = */ @@ -285,7 +285,7 @@ static struct SMPTestData data_generic_valid[] =3D { }, }; =20 -static struct SMPTestData data_generic_invalid[] =3D { +static const struct SMPTestData data_generic_invalid[] =3D { { /* config: -smp 2,dies=3D2 */ .config =3D SMP_CONFIG_WITH_DIES(T, 2, F, 0, T, 2, F, 0, F, 0, F, = 0), @@ -319,7 +319,7 @@ static struct SMPTestData data_generic_invalid[] =3D { }, }; =20 -static struct SMPTestData data_with_dies_invalid[] =3D { +static const struct SMPTestData data_with_dies_invalid[] =3D { { /* config: -smp 16,sockets=3D2,dies=3D2,cores=3D4,threads=3D2,maxc= pus=3D16 */ .config =3D SMP_CONFIG_WITH_DIES(T, 16, T, 2, T, 2, T, 4, T, 2, T,= 16), @@ -356,7 +356,7 @@ static char *smp_config_to_string(SMPConfiguration *con= fig) config->has_maxcpus ? "true" : "false", config->maxcpus); } =20 -static char *cpu_topology_to_string(CpuTopology *topo) +static char *cpu_topology_to_string(const CpuTopology *topo) { return g_strdup_printf( "(CpuTopology) {\n" @@ -372,7 +372,7 @@ static char *cpu_topology_to_string(CpuTopology *topo) } =20 static void check_parse(MachineState *ms, SMPConfiguration *config, - CpuTopology *expect_topo, const char *expect_err, + const CpuTopology *expect_topo, const char *expect= _err, bool is_valid) { g_autofree char *config_str =3D smp_config_to_string(config); @@ -466,7 +466,7 @@ static void smp_parse_test(MachineState *ms, SMPTestDat= a *data, bool is_valid) } =20 /* The parsed results of the unsupported parameters should be 1 */ -static void unsupported_params_init(MachineClass *mc, SMPTestData *data) +static void unsupported_params_init(const MachineClass *mc, SMPTestData *d= ata) { if (!mc->smp_props.dies_supported) { data->expect_prefer_sockets.dies =3D 1; --=20 2.31.1 From nobody Mon Feb 9 03:31:34 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1636988395; cv=none; d=zohomail.com; s=zohoarc; b=QJrjb4t/8/GmChtJtjr6p8y5LSKXv8OJ3Z2cDLZd1wLNhSsk8eFk3D8gs74qEG8Mjf/HbUU+hchpftS6uaaXqFAn11jpfdHkaHB3FezUEqC5EKgMo7ptegTo0lJwVWcHtad+dCWCAEZOsVAD8tkUNnohS+rI0qqj+Yqvwwm8L4s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1636988395; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=yztInNsLIu7QfwRSSpxpOx1pYZAWme74L6OF+WOPa2U=; b=eaZoXFg6ntICjL/cJkVOzYboDywBWdExmXSWBm3/esHM+FgioS+AkJt9/Rmh4lLtUs0nYxllln/aTrlhIl3WqtercTp3AsPoOrAPM87S2bDGrURgOdovgBDyT9S63UcUfEIPRz0P3X6z4P9BHrUjnHyvByeyljSa29T9dRin8NE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1636988395274720.3411419912492; Mon, 15 Nov 2021 06:59:55 -0800 (PST) Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-51-7_puFaltOaGEZDXwA6KYVg-1; Mon, 15 Nov 2021 09:59:52 -0500 Received: by mail-wr1-f71.google.com with SMTP id q17-20020adff791000000b00183e734ba48so3661409wrp.8 for ; Mon, 15 Nov 2021 06:59:51 -0800 (PST) Return-Path: Return-Path: Received: from x1w.redhat.com (62.red-83-57-168.dynamicip.rima-tde.net. [83.57.168.62]) by smtp.gmail.com with ESMTPSA id l8sm22753146wmc.40.2021.11.15.06.59.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Nov 2021 06:59:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636988394; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=yztInNsLIu7QfwRSSpxpOx1pYZAWme74L6OF+WOPa2U=; b=czzeCmOYeZgVB+OIteWAilpYgM2dwifo6SNZKC6X4d/l6DSEo0s5Kislst+F/4zFk18uxs UpuzEuTgRtxqxFnF5PhXXog+AZH53fXPEkF71LG8UT3u3vDQGEhb+J6KBMXas7jKCxYqOD Wo0Qh2HYIUKYDq/vYERgWRQoq7V0dmk= X-MC-Unique: 7_puFaltOaGEZDXwA6KYVg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=yztInNsLIu7QfwRSSpxpOx1pYZAWme74L6OF+WOPa2U=; b=iCAEVSNQpJEHbctmDVjgdHaWN1XOeYY3qT9ZCInIVgaL9xjb449dxn/q4pZVqeID/B n0n/1F4uZb/2l8X4TCF257yYJbS/9NYg91FVdyMrvnkNG1BvSWO0IPB+3XxwenzlGgVP idq0SXrmehgGAA8y6kLkw3rhXQX2tCdwbnVw0kLC+PI6tP0gjd9iwi/kFC8CZuBq98us iT+vsAsx52sUNm+zv8iJcqySCfdF1MNPEVOGh32WTUZDCmnlNhg3oumhTzvsCQLApDzU BJjDOVt9G9trEpqkC35abVyL7+uiEBuOIPaqUsvsfLHpg6U+SY6xMRyf3JG68VImcyVt tdXg== X-Gm-Message-State: AOAM533mtzFP2fF0bQ9ZdiMCF70zCMa0PKPXJQhUVOuUsaeHCDNoplDc 40BbmAPj4JK82h8r2tmrQt2rN28tJlpwgBhXbiL7+CtvV57hgr7wkNyjultJtMUCO8oUGyAMxtO rCziU1CprM7cYNg== X-Received: by 2002:a5d:4582:: with SMTP id p2mr48488329wrq.364.1636988390671; Mon, 15 Nov 2021 06:59:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJwIoKRUnjRgOgfAroUSLRHpDuDgLBussq3AjSBId67KMcnGz8tMSA1Y3CIZq7AyxOb0lKUIOw== X-Received: by 2002:a5d:4582:: with SMTP id p2mr48488287wrq.364.1636988390476; Mon, 15 Nov 2021 06:59:50 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Markus Armbruster , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Yanan Wang , Andrew Jones , Eduardo Habkost , Thomas Huth , Marcel Apfelbaum , Richard Henderson Subject: [PATCH-for-7.0 v4 11/11] hw/core: Rename smp_parse() -> machine_parse_smp_config() Date: Mon, 15 Nov 2021 15:59:00 +0100 Message-Id: <20211115145900.2531865-12-philmd@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211115145900.2531865-1-philmd@redhat.com> References: <20211115145900.2531865-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1636988397267100001 All methods related to MachineState are prefixed with "machine_". smp_parse() does not need to be an exception. Rename it and const'ify the SMPConfiguration argument, since it doesn't need to be modified. Reviewed-by: Andrew Jones Reviewed-by: Richard Henderson Reviewed-by: Yanan Wang Tested-by: Yanan Wang Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- include/hw/boards.h | 3 ++- hw/core/machine-smp.c | 6 ++++-- hw/core/machine.c | 2 +- tests/unit/test-smp-parse.c | 8 ++++---- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/include/hw/boards.h b/include/hw/boards.h index 9c1c1901046..7597cec4400 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -34,7 +34,8 @@ HotpluggableCPUList *machine_query_hotpluggable_cpus(Mach= ineState *machine); void machine_set_cpu_numa_node(MachineState *machine, const CpuInstanceProperties *props, Error **errp); -void smp_parse(MachineState *ms, SMPConfiguration *config, Error **errp); +void machine_parse_smp_config(MachineState *ms, + const SMPConfiguration *config, Error **errp= ); =20 /** * machine_class_allow_dynamic_sysbus_dev: Add type to list of valid devic= es diff --git a/hw/core/machine-smp.c b/hw/core/machine-smp.c index 116a0cbbfab..2cbfd574293 100644 --- a/hw/core/machine-smp.c +++ b/hw/core/machine-smp.c @@ -44,7 +44,8 @@ static char *cpu_hierarchy_to_string(MachineState *ms) } =20 /* - * smp_parse - Generic function used to parse the given SMP configuration + * machine_parse_smp_config: Generic function used to parse the given + * SMP configuration * * Any missing parameter in "cpus/maxcpus/sockets/cores/threads" will be * automatically computed based on the provided ones. @@ -63,7 +64,8 @@ static char *cpu_hierarchy_to_string(MachineState *ms) * introduced topology members which are likely to be target specific shou= ld * be directly set as 1 if they are omitted (e.g. dies for PC since 4.1). */ -void smp_parse(MachineState *ms, SMPConfiguration *config, Error **errp) +void machine_parse_smp_config(MachineState *ms, + const SMPConfiguration *config, Error **errp) { MachineClass *mc =3D MACHINE_GET_CLASS(ms); unsigned cpus =3D config->has_cpus ? config->cpus : 0; diff --git a/hw/core/machine.c b/hw/core/machine.c index 26ec54e7261..a2d3c9969d9 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -760,7 +760,7 @@ static void machine_set_smp(Object *obj, Visitor *v, co= nst char *name, return; } =20 - smp_parse(ms, config, errp); + machine_parse_smp_config(ms, config, errp); } =20 static void machine_class_init(ObjectClass *oc, void *data) diff --git a/tests/unit/test-smp-parse.c b/tests/unit/test-smp-parse.c index 8f47a2e65f6..8e488e95145 100644 --- a/tests/unit/test-smp-parse.c +++ b/tests/unit/test-smp-parse.c @@ -337,7 +337,7 @@ static const struct SMPTestData data_with_dies_invalid[= ] =3D { }, }; =20 -static char *smp_config_to_string(SMPConfiguration *config) +static char *smp_config_to_string(const SMPConfiguration *config) { return g_strdup_printf( "(SMPConfiguration) {\n" @@ -371,7 +371,7 @@ static char *cpu_topology_to_string(const CpuTopology *= topo) topo->cores, topo->threads, topo->max_cpus); } =20 -static void check_parse(MachineState *ms, SMPConfiguration *config, +static void check_parse(MachineState *ms, const SMPConfiguration *config, const CpuTopology *expect_topo, const char *expect= _err, bool is_valid) { @@ -380,8 +380,8 @@ static void check_parse(MachineState *ms, SMPConfigurat= ion *config, g_autofree char *output_topo_str =3D NULL; Error *err =3D NULL; =20 - /* call the generic parser smp_parse() */ - smp_parse(ms, config, &err); + /* call the generic parser */ + machine_parse_smp_config(ms, config, &err); =20 output_topo_str =3D cpu_topology_to_string(&ms->smp); =20 --=20 2.31.1