Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp724063pxb; Thu, 30 Sep 2021 16:07:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwLzq6H+lr6bn1gxWahNDqOATyrccF4d05rNPq1/1CtM18VTeRK1c0TsTNfJf7GoTX1b/rf X-Received: by 2002:a17:90a:c89:: with SMTP id v9mr9260618pja.71.1633043224371; Thu, 30 Sep 2021 16:07:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633043224; cv=none; d=google.com; s=arc-20160816; b=oc5DvLxvOOX36O7hihCkNhxpzIvLeiEqis1jaEOYY2xOgHDUsdyNrWNsRZCI1HPOfu Km50y44ooTv+Au60DTo8I6wshPz6WII+teXP+ipTLADjzUXE+gPTSO2JqVtYdeUjBIy6 cVwDFg5r3joY/nOb3lyApyEXr68upRIrnYhITfKaMBg5cPG6v3J2Ch/0ocaKtIWN7NSl ISmO+voA98MUMhfxS7l1WalzDTF8oJfg4E42nCaS8AZFF1YgWeR2jFVgqvAhaQoQz1DL aMZKq41BmKnxAY7bCA7EBlJRhW5cM+yruu3Gc99f8stMyFgPoZFlepQuir4CuQ8QMvAj 4IwA== 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=/0ppBwTzFJyZU29k8NnFVLUpHHN0JjRi2ilKWlfGyr0=; b=a96fPiSeM13ATzt/fwVMCijFPEOekiyl++J+ioZLvW1hAlArIxiQ+l4dl0iNr3t0b4 sEGDyavBsDqEZAAmpyhdKYkC+GZhCX/RxLdElQBLUCtMdioywOcRfqiRNc13uMsJmxtZ vh4WnEi2nrjc5uYv+NZYVAE8D+96FtikXxFLHFrK7xoMQTzp6vF5rUkJaKPjf+3EZi1C v4E6r0AwMKyVpR6MDsfZrZLYlM0XMa1A5R0XmRVhzN4YiiXNt82NsjhmUFeHZZ8jSsRl uC6gEtwufnQda2t2LtCXARR/vIKKfCDXjAi2sTXB56n3kMRHV80XT42KLs2DQGCZisqu IdRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=m2W5aSaV; 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 b24si2265829pff.321.2021.09.30.16.06.50; Thu, 30 Sep 2021 16:07:04 -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=m2W5aSaV; 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 S230180AbhI3XHK (ORCPT + 99 others); Thu, 30 Sep 2021 19:07:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42532 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230167AbhI3XHJ (ORCPT ); Thu, 30 Sep 2021 19:07:09 -0400 Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A5DE4C06176A for ; Thu, 30 Sep 2021 16:05:23 -0700 (PDT) Received: by mail-wm1-x32c.google.com with SMTP id v127so5831032wme.5 for ; Thu, 30 Sep 2021 16:05:23 -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=/0ppBwTzFJyZU29k8NnFVLUpHHN0JjRi2ilKWlfGyr0=; b=m2W5aSaVDKwfE3FNc+9wDnzbsnXUemJv1W/XOL/bODteZ54AjfeknMIk0XJmaHIXGk IiFldHCpDiSZXB27lktyzl2WdQPvYj3GRqi8aPca+9ZHwQcJmIG5J8FJN0hoAhaVb1k+ naiQmaAMU4RBS1xtI88TWO0YEWcBcRQd9Uginpojd5BDJeMmA9NjJbdeQxKK2sCfQSUn 5MChR5QLV+mKB60e4Q1RLjzDCuDr7HZm1GjYr8l2nOhDnuTm40eF28v517eCMIhPqBYk ZV6hrXHgC/yExiT/3vMJd8W88pibHT05YG3ZLzzvsXjQF9wswSfYciSVljvHFrnhA0ZX 0qEw== 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=/0ppBwTzFJyZU29k8NnFVLUpHHN0JjRi2ilKWlfGyr0=; b=JpbfyIOPqNuBtciEOsKUWoyNOV4VRbuGzdUF6nFuGfbC+/AQYGigtXahE0Jp/tLVKU EKbGDW21ubWwXkJvfCye0ZrifwEZ/L59nqjIs+NiNHbghh2AoPT+FhnLZ0JnQSEBZdBo iVnNfu/6vjjTS9xWJw3qu98ciai3COxjgCBVMFlw3NzZtR9ZH94AohXtsLcfyZOS1Nxm I7HupRcwVBYK5D/26B9Com8vhGBgHB5ok+jjGkpimTU7eL4bx27/TJr2S9MJ007lCHq5 kwd3FJPoUWslbMhuYSW6zJ13uzm7A/UGtkpZnzwo8TfOHSTDcQUdXLiFb6cYHpVzSMHQ gl0g== X-Gm-Message-State: AOAM530Bfs961oZQ2OAdAzwAh/iphjjeGD0LI7U2K/U48wIhToHHYPUW dOOOfXfBBHX+Hza3teBJGeWUDaa5qIky00LwVTNZ1g== X-Received: by 2002:a7b:c453:: with SMTP id l19mr1390669wmi.7.1633043121905; Thu, 30 Sep 2021 16:05:21 -0700 (PDT) MIME-Version: 1.0 References: <20210930222048.1692635-1-dlatypov@google.com> <20210930222048.1692635-5-dlatypov@google.com> In-Reply-To: <20210930222048.1692635-5-dlatypov@google.com> From: David Gow Date: Fri, 1 Oct 2021 07:05:10 +0800 Message-ID: Subject: Re: [PATCH v4 4/4] kunit: tool: support running each suite/test separately To: Daniel Latypov Cc: Brendan Higgins , 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 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. Cheers, -- David