From nobody Sun Feb 8 18:31:48 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=1637016491; cv=none; d=zohomail.com; s=zohoarc; b=b+ZmfNCEWzErchXlXN5EIxm8CfDq3KdkkbfhU/bIrlH8mNrpS+zqZ6ynIVMMNEAhDPJ/EdDjzncjA72+yieBjYnlfNyyozh3aQ6Dxr0j5dWysQ51nU0UX++ZwmtRvwYKzXCObXaVHSi+yzG1ad4gAwIAEeOC0NmJixa8Kta8H54= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1637016491; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=DWI+cx9qApZnpufdk+eCQH7BppqYrJuE51M3l3XNNKQ=; b=En0B5owwdD+M/D/JjWXoXMTE2cUbesZQTHuheO3kpZ9cwTEbpOxSd2PJxx+HUFebr+cUpI0zo8Zyg18ocp27rELjgcDgtjRRLs287zhUZI+pY3F7bU2+5Nicj2gvFQUuXzyN+r4aS13uo+RBi0xmkEiUBtGefEjTCbS4Ffae1F0= 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 1637016491831656.1554306231907; Mon, 15 Nov 2021 14:48:11 -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-283-GL6-xRhZNVyQr5mDH6Nb3w-1; Mon, 15 Nov 2021 17:48:09 -0500 Received: by mail-wm1-f72.google.com with SMTP id o22-20020a1c7516000000b0030d6f9c7f5fso6549855wmc.1 for ; Mon, 15 Nov 2021 14:48:09 -0800 (PST) Return-Path: Return-Path: Received: from x1w.. (62.red-83-57-168.dynamicip.rima-tde.net. [83.57.168.62]) by smtp.gmail.com with ESMTPSA id t8sm669534wmq.32.2021.11.15.14.48.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Nov 2021 14:48:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637016490; 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=DWI+cx9qApZnpufdk+eCQH7BppqYrJuE51M3l3XNNKQ=; b=hVp6opzur603X66E7jYuJZGls4ENyLB4p9WoHwLwoRHcjDkwrERrNnGCtc/QtuZFEK6tJi eOD1FQSBdeEOwZLUNVD6g58RQGRGif3ETRbAp7SlXLMYNGB+S5/CDxfJa3VJ7yEhrWLN84 AeRLjRPLb+23EzkN/0v6Sly7Jw/Dfw8= X-MC-Unique: GL6-xRhZNVyQr5mDH6Nb3w-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=DWI+cx9qApZnpufdk+eCQH7BppqYrJuE51M3l3XNNKQ=; b=sCbPZ/5A/A5BuJk6Q8GkRDAKBetq5nxBTJxTEOYW3h4BWhCUkoljDiQC54lKsp9rM/ yG6RWJ0KPS8KwANi1DNtNdGIJQphVFI6/he9ninbyZGRzVzkqC37BAF9j+Iw1qvKCKml 0xJikPUwncIt0MU2jC0WISJ/vTPcNnSbMkKmQSIQdgCahPZMRO7hUVozbp4kwIHT0HSL yoREajhgP/j5P9VTjZS9eXBuoLiPUZ0jOFSJoHCm78ds3Bc8GBqsa9Oej81iDcbRdYtS frWZsuXCBxaXowEhnANl0cSyukU1N2QDVnzn3HDlydrXXpKzOzsVKQ+HqUpTMXZ4KWos Zi1A== X-Gm-Message-State: AOAM5326r/C7kx+MTnvwgK4K4S5+zgy4t+8+7Te7HwPxcdGrJz8niwbt tg+tCOY/i99N5t5CD3tN8raX58xO3JDhQmHERLHY/2jTweQCwjiA70l0jj2Lw8eh2SJD9CnE2gf oSuq0lVXNiwBdJA== X-Received: by 2002:a05:600c:4e8d:: with SMTP id f13mr64733391wmq.7.1637016488654; Mon, 15 Nov 2021 14:48:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJwjlDNL5VzZGyDjQWO+VAHonka3hCNfH6XY6wn8DcCY//dndRnpHeVt3FfeNIur+zaAopOpZg== X-Received: by 2002:a05:600c:4e8d:: with SMTP id f13mr64733368wmq.7.1637016488472; Mon, 15 Nov 2021 14:48:08 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Eduardo Habkost , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Marcel Apfelbaum , Andrew Jones , Richard Henderson , Yanan Wang Subject: [PULL 1/3] tests/unit/test-smp-parse: Restore MachineClass fields after modifying Date: Mon, 15 Nov 2021 23:48:00 +0100 Message-Id: <20211115224802.2602894-2-philmd@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211115224802.2602894-1-philmd@redhat.com> References: <20211115224802.2602894-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: 1637016493637100001 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 Message-Id: <20211115145900.2531865-2-philmd@redhat.com> --- 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 Sun Feb 8 18:31:48 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=1637016496; cv=none; d=zohomail.com; s=zohoarc; b=SlRyLLD/2QNHsO3A6YUQQbdERX44Rem/tKzj4oA/4Her0cZ3LwJBALUWoHwJeLyK019qWNg7W/mptWUPvgnXNA00c0XYoTcA/R8vTpaj0YTp570y0CLwq4I4QU+41I/loPrrOPrnXP1uxVGQXuUS5rdbiw0FMl81CSDLTQjJE/Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1637016496; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=nEd/ygkIQTZNVKYYqfDQ3gUYWshnM+QoFjlZKizg/LY=; b=gjb/e9iOfVR0y9tk6ve1W6G0qiElF7OUhC8iyzos5cb4IRw1rb43BjeLuE0Ty1KsGndOPgr9VBLpT89PnBD5qpzpEIasAl5ox4KMGvBj6iz/LjFYsvFhGAAfqd17hQJb+V4teNXYsYA3X95a1sQY2ljExkmZZvgh7RXR9IBbljw= 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 1637016496703929.9486166504557; Mon, 15 Nov 2021 14:48:16 -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-105-ZNJnjY7JPvOo2wCvx6NfcA-1; Mon, 15 Nov 2021 17:48:14 -0500 Received: by mail-wm1-f69.google.com with SMTP id r129-20020a1c4487000000b00333629ed22dso245500wma.6 for ; Mon, 15 Nov 2021 14:48:14 -0800 (PST) Return-Path: Return-Path: Received: from x1w.. (62.red-83-57-168.dynamicip.rima-tde.net. [83.57.168.62]) by smtp.gmail.com with ESMTPSA id n32sm569230wms.42.2021.11.15.14.48.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Nov 2021 14:48:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637016495; 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=nEd/ygkIQTZNVKYYqfDQ3gUYWshnM+QoFjlZKizg/LY=; b=F8cMMQhOe9e5wqsqBNvS50fZ2V5rUUD59PS2pyZ1pbz3pEIOaSA1uHYLSSlHTcHxo2zcB2 d22c23hYV0riRU8nlb12xzCwlWDrenrIVphHjkI3UAwaviF7J3ly511hIYVRdcJxLYziZG vEtO+FBvUY563yyyckVNUdgOh16Exp0= X-MC-Unique: ZNJnjY7JPvOo2wCvx6NfcA-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=nEd/ygkIQTZNVKYYqfDQ3gUYWshnM+QoFjlZKizg/LY=; b=oNy1eo/wcijs7q6zTmfYuabBMLf7PblckHZIE/sntAyQWu9BRdc4IGNXgpoNwEgXM2 1bp1X05aAUWY3wovp0cF0y+0MeLHQX9GSEAecJRgcSsVOcEl5cSN2a6GpqUpqbmw/KZt ha3MPzHMTsFwYddjNhfDwS9ibXo1WTct/2G0mnOF366DyPg5fyv62DWvTcSYZ0IL/G6D aar4U9d943dOw1GTe4tidfgbApIikc9pLmEOtzilkvuaUHEKaCeVIIfieFJXRBJdCkWK uM9t7R3cJoqp0iarBOEXPiOhOK5pqjn5wcOVPqNtwgQWDovNShUk/ZUkOMPg8dRceMCK OS6A== X-Gm-Message-State: AOAM533SPY1fLVqQB8yxJdsrXoFRKik1vUNQJqmbUrcRYCtYoBMRBf9A iLhpBFboRie+DfzIKncni/9yRZLl13Gg2GUba4eGxCai4ZoZheqJlQ+hiTEDQKceYsSasa7wkoA ijAzNWSoq4NdL7Q== X-Received: by 2002:a05:6000:1813:: with SMTP id m19mr3265210wrh.51.1637016493105; Mon, 15 Nov 2021 14:48:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJwlw6Spi22UL5K2B0CXJ+L1BIp50mO4OVEhJnoBZMR8wfvCTeavkZcHpNbKuDxei2CobzlXqw== X-Received: by 2002:a05:6000:1813:: with SMTP id m19mr3265194wrh.51.1637016492993; Mon, 15 Nov 2021 14:48:12 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Eduardo Habkost , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Marcel Apfelbaum , Andrew Jones , Richard Henderson , Yanan Wang Subject: [PULL 2/3] tests/unit/test-smp-parse: QOM'ify smp_machine_class_init() Date: Mon, 15 Nov 2021 23:48:01 +0100 Message-Id: <20211115224802.2602894-3-philmd@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211115224802.2602894-1-philmd@redhat.com> References: <20211115224802.2602894-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: 1637016498327100001 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 Message-Id: <20211115145900.2531865-3-philmd@redhat.com> --- 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 Sun Feb 8 18:31:48 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1637016501; cv=none; d=zohomail.com; s=zohoarc; b=IIf8H9uWzs1cT3pHIym0HHsQ394CDvweLkWgsXbh6tCn03RNIs3KEFkJ9V285liztB0O8AXgflWgQbONkyhrHFKzft62NM6f4nQFqXI+DX/f+b34RMUTroGtgmM2vfxBC6M2h4d3sZga09B7GbLmFgmNfS8zwB3W8ZGiFrMMbzQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1637016501; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=byTizwcSSoKyIq1puLjEKJm8typeg4ZcFgPzEW52fJE=; b=nkGag8fn3cB3pFclMHEWYo8y8lch+PaQY/tz3ZrPnGQR13V1purfQtC8Ieda9sTKKsUZARHCxnigvu9zY+Sq/B7Dsu+I0lB5qwXKFttWUCH2j4Lw5bYOfL2z1LyUNkLP0/EjZ5HGcJ8iAHZ/f2+SJTF7qCcYuHpLTJxf+xDPTxs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 1637016501675585.7049179177458; Mon, 15 Nov 2021 14:48:21 -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-413-DjA3aKVxOges8qAPgzZALA-1; Mon, 15 Nov 2021 17:48:18 -0500 Received: by mail-wm1-f72.google.com with SMTP id m14-20020a05600c3b0e00b0033308dcc933so550763wms.7 for ; Mon, 15 Nov 2021 14:48:18 -0800 (PST) Return-Path: Return-Path: Received: from x1w.. (62.red-83-57-168.dynamicip.rima-tde.net. [83.57.168.62]) by smtp.gmail.com with ESMTPSA id o63sm613510wme.2.2021.11.15.14.48.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Nov 2021 14:48:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637016500; 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=byTizwcSSoKyIq1puLjEKJm8typeg4ZcFgPzEW52fJE=; b=KjzxV5dWLf/HPWl/qiocO0oXSIVO9LY7VqfiSyLgXAlfXl0Da1iPNUZFQuP4FPwJ2cMK0C hr4ri5D9hezYiiTEIlN1A/01HxlDn+TRWbD5ZVAlHJ9UUSkd76EpSrYpSUIin0zhQrbCIc QZUcy7gdtMOrfBSJL/+rYezIanKZfRs= X-MC-Unique: DjA3aKVxOges8qAPgzZALA-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=byTizwcSSoKyIq1puLjEKJm8typeg4ZcFgPzEW52fJE=; b=ZMkJtFGAhG6W8Qtp9TK6ks0z5fUN+PJURISWKm0uBP7MiaYeC0XZoB9PZGb3WsXcIE msvlCYpkFvZh1F0PVzgqSwiL/ybxmGMfHw2ZHkn5EMrQgxPry401tExBpMhE/M1hpeoO aLimIPlvPlOgx/wEn2j0hVlV4MPlWsL0RBRDUt4TyMwPTAGVC3NQ3DQdGcl9DfF5ElBy FhOVhln9miJmMzoUlcfiQaK/CF2PgGdod9M3bV3/E9yCWPK+n1DIRu+Jv98titPGn+Zy Tq0lvLZlC0yxaEmmvblflmQhi9bc6j+LUoxcFLDGawJQrsnRsq4gZVLIKa4mju5T4GUz bvFA== X-Gm-Message-State: AOAM531SO9bcYK4sT10RF3m/6WJKOiHpwarJSnEUraEcDw7LPWqikg7J k9Vv22DBjhLd7H3M+80YDM0c27G62ns7xAUzkxk4Bu8xopBkM9at8KXnbty+pWpZTDj6zozGAwg T+UbGIUJM/76PSg== X-Received: by 2002:a7b:c157:: with SMTP id z23mr63780280wmi.113.1637016497506; Mon, 15 Nov 2021 14:48:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJwyUxgeyIf+IubjhuVTfJfUFbfIMBiJ1BfbKXAXROwmjorBqnPkThWuY9iSPlyvdjTF1Du8kw== X-Received: by 2002:a7b:c157:: with SMTP id z23mr63780256wmi.113.1637016497309; Mon, 15 Nov 2021 14:48:17 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Eduardo Habkost , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Marcel Apfelbaum , Andrew Jones , Richard Henderson , Yanan Wang Subject: [PULL 3/3] tests/unit/test-smp-parse: Explicit MachineClass name Date: Mon, 15 Nov 2021 23:48:02 +0100 Message-Id: <20211115224802.2602894-4-philmd@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211115224802.2602894-1-philmd@redhat.com> References: <20211115224802.2602894-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: 1637016502291100001 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 Message-Id: <20211115145900.2531865-4-philmd@redhat.com> --- 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