Received: by 2002:a05:7412:8d11:b0:fa:4934:9f with SMTP id bj17csp662368rdb; Mon, 15 Jan 2024 09:21:17 -0800 (PST) X-Google-Smtp-Source: AGHT+IHNd2hrDHHn+OpWPimcDDUaLS1rtmojsXw2GZWcv7Quw/eyvuE/RPKEEgZIdL+0/ZkNulj/ X-Received: by 2002:a05:6808:1154:b0:3bd:446c:a65d with SMTP id u20-20020a056808115400b003bd446ca65dmr7696258oiu.90.1705339277293; Mon, 15 Jan 2024 09:21:17 -0800 (PST) Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id a34-20020a631a22000000b005bcfc60520asi9476507pga.586.2024.01.15.09.21.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jan 2024 09:21:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-26304-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=cnWXZbWQ; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-26304-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-26304-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 6D16528363C for ; Mon, 15 Jan 2024 17:14:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 091DA1865C; Mon, 15 Jan 2024 17:14:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="cnWXZbWQ" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.7]) (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 7DE97182DD for ; Mon, 15 Jan 2024 17:14:20 +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=1705338860; x=1736874860; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=8Dh8wTx4iSOMWjRrki215AMLxAvFo/rjwYyFI7+uuvg=; b=cnWXZbWQWfyNmR7VjGVlbo5nfx344kobaGkH0UyL9Nq1v4N0X7zKIdGk 22uIrsSbq2rdJRyisT0wsEucE5+c6VntVN7wAB4lmTYy1fVGVEsv5p68m P8Y6EVxoqASKn61MtKtNZStHnBFKea0TWv5nz+ofk5diejx+yfZu1asco 24PkovbH49CllBBmuNj9w32d7A+AowmHKThxv5Q3ciFqmGWY4JaJgfmwp eU1WBmUXpy81r26dR5Pp2vXvcgavCAJH17jmoJk0iWp8V+mz1PJPrUmPO //ZVHIPa01oH+yhn0c1TAnMuOASFBYCiVz/cwARXFQ9suvXWN3ZP0wFBZ g==; X-IronPort-AV: E=McAfee;i="6600,9927,10954"; a="21139055" X-IronPort-AV: E=Sophos;i="6.04,197,1695711600"; d="scan'208";a="21139055" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jan 2024 09:14:20 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10954"; a="854063866" X-IronPort-AV: E=Sophos;i="6.04,197,1695711600"; d="scan'208";a="854063866" Received: from fmsmsx601.amr.corp.intel.com ([10.18.126.81]) by fmsmga004.fm.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 15 Jan 2024 09:14:20 -0800 Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) by fmsmsx601.amr.corp.intel.com (10.18.126.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Mon, 15 Jan 2024 09:14:19 -0800 Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) by fmsmsx610.amr.corp.intel.com (10.18.126.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35 via Frontend Transport; Mon, 15 Jan 2024 09:14:19 -0800 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (104.47.59.169) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Mon, 15 Jan 2024 09:14:19 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jeoA4CDSHt5/8V7xW/1AZHR7S3OPW1fqhtHppcExyZ118WuBB/THogGqlkCDSJFZgzb5A3PeqzqNbBHoa5fM/+ePA2XNPOFIpDpYM1e7neKHdIYRoCfNuM0C/boIzPHVCV6fvIq05EyaW3vwPU2N3DMeqRYO4xhPRrJg+r87iQFb/mSbqZRVsCVks2c90P3t5kxqym8vena8C2yeXIcH4GCZ2FENh7vKO9gNU4GxJDKFfSHlwI8Jiki8Wcu+QL8yzq2KGSu+TYirwJUaCzZj2pVi/vqyGyjHe3of7QgbJZCbSLtYQvKBku5pgMnO3ZuofjCZXFVpvhGkYNMIYHajgg== 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=YTT7RD8ggPmqsumV0FqAc1SmuGLprf292fW+WgMvISc=; b=G4TikFw5KJUz33L3tmgfSnfvxd9nSfMeqlkC7kG41f6LFtysq5Z0ZXYxGrCZAZIAmzylkUIik3aWb1kXGZ1mKA/68LraCUBuuZm4l48sqijkb7uB1WUk0SS+4sXYbzXDro6Lir+K5lUUzWDumyV/YzFaytcFh3Ea+hEAf6L0FprleKSXOsGKN56tj63GOQLKFw3CznjahhKFfkPJgTTws85p9sRTwguX8ICMbw56C2VF9AiszNqWUPHN6K1XPR+3ekzACT9FuNwAcdNlXQtbVqvgDGuhKvbijj+pqEcyA/XX/Mn3cgvRB41v5pk1q1ZJjrB4yYXJ1tuHYC2lqtSO3Q== 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 CY5PR11MB6391.namprd11.prod.outlook.com (2603:10b6:930:38::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7181.18; Mon, 15 Jan 2024 17:14:17 +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.7181.020; Mon, 15 Jan 2024 17:14:17 +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 v5 4/5] drm/tests: managed: Extract device initialization into test init Date: Mon, 15 Jan 2024 18:13:50 +0100 Message-ID: <20240115171351.504264-5-michal.winiarski@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240115171351.504264-1-michal.winiarski@intel.com> References: <20240115171351.504264-1-michal.winiarski@intel.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-ClientProxiedBy: FR0P281CA0198.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:ad::8) To DM4PR11MB5373.namprd11.prod.outlook.com (2603:10b6:5:394::7) 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_|CY5PR11MB6391:EE_ X-MS-Office365-Filtering-Correlation-Id: e961c0ef-03c0-4849-f8cc-08dc15ed67ea X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8FSZy1hIdnSzpiMI0JI5hfL7PNiRfkoKgbkJHgratIFg6YhwtHvASugSZbBQJENdFoNdTdSFJPG61ALwyRIesJ9YwTEG3NLOZzBHEQORouthVirQ318B4pJU08K8vbS3OyBEF5XaFvmTH/gzcnHQ/qHXvlWFo0DZ8RIbpQ48RJ/Wbn81RXXmqcPlDBJRQBSgVHP0AF0MqbIMxIeWr72Kdi8EBqpLUAohIwgU936WAVB2AYf1s5avpXPXJ+Jy1jTPR5+ET3Tau9r+rLWukM2BVGA4edIM1Mw1zSHiSOig7DiHBFBe+7stjxhDdgMUQf02BVJqfsa0qb+dr4BouzHhx/hzQq0rGcz2flEB7AbHZsbdjBgCrX3yf0GCBrkm16XyvrGb0tf33NILXq3wBbl5zk1o3N0VVwZPTmxo13eCYfBBxzUheoIAafaY8K9MeJKHCGTY2N8/tP5caON20VJoc0D+vgllBh+5ouLfUlXXZw1FdotR4zlxw73AZHjFl9MA3rwxxyBwsZCYn01hCPTo0LgLc7y8TMkudHGgEjdsSC4= 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)(136003)(346002)(39860400002)(366004)(376002)(396003)(230922051799003)(451199024)(186009)(64100799003)(1800799012)(66946007)(6506007)(1076003)(6666004)(2616005)(478600001)(82960400001)(66476007)(86362001)(316002)(6486002)(83380400001)(66556008)(26005)(54906003)(5660300002)(8676002)(36756003)(6512007)(41300700001)(7416002)(38100700002)(4326008)(8936002)(2906002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?OWx2RmtUeFlKY3NzTzh6YXJpTUZ1YU1nQjZpQUZVaGZjUVpTZGtmOVV3Y1gz?= =?utf-8?B?WDVkdGJiZFUrMllXSnpqUFpseHA1WWQzeWZXVFlmZy9VZ1JSM2JFdnU4NW05?= =?utf-8?B?byt3czRPQnU0TlgxVUxSY2JGZXlqQ3Y2VzEweXNDdjRPdjhHT3hyaUVmOXhi?= =?utf-8?B?WTRZRjFVL2wyYWxKUTNzVTVYeFVrOGsrOVQzN2NWYlhQcG5xSGhXcE02UEtU?= =?utf-8?B?dHVDbmNIL2NiUGIyUXM2VWp3RExtM3VocVVMVTg4OGlCRTJjeDNaSVFRZ2l6?= =?utf-8?B?SVdhTmFldmNmdkRZVHoxSG8zanFNb2xJbXNvbWpCUzlZQzRpcWpFcjF3dytS?= =?utf-8?B?bVRoZmVLR1NTN1RSaGdLOFF0U3JVWk5ab0duQUVIZVZZMGtEVGJLQkdyNVBh?= =?utf-8?B?cDc0eTBkMldLcW9HakViWWZxT0FPRzZxTVpOTDhNL0t6VmlLMENubklY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namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Jan 2024 17:14:17.5568 (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: h3TPc91/AQ9BU1FRnZuXiiGL7AsVaQ60PYJd9jZbLqVFlH1rBkyptd+CizSmVNzyac5+mH/+gfVyN7+V17WxD18ldfjD3wVCwv/GONcxLnY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR11MB6391 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 Acked-by: Maxime Ripard --- drivers/gpu/drm/tests/drm_managed_test.c | 41 +++++++++++++++--------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/drivers/gpu/drm/tests/drm_managed_test.c b/drivers/gpu/drm/tests/drm_managed_test.c index b5cf46d9f5cf8..d936c879a4a30 100644 --- a/drivers/gpu/drm/tests/drm_managed_test.c +++ b/drivers/gpu/drm/tests/drm_managed_test.c @@ -12,6 +12,7 @@ #define TEST_TIMEOUT_MS 100 struct managed_test_priv { + struct drm_device *drm; bool action_done; wait_queue_head_t action_wq; }; @@ -29,11 +30,28 @@ 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); + + ret = wait_event_interruptible_timeout(priv->action_wq, priv->action_done, + msecs_to_jiffies(TEST_TIMEOUT_MS)); + KUNIT_EXPECT_GT(test, ret, 0); +} + +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); @@ -47,21 +65,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); - - ret = wait_event_interruptible_timeout(priv->action_wq, priv->action_done, - msecs_to_jiffies(TEST_TIMEOUT_MS)); - KUNIT_EXPECT_GT(test, ret, 0); + return 0; } static struct kunit_case drm_managed_tests[] = { @@ -71,6 +81,7 @@ static struct kunit_case drm_managed_tests[] = { static struct kunit_suite drm_managed_test_suite = { .name = "drm_managed", + .init = drm_managed_test_init, .test_cases = drm_managed_tests }; -- 2.43.0