Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp5983088rwl; Wed, 22 Mar 2023 05:09:11 -0700 (PDT) X-Google-Smtp-Source: AK7set88WOED4CrhgUJyvnTO/isIJA3o/ZWXPYB0pOozBmGqtUVASz7iogZb1LLhY7XV4MxBnkNS X-Received: by 2002:a17:906:170c:b0:931:c2f0:9437 with SMTP id c12-20020a170906170c00b00931c2f09437mr6600982eje.8.1679486950790; Wed, 22 Mar 2023 05:09:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679486950; cv=none; d=google.com; s=arc-20160816; b=FdIiawqTGMKjtfnU0V2HprefXvYpvAalfgyL/C5ZPrY1ycksQiaPribTG2mqkHWbIO TSBqJeUphZEiPzjNKMcInAizApgDHxmtyybNnZKNgYLl0sfNHY2vKOR+KLfFaRDkKkZN 1UVeO46nw/rVuLSax4rnn9UVL9zMtm3wRssEwE+e9D7lxCEyKAD0zzrR/XweZgPU6wwC Lgj6q1WrWB4vRNGGjgtMIbhxXuBSTkmG86z2hrgkiNJeRZjVTrlr9iyM18uCDnEMvAxw uHV8bBWcgsAgic7oJ+jJonyFQrH34hN9KERlyZQDX0/Ppt9LI9wPd5RPkuRYhNtmEuRi 8v8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=0CeHW/pJK8XL8BXYqiwg3dzML61ucNGygxSUi/qceRA=; b=P08bM7Tqihk7H69UgVYI0eDs0AY6v3vygCZ8Mzap9zSRaEoWutHZKOcELCX26yfzit TUeK9oQd31Jlx8IPYggFpTOvxljZ+/htMHypgcwjFQwjJtPYEf2CMStZ1D0FYIhrQwyV Hlr30cVJzxUcUYSygPO8VqPZHQY35rR+acnPlNAG9dch71HlwG7urF1C1Bge9nBiGn7y kYBATlIbcUrlhc79gueYPlug1cdZoXUeuuyFU0229/BzKsFre5Bo+zBPeC/agAGONfEU dv+Su6HcNT+cawjXRuQ0kIKLat+G6MfG/JRVsQjaJVGWdZjEkjdVmVrJKbN6IHsK3FGz uCfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=oVvHbdtI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s26-20020a170906355a00b008b6e649a975si16570123eja.559.2023.03.22.05.08.42; Wed, 22 Mar 2023 05:09:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=oVvHbdtI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229941AbjCVMHj (ORCPT + 99 others); Wed, 22 Mar 2023 08:07:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55538 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229727AbjCVMHh (ORCPT ); Wed, 22 Mar 2023 08:07:37 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3C8C1199D4; Wed, 22 Mar 2023 05:07:37 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D2EC162066; Wed, 22 Mar 2023 12:07:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B714AC433D2; Wed, 22 Mar 2023 12:07:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1679486856; bh=mEJBZcKnQmCiiCvxN31byXP3FWkhhpXgi2bleto/pZY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=oVvHbdtIrceHMsNsG1JliX1Imp2jpxAyB/7iKh6TAQO8mXt5KOMRLzmxLzzL10QLR d04cpbbZPQJNxSY4glIF7yKTzHJj0nrruhfXM5nfoLymMbB6IKaxeMmYQbz1ymPSIE f0cZTDrkreVxliUPoQqB0NzaEvaB8MqLF/edGU5U= Date: Wed, 22 Mar 2023 13:07:33 +0100 From: Greg Kroah-Hartman To: Matti Vaittinen Cc: Matti Vaittinen , "Rafael J. Wysocki" , Brendan Higgins , David Gow , Andy Shevchenko , Heikki Krogerus , linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com, Stephen Boyd , Maxime Ripard , Jonathan Cameron , linux-iio@vger.kernel.org Subject: Re: [PATCH v5 1/8] drivers: kunit: Generic helpers for test device creation Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.5 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Mar 22, 2023 at 11:05:55AM +0200, Matti Vaittinen wrote: > --- /dev/null > +++ b/drivers/base/test/test_kunit_device.c > @@ -0,0 +1,83 @@ > +// SPDX-License-Identifier: GPL-2.0 > +/* > + * These helpers have been extracted from drm test code at > + * drm_kunit_helpers.c which was authored by > + * Maxime Ripard > + */ > + > +#include > +#include > + > +#include > + > +#define KUNIT_DEVICE_NAME "test-kunit-mock-device" > + > +static int fake_probe(struct platform_device *pdev) Please do not abuse platform devices and drivers for things that are not actually platform devices and drivers. > +{ > + return 0; > +} > + > +static int fake_remove(struct platform_device *pdev) > +{ > + return 0; > +} > + > +static struct platform_driver fake_platform_driver = { > + .probe = fake_probe, > + .remove = fake_remove, > + .driver = { > + .name = KUNIT_DEVICE_NAME, > + }, > +}; Why do you need this fake platform driver at all? Why not just use a virtual device? > + > +/** > + * test_kunit_helper_alloc_device - Allocate a mock device for a KUnit test > + * @test: The test context object > + * > + * This allocates a fake struct &device to create a mock for a KUnit > + * test. The device will also be bound to a fake driver. It will thus be > + * able to leverage the usual infrastructure and most notably the > + * device-managed resources just like a "real" device. What specific "usual infrastructure" are you wanting to access here? And again, if you want a fake device, make a virtual one, by just calling device_create(). Or are you wanting to do "more" with that device pointer than device_create() can give you? Again, please do not abuse the platform device infrastructure for things it was never ment to do (i.e. create fake devices that are not really a platform device.) thanks, greg k-h