Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp4755606rwb; Wed, 17 Aug 2022 05:43:54 -0700 (PDT) X-Google-Smtp-Source: AA6agR4xKIRJf4/3NUOVU1etD4bjFxqttuQJgrU3ZuuB2ZPY0iFcWPp4LIl403ZgA6wKTOlkYyEa X-Received: by 2002:a17:907:94d6:b0:730:bfe6:8352 with SMTP id dn22-20020a17090794d600b00730bfe68352mr16483411ejc.348.1660740234102; Wed, 17 Aug 2022 05:43:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660740234; cv=none; d=google.com; s=arc-20160816; b=jq7wvXf8tv9+hYMAoBHU2w9AT+zrt/LKbRQuycuhUoZr9AXB8WMHurRlHfCgnHdCU+ nnkVA7GTbXxYDS+uuSfP6ZWR6YVzVzIKAviY4CjHcJY/o5WhsGpWzPPCOuf3B4b2s4Xp YktW6lfIuir25sSY0m9b16irvowsVBvjZu6QT75et2vb88LKyRedf4AgyK8tosQvDayH 1yje59i8y8ITKVO1tBa8H9gSNVvfDrufXyx/C2iEU0IMFHXsed0sr5iDp0YPZ4w0QklZ cdTgz/jz0l2LY5broniRo0O1STjpKKz3RMSFRm1NJTR3dPUYYyaGbiLeQwW+xZG9++0X YwCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=PvQ1VTkR2TBqqjzA69gfrLsfT8nfazvXfsefYA9g+lo=; b=ePSPsS9Z9+RGotxG4cN/8BDKa50vtM6ytbrML4sHSjfhRFQctkbzbjGAw14s+ofzyE unnCioMSzRNEf4K6AxP3IrIXk1ZfUgptcY6jdpEiVQaNnzIUp0swZp4jjWU4cuDxr4Sx C0G8576omVhWE65evbMoCuD7vRsUnjk4GWrJZBgpeurbOnbYv2HT6xLkPHMC7JOBSE2G BklqOmV66HE57+DxwmCT+KTzYy+5vf1lqbNiVgvevBMBQ+7Wdvu68wLwMwAmwc1JOd52 tu47G079rzbfPxKqRZ1VaFsFXCRiJO37T7eTzW4vdkt04OX1LruyrqhfHt545zQjVJL/ vPMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=e9akmKRp; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qw9-20020a1709066a0900b007309346cfcasi150515ejc.773.2022.08.17.05.43.27; Wed, 17 Aug 2022 05:43:54 -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=@gmail.com header.s=20210112 header.b=e9akmKRp; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239409AbiHQMTY (ORCPT + 99 others); Wed, 17 Aug 2022 08:19:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47116 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239393AbiHQMTS (ORCPT ); Wed, 17 Aug 2022 08:19:18 -0400 Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A57B2640; Wed, 17 Aug 2022 05:19:17 -0700 (PDT) Received: by mail-wr1-x42d.google.com with SMTP id u14so1461404wrq.9; Wed, 17 Aug 2022 05:19:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc; bh=PvQ1VTkR2TBqqjzA69gfrLsfT8nfazvXfsefYA9g+lo=; b=e9akmKRpa6Fp06HHF72K5rqZcPAVV/QyCi2T6/klrrcHO9vbhKVl4f4DVektjn+DX3 EAgoLG+Iq4oBXugdtjHXjsU4WuQ9ZHgJOBS6ci+etwNviZgUiBdltXC4qVmsuokjAasa hAvmF/oYjJ5/mzK6JUx/bBy5wXY4JS7qPOcN+PqZY36e+AWfE5qnkiU3R9o1WqhvWSMw i09E3MLgPFMsv8FqnNHPut5SOXpDG9LQSZlG4Ff+39/oL6Vwr/Z6erfAbhzxhIpCHqFj UvRPgQoiP4fXXM5DDd0aLp+f5+GnJ0VWeuSz95yiq7PpiIsYohvIW7QwyhBWy8dl0Zlq uQKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc; bh=PvQ1VTkR2TBqqjzA69gfrLsfT8nfazvXfsefYA9g+lo=; b=P6nWgBzD5DTxSE1Z7tU1wRWVAI5HfcXp6L9T92+6fSXnFI3Ygr8WuNy1PdlNCQp+Q2 Nj8/CVevlc43l1mgpW75xlhhYbjdlYjRjS+LVCiU/DI0UL4ckaCJUwuX+SScQgTcplpv FpSlLihaXaKuFX0DhnRDco5aCcYY7DbCbMdzHmrggLA9hcC5t2Nch0efdn9f0rYG/3Vl 2PXxWGwrtuE7JR87v/3pW4JrnPdDIsZL/TVhxVTr8po7gts/XrTFXeNQE9qtr240y/JX eR4jd9Zw+g9uaEM78bvKExAXa5qwiayHiVBpTGwGluCjusAcS33TVzGXIlKOoccwbrnb P7mw== X-Gm-Message-State: ACgBeo1eBt7GFP4xbvmW0O2LwG0uo9+HpC4iHFyuiP1cFdYez1pd2EuZ ki2zp2IMKnWuu8Z73QDRW/CkU+0wdRu8HSaTToDqQaerJOc= X-Received: by 2002:a5d:404c:0:b0:225:1a39:d69f with SMTP id w12-20020a5d404c000000b002251a39d69fmr4042257wrp.576.1660738756137; Wed, 17 Aug 2022 05:19:16 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Ramon Fried Date: Wed, 17 Aug 2022 15:19:03 +0300 Message-ID: Subject: Re: Running kunit tests on platform devices To: David Gow Cc: Brendan Higgins , "open list:KERNEL SELFTEST FRAMEWORK" , KUnit Development , LKML Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham 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, Aug 17, 2022 at 7:43 AM David Gow wrote: > > On Mon, Aug 15, 2022 at 5:16 PM Ramon Fried wrote: > > > > Hi. > > I implemented a test suite that checks a platform driver, that's the > > only way I can test interrupts behavior in the code. > > Because it's a platform, I can't use kunit_test_suite(), so I call > > __kunit_test_suites_init() as part of the platform driver probe > > function. > > > > This works fine but has the following problems. > > "TAP version 14" string is not printed and it's impossible to parse > > the results using the script. > > In addition, the suite is not displayed in /sys/kernel/debug/kunit. > > > > It would be my pleasure to provide a patch that fixes this, I just > > wanted to make sure that my testing strategy makes sense. > > > > Thanks, > > Ramon > > > Hi Ramon, > > Thanks for reaching out. Calling __kunit_test_suites_init() directly > is not something we'd recommend (and are trying desperately to remove > existing uses), so several of the issues re: the "TAP version 14" > string et al are side effects of calling what is supposed to be an > internal KUnit function manually. > > That being said, we definitely do want to make testing platform > drivers as convenient as possible. I'm not sure why kunit_test_suite() > doesn't work for you for platform drivers: are you just missing some > way of instantiating the device from within a test context? > > I know Brendan has experimented with some hardware faking code, for > which there's some example use here: > https://kunit-review.googlesource.com/c/linux/+/5275 > (Note that you'll need to look at the other patches in the 'relation > chain' for dependencies.) > > Equally, I've experimented a bit with testing old soundcard drivers > (via a platform device) here, which may be an easier way to look > through: > https://github.com/sulix/linux/commit/4e1620c86553b9edde7f032318cf417dc13e4d26 > > Note that neither of those examples are anything other than > experiments, so may not work as-is, or be ideal. > > Otherwise, we're always happy to accept patches, though again, if > there's any way of getting your tests working without a direct call to > __kunit_test_suites_init() --- even if that would require patches to > work --- that'd be preferable on our end. > > Cheers, > -- David Hi David, Thanks for replying. I looked at the examples you shared, and they all fake the actual device. My intention is to actually interact with the real device. - get a real interrupt, etc. Is it wrong, was the intention that the platform device be mocked ? Thanks, Ramon.