Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp558700pxb; Wed, 6 Oct 2021 10:27:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyrR3KG9+R8KG+989Cp3k7HQTG7UaEhbt5XPSg/XZ8SQbraaygC7PPNkkIU6psZ5WRIhMbF X-Received: by 2002:aa7:8246:0:b0:44b:4870:1b09 with SMTP id e6-20020aa78246000000b0044b48701b09mr38250671pfn.82.1633541268684; Wed, 06 Oct 2021 10:27:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633541268; cv=none; d=google.com; s=arc-20160816; b=JPHijRijN06o6pO+GMGuK/KlOD9DqRPEXYxlF4cv37X3ssAA9co/syyjMz4WDwsNYg UWO+mGmLNQ/7lWOe73zJ0SWszGMh7Z9INzfxAY5JmI2IxITrUuTenXRi32KoRCEvHf4V 00Is4WOAyC8VHiF64n6zrmx6J9gC+SoQGykVjcsqse9Awyvb7nQvEiqnkrjGCAb7duAO 3zZ6xVsB/yG2coRs8mlou73bJb2o68IvslCMGsMBMqWPmFhshP8qB+z52uuazLjunPdK yV0vKx6jx82bT/865fF2frczTb7bjwWByK36VO7rAZjLN6VIr0wzm8C7e30DpT9NBDny bapA== 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=jM95yKFhV2qB0CLFdficrXk+L5A5ZWpI+xeKTC4LLR4=; b=Wjkyqw3ITUlz0KGJOEmM5HxxbG+3MUiwWgqgHENCrgW4N7ghpmJXZnujuBHW4kT/4N OnA/8iV0cBlPLmrWxpkU6SiZjnWidlMvmomTUxK8aZX0G1BVuuF1qquqzHEPwD/Qxa2N 8Nn4KSCn0Syzi/d1jbZdCWSgoEU55Nk1oXqKLqObsDdul+rHhXLsizOCeqeJFMzcrFTW BXng1qDIeILImJ52YMKkm+t+FGDUNXiBVcRW4NoEtyk4ILjn7tPC0SA2asIpTm3l5VKD 2pdoYHaoa1cXFcrhh6qSmwl3spseAImgXYK2Js/HMJz6SGGE0c5nCK1jIp710/v9FPSj U/Yw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=MN6d1YTV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u6si794329plf.76.2021.10.06.10.27.31; Wed, 06 Oct 2021 10:27:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=MN6d1YTV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229564AbhJFR2a (ORCPT + 99 others); Wed, 6 Oct 2021 13:28:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51426 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231942AbhJFR2a (ORCPT ); Wed, 6 Oct 2021 13:28:30 -0400 Received: from mail-io1-xd31.google.com (mail-io1-xd31.google.com [IPv6:2607:f8b0:4864:20::d31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E2291C061753 for ; Wed, 6 Oct 2021 10:26:37 -0700 (PDT) Received: by mail-io1-xd31.google.com with SMTP id b78so3713445iof.2 for ; Wed, 06 Oct 2021 10:26:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=jM95yKFhV2qB0CLFdficrXk+L5A5ZWpI+xeKTC4LLR4=; b=MN6d1YTVj88nQqwDa53hJ5/h9IC/CoxXaMUX4gfp/8cq6fsmWh367DWJ2CcrpUkBoX /p/OmZ4kyKc+hjLw54ZIXZcLn015XLX/Yb9Eg1vBp+abb53a914LDDLFTiHdvxKQmcCA vZWArFMYnMkvp05TwqqFzwipPcYbQUbKFkqWiTYnKLOMvOPwauWxhP3XNPzEN2u3yiVv 27e5QJDSrNZI0B6EFca/YgUPNzMLc7TOizQbNzUB59qACGmBIU2hgRywH5x39X6xH6jw 0r+qbqPIilq7gPTroe7HrljiGydi/ykjidOyzC/lSbLWoYLK6JRaPjFmNvMxPBB7boRw PAtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=jM95yKFhV2qB0CLFdficrXk+L5A5ZWpI+xeKTC4LLR4=; b=uxIzp4z6YaifTQ5f6IPuGe9NLEmUguW6KtatWCURnG43fXeeVjPuobYUaVmDOGy8I7 WWfNAtfKtWJs+tHe6g+5sWHCrllYJs9bszAgkbTJQLbWFseLBDP9I48hHi/DMEKqJjat wFX76HlHj1yy243X+7Owl0NVP9M9wSJMJaqcJvrL7n6KJAjSseq1uduHJ3LLRIB+CWNc hwXy/UhA7iEtBupPbnvHJ+5ryCDl8yEmttlrVy86G1Dow8ow/oJn2OIcJfNZ2dAfYN58 tLN98iYuMqP1IdWe27Z138OKB2NhHbU6CzxMd0tCcLFRigYNeTtL1AEAJ6EZ8r1oDnw6 /nHQ== X-Gm-Message-State: AOAM530okV7/3+7kGsKxC3yJyftCbKYrNxSbiVBJzcMKGWNL6v59ClCu 4tIzQwG/s3EfTYT9J/DvHVIdz/P/IRQBA1COYSt/a14DW3XFKQ== X-Received: by 2002:a02:cbc2:: with SMTP id u2mr8073356jaq.96.1633541197109; Wed, 06 Oct 2021 10:26:37 -0700 (PDT) MIME-Version: 1.0 References: <20210930222048.1692635-1-dlatypov@google.com> <20210930222048.1692635-5-dlatypov@google.com> In-Reply-To: From: Daniel Latypov Date: Wed, 6 Oct 2021 10:26:25 -0700 Message-ID: Subject: Re: [PATCH v4 4/4] kunit: tool: support running each suite/test separately To: Brendan Higgins Cc: David Gow , Linux Kernel Mailing List , KUnit Development , "open list:KERNEL SELFTEST FRAMEWORK" , Shuah Khan Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Oct 6, 2021 at 10:23 AM 'Brendan Higgins' via KUnit Development wrote: > > On Thu, Sep 30, 2021 at 4:05 PM David Gow wrote: > > > > On Fri, Oct 1, 2021 at 6:21 AM Daniel Latypov wrote: > > > > > > The new --run_isolated flag makes the tool boot the kernel once per > > > suite or test, preventing leftover state from one suite to impact the > > > other. This can be useful as a starting point to debugging test > > > hermeticity issues. > > > > > > Note: it takes a lot longer, so people should not use it normally. > > > > > > Consider the following very simplified example: > > > > > > bool disable_something_for_test = false; > > > void function_being_tested() { > > > ... > > > if (disable_something_for_test) return; > > > ... > > > } > > > > > > static void test_before(struct kunit *test) > > > { > > > disable_something_for_test = true; > > > function_being_tested(); > > > /* oops, we forgot to reset it back to false */ > > > } > > > > > > static void test_after(struct kunit *test) > > > { > > > /* oops, now "fixing" test_before can cause test_after to fail! */ > > > function_being_tested(); > > > } > > > > > > Presented like this, the issues are obvious, but it gets a lot more > > > complicated to track down as the amount of test setup and helper > > > functions increases. > > > > > > Another use case is memory corruption. It might not be surfaced as a > > > failure/crash in the test case or suite that caused it. I've noticed in > > > kunit's own unit tests, the 3rd suite after might be the one to finally > > > crash after an out-of-bounds write, for example. > > > > > > Example usage: > > > > > > Per suite: > > > $ ./tools/testing/kunit/kunit.py run --kunitconfig=lib/kunit --run_isolated=suite > > > ... > > > Starting KUnit Kernel (1/7)... > > > ============================================================ > > > ======== [PASSED] kunit_executor_test ======== > > > .... > > > Testing complete. 5 tests run. 0 failed. 0 crashed. 0 skipped. > > > Starting KUnit Kernel (2/7)... > > > ============================================================ > > > ======== [PASSED] kunit-try-catch-test ======== > > > ... > > > > > > Per test: > > > $ ./tools/testing/kunit/kunit.py run --kunitconfig=lib/kunit --run_isolated=test > > > Starting KUnit Kernel (1/23)... > > > ============================================================ > > > ======== [PASSED] kunit_executor_test ======== > > > [PASSED] parse_filter_test > > > ============================================================ > > > Testing complete. 1 tests run. 0 failed. 0 crashed. 0 skipped. > > > Starting KUnit Kernel (2/23)... > > > ============================================================ > > > ======== [PASSED] kunit_executor_test ======== > > > [PASSED] filter_subsuite_test > > > ... > > > > > > It works with filters as well: > > > $ ./tools/testing/kunit/kunit.py run --kunitconfig=lib/kunit --run_isolated=suite example > > > ... > > > Starting KUnit Kernel (1/1)... > > > ============================================================ > > > ======== [PASSED] example ======== > > > ... > > > > > > It also handles test filters, '*.*skip*' runs these 3 tests: > > > kunit_status.kunit_status_mark_skipped_test > > > example.example_skip_test > > > example.example_mark_skipped_test > > > > > > Signed-off-by: Daniel Latypov > > > Reviewed-by: David Gow > > > --- > > > > Thanks -- this version works for me. > > > > I think the requirement that test and suite names contain neither full > > stops nor spaces is a reasonable one. There aren't any current tests > > which would break it, as far as I know. > > I agree. Is this currently codified in the test naming conventions document? https://www.kernel.org/doc/html/latest/dev-tools/kunit/style.html We have Test suites are named after the subsystem they are part of. If a subsystem contains several suites, the specific area under test should be appended to the subsystem name, separated by an underscore. As tests are C functions, they should be named and written in accordance with the kernel coding style. So nothing is explicitly stated for test suites. Just a preference for underscores, sorta implying you shouldn't use spaces or other delimiters like periods. > > -- > You received this message because you are subscribed to the Google Groups "KUnit Development" group. > To unsubscribe from this group and stop receiving emails from it, send an email to kunit-dev+unsubscribe@googlegroups.com. > To view this discussion on the web visit https://groups.google.com/d/msgid/kunit-dev/CAFd5g45qD0H1sO2n-NcgpVKm-QRRBVSHXLyMRr9mmJxKDgpWMw%40mail.gmail.com.