From patchwork Wed Dec 15 16:48:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 12678755 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C353BC433EF for ; Wed, 15 Dec 2021 16:58:33 +0000 (UTC) Received: from localhost ([::1]:59134 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mxXbs-00023H-Hs for qemu-devel@archiver.kernel.org; Wed, 15 Dec 2021 11:58:32 -0500 Received: from eggs.gnu.org ([209.51.188.92]:34132) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mxXSv-0004TR-G3 for qemu-devel@nongnu.org; Wed, 15 Dec 2021 11:49:19 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:52408) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mxXSu-0001yl-3v for qemu-devel@nongnu.org; Wed, 15 Dec 2021 11:49:17 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639586953; 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=t0HaJa5hL0xbci94VgrhNJFI3KFO8etTJC6TchOuXSE=; b=D6KApL2/N+DpfHszngJAjObY8/+QiSRXh7xt8FJsJU32/i2RoHSDmZ/YYqZZqjlPPYDT8w rY3Kj7zIRi1v9cTLz7Of4MRpq6Mc5VqaslEu+fVS6atXATLJyhDgwj6TaguyR3qhBe6N5Y 1DaFQ21cI8ywmy29aKc2u4x1otrFY60= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-110-NJbcAciCORqZhH_EL14tRw-1; Wed, 15 Dec 2021 11:49:12 -0500 X-MC-Unique: NJbcAciCORqZhH_EL14tRw-1 Received: by mail-wm1-f69.google.com with SMTP id k25-20020a05600c1c9900b00332f798ba1dso14892898wms.4 for ; Wed, 15 Dec 2021 08:49:11 -0800 (PST) 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=t0HaJa5hL0xbci94VgrhNJFI3KFO8etTJC6TchOuXSE=; b=2u5j7VxewWzQJcp5v/fcfu7jGZq3/09rV3xTBbpK/mHxvdCXidWMIN8ect4v+zWdgw fqIQJakDEZ7TRKM3+ViU9qpRfEm12xTy7YUeobkXxQt9zT1EjgVyNDpViYvKD8Nu5lTz ByPmfRiwMLHrRYFqZSgTeC+tepBfj5wu1gKRAcS+Bau+YdDOllBiWXqU9PgactaY5JDY eWkdM8QKgh91LJ4ytrfjIQO17MAU3Mp4Q5qD7kjNshX2OUDS/EErMjcij+6IyCSBl5n4 +MvnbV31qo8V0m9qvsxeDjDTcP2lxxozgvywOvLpm0AJycvmvC4sUStalP/ygIsPgXHd MphQ== X-Gm-Message-State: AOAM5312j3xd1LTgFTxUnoT2GSbECF4uiB32+lRV8iXd4EPxuBnNtfVR vtzjiEzipA+ZuHdAZVNBdVwV8TJDsHzCY5eajbobCjJbdF+DL+FbFctC3fouUfPQUEBj0bCLZLr YZuvGyyGMiCAHlcMHxBE3qLPQ8Wp9YWjS9W5/YKD9QkMhzmJyxj66xdBHt4z13ino X-Received: by 2002:adf:ce08:: with SMTP id p8mr5261319wrn.154.1639586950615; Wed, 15 Dec 2021 08:49:10 -0800 (PST) X-Google-Smtp-Source: ABdhPJy4BJQagz8bKCSuYyL0rib/QaODn0P2WzfvKuta6q12qVha+fVsACKfLrpg4NpukFFKeJht0w== X-Received: by 2002:adf:ce08:: with SMTP id p8mr5261299wrn.154.1639586950448; Wed, 15 Dec 2021 08:49:10 -0800 (PST) Received: from localhost.localdomain (174.red-83-50-185.dynamicip.rima-tde.net. [83.50.185.174]) by smtp.gmail.com with ESMTPSA id w17sm2604355wmc.14.2021.12.15.08.49.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Dec 2021 08:49:10 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v5 1/8] tests/unit/test-smp-parse: Pass machine type as argument to tests Date: Wed, 15 Dec 2021 17:48:49 +0100 Message-Id: <20211215164856.381990-2-philmd@redhat.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211215164856.381990-1-philmd@redhat.com> References: <20211215164856.381990-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 Received-SPF: pass client-ip=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.719, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , Richard Henderson , Yanan Wang , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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). Reviewed-by: Richard Henderson Reviewed-by: Yanan Wang Signed-off-by: Philippe Mathieu-Daudé --- 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, void *data) mc->name = g_strdup(SMP_MACHINE_NAME); } -static void test_generic(void) +static void test_generic(const void *opaque) { - Object *obj = object_new(TYPE_MACHINE); + const char *machine_type = opaque; + Object *obj = object_new(machine_type); MachineState *ms = MACHINE(obj); MachineClass *mc = MACHINE_GET_CLASS(obj); SMPTestData *data = &(SMPTestData){{ }}; @@ -525,9 +526,10 @@ static void test_generic(void) object_unref(obj); } -static void test_with_dies(void) +static void test_with_dies(const void *opaque) { - Object *obj = object_new(TYPE_MACHINE); + const char *machine_type = opaque; + Object *obj = object_new(machine_type); MachineState *ms = MACHINE(obj); MachineClass *mc = MACHINE_GET_CLASS(obj); SMPTestData *data = &(SMPTestData){{ }}; @@ -599,8 +601,12 @@ int main(int argc, char *argv[]) g_test_init(&argc, &argv, NULL); - 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); g_test_run(); From patchwork Wed Dec 15 16:48:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 12678749 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1D8C5C433EF for ; Wed, 15 Dec 2021 16:52:34 +0000 (UTC) Received: from localhost ([::1]:42658 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mxXW5-0007du-2i for qemu-devel@archiver.kernel.org; Wed, 15 Dec 2021 11:52:33 -0500 Received: from eggs.gnu.org ([209.51.188.92]:34152) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mxXSx-0004TW-Qz for qemu-devel@nongnu.org; Wed, 15 Dec 2021 11:49:21 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:40138) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mxXSw-0001yu-Ce for qemu-devel@nongnu.org; Wed, 15 Dec 2021 11:49:19 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639586957; 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=GXx7W8UBpOZBRJ+rhAKMv79kybQ7cCiq3Z9AZnQ5faU=; b=VMHFT7AB4LY5hijKf6MQXsHezajteBCFui7IpTIzsHEM3G6kx2qu7p9tP6PYMG/KVuELkM 2GkZlayL5xmjNwbx4Unzy4woGL9WUYdSxpWVrvpmRvwgTJU+zYYSIPGDBxB8Vfy24waQKz i9iqu36GOnfQACgZT9oDlXrV8g/9xHY= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-115-W9rqMpFlPRerC_zfuP-sYw-1; Wed, 15 Dec 2021 11:49:16 -0500 X-MC-Unique: W9rqMpFlPRerC_zfuP-sYw-1 Received: by mail-wm1-f69.google.com with SMTP id j25-20020a05600c1c1900b00332372c252dso9266535wms.1 for ; Wed, 15 Dec 2021 08:49:16 -0800 (PST) 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=GXx7W8UBpOZBRJ+rhAKMv79kybQ7cCiq3Z9AZnQ5faU=; b=0WAmafu+i0oJghrkLKkIiI5WyRTRKzPDhXuyqnEEeh6f0Un6wKuDGuphX+O4K3Q8mC QDAvlmyivzBMkC2vKbruZ4vwKUkxp7Cc6bnLTtNHYNFtxppeSKaPEJMZf/05fOu6A+AL mIRxn8x/Bj9XIcA5eWQjuqsGbMyDesz6fW0kzMPtgRZmseDyrdrbG6QMYfg8FMK3KfGS dSonWBJBzqmUeWcx7CkzkKaFvbqP+lkDIhpB4KKMF6yyTD23VL46UTTQL6A7jgczOWZd jcadeKdGZzYX0FF67NbhiObeziIuu5BNrlLINm9iMg1JU/oJYVt2nfkV5KDWErpRLpkV x2WA== X-Gm-Message-State: AOAM533WV09VVcQ4glbfCBX9EH58hXllpIpOwzWYYh8Kte9meAa2LWlt HORh7sgTQgcX3T8I83FRtfq+R0cNyEJvyqzMv3204zeZcYkan8M1OK+9izfUNlPy7n8sFEPVzhd wfiI7zSTjVxgbCLI1erXZejjGU2xRR6xRO7/sW/hv8rMEzcPo0eHkCOb7ebYgDMLp X-Received: by 2002:a05:6000:cd:: with SMTP id q13mr5327583wrx.488.1639586955214; Wed, 15 Dec 2021 08:49:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJySnjyTdiPcc1h3etCGx8TgmtMe9GuGO1/2cJhrkebD7KlCmVh0OejZtO4Wolw7jo0abvs02g== X-Received: by 2002:a05:6000:cd:: with SMTP id q13mr5327551wrx.488.1639586954864; Wed, 15 Dec 2021 08:49:14 -0800 (PST) Received: from localhost.localdomain (174.red-83-50-185.dynamicip.rima-tde.net. [83.50.185.174]) by smtp.gmail.com with ESMTPSA id w15sm2428449wrk.77.2021.12.15.08.49.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Dec 2021 08:49:14 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v5 2/8] tests/unit/test-smp-parse: Split the 'generic' test in valid / invalid Date: Wed, 15 Dec 2021 17:48:50 +0100 Message-Id: <20211215164856.381990-3-philmd@redhat.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211215164856.381990-1-philmd@redhat.com> References: <20211215164856.381990-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 Received-SPF: pass client-ip=170.10.129.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.719, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , Richard Henderson , Yanan Wang , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Split the 'generic' test in two tests: 'valid' and 'invalid'. This will allow us to remove the hack which modifies the MachineClass internal state. Reviewed-by: Richard Henderson Reviewed-by: Yanan Wang Signed-off-by: Philippe Mathieu-Daudé --- tests/unit/test-smp-parse.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/tests/unit/test-smp-parse.c b/tests/unit/test-smp-parse.c index 37c6b4981db..425ed6b6b92 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, void *data) mc->name = g_strdup(SMP_MACHINE_NAME); } -static void test_generic(const void *opaque) +static void test_generic_valid(const void *opaque) { const char *machine_type = opaque; Object *obj = object_new(machine_type); @@ -508,6 +508,18 @@ static void test_generic(const void *opaque) smp_parse_test(ms, data, true); } + object_unref(obj); +} + +static void test_generic_invalid(const void *opaque) +{ + const char *machine_type = opaque; + Object *obj = object_new(machine_type); + MachineState *ms = MACHINE(obj); + MachineClass *mc = MACHINE_GET_CLASS(obj); + SMPTestData *data = &(SMPTestData){}; + int i; + /* Force invalid min CPUs and max CPUs */ mc->min_cpus = 2; mc->max_cpus = 511; @@ -601,9 +613,12 @@ int main(int argc, char *argv[]) g_test_init(&argc, &argv, NULL); - 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); From patchwork Wed Dec 15 16:48:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 12678771 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3489CC433EF for ; Wed, 15 Dec 2021 17:02:59 +0000 (UTC) Received: from localhost ([::1]:39820 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mxXg8-0008GZ-8y for qemu-devel@archiver.kernel.org; Wed, 15 Dec 2021 12:02:57 -0500 Received: from eggs.gnu.org ([209.51.188.92]:34214) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mxXTB-0004YQ-Sw for qemu-devel@nongnu.org; Wed, 15 Dec 2021 11:49:35 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:50196) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mxXT0-0001zT-CO for qemu-devel@nongnu.org; Wed, 15 Dec 2021 11:49:23 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639586961; 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=1chFsAOK0rTvA7TehLOkyqZafZUrvfp4t7SGxNleGGw=; b=CGdHdzBN8pWu93Mub35Bdupg4hi7zTxbKH4B1gN1+VKeRoCOpg/EO0txZGjYvbDQkE+0ly cWQ359xpYcjT7ktu7xviYOTruipSlCs1i0EAjbCCUI3HHfYt5jUiXbXQo2cKUDR6fT27En TTgYYKREOJLSaKPMMr0Mhj4pclTY4Ao= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-564-blWiBLeAP2WifNyYChzwnA-1; Wed, 15 Dec 2021 11:49:21 -0500 X-MC-Unique: blWiBLeAP2WifNyYChzwnA-1 Received: by mail-wm1-f69.google.com with SMTP id k25-20020a05600c1c9900b00332f798ba1dso14893057wms.4 for ; Wed, 15 Dec 2021 08:49:20 -0800 (PST) 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=1chFsAOK0rTvA7TehLOkyqZafZUrvfp4t7SGxNleGGw=; b=VTaMT4KWkVJJY6xt0z04mZ79yMNYvGz8wb3b08CTxWppbiW2WIVEJSg2ALPJ7K4BsO uDuZK3Eq8XoBDgk5ofOikEIkVA+QUsm80Bu2Crx3fC81hYJeToksUQdFfDBS5epaeQ6a yIvUkqrubma5DsF4G3jR4/tKDiMbC76Lw8CE1nsMKAYdrE1C2melXvLddRb1ibcox8/S 8Cl/zidlPHsngKKCb3t2uUK1KYdz7sNILlMGBkPJpWNKQ1+HVfOUjGXQ8BL8V42UsTN3 aA96OjvoY6bH3MpRJLAL/g7R/zuIpsHhc1v1fHI9gWFg/G9K4nE9FaKqNfHdVlSAB9cY WWaw== X-Gm-Message-State: AOAM532PpqPYzS/q7N18T+CcIRWMQkZ4LmeVMHMWv5grV/2jBysNxnE2 yIaEPSbZc0EEcWucFElrjyesVZd1GKyL7YUM8WYTlTOll8jeDcxXso+Yug12Hoi1VU55QMs9E94 RsuVNRwrgGKdq3PeXaHgEKp3dLKyppeOTfCNjMRgfW5oJnceuwUJlYCE5PPEhx98B X-Received: by 2002:adf:f252:: with SMTP id b18mr2219710wrp.341.1639586959593; Wed, 15 Dec 2021 08:49:19 -0800 (PST) X-Google-Smtp-Source: ABdhPJzvMe099VeiUOsjwqp5vjLQgdbQE2t1ELl+aWSPW++zwyoBgykdmWf3GfuR9CnXjG1nkowesw== X-Received: by 2002:adf:f252:: with SMTP id b18mr2219686wrp.341.1639586959359; Wed, 15 Dec 2021 08:49:19 -0800 (PST) Received: from localhost.localdomain (174.red-83-50-185.dynamicip.rima-tde.net. [83.50.185.174]) by smtp.gmail.com with ESMTPSA id g198sm2770354wme.23.2021.12.15.08.49.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Dec 2021 08:49:18 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v5 3/8] tests/unit/test-smp-parse: Add 'smp-with-dies' machine type Date: Wed, 15 Dec 2021 17:48:51 +0100 Message-Id: <20211215164856.381990-4-philmd@redhat.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211215164856.381990-1-philmd@redhat.com> References: <20211215164856.381990-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 Received-SPF: pass client-ip=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.719, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , Richard Henderson , Yanan Wang , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Avoid modifying the MachineClass internals by adding the 'smp-with-dies' machine, which inherits from TYPE_MACHINE. Reviewed-by: Richard Henderson Reviewed-by: Yanan Wang Tested-by: Yanan Wang Signed-off-by: Philippe Mathieu-Daudé --- 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 425ed6b6b92..f66cf7bb598 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, void *data) mc->name = g_strdup(SMP_MACHINE_NAME); } +static void machine_with_dies_class_init(ObjectClass *oc, void *data) +{ + MachineClass *mc = MACHINE_CLASS(oc); + + mc->min_cpus = MIN_CPUS; + mc->max_cpus = MAX_CPUS; + + mc->smp_props.dies_supported = true; +} + static void test_generic_valid(const void *opaque) { const char *machine_type = opaque; @@ -548,9 +558,6 @@ static void test_with_dies(const void *opaque) unsigned int num_dies = 2; int i; - /* Force the SMP compat properties */ - mc->smp_props.dies_supported = true; - for (i = 0; i < ARRAY_SIZE(data_generic_valid); i++) { *data = data_generic_valid[i]; unsupported_params_init(mc, data); @@ -588,9 +595,6 @@ static void test_with_dies(const void *opaque) smp_parse_test(ms, data, false); } - /* Restore the SMP compat properties */ - mc->smp_props.dies_supported = false; - object_unref(obj); } @@ -602,6 +606,10 @@ static const TypeInfo smp_machine_types[] = { .class_init = machine_base_class_init, .class_size = sizeof(MachineClass), .instance_size = sizeof(MachineState), + }, { + .name = MACHINE_TYPE_NAME("smp-with-dies"), + .parent = TYPE_MACHINE, + .class_init = machine_with_dies_class_init, } }; @@ -620,7 +628,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); g_test_run(); From patchwork Wed Dec 15 16:48:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 12678775 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 499D5C433EF for ; Wed, 15 Dec 2021 17:05:42 +0000 (UTC) Received: from localhost ([::1]:45786 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mxXin-000490-B2 for qemu-devel@archiver.kernel.org; Wed, 15 Dec 2021 12:05:41 -0500 Received: from eggs.gnu.org ([209.51.188.92]:34234) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mxXTD-0004YV-1q for qemu-devel@nongnu.org; Wed, 15 Dec 2021 11:49:35 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:30985) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mxXTB-0001zb-FG for qemu-devel@nongnu.org; Wed, 15 Dec 2021 11:49:34 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639586966; 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=gzBQu4QmY83ZJxn/RGUigkeYNejwi9D3HBZlC+kt004=; b=SrsmXejsc7wI3y917n/+Cep/siU5L/b+DcMmAdP6W5fp8yGUYFMwIpR2gkadaczbjWSMGd OW1iGG/T2hwd1IBxvtxzB3hw2AB7H4/RnT9G8Wqb9pttT80NCv6rQ9RaSdfsLODfaMD7a6 585nSnfF5fciLmya+2ioufUZSgJSqZ4= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-383-tARZ9GLHOgyhOQUQORpDZQ-1; Wed, 15 Dec 2021 11:49:25 -0500 X-MC-Unique: tARZ9GLHOgyhOQUQORpDZQ-1 Received: by mail-wm1-f72.google.com with SMTP id b75-20020a1c804e000000b0034569bde713so1017032wmd.9 for ; Wed, 15 Dec 2021 08:49:25 -0800 (PST) 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=gzBQu4QmY83ZJxn/RGUigkeYNejwi9D3HBZlC+kt004=; b=bEeOrKsDLeL/hXcd3Nvmajh+PFBAY1auSiiXpHWviIDGSf+4A3nJlouRKfpTG3fK2k abm47AXXb63xdZ0CWIsrvEqk3jqxVmpYz1TSraom62ZJ4/yOuHvSf5kDrm8aRHXr0Oe/ pce4KJ5eA8W+Tsn3vpzAvD/htcfam3KJT0M1LttNsn4ZiS6WmxnLHUqngByeaEmZaMAk aYKinRoD2dbdABOlbcT+htVurE3/J2L/1+zhuMUPviyNW0oH3Ho+Hj37l+2M5mfm6Ybh gURL86W4ct40EcAUO4EH6VNVBPijiDWgzorItJJ0aXdPH+EjNy7FeCAyo9oCy6RxSo6m D8nw== X-Gm-Message-State: AOAM531BBdLwk7DGbKUCV5RTO0bSrVY3IbmSGe52e7jUzU1FQquls54L DQ9nMknf9Kkkzko2TeJjgOE+LHK5ZLdFFRJT8rki5av2vYGaKIyMKE0OrCVmkgfB14aiA62fYeX A4EuafDegnzufaPCnHaQBmZ4RGlOsmgFf4EtCkexXOAlLI048Px30vvhNl1UAf1rN X-Received: by 2002:adf:9cc4:: with SMTP id h4mr5178906wre.644.1639586963875; Wed, 15 Dec 2021 08:49:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJwXuiAJUWKwJjDdKhC6tiSLXZKZVSJVpPsjSjHdVdioz1ncOuETMqAfL+zESKB3gKAuPP+www== X-Received: by 2002:adf:9cc4:: with SMTP id h4mr5178890wre.644.1639586963692; Wed, 15 Dec 2021 08:49:23 -0800 (PST) Received: from localhost.localdomain (174.red-83-50-185.dynamicip.rima-tde.net. [83.50.185.174]) by smtp.gmail.com with ESMTPSA id g18sm2470449wrv.42.2021.12.15.08.49.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Dec 2021 08:49:23 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v5 4/8] tests/unit/test-smp-parse: Add 'smp-generic-invalid' machine type Date: Wed, 15 Dec 2021 17:48:52 +0100 Message-Id: <20211215164856.381990-5-philmd@redhat.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211215164856.381990-1-philmd@redhat.com> References: <20211215164856.381990-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 Received-SPF: pass client-ip=170.10.129.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.719, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , Richard Henderson , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Avoid modifying the MachineClass internals by adding the 'smp-generic-invalid' machine, which inherits from TYPE_MACHINE. Reviewed-by: Richard Henderson Signed-off-by: Philippe Mathieu-Daudé --- tests/unit/test-smp-parse.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/tests/unit/test-smp-parse.c b/tests/unit/test-smp-parse.c index f66cf7bb598..72e7236afd9 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, void *data) mc->name = g_strdup(SMP_MACHINE_NAME); } +static void machine_without_dies_invalid_class_init(ObjectClass *oc, void *data) +{ + MachineClass *mc = MACHINE_CLASS(oc); + + /* Force invalid min CPUs and max CPUs */ + mc->min_cpus = 2; + mc->max_cpus = 511; + + mc->smp_props.dies_supported = false; +} + static void machine_with_dies_class_init(ObjectClass *oc, void *data) { MachineClass *mc = MACHINE_CLASS(oc); @@ -530,10 +541,6 @@ static void test_generic_invalid(const void *opaque) SMPTestData *data = &(SMPTestData){}; int i; - /* Force invalid min CPUs and max CPUs */ - mc->min_cpus = 2; - mc->max_cpus = 511; - for (i = 0; i < ARRAY_SIZE(data_generic_invalid); i++) { *data = data_generic_invalid[i]; unsupported_params_init(mc, data); @@ -541,10 +548,6 @@ static void test_generic_invalid(const void *opaque) smp_parse_test(ms, data, false); } - /* Reset the supported min CPUs and max CPUs */ - mc->min_cpus = MIN_CPUS; - mc->max_cpus = MAX_CPUS; - object_unref(obj); } @@ -606,6 +609,10 @@ static const TypeInfo smp_machine_types[] = { .class_init = machine_base_class_init, .class_size = sizeof(MachineClass), .instance_size = sizeof(MachineState), + }, { + .name = MACHINE_TYPE_NAME("smp-generic-invalid"), + .parent = TYPE_MACHINE, + .class_init = machine_without_dies_invalid_class_init, }, { .name = MACHINE_TYPE_NAME("smp-with-dies"), .parent = TYPE_MACHINE, @@ -625,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-generic-invalid"), test_generic_invalid); g_test_add_data_func("/test-smp-parse/with_dies", MACHINE_TYPE_NAME("smp-with-dies"), From patchwork Wed Dec 15 16:48:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 12678757 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7291BC433EF for ; Wed, 15 Dec 2021 16:58:49 +0000 (UTC) Received: from localhost ([::1]:60924 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mxXc8-0003Df-Hx for qemu-devel@archiver.kernel.org; Wed, 15 Dec 2021 11:58:48 -0500 Received: from eggs.gnu.org ([209.51.188.92]:34256) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mxXTE-0004ZB-9d for qemu-devel@nongnu.org; Wed, 15 Dec 2021 11:49:36 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:29486) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mxXTB-0001zs-MS for qemu-devel@nongnu.org; Wed, 15 Dec 2021 11:49:36 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639586970; 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=TZ3gZVz3PQYnFV6233ldFCcy6QtI3ljXwdYY5S65e7Q=; b=LHFGUYHiX0aQU74tuIiNTNx1U6hOvOHv/5Cy9WVhUl6n95TzvkQyp5Du+WW2a0q1EhVcm7 EyaXaCfqfzeX37vF4I+MVVzqndF+ROh5GvpFjGlTejpO+9NvGADMTlTu6iAw7fDMQ16niN lOYyA31rb6HMh2p7X6QK1DTlYSh1eEs= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-335-kO-ZbPsQNNmiUlWftBI0pA-1; Wed, 15 Dec 2021 11:49:29 -0500 X-MC-Unique: kO-ZbPsQNNmiUlWftBI0pA-1 Received: by mail-wm1-f72.google.com with SMTP id ay34-20020a05600c1e2200b00337fd217772so9263246wmb.4 for ; Wed, 15 Dec 2021 08:49:29 -0800 (PST) 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=TZ3gZVz3PQYnFV6233ldFCcy6QtI3ljXwdYY5S65e7Q=; b=J+QkVnqruN2EnrThLOjZEuAy/A9MQ+C57xOkQlwWtiKdtAstxQ9u943UZaKFPTzJjT qavN+sH0lOw6sIMNPxgo6o26FRczVxYBj8YJJp2Fzbf1cb9A6CKBWHl7GRVP2LwwywJI XpPifoVNpx9eHN53LFYTR3NyiT5uqldR+ELR2w4JlXbzAfZTDGXDLEU95txMUa218yrg SnPRFBN4Hu9o5bTaJcizXRDZ562waYK1RCTgGzmTxpdhW//mLdfXXwdhq4qmDjpK9Q2K OFCbLEd/PXbeVOHCODISA0cvuOF15aekQLa51yNVQJcOBObzIIUil3UP5XwTZOQKRq78 i5eg== X-Gm-Message-State: AOAM532OWu6U6ywhLR86LxZj5kgl1Pd0TNulQPDX6tXEbjGT5FtXih5M aJoRL2AVTXnpNnfLL2DK0G3RTE2SSCZLtQhQeKK/6/I28LpQI921ahTROBjFsSpzPAwemKN0M0x J8OgWQ95hFJMOXZ89jB5cTGGUeHdmS8w/pb4Llx53Z6wmX3vu83C91gaxntlHw6IT X-Received: by 2002:adf:8b0e:: with SMTP id n14mr5006025wra.281.1639586968251; Wed, 15 Dec 2021 08:49:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJyLZRNl/QXAWmtQyPA9iurspmt/Cty8dTXKkBrflwruYnS/bfbzLrk4O0fEL1keu3xvvP4sWQ== X-Received: by 2002:adf:8b0e:: with SMTP id n14mr5006013wra.281.1639586968057; Wed, 15 Dec 2021 08:49:28 -0800 (PST) Received: from localhost.localdomain (174.red-83-50-185.dynamicip.rima-tde.net. [83.50.185.174]) by smtp.gmail.com with ESMTPSA id g7sm2096280wrx.104.2021.12.15.08.49.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Dec 2021 08:49:27 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v5 5/8] tests/unit/test-smp-parse: Add 'smp-generic-valid' machine type Date: Wed, 15 Dec 2021 17:48:53 +0100 Message-Id: <20211215164856.381990-6-philmd@redhat.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211215164856.381990-1-philmd@redhat.com> References: <20211215164856.381990-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 Received-SPF: pass client-ip=170.10.129.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.719, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , Richard Henderson , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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-generic-valid". Reviewed-by: Richard Henderson Signed-off-by: Philippe Mathieu-Daudé --- 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 72e7236afd9..5349ae14824 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 = MACHINE_CLASS(oc); + mc->smp_props.prefer_sockets = true; + + mc->name = g_strdup(SMP_MACHINE_NAME); +} + +static void machine_without_dies_valid_class_init(ObjectClass *oc, void *data) +{ + MachineClass *mc = MACHINE_CLASS(oc); + mc->min_cpus = MIN_CPUS; mc->max_cpus = MAX_CPUS; - mc->smp_props.prefer_sockets = true; mc->smp_props.dies_supported = false; - - mc->name = g_strdup(SMP_MACHINE_NAME); } static void machine_without_dies_invalid_class_init(ObjectClass *oc, void *data) @@ -606,9 +612,14 @@ static const TypeInfo smp_machine_types[] = { { .name = TYPE_MACHINE, .parent = TYPE_OBJECT, + .abstract = true, .class_init = machine_base_class_init, .class_size = sizeof(MachineClass), .instance_size = sizeof(MachineState), + }, { + .name = MACHINE_TYPE_NAME("smp-generic-valid"), + .parent = TYPE_MACHINE, + .class_init = machine_without_dies_valid_class_init, }, { .name = MACHINE_TYPE_NAME("smp-generic-invalid"), .parent = TYPE_MACHINE, @@ -629,7 +640,7 @@ int main(int argc, char *argv[]) g_test_init(&argc, &argv, NULL); g_test_add_data_func("/test-smp-parse/generic/valid", - TYPE_MACHINE, + MACHINE_TYPE_NAME("smp-generic-valid"), test_generic_valid); g_test_add_data_func("/test-smp-parse/generic/invalid", MACHINE_TYPE_NAME("smp-generic-invalid"), From patchwork Wed Dec 15 16:48:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 12678753 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8F31CC433F5 for ; Wed, 15 Dec 2021 16:56:10 +0000 (UTC) Received: from localhost ([::1]:51462 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mxXZZ-0005G9-Ir for qemu-devel@archiver.kernel.org; Wed, 15 Dec 2021 11:56:09 -0500 Received: from eggs.gnu.org ([209.51.188.92]:34276) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mxXTH-0004ar-BU for qemu-devel@nongnu.org; Wed, 15 Dec 2021 11:49:39 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:44889) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mxXTE-00020j-FD for qemu-devel@nongnu.org; Wed, 15 Dec 2021 11:49:38 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639586975; 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=D0SkCPb2Wszbwa3QNykXiWoYzTzgco57XfQsArolZfs=; b=J91PyIGIwQy7gG1RvFUcLPXMlgQF67+xhYx4zzANuO/X4WzfsfByITqhmz82eDFvux8KF6 l7xt0ZDRoY215TZ6ijHPGeixXsK0r+nnsDEGgB9tUns7zYXSlFOFSWYu73krq1/FlQxOR3 wk9O6IqjyjDQidYJNFJCk0B568xy8Nc= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-163-Os1MyDdYNJWaeluRUwAAkw-1; Wed, 15 Dec 2021 11:49:34 -0500 X-MC-Unique: Os1MyDdYNJWaeluRUwAAkw-1 Received: by mail-wr1-f72.google.com with SMTP id h12-20020adfa4cc000000b001a22dceda69so777984wrb.16 for ; Wed, 15 Dec 2021 08:49:34 -0800 (PST) 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=D0SkCPb2Wszbwa3QNykXiWoYzTzgco57XfQsArolZfs=; b=OEgGXvcgHeQptHys1EAW6t2Wy6LtmAG6QgCA51B2wr4+LKvOp7jH/F0Sl/kM+fejrp 8m6wL+Szte6LyPaJRNV6mpppIWRbnSLX1wiQDSsrmmb6QrEYUv0KYJPMAH8CGXp+exme WMWc7wXf+3C/NuFVsfFYvQI0h1eLYJlwxaPMoezisFWsSmSXZaCI6g/n65rQ/iGGTS+R FZ+FGzwJXU2nN5zR3R1dQG28GyrztU2/D+c/PRoEhZyRMy6ozUL/XyojNY9aRL2eEFwk 8ZkMRpuu9QKxRaxh+vGOCz0ii5mXIPWT7FATCk7v546b1M8Db3no+xzjRU9WsqBSoJWn UcVg== X-Gm-Message-State: AOAM531CfBybX18RYo91VK5atGdYb7mhn7Hiwsoafwe2H29X0Pu09yCe BylB7z0JvSMukKV73MRLUIQm0bthMqTEMvvWi3utA9TxzhJdNEk9kYGEyOaHShkrU55Bpauc2qi RanICan1jjSrw0TL8ZmwG9vHaB6Bxbfr0ERWewa226uoxMReIRvpZeOukZ4ZYA8Kc X-Received: by 2002:a7b:c2f7:: with SMTP id e23mr743156wmk.92.1639586972635; Wed, 15 Dec 2021 08:49:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJxUh5gt6K62qDoWHEvtRipwUyEYToY0j/sL2PlV2cCMr4cBHVx4QqF22sqe8KUvvvqZF0MTjw== X-Received: by 2002:a7b:c2f7:: with SMTP id e23mr743129wmk.92.1639586972422; Wed, 15 Dec 2021 08:49:32 -0800 (PST) Received: from localhost.localdomain (174.red-83-50-185.dynamicip.rima-tde.net. [83.50.185.174]) by smtp.gmail.com with ESMTPSA id o64sm2480926wme.28.2021.12.15.08.49.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Dec 2021 08:49:32 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v5 6/8] tests/unit/test-smp-parse: Simplify pointer to compound literal use Date: Wed, 15 Dec 2021 17:48:54 +0100 Message-Id: <20211215164856.381990-7-philmd@redhat.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211215164856.381990-1-philmd@redhat.com> References: <20211215164856.381990-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 Received-SPF: pass client-ip=170.10.129.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.719, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , Andrew Jones , Richard Henderson , Yanan Wang , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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é --- 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 5349ae14824..251c83c60c2 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 = object_new(machine_type); MachineState *ms = MACHINE(obj); MachineClass *mc = MACHINE_GET_CLASS(obj); - SMPTestData *data = &(SMPTestData){{ }}; + SMPTestData data = {}; int i; for (i = 0; i < ARRAY_SIZE(data_generic_valid); i++) { - *data = data_generic_valid[i]; - unsupported_params_init(mc, data); + data = data_generic_valid[i]; + unsupported_params_init(mc, &data); - smp_parse_test(ms, data, true); + smp_parse_test(ms, &data, true); /* Unsupported parameters can be provided with their values as 1 */ - data->config.has_dies = true; - data->config.dies = 1; - smp_parse_test(ms, data, true); + data.config.has_dies = true; + data.config.dies = 1; + smp_parse_test(ms, &data, true); } object_unref(obj); @@ -544,14 +544,14 @@ static void test_generic_invalid(const void *opaque) Object *obj = object_new(machine_type); MachineState *ms = MACHINE(obj); MachineClass *mc = MACHINE_GET_CLASS(obj); - SMPTestData *data = &(SMPTestData){}; + SMPTestData data = {}; int i; for (i = 0; i < ARRAY_SIZE(data_generic_invalid); i++) { - *data = data_generic_invalid[i]; - unsupported_params_init(mc, data); + data = data_generic_invalid[i]; + unsupported_params_init(mc, &data); - smp_parse_test(ms, data, false); + smp_parse_test(ms, &data, false); } object_unref(obj); @@ -563,45 +563,45 @@ static void test_with_dies(const void *opaque) Object *obj = object_new(machine_type); MachineState *ms = MACHINE(obj); MachineClass *mc = MACHINE_GET_CLASS(obj); - SMPTestData *data = &(SMPTestData){{ }}; + SMPTestData data = {}; unsigned int num_dies = 2; int i; for (i = 0; i < ARRAY_SIZE(data_generic_valid); i++) { - *data = data_generic_valid[i]; - unsupported_params_init(mc, data); + data = data_generic_valid[i]; + unsupported_params_init(mc, &data); /* when dies parameter is omitted, it will be set as 1 */ - data->expect_prefer_sockets.dies = 1; - data->expect_prefer_cores.dies = 1; + data.expect_prefer_sockets.dies = 1; + data.expect_prefer_cores.dies = 1; - smp_parse_test(ms, data, true); + smp_parse_test(ms, &data, true); /* when dies parameter is specified */ - data->config.has_dies = true; - data->config.dies = num_dies; - if (data->config.has_cpus) { - data->config.cpus *= num_dies; + data.config.has_dies = true; + data.config.dies = num_dies; + if (data.config.has_cpus) { + data.config.cpus *= num_dies; } - if (data->config.has_maxcpus) { - data->config.maxcpus *= num_dies; + if (data.config.has_maxcpus) { + data.config.maxcpus *= num_dies; } - data->expect_prefer_sockets.dies = num_dies; - data->expect_prefer_sockets.cpus *= num_dies; - data->expect_prefer_sockets.max_cpus *= num_dies; - data->expect_prefer_cores.dies = num_dies; - data->expect_prefer_cores.cpus *= num_dies; - data->expect_prefer_cores.max_cpus *= num_dies; + data.expect_prefer_sockets.dies = num_dies; + data.expect_prefer_sockets.cpus *= num_dies; + data.expect_prefer_sockets.max_cpus *= num_dies; + data.expect_prefer_cores.dies = num_dies; + data.expect_prefer_cores.cpus *= num_dies; + data.expect_prefer_cores.max_cpus *= num_dies; - smp_parse_test(ms, data, true); + smp_parse_test(ms, &data, true); } for (i = 0; i < ARRAY_SIZE(data_with_dies_invalid); i++) { - *data = data_with_dies_invalid[i]; - unsupported_params_init(mc, data); + data = data_with_dies_invalid[i]; + unsupported_params_init(mc, &data); - smp_parse_test(ms, data, false); + smp_parse_test(ms, &data, false); } object_unref(obj); From patchwork Wed Dec 15 16:48:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 12678777 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E349BC433EF for ; Wed, 15 Dec 2021 17:08:56 +0000 (UTC) Received: from localhost ([::1]:54488 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mxXlw-0002Nl-3I for qemu-devel@archiver.kernel.org; Wed, 15 Dec 2021 12:08:56 -0500 Received: from eggs.gnu.org ([209.51.188.92]:34324) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mxXTM-0004dl-PI for qemu-devel@nongnu.org; Wed, 15 Dec 2021 11:49:45 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:27052) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mxXTI-00021C-7J for qemu-devel@nongnu.org; Wed, 15 Dec 2021 11:49:44 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639586979; 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=qKTQTHa1hb0SLmS1AjA4KYFgifkhSYsgZCXWCGHH/MU=; b=BYXnI6KoYoOg/SuXkNJl2Dld4LPWZFwH+CYmiJMsO3Z5mchX6dopSURrKzzsSLC9PwHKh+ y2k69l+osLH6CTX2R3sVYJNL7+9KMgKTkPsQhI0F5XINoDK4+a44wSnaGlGLfqjyhj8hzr 2wABXV528DFgspvQdTh3AlXmaK+0GhI= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-453-Dwif_zsGP1umk-sRSHugbA-1; Wed, 15 Dec 2021 11:49:38 -0500 X-MC-Unique: Dwif_zsGP1umk-sRSHugbA-1 Received: by mail-wr1-f69.google.com with SMTP id k8-20020a5d5248000000b001763e7c9ce5so6096412wrc.22 for ; Wed, 15 Dec 2021 08:49:38 -0800 (PST) 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=qKTQTHa1hb0SLmS1AjA4KYFgifkhSYsgZCXWCGHH/MU=; b=sVB93JCCLVR4VhN0VJOfqmzutRbJ5zIlsJs0Nr1OM8gcxQ51YxnofMc28rCPSUC3zR xLLNutAq5aDTcGjq9DV1GBvvOrAK4nWRFKhL2JKDDgcqdbw9Mqv+gWeEpY9x6xG+5v/e KYc/yLJU+TxlbyOXKR0pK+fAdYNBQ77M9ESLXMWGR60Wu72zaz+IFmxiSBADUWXCFdAI vUOEzVRFel1AVanP1u2ij3lEoBfeed//Wd8gbLVIlxNSB2tBE20cUT0XBvSjUdHePf50 bYphJKgkQ0PfBvge2+3hQif9TkLnjcHsRMoC4cOZ0SxMHwuVbyo5vqU0lH6TegsXbDQs pxGg== X-Gm-Message-State: AOAM53375EFLQxKrHoaZP7Lqu6Knn5t5a71qOXLopGc+SNqz4R5sMMZP EjWN5yhEit0zxzlEcilknZIpCvZ+o+UIaCJCZCvuPpZbTCTecCMc3WdV5NBQ7kTEkBOZFzI/jiz +kJaTGnNV4U53YC4POrwCa/zdevFHfyRsjKFa35wp0/W0TTae8R3TYAJDlR85pswQ X-Received: by 2002:a5d:4e92:: with SMTP id e18mr5327182wru.89.1639586977113; Wed, 15 Dec 2021 08:49:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJzJo3BmYeKI5A5faSWgVV4zxE03y+Be0PSzuG2dBR73uIYvIM1HLURPQluw+jS1AbmQIlFYzQ== X-Received: by 2002:a5d:4e92:: with SMTP id e18mr5327158wru.89.1639586976864; Wed, 15 Dec 2021 08:49:36 -0800 (PST) Received: from localhost.localdomain (174.red-83-50-185.dynamicip.rima-tde.net. [83.50.185.174]) by smtp.gmail.com with ESMTPSA id z15sm2333023wrr.65.2021.12.15.08.49.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Dec 2021 08:49:36 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v5 7/8] tests/unit/test-smp-parse: Constify some pointer/struct Date: Wed, 15 Dec 2021 17:48:55 +0100 Message-Id: <20211215164856.381990-8-philmd@redhat.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211215164856.381990-1-philmd@redhat.com> References: <20211215164856.381990-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 Received-SPF: pass client-ip=170.10.129.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.719, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , Andrew Jones , Richard Henderson , Yanan Wang , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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é --- 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 251c83c60c2..1f26edc5f82 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[] = { +static const struct SMPTestData data_generic_valid[] = { { /* config: no configuration provided * expect: cpus=1,sockets=1,cores=1,threads=1,maxcpus=1 */ @@ -285,7 +285,7 @@ static struct SMPTestData data_generic_valid[] = { }, }; -static struct SMPTestData data_generic_invalid[] = { +static const struct SMPTestData data_generic_invalid[] = { { /* config: -smp 2,dies=2 */ .config = 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[] = { }, }; -static struct SMPTestData data_with_dies_invalid[] = { +static const struct SMPTestData data_with_dies_invalid[] = { { /* config: -smp 16,sockets=2,dies=2,cores=4,threads=2,maxcpus=16 */ .config = 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 *config) config->has_maxcpus ? "true" : "false", config->maxcpus); } -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) } 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 = smp_config_to_string(config); @@ -466,7 +466,7 @@ static void smp_parse_test(MachineState *ms, SMPTestData *data, bool is_valid) } /* 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 *data) { if (!mc->smp_props.dies_supported) { data->expect_prefer_sockets.dies = 1; From patchwork Wed Dec 15 16:48:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 12678785 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 59A86C4332F for ; Wed, 15 Dec 2021 17:11:25 +0000 (UTC) Received: from localhost ([::1]:35240 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mxXoK-0008Ta-3i for qemu-devel@archiver.kernel.org; Wed, 15 Dec 2021 12:11:24 -0500 Received: from eggs.gnu.org ([209.51.188.92]:34354) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mxXTO-0004f8-Jx for qemu-devel@nongnu.org; Wed, 15 Dec 2021 11:49:46 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:43183) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mxXTM-00021i-Hl for qemu-devel@nongnu.org; Wed, 15 Dec 2021 11:49:46 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639586984; 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=BmkMZOil0JU/xcw7wrU9Zc8Yh5vuQbVB83QLL1RhrjI=; b=SOtPnPmRvs4JVJrgkZAnotADK8idA307F/quyMNF5BvBg2sW91ioL4/z4TBzcfq42usOPM YhYqGR6xQik7x2o0tvzGID1eK+AeNxP5afkHn1JanOIh9S20jKEQ/Dafa3Wf0yz6zxNGEB QaQ3hgCDQDVAwqpkNt52MJgHQpe/Iq8= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-475-SV9IztkVPd6RO8KCZHTGTQ-1; Wed, 15 Dec 2021 11:49:43 -0500 X-MC-Unique: SV9IztkVPd6RO8KCZHTGTQ-1 Received: by mail-wm1-f70.google.com with SMTP id n31-20020a05600c3b9f00b0034440f99123so2290248wms.7 for ; Wed, 15 Dec 2021 08:49:42 -0800 (PST) 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=BmkMZOil0JU/xcw7wrU9Zc8Yh5vuQbVB83QLL1RhrjI=; b=MTjI+W1aDcDylvU6OE2PFcJK57A1SojQB9yOhpUFgz7DQwvzin0ATDPZm15IJL7tSy 6ReXszt2mIZHkd3u2JsAB/jkxo9AMmuAbxaKRSH1Vg+YFZ4uNyNXZMMN2RqwqghCkTuA QmR/rc38GiunE8ATUdZ2UCt9aWdg5gO/0ESRl6GY78yUa6LvbOF4ZWuy54eqIZs5+Hgo XXN+KNnW4j9cOAGDUW+qOHbgM5IMa2zvMemzgswp1K6NqN3wzlwIJcM8CVkqsmAehPkl tUkASIsYNOFD8VsZgwv107EJNWHS77lBH0oAkTVCwgGiSJfBCrJI8D3OkGnOfXmvznhY f3Rw== X-Gm-Message-State: AOAM530p5IkLaMdSQiFgbzMhBpLdE/MOZo17bWSeA2Hev5uh5fO9Af2J ngp0uh33ApnS4CfQZ3BlPBwlDlOPi++W6efsYp0nZZBMugYDkHPuth9+tjE9A0fRWiX7jjKqMmd ao+veQtYvVvJTWAC0uqhQ4vkMIMd3NnOeCx9W/bNWtUbYIfeWsd+h4czqd6gKb267 X-Received: by 2002:a1c:9dd4:: with SMTP id g203mr756594wme.114.1639586981631; Wed, 15 Dec 2021 08:49:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJxlZgpxaYpwpnsenpIfwM7p0/811ln/m4JkvZxNNTIz/Wk3OCTK6xU55UsUS3mTrunITmJACQ== X-Received: by 2002:a1c:9dd4:: with SMTP id g203mr756569wme.114.1639586981270; Wed, 15 Dec 2021 08:49:41 -0800 (PST) Received: from localhost.localdomain (174.red-83-50-185.dynamicip.rima-tde.net. [83.50.185.174]) by smtp.gmail.com with ESMTPSA id w17sm2605539wmc.14.2021.12.15.08.49.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Dec 2021 08:49:40 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v5 8/8] hw/core: Rename smp_parse() -> machine_parse_smp_config() Date: Wed, 15 Dec 2021 17:48:56 +0100 Message-Id: <20211215164856.381990-9-philmd@redhat.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211215164856.381990-1-philmd@redhat.com> References: <20211215164856.381990-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 Received-SPF: pass client-ip=170.10.129.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.719, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , Andrew Jones , Richard Henderson , Yanan Wang , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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é --- 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(MachineState *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); /** * machine_class_allow_dynamic_sysbus_dev: Add type to list of valid devices 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) } /* - * 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 should * 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 = MACHINE_GET_CLASS(ms); unsigned cpus = config->has_cpus ? config->cpus : 0; diff --git a/hw/core/machine.c b/hw/core/machine.c index 53a99abc560..3993c534b90 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -761,7 +761,7 @@ static void machine_set_smp(Object *obj, Visitor *v, const char *name, return; } - smp_parse(ms, config, errp); + machine_parse_smp_config(ms, config, errp); } 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 1f26edc5f82..7f5c4ad222f 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[] = { }, }; -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); } -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, SMPConfiguration *config, g_autofree char *output_topo_str = NULL; Error *err = NULL; - /* call the generic parser smp_parse() */ - smp_parse(ms, config, &err); + /* call the generic parser */ + machine_parse_smp_config(ms, config, &err); output_topo_str = cpu_topology_to_string(&ms->smp);