From patchwork Thu Dec 16 13:20:08 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: 1569213 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=gmOmqOvS; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4JFDl25LhGz9s5P for ; Fri, 17 Dec 2021 01:19:26 +1100 (AEDT) Received: from localhost ([::1]:49806 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mxqt6-0000Vb-Uo for incoming@patchwork.ozlabs.org; Thu, 16 Dec 2021 08:33:36 -0500 Received: from eggs.gnu.org ([209.51.188.92]:37028) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mxqgV-0006gf-Be for qemu-devel@nongnu.org; Thu, 16 Dec 2021 08:20:35 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:44495) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mxqgS-0008Eu-SB for qemu-devel@nongnu.org; Thu, 16 Dec 2021 08:20:34 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639660832; 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=gmOmqOvSyZSblzZDQz6Eb+0mK68ysT95jvjG7pRTNJ/0SlMG68lwULM31dAeeZWsPN8d8D IJTiI4IncUvLbsP0S8+fVwUbFDdJK2JYQ+Yqu43nx8IBOJcB468058/MMMvKgFSBZHDbLq 4NwCTYYxSBNbn+r2GsqQu/wGmM1iheQ= 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-605-DTm0DKXRMn2kh8ukrt-9GQ-1; Thu, 16 Dec 2021 08:20:31 -0500 X-MC-Unique: DTm0DKXRMn2kh8ukrt-9GQ-1 Received: by mail-wm1-f70.google.com with SMTP id l34-20020a05600c1d2200b00344d34754e4so1255273wms.7 for ; Thu, 16 Dec 2021 05:20:31 -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=fdLHo6X9k5oo1uMoXaNJN/jf8hIAJhrsh3gqFE8PeX5nxNK0rF71MIQPFQ+YLe2j0t l8b/EjAN3wETy/UltNesbH2rvc/W/dQljw3GMSfin2sgSOCIZO/+nB1dcq8W3E7FqyI5 JFY2nngHtkxDxkGFuLfsyJEvMoURL9GcFKdsoxNZdQ4jsdSr8Mt5GkcH9GgVREmMWReH dSFrd7epiKRMg6nST9/9fYzRb1fu6GDXmwg0K1SIuQB8ZcWHEmuTIXgQ0CumA5S/Md99 fWTKdllug4c6u2ZyDArdBJ53H6YU/uoA7E/20Y6EEfPl7BZfFMwlakAOTvl6gqC1kL90 nMnw== X-Gm-Message-State: AOAM531g2jioZdhdIeQKm6NOH0zgvM8nLkZG98wDrk7js3FChGROZN/H cw9H/Tru4KfYx+UBxBfTQycMbqzVAVliQITFHeEAQGoZo04UzoM7HycXTiNZXXmEbA6LPL8mt5z skWJRDV23swDRJs0iqD4N8wDE67NQyHHZFdB+qhA+/cDi37IqGRd2Gdk90wdHp8lO X-Received: by 2002:a5d:4486:: with SMTP id j6mr1263871wrq.160.1639660829932; Thu, 16 Dec 2021 05:20:29 -0800 (PST) X-Google-Smtp-Source: ABdhPJwQ8DG5F2/GyHtKr4ceY/cv2HsvzJMgdXn0wjTMzUVOvZl4mD4Z+fq+HLBWqw1JPcGEtabUNg== X-Received: by 2002:a5d:4486:: with SMTP id j6mr1263857wrq.160.1639660829743; Thu, 16 Dec 2021 05:20:29 -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 d13sm622953wru.41.2021.12.16.05.20.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Dec 2021 05:20:29 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v6 1/8] tests/unit/test-smp-parse: Pass machine type as argument to tests Date: Thu, 16 Dec 2021 14:20:08 +0100 Message-Id: <20211216132015.815493-2-philmd@redhat.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211216132015.815493-1-philmd@redhat.com> References: <20211216132015.815493-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.718, 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+incoming=patchwork.ozlabs.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 Thu Dec 16 13:20:09 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: 1569183 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=dt7P8Qgx; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4JFCVC2slwz9s5P for ; Fri, 17 Dec 2021 00:23:13 +1100 (AEDT) Received: from localhost ([::1]:35128 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mxqiz-0006lg-Eh for incoming@patchwork.ozlabs.org; Thu, 16 Dec 2021 08:23:09 -0500 Received: from eggs.gnu.org ([209.51.188.92]:37084) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mxqgj-0006kH-Km for qemu-devel@nongnu.org; Thu, 16 Dec 2021 08:20:49 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:40725) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mxqgi-0008H8-5E for qemu-devel@nongnu.org; Thu, 16 Dec 2021 08:20:49 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639660836; 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=dt7P8QgxZGdQgPZCwqvjTcUp41vxBh+lTps0r1tLOUxr7i41TrWDv544FHo0nO2gq0/xQp OX1ah0QSApB0DuFxMWc9JpobBct20lxkdyVKIT/C1JaCuk1IqZ1YtP/FuHBlcgjCCYJRem rriuffGlUWVgfc3n2SnNRxJtpARXmNc= 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-416-LUlLDJtkPeag5jDX-2XWtw-1; Thu, 16 Dec 2021 08:20:35 -0500 X-MC-Unique: LUlLDJtkPeag5jDX-2XWtw-1 Received: by mail-wm1-f69.google.com with SMTP id i15-20020a05600c354f00b0034566ac865bso2054940wmq.6 for ; Thu, 16 Dec 2021 05:20:35 -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=e/7x6mO9GcN8OkoqwsU3zZcGyBRvtoJMy48ksRPWpeBlG+C0Thr23M04DlyQhAhGtI s1cQxL3TaS/cF1L9PwmEnDqImwffpp5GIJ4Th83vLpaju0SG1ofzAPhwBE3/pYz1Va1P 5Xn0vjLJu5lHcBrAc+aNAlt9n76wjCPdAwSIjkTeDLS1MF/mUIpi1DzLWqwBiqCod719 DBRRMamcl1MrPIsvwNWiadxSS3VAw+KxBxfndxjCIZIeFk/ExrOzPsaNWbWb4LPDbEBZ 7NRd3fcdDFLJges9txfrYgP8RpInjD+rq2VkBk0qDBBXCIOlIH0nDwf3oQgFmJ5Y18e9 ATmw== X-Gm-Message-State: AOAM530mbaNY62KkCxWCXsEgXqZI2RAgO0/q3If4zZ9l8I8wE2hi4uZk kcBcFKmWK/u7TGe7vbD9uWIlqMHrVtuP/WwL4yePeqt4JI6beZW38N0jLsHrmQY8iEeixN1BUMb UDJWLojXfap2UZyyfzL/CHiLKqpc9uf3E2gZ0eat5pz1HuKFwIDecOa1EjkrU9/Ae X-Received: by 2002:adf:f40b:: with SMTP id g11mr2246648wro.645.1639660834244; Thu, 16 Dec 2021 05:20:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJw0ivJJuE7YYVPPtmTmDxTvvNMxH4jY1xs7qs0KFisPeXoVwTJUJVCYOIyMABEJ5KhM1mUpvg== X-Received: by 2002:adf:f40b:: with SMTP id g11mr2246626wro.645.1639660834009; Thu, 16 Dec 2021 05:20:34 -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 b13sm4913829wrh.32.2021.12.16.05.20.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Dec 2021 05:20:33 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v6 2/8] tests/unit/test-smp-parse: Split the 'generic' test in valid / invalid Date: Thu, 16 Dec 2021 14:20:09 +0100 Message-Id: <20211216132015.815493-3-philmd@redhat.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211216132015.815493-1-philmd@redhat.com> References: <20211216132015.815493-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.718, 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+incoming=patchwork.ozlabs.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 Thu Dec 16 13:20:10 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: 1569210 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=UKeLArtn; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4JFDcr06f4z9s5P for ; Fri, 17 Dec 2021 01:14:04 +1100 (AEDT) Received: from localhost ([::1]:36234 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mxr0f-0002Iy-7A for incoming@patchwork.ozlabs.org; Thu, 16 Dec 2021 08:41:25 -0500 Received: from eggs.gnu.org ([209.51.188.92]:37112) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mxqgk-0006kw-RF for qemu-devel@nongnu.org; Thu, 16 Dec 2021 08:20:51 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:51238) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mxqgi-0008KT-8B for qemu-devel@nongnu.org; Thu, 16 Dec 2021 08:20:50 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639660840; 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=UKeLArtn1mF4w2MoUm378xRwmxnSMd/SuSSe66zY/2yCyDizXpks/xeLCZvFQQC8YLAnm7 /Rw3I8iFGoESb/qncik8hxgtxTi9Y1ENAzja0CFd814To3GP0bpv9hEbQD3pRH2GuKalmd 0YJORsljHTNI7tNRkU3nkq20FkOZMQY= 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-516-SMOq3L9vO1eVUALNuFvAYA-1; Thu, 16 Dec 2021 08:20:40 -0500 X-MC-Unique: SMOq3L9vO1eVUALNuFvAYA-1 Received: by mail-wm1-f70.google.com with SMTP id ay17-20020a05600c1e1100b0033f27b76819so13809199wmb.4 for ; Thu, 16 Dec 2021 05:20:39 -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=K1QDxW945YZgWKBIj/JcpKP8tt2IJ4YKHELj5t/mu1XvRGYQlni9bI/ICuO5wRvH/p vYzL4a0nBWnb3tNjOQ2oFhyccDKSJQvjNEpL1C/3Ex9mPMOL5L2cl++HfSSIGsKiIv9W 9RnGMWVdy56IVc60oT9Et05e4rlluoChUNUQNWaH5iiN4ZsOl82FAdVOKD1Rn/A2IkIR CDwL21EjP212ndE8LYaLJbdlTNdWlN0fS+NQA5ZfBkusqZ3qdNb+n9rLgRkUh1wwS8b1 AOUXt/aElDxscA156mVZVfb/hLxyQ/EMHEHIjro0WiDzaitU/PI+/gcNjqudDDgyscDb FYcQ== X-Gm-Message-State: AOAM532GqlQCH15yMPLcY70QP3Bz9CllfyNDZ/+7D7O+E3XYXzAmQX+R wGHQ5os36iSIJfWYNWptwnYlnYArruh06jTcuTkcZfqQz1q9/2VQsr3WKjnhUH8U1zANwopeGV5 pTH9Fv1UyWuoztX9nDKJpc8M6c1bmereAIlhfCb+JK3rTpAWbVV3m1N6Euxl3+7os X-Received: by 2002:a05:6000:104c:: with SMTP id c12mr8638553wrx.588.1639660838581; Thu, 16 Dec 2021 05:20:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJz9FyDLN2KLSJxbfwjviG1yY8ZaRuGTvyxYv7cYvz73wWlktpKvitGPeP6AifT0+LQF5uwrZQ== X-Received: by 2002:a05:6000:104c:: with SMTP id c12mr8638525wrx.588.1639660838335; Thu, 16 Dec 2021 05:20:38 -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 t11sm4597752wrz.97.2021.12.16.05.20.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Dec 2021 05:20:37 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v6 3/8] tests/unit/test-smp-parse: Add 'smp-with-dies' machine type Date: Thu, 16 Dec 2021 14:20:10 +0100 Message-Id: <20211216132015.815493-4-philmd@redhat.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211216132015.815493-1-philmd@redhat.com> References: <20211216132015.815493-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.718, 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+incoming=patchwork.ozlabs.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 Thu Dec 16 13:20:11 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: 1569229 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=SL2Edyvh; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4JFGWv06qkz9s1l for ; Fri, 17 Dec 2021 02:39:55 +1100 (AEDT) Received: from localhost ([::1]:57568 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mxqxy-0005w9-QU for incoming@patchwork.ozlabs.org; Thu, 16 Dec 2021 08:38:38 -0500 Received: from eggs.gnu.org ([209.51.188.92]:37086) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mxqgj-0006kI-N1 for qemu-devel@nongnu.org; Thu, 16 Dec 2021 08:20:49 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:21220) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mxqgi-0008MP-7n for qemu-devel@nongnu.org; Thu, 16 Dec 2021 08:20:49 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639660845; 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=Jq9mjYYb0qGdPqgYaDEj1wSgWHxTePfmSvB1yYAydck=; b=SL2EdyvhbwMcdBWrmK1gtkypcMOKOX9pJqV6BTryHD+HhKX9dscs7QcITW4w1suHbS5B4W 9Bbogv0Hbp6FKCumwLM0qv2owiN+e9QNV0aM5jb0pouHPAPBElJChO+ZaCinH4NQuSUKGf WN5EfygwrigmIZFVNJnBMlh3gKEfbOU= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-546-S78x5mFMMBCT6CjqBtBu2w-1; Thu, 16 Dec 2021 08:20:44 -0500 X-MC-Unique: S78x5mFMMBCT6CjqBtBu2w-1 Received: by mail-wr1-f70.google.com with SMTP id s23-20020adf9797000000b001a24674f0f7so478721wrb.9 for ; Thu, 16 Dec 2021 05:20:44 -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=Jq9mjYYb0qGdPqgYaDEj1wSgWHxTePfmSvB1yYAydck=; b=6gJv+MKdBfsQJL5jHWMcCh0eQ41rYhD/rn+4g8r5+o5VU+YAevUThkaOCZ4lbClplv FqQjWqmktZNbSNxkHu7Zaw/n/5W0qhtSffSvEkBO/GeU/LcAARWXKJPCsLkWxM4FSCea Y9wUZE8S+slXyIi2FhIkNAF3vCyIfsrzQMk7qDmrAroOMPUsM2c86+409+a4863qezsL jOR4ycQ2726vUCEpcNhJFNxt+Ajal70ds9f0NIRe5axYvwWJ+CgkIOKc3n31Dxa9oZBG TPA5HTqQuHXS5r47VdIlsqZquXq3rIQaTI3eRFcRgaxA2nTQHIrcfpI+FcARBu1g7drJ PG2Q== X-Gm-Message-State: AOAM531tFnZixKfrJ6bP9bl+ZaPMQIQXTTI2En4CWS7/eU7wRdYZWU80 ktbblilIPwjiev6qloOrAVQODqtHdV9LrG4F4O1suP8Yw8urCsExmJSbon7iaO0zRydJvjU+27n W2jig/3w8eRp1KbizRbENATGsjttA73Z5WiUMUnd2tLQ9aQu55I7Otop1nAXAXZ1k X-Received: by 2002:a5d:50c7:: with SMTP id f7mr8721530wrt.327.1639660842883; Thu, 16 Dec 2021 05:20:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJxC9x+fuE0iUTpPPeFN3hAmrvHgs+mtnao9AhdPvImgRKlxsxQmddMWnfRev9Gzspys9TuanA== X-Received: by 2002:a5d:50c7:: with SMTP id f7mr8721510wrt.327.1639660842620; Thu, 16 Dec 2021 05:20:42 -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 j18sm10293444wmq.44.2021.12.16.05.20.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Dec 2021 05:20:42 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v6 4/8] tests/unit/test-smp-parse: Add 'smp-generic-invalid' machine type Date: Thu, 16 Dec 2021 14:20:11 +0100 Message-Id: <20211216132015.815493-5-philmd@redhat.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211216132015.815493-1-philmd@redhat.com> References: <20211216132015.815493-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.718, 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 , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.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..47e11089e22 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_generic_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_generic_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 Thu Dec 16 13:20:12 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: 1569182 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=OV8BX+MG; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4JFCVC1ch3z9s3q for ; Fri, 17 Dec 2021 00:23:13 +1100 (AEDT) Received: from localhost ([::1]:35214 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mxqj0-0006rr-Pp for incoming@patchwork.ozlabs.org; Thu, 16 Dec 2021 08:23:10 -0500 Received: from eggs.gnu.org ([209.51.188.92]:37126) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mxqgl-0006kx-Mz for qemu-devel@nongnu.org; Thu, 16 Dec 2021 08:20:51 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:25670) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mxqgk-0008Mx-AW for qemu-devel@nongnu.org; Thu, 16 Dec 2021 08:20:51 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639660849; 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=HqXPiCt79z3PGUD6iKjmKupwIGk6gXPKMLdUw9UGyco=; b=OV8BX+MG6muGqbBNUaGIrtii6URCrsNFVfdHRbY8T4IOn4GBfK3ZVs1ROMtNbjXHJtjPnW stvqnpIcCIKYhvxLhFDYffBBktw0uZ9xVwWFi8vvO4H+FLm4hCpIC0akKuoBrgeAlgZA3e e3QSU5QfQwKHBTKBRXIQ/sHL/ZEssr8= 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-626-9a_N-uKkN0aLJz0BZ5S37A-1; Thu, 16 Dec 2021 08:20:48 -0500 X-MC-Unique: 9a_N-uKkN0aLJz0BZ5S37A-1 Received: by mail-wm1-f69.google.com with SMTP id m14-20020a05600c3b0e00b0033308dcc933so10277909wms.7 for ; Thu, 16 Dec 2021 05:20:48 -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=HqXPiCt79z3PGUD6iKjmKupwIGk6gXPKMLdUw9UGyco=; b=dKTKIeDlxiZ0Q0BksyDfgbtXVsL/Xo1PN18MaDYtpR0lOVLQxuT5oRgPwCHz0vOcr9 H3LxpeLH1+xLsaDFaOba2VR2DZIPUHppcgyFMxAsB+1nMqH2X24/TaCRY6lhLtiMkn9s i1jsfuIAu2d6kGQjsXFkKAPzpUKqzFwpI8admfV+OHwhCmwN1jsMf4pj9lLgAW5mtmGI ug5O8cyOZbLnwthAJyZziS79XLWBa6gMCSobg9shzMzcV6LpOQnwMlskciw8wfXBS1Si ERnA1Ievnadkcy5VhJNn3ZhxZKnOvZ9MC7Wrw5HCW9RteMuqzN3TOzKihVKKqkFJVplV I9Ng== X-Gm-Message-State: AOAM532qP8v0ihVCxTUpyX5Akpjh2n+izkMAxdRgJCP4OCgNVR5fnoNE 7eIwwPWxHfbpzHTYARHoE5d0skVThyYNrSRVjnRG/LeibV2KiJpGMlKnSDyvwsQ6baOawqUbekZ qTk/FEzmuScINLVLvETfoLyA2BWSrDP/X9WyOq+mtqphAakRA1I1S5H3SoNvyud/D X-Received: by 2002:a1c:e915:: with SMTP id q21mr5156156wmc.94.1639660847241; Thu, 16 Dec 2021 05:20:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJzTfBEZYFWlOjEVkuNxIRychZ9SzNiZ9yOpxrRedeLrrvVnM2qwi8cxU9rFC8MNaw+Ay9QUcg== X-Received: by 2002:a1c:e915:: with SMTP id q21mr5156131wmc.94.1639660846988; Thu, 16 Dec 2021 05:20:46 -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 f18sm4663357wre.7.2021.12.16.05.20.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Dec 2021 05:20:46 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v6 5/8] tests/unit/test-smp-parse: Add 'smp-generic-valid' machine type Date: Thu, 16 Dec 2021 14:20:12 +0100 Message-Id: <20211216132015.815493-6-philmd@redhat.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211216132015.815493-1-philmd@redhat.com> References: <20211216132015.815493-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.718, 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 , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.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 47e11089e22..b20bf2c2359 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_generic_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_generic_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_generic_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 Thu Dec 16 13:20:13 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: 1569185 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=HJF0bG3p; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4JFCbK3nL1z9s3q for ; Fri, 17 Dec 2021 00:27:41 +1100 (AEDT) Received: from localhost ([::1]:42300 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mxqnL-0003MS-Az for incoming@patchwork.ozlabs.org; Thu, 16 Dec 2021 08:27:39 -0500 Received: from eggs.gnu.org ([209.51.188.92]:37228) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mxqgv-0006rj-38 for qemu-devel@nongnu.org; Thu, 16 Dec 2021 08:21:02 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:49326) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mxqgp-0008Nv-CG for qemu-devel@nongnu.org; Thu, 16 Dec 2021 08:20:56 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639660854; 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=Gas95xydnkNBfxR9mpd2N4KEjaivWAJSZ81O3dj9XTI=; b=HJF0bG3pd2cGMC8/pL2P20K0oeYVtAfaoK4ZGxO2txC1srlc9cG+Bte1E8QPTU4hSprWpd eBEzwvuFI5+b435PYbGp26oKJ9uxb95PoEup1/6Rj7DG/IiXCof9g+aEWRe4jItkjjQVDJ V71zS8iI7DnlS+uN4aUihLcM8sFVZgw= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-422-VezprTsuNpSiBEk39gTJmw-1; Thu, 16 Dec 2021 08:20:53 -0500 X-MC-Unique: VezprTsuNpSiBEk39gTJmw-1 Received: by mail-wr1-f71.google.com with SMTP id f13-20020adfe90d000000b001a15c110077so2144634wrm.8 for ; Thu, 16 Dec 2021 05:20:53 -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=Gas95xydnkNBfxR9mpd2N4KEjaivWAJSZ81O3dj9XTI=; b=wwvSZnpCyaBYNwoP/R1q2SMUSHjJMeDyM8qJjNAksHvV9+h4Dy5pqt5N5vO7eSmVGc BMM0Uh0iWd2u+94t291kAzg83MwlxTS9In2OqprqAASP7dWPYe6kOa1WYA+RrWUMVwjt NvKLAzhdJvwP2O3dge81FSmQjFHF0OL7K/3vxwo8BAOXPBSgRrvbWXoKnunkYQUJV5K5 3qIYy0jL0pxwQeSizPMphBU1hNn32CKwBlEnAdvsmOZ/Nj6SJzIpUDnwFzGpSsRnkhr/ rh4t9FAtKCPiz6z0bIOXYPbYGHYMATdu1csz8o9uJh8BRV8OZQCp/vOUJfLzeQkBAvFj JAoQ== X-Gm-Message-State: AOAM531pqlIAanhjEftSOo3249YmUKpILI/RZ6LqGl+honxk56SDla9s B6o8awfvdCxHkT9GqtILxOZveK2dJk0MJSi0mtLpmbOiBiU48phJD2JiFEfomF1ureDpAmOqsoO JLERpaiKWJQR4ym0W7/lJsDpAyMeSQp1rQxF7SGUR4wZugH9903cdZkAIH0rbzE3d X-Received: by 2002:a05:600c:4ec7:: with SMTP id g7mr4971857wmq.138.1639660851587; Thu, 16 Dec 2021 05:20:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJwdHxlLrzvqG2sxs1BgKH2jaCOPoHWBWJTUcJhPLqj6Cy/ONngWBm8MpXjceFkdkLk5iLgH9Q== X-Received: by 2002:a05:600c:4ec7:: with SMTP id g7mr4971833wmq.138.1639660851318; Thu, 16 Dec 2021 05:20:51 -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 e11sm6018238wrq.28.2021.12.16.05.20.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Dec 2021 05:20:50 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v6 6/8] tests/unit/test-smp-parse: Simplify pointer to compound literal use Date: Thu, 16 Dec 2021 14:20:13 +0100 Message-Id: <20211216132015.815493-7-philmd@redhat.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211216132015.815493-1-philmd@redhat.com> References: <20211216132015.815493-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.718, 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 , Andrew Jones , Yanan Wang , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.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 b20bf2c2359..395929b66cf 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 Thu Dec 16 13:20:14 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: 1569186 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=VEswnaTa; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4JFCbK73c9z9s5P for ; Fri, 17 Dec 2021 00:27:41 +1100 (AEDT) Received: from localhost ([::1]:42310 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mxqnL-0003Md-CH for incoming@patchwork.ozlabs.org; Thu, 16 Dec 2021 08:27:39 -0500 Received: from eggs.gnu.org ([209.51.188.92]:37258) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mxqgw-0006sa-AM for qemu-devel@nongnu.org; Thu, 16 Dec 2021 08:21:03 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:51035) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mxqgu-0008Ob-RT for qemu-devel@nongnu.org; Thu, 16 Dec 2021 08:21:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639660858; 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=XIR/7k3+LEqXkFaBCSIJ9jj6FHOlOGORQLMrHC9gYqo=; b=VEswnaTavNZ86BByiDfMUI0BCd0LLmgSmWjh/H1IdQSZfu9ZMhM5QD2nAZ2hnFMxxD5YIT jiBMutKpCI767mNdVBbNOSmTDXr405Hf0IsFGE9FPjthGpoNCfINh7E24To3NGXi7OsJiK E2/uPcaulRJhy2i268UT7KCPErvD6V0= 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-453-J8I--slNNtOUUjoZhH3OZA-1; Thu, 16 Dec 2021 08:20:57 -0500 X-MC-Unique: J8I--slNNtOUUjoZhH3OZA-1 Received: by mail-wm1-f72.google.com with SMTP id l34-20020a05600c1d2200b00344d34754e4so1255727wms.7 for ; Thu, 16 Dec 2021 05:20:57 -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=XIR/7k3+LEqXkFaBCSIJ9jj6FHOlOGORQLMrHC9gYqo=; b=mmPLM6pfb84+/7ulJvRFCy4CciAJGfIvmb+MtdwDbX7FNy6CRiGR/xZFlFKVG9DdF/ IAsocSmgPQQ2JtVhIK3HBjYmSrYfHXaI4Q0luNn0EamxrgM6LsfkRkaO57v9NJFKQ398 HUHE7c/iljipZnz39z3+TeU44TXyWOAgthkZOGpNsicGJAkS/prPlCxUpnjarR3So7iS jWtGl6AlaaKAHP9HVhR7wy/0heHz634DXy9RvHmzJhEErXG4FhJiHYQ8QA6JqLuMlHPN 3uXjdHDFE4zBMqYXCMYD3BR/u8QRJUBpDrOdQN5kVuYqZiZguyErT4wXuVlAmyTv4PDj Yt4A== X-Gm-Message-State: AOAM530CwVFaIgq3K+CZusnZgBxcLMc70G8fulfvSyIAKVQe6kA4ftp7 NfTjPKzrtR8OcknOpY/nXwVFIKQJzO7KQipdEpiz2OhaGlc76k6wYJi/Ajl67Hy7A/62BWXuOUm V0M9i9VwaSdy+OqKhvRR4+p3s/oX7KsLLx5PerHKO7BOFnAYdaKPV8C/rWhDybd+9 X-Received: by 2002:a05:600c:b43:: with SMTP id k3mr4914771wmr.159.1639660855902; Thu, 16 Dec 2021 05:20:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJx7U9ulwEmx8HA2/W7bSkCYEuamU6pe/+WHQWJiprLrnjx/99BgT0v2MoxfsRIEgrzN+DUZGA== X-Received: by 2002:a05:600c:b43:: with SMTP id k3mr4914741wmr.159.1639660855649; Thu, 16 Dec 2021 05:20:55 -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 w25sm5045259wmk.20.2021.12.16.05.20.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Dec 2021 05:20:55 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v6 7/8] tests/unit/test-smp-parse: Constify some pointer/struct Date: Thu, 16 Dec 2021 14:20:14 +0100 Message-Id: <20211216132015.815493-8-philmd@redhat.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211216132015.815493-1-philmd@redhat.com> References: <20211216132015.815493-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.718, 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 , Andrew Jones , Yanan Wang , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.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 395929b66cf..0f98c9509ee 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 Thu Dec 16 13:20:15 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: 1569212 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=GZT7q4MS; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4JFDhY1KmVz9s5P for ; Fri, 17 Dec 2021 01:17:17 +1100 (AEDT) Received: from localhost ([::1]:50520 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mxqtJ-0000zF-FE for incoming@patchwork.ozlabs.org; Thu, 16 Dec 2021 08:33:49 -0500 Received: from eggs.gnu.org ([209.51.188.92]:37300) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mxqgz-0006vT-SD for qemu-devel@nongnu.org; Thu, 16 Dec 2021 08:21:05 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:35368) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mxqgx-0008PK-6W for qemu-devel@nongnu.org; Thu, 16 Dec 2021 08:21:05 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639660862; 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=qjhf+bvQNgSb5Piftj9ZwUSggj/6sIcVgFV+K5PRUr0=; b=GZT7q4MSqCtokuJTVS4lrCvAeG66Yif1rTX7bRKQyqZZMjHr6Wa4bVmEfTvV88vDo5AVzQ 3zlLJbuLDpCcpVuy4bOM0eUji1kr2OXeu14o8jcJm8Hsz8w2LKzZXM6P6G7NXJI++K/RIX MayYYASXGCDY+scNkbv2anfOtlkdiq4= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-208-OUpFXy-LMreEO-7kd1aEUQ-1; Thu, 16 Dec 2021 08:21:01 -0500 X-MC-Unique: OUpFXy-LMreEO-7kd1aEUQ-1 Received: by mail-wm1-f71.google.com with SMTP id b83-20020a1c1b56000000b0033283ea5facso962837wmb.1 for ; Thu, 16 Dec 2021 05:21:01 -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=qjhf+bvQNgSb5Piftj9ZwUSggj/6sIcVgFV+K5PRUr0=; b=KX7RY/d4MkvxOWFZOqH7W3otFY1vgc0TA0WGihlh0OIcAyWw6cyS7RFgJW0cIOtekV E7guZUI5JVWm+/o3XsX0sx95DE+GgII9MbKWTi0232Kb/ClnKtPHYvMTzKAKUkoe0pGF xl1KQbDEWIYxJfSIQJzqsnUUPjzuYhPynBL9rcXBrNDn3i47bwEKHneQyNpJ6aQS817j Mtn7qeT+Umnm6e0ijNDlVQTyV1Kx6PvqX5mQblSJonSw/JEQRTWapfTj+TSMZ6G9WC7m DDvWxLwvgorAxVNopuNajPDxvmB1wVK78f5QitLu+T8z3i/gJqLdqXouYNgf1OiBnCoq ugOA== X-Gm-Message-State: AOAM5316sMibK/3R0+ekJeoZ4gY1vI/K61q4pbMESERrOTCMIwAFrD6Z 26FO55GmLKrzZUYYuYyECEHUkSh/FUKHcK25IxpJwgT4v0nefTko82hfR0LlMzBpUO+F8f3CvgL AGsppT91XYgckZ6/BpEz+HeJo59ohC8EKt1PKL0Ex3vFD/+ksLxdCf+vWNzCfZOlA X-Received: by 2002:a05:6000:1541:: with SMTP id 1mr8843909wry.347.1639660860290; Thu, 16 Dec 2021 05:21:00 -0800 (PST) X-Google-Smtp-Source: ABdhPJxF6mqbnnOOH3WtFObppwPWGxmCzxXXciFV6QUOHqi4+4GvdHf1nWm8z4QCZxFjkTYfPtVJ3g== X-Received: by 2002:a05:6000:1541:: with SMTP id 1mr8843884wry.347.1639660860004; Thu, 16 Dec 2021 05:21:00 -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 g18sm4785470wrv.42.2021.12.16.05.20.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Dec 2021 05:20:59 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v6 8/8] hw/core: Rename smp_parse() -> machine_parse_smp_config() Date: Thu, 16 Dec 2021 14:20:15 +0100 Message-Id: <20211216132015.815493-9-philmd@redhat.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211216132015.815493-1-philmd@redhat.com> References: <20211216132015.815493-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.718, 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 , Andrew Jones , Yanan Wang , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.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 0f98c9509ee..b6df8137fcc 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);