Received: by 2002:a05:7412:98c1:b0:fa:551:50a7 with SMTP id kc1csp49290rdb; Fri, 5 Jan 2024 02:15:28 -0800 (PST) X-Google-Smtp-Source: AGHT+IEmikUctVy+GdxaQOg8i3j7Aj/+dhwrY2kJnZ5VVnr79fw+p9YSX6RJpCDtA3kf5cM1ULS0 X-Received: by 2002:a05:6512:3297:b0:50e:6ddb:551d with SMTP id p23-20020a056512329700b0050e6ddb551dmr982052lfe.73.1704449727861; Fri, 05 Jan 2024 02:15:27 -0800 (PST) Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id bw6-20020a170906c1c600b00a26dc9070e9si470276ejb.362.2024.01.05.02.15.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jan 2024 02:15:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-17724-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=HcUqTmDQ; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-17724-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-17724-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 72D171F23DD4 for ; Fri, 5 Jan 2024 10:15:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2D01F2C688; Fri, 5 Jan 2024 10:14:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="HcUqTmDQ" X-Original-To: linux-kernel@vger.kernel.org Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C936925572 for ; Fri, 5 Jan 2024 10:13:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1704449637; x=1735985637; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=kBoUF9HYOTFjNe2KivFWvaOTPojfkpwp8QWHNhicEKk=; b=HcUqTmDQq3Mo8kIaX9FAD2l0+hhW8FtkTHn0IU+DvH+b4ZpOG5Y5ZzxZ JNpGI22v+EXYBe+oz+BfPkx+0c524jqExxOxFRLbcrYE/3eWlmKHhxlND YExwsL6so1h3dLA21n/bCgf+TzU+hBVfFZXZceHUK03gPRxdHcfv7oO+X l7VG2NqIBdyDJOi2JVSdYRlPJvMsUgnUOev5MMGUBvhC8gAsJ5PFGs9cA /A2mQiRx3U4FagtXZ63oKQyP1ki9sdrxmPnYQ3qmvmsxGvNEjpaqTpvcJ /gS3AynDBhWJOLqo2Lp72ee+Jx1mbL4w/Ganf27GdMhig9RDBgPaKw6lB g==; X-IronPort-AV: E=McAfee;i="6600,9927,10943"; a="483651639" X-IronPort-AV: E=Sophos;i="6.04,333,1695711600"; d="scan'208";a="483651639" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Jan 2024 02:13:57 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10943"; a="730435477" X-IronPort-AV: E=Sophos;i="6.04,333,1695711600"; d="scan'208";a="730435477" Received: from orsmsx602.amr.corp.intel.com ([10.22.229.15]) by orsmga003.jf.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 05 Jan 2024 02:13:57 -0800 Received: from orsmsx612.amr.corp.intel.com (10.22.229.25) by ORSMSX602.amr.corp.intel.com (10.22.229.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Fri, 5 Jan 2024 02:13:56 -0800 Received: from orsmsx612.amr.corp.intel.com (10.22.229.25) by ORSMSX612.amr.corp.intel.com (10.22.229.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Fri, 5 Jan 2024 02:13:56 -0800 Received: from ORSEDG601.ED.cps.intel.com (10.7.248.6) by orsmsx612.amr.corp.intel.com (10.22.229.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35 via Frontend Transport; Fri, 5 Jan 2024 02:13:56 -0800 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (104.47.59.169) by edgegateway.intel.com (134.134.137.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Fri, 5 Jan 2024 02:13:55 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Cckap2kZKrRR74mmqOwAg3vJ3ocTDoZUAohhjt1xCGv2kZE5m1cuCpOVf1wxvDYxcTOTGiCxh96lfPDa5O3grOJtg5zBqgzsmej7yNHkdyygyj9+Z48tYgP5lLkE/up25I6jwhSrI6HjyOPy5tafIgBOFPAtC7wQ8gWnM9sPa1+fbwXjI7JLET6VDpPoDStZMPS4kLFCt0rxvudhUskFK7u1bMI+RkuFl/+g7Y+Xy3l5AnhtGm5yAgNKDrG0OLk1UkgOs+5eP2upnzHZBjSpGQB+AtsTwSE+6BhfqHbTmq1OtvfDsPXYURMUZUuhppGCJMMxpoOpcjm4WoOJlZZeoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=VyCAC7LWE14HvBFc2H+TqGWJ5O9b40rs5udZJZAwzPw=; b=a5bWX1etx8YXElWd/x7br+YKfb+BLMP+myFYcNBiTfINVq+JrLFUc0Zv4Hyko1cNDimBESJKvv66Nf1bNs9eNmg+KT7bg7PyY8SplfjWB0X0uA1+tn0rFOBZeIboSjeyDVs1TYcYP1R7e0xceGn7mlhNK/D/YdeXcdfAYz5Y6eLIiLyc1hthj7rKK/kxkoxRm/rgz7qk+GKSFKkpKyzrOJHG9U00sWjLDN4a9N+MbME63nsTi3eLOm6NWUDW7cNHsUwTLRiyvqM42xvoxAqg6NxvMspOfJPy1zgfqeqJwn/ZpDMMYTxkavfrdi+RBaHbL9h2d5XLaqgmeFlDBMKKjw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from DM4PR11MB5373.namprd11.prod.outlook.com (2603:10b6:5:394::7) by PH0PR11MB4823.namprd11.prod.outlook.com (2603:10b6:510:43::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7159.17; Fri, 5 Jan 2024 10:13:51 +0000 Received: from DM4PR11MB5373.namprd11.prod.outlook.com ([fe80::f105:47dd:6794:6821]) by DM4PR11MB5373.namprd11.prod.outlook.com ([fe80::f105:47dd:6794:6821%4]) with mapi id 15.20.7159.015; Fri, 5 Jan 2024 10:13:51 +0000 From: =?UTF-8?q?Micha=C5=82=20Winiarski?= To: , , CC: Rodrigo Vivi , Michal Wajdeczko , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Javier Martinez Canillas , =?UTF-8?q?Ma=C3=ADra=20Canal?= , =?UTF-8?q?Micha=C5=82=20Winiarski?= Subject: [PATCH v4 5/6] drm/tests: managed: Extract device initialization into test init Date: Fri, 5 Jan 2024 11:13:23 +0100 Message-ID: <20240105101324.26811-6-michal.winiarski@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240105101324.26811-1-michal.winiarski@intel.com> References: <20240105101324.26811-1-michal.winiarski@intel.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-ClientProxiedBy: VI1PR03CA0044.eurprd03.prod.outlook.com (2603:10a6:803:50::15) To BL1PR11MB5365.namprd11.prod.outlook.com (2603:10b6:208:308::18) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR11MB5373:EE_|PH0PR11MB4823:EE_ X-MS-Office365-Filtering-Correlation-Id: 3a2eb0d0-c9ad-4c31-a41e-08dc0dd703dd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: DTF7t0WS3M4UsvM9kA9ynwXKRrG0SipTGfDaHmaEDSPzoWuH8PhHj9GVpogBebo7eCM2UATjeRaSoY4MBSjdd62M/HawHbGhSchEsQ22Lh1ADoWZ4ige4aj2/xy7TUVy6baE2HQ04JNqhKl6JU2MxZnFT3qpkRrm+hRfLdTV8aPDsCGFhGEPuVgjony3yRTBCexA7wwyarIgddsdxlaZSiOVXsLyAriDRJHUuTU4qGT12UZgpOr6xIKPvPHtE/mNIt6LVIIF3MuBWpTiVAMQIGaQEMZ3QLIkxIgARZAE3hEYbH+4jGwlxL6ld+6197A3BkGm0MlP+hMX9YpVT+s5U+dlqdriCvR0VQy+nk6vQeM313zMEXJ57UrsWe4h659XSIRKmc0g/V1Z+mteEL1r7fD/cCf5UgGUxXKb4yic1QF9Fe0BnJ2hC0TUkGPHmjm5Kn67xSVurpYcfuq63Kwu3DAaAGxLDbm5zIYl43wF7F7IYb18ml3g/NKo+BvQSQu4FAnh7m1TV349u91ti1j2SnTLaSrkiX13ciRUH6HzGcqQGhBPh+jPuh4P+fyJeArZ X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM4PR11MB5373.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(366004)(136003)(39860400002)(396003)(376002)(346002)(230922051799003)(451199024)(186009)(1800799012)(64100799003)(2616005)(26005)(1076003)(6666004)(6506007)(6512007)(86362001)(83380400001)(4326008)(8676002)(8936002)(316002)(54906003)(7416002)(36756003)(2906002)(5660300002)(6486002)(478600001)(66946007)(66476007)(66556008)(38100700002)(82960400001)(41300700001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?S0Y4ZHZCMzZTT0k4VFM0NDdLUWZxM3ZLRUEwalYxV0c4TUxOQ04yaHN0d1Vs?= =?utf-8?B?cDZ1T0tzQ0JJM3NaK00vSWdaeVBWU2EvQUVMYklzTlhXODFUa3NjeEdCUnpV?= =?utf-8?B?d3c4WHBXcVp5VnZwdFcrSU5uVlVBb09mSWNCckVMdXplWkZ2ZEs1aTVvVFRC?= =?utf-8?B?Ukg3bDlOa0lVRkM5L29SUU5rNGluaW8vTjRLV3ZqN3p2b0trQlpPNytJWjRK?= =?utf-8?B?UVMrVkpJN2VvRkZl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?B?UXN5a1c3V29KTWNUSEVpK1RVVTJrOWFFdklmeVVHYVNrWmw3ODZCdUgrdEtp?= =?utf-8?B?RUJZaEhFQy9YbGFvdTBsRURMUjF4cW93YWNtL2VDemJ4QzZSRStMTDlLU1p2?= =?utf-8?B?MXc9PQ==?= X-MS-Exchange-CrossTenant-Network-Message-Id: 3a2eb0d0-c9ad-4c31-a41e-08dc0dd703dd X-MS-Exchange-CrossTenant-AuthSource: BL1PR11MB5365.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jan 2024 10:13:51.8484 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 9fNj23lPpkWrPKipt7YoRe+OZF7iE7yhp9XDN2EfgsDisDzlGqv3jg5jqm5ClP1xa9Xw1KlH+r0QQkqaSpUDZ27a2vxc9ukB9amoGTA9o+c= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR11MB4823 X-OriginatorOrg: intel.com It simplifies the process of extending the test suite with additional test cases without unnecessary duplication. Signed-off-by: MichaƂ Winiarski --- drivers/gpu/drm/tests/drm_managed_test.c | 37 +++++++++++++++--------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/drivers/gpu/drm/tests/drm_managed_test.c b/drivers/gpu/drm/tests/drm_managed_test.c index 986a38c9144a5..c1fc1f0aac9b2 100644 --- a/drivers/gpu/drm/tests/drm_managed_test.c +++ b/drivers/gpu/drm/tests/drm_managed_test.c @@ -9,6 +9,7 @@ #include struct managed_test_priv { + struct drm_device *drm; bool action_done; }; @@ -24,11 +25,26 @@ static void drm_action(struct drm_device *drm, void *ptr) * device is released. */ static void drm_test_managed_run_action(struct kunit *test) +{ + struct managed_test_priv *priv = test->priv; + int ret; + + ret = drmm_add_action_or_reset(priv->drm, drm_action, priv); + KUNIT_EXPECT_EQ(test, ret, 0); + + ret = drm_dev_register(priv->drm, 0); + KUNIT_ASSERT_EQ(test, ret, 0); + + drm_dev_unregister(priv->drm); + drm_kunit_helper_free_device(test, priv->drm->dev); + + KUNIT_EXPECT_TRUE_MSG(test, priv->action_done, "Release action was not called"); +} + +static int drm_managed_test_init(struct kunit *test) { struct managed_test_priv *priv; - struct drm_device *drm; struct device *dev; - int ret; priv = kunit_kzalloc(test, sizeof(*priv), GFP_KERNEL); KUNIT_ASSERT_NOT_ERR_OR_NULL(test, priv); @@ -41,19 +57,13 @@ static void drm_test_managed_run_action(struct kunit *test) * to remain allocated beyond both parent device and drm_device * lifetime. */ - drm = __drm_kunit_helper_alloc_drm_device(test, dev, sizeof(*drm), 0, DRIVER_MODESET); - KUNIT_ASSERT_NOT_ERR_OR_NULL(test, drm); + priv->drm = __drm_kunit_helper_alloc_drm_device(test, dev, sizeof(*priv->drm), 0, + DRIVER_MODESET); + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, priv->drm); - ret = drmm_add_action_or_reset(drm, drm_action, priv); - KUNIT_EXPECT_EQ(test, ret, 0); + test->priv = priv; - ret = drm_dev_register(drm, 0); - KUNIT_ASSERT_EQ(test, ret, 0); - - drm_dev_unregister(drm); - drm_kunit_helper_free_device(test, dev); - - KUNIT_EXPECT_TRUE_MSG(test, priv->action_done, "Release action was not called"); + return 0; } static struct kunit_case drm_managed_tests[] = { @@ -63,6 +73,7 @@ static struct kunit_case drm_managed_tests[] = { static struct kunit_suite drm_managed_test_suite = { .name = "drm_test_managed", + .init = drm_managed_test_init, .test_cases = drm_managed_tests }; -- 2.43.0