Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp320906pxb; Wed, 20 Oct 2021 23:33:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwGsM59b/dNriPzuUvJO1oLQPBTfQd9xYKiIlgLOB63VyW/HTlFzAtcz/by+SnjBDUKolM3 X-Received: by 2002:a17:907:1c0e:: with SMTP id nc14mr4997653ejc.103.1634797981524; Wed, 20 Oct 2021 23:33:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634797981; cv=none; d=google.com; s=arc-20160816; b=hDoc+RkASm0X6aPOq7ADeIuMMnqv6pP6RRJD4NfZ/d2yNO+WKOWMVFXCVfu1zrqL48 cw78p25mhpucejJ+SNo7PCcaa7Ak5q2/mRE8/O2zGYwcNz2BN6v1ZgO6HlBdsNQKcn+5 e6g1EfQI6Bc5X+jZDBQ+4GNuYo9/4FstBXEBKvhBJwiD9DrWDsHCodc+GbfqBWM/tGhA Rn+B+tRqvk/3M7Ba/CnlWa9rY3J74iQAOV5mJvvds2UFDHH3nYeUQiFtzd7TUgQkOgXD smG0val6y5iGaCoCTZ3F0ZAF9JtsDLazUcLLxPiCHtPJEWk8wKCURTmP4qOQ4Kc4sRi8 nIxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:mime-version:message-id:date :dkim-signature; bh=O4M/tQHIU9ygzYdcq00Cuq5xDfJVENaFvMJsaxgv1Uk=; b=SM4vaeXlGDJWh94aoeZQjdi540pKauRJVHIEeOwulsi1c7q5PLxGF3DDr4Vz/tdiVB zXs2hoz40PL6Wjjgpe0dhsgQVT34/J8dzPGCg+rlHmV30+ckFhDrsJUQC6hu1768jyQz ++oB1hcLba/AIuRALIvXcjNMOfs7xv2ivb5uQorhjbKNXTaexiqw3VOepJxhCc39Aamf 2wvpxkwgrI/KpiMWAyPi96IGo8xB+NCSoOM6Y52u4I+wW7H6wP78dsOJx/X8M/nMR2nw 4/mHsjil1FJu6P3cqFuPY7qUCTlJ6xkj9OGgL8M42QIFOZ5DuHBW3cRbW5hnVwXy7McO o/cw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=e0ZPev5S; 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 r20si5794330edb.270.2021.10.20.23.32.37; Wed, 20 Oct 2021 23:33:01 -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=e0ZPev5S; 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 S231208AbhJUGaw (ORCPT + 99 others); Thu, 21 Oct 2021 02:30:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41108 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229499AbhJUGan (ORCPT ); Thu, 21 Oct 2021 02:30:43 -0400 Received: from mail-qt1-x849.google.com (mail-qt1-x849.google.com [IPv6:2607:f8b0:4864:20::849]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 64C28C06161C for ; Wed, 20 Oct 2021 23:28:27 -0700 (PDT) Received: by mail-qt1-x849.google.com with SMTP id q2-20020a05622a030200b002a7adb98bbfso3876790qtw.14 for ; Wed, 20 Oct 2021 23:28:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:message-id:mime-version:subject:from:to:cc; bh=O4M/tQHIU9ygzYdcq00Cuq5xDfJVENaFvMJsaxgv1Uk=; b=e0ZPev5S1yXkp8gSTDcCadahubPewHibI57BZUd/3J1ij+TLIxPmeJPN+RytbEhNHK YHymvVDt1vDGGQ20g4qMcadvcFgnu8g8fAaTOLhGjhelLaJos4Uv1WwR+4Sepy42UeYf DxX3dNvqQrIZxINaorN98+gqKL0CJBR6GZKztxy2mM54aILe67YT7DrHzetzIgWE+ehH 3hjs8uVS5bSEFOgrROcl/IblOCmhmVFeIWAlKWtr98vw2HNkXYWEWPBgAR1HGAgJXhiO CLUFqum6redfCy5V4zZiDnQXYNK6uflGKXmdmXfWvoSLI+ViXlQ3t2QpOHEvLGUHM11E 9xHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=O4M/tQHIU9ygzYdcq00Cuq5xDfJVENaFvMJsaxgv1Uk=; b=3ymZHW5lxWOGcrZw5RCzr0Uq0sNS7hGYcIfBc2/dglsHo46wjlzixjzLsN9yawOyHY xIn+8ZpitsQo+RuS8Mxynf1g/O40A0wIImw/wnNjOITPGCQOu83zjZhd04PSOA28mHeV TxSwCnbR3s0xovDit+CHm5Nr9/34MUeexbSJnIaZD65uo5DyEuzz9qlm/zxhhBIxB181 Z+xYC7kmCEzv25cfxDjVmCMkg+vuLBIlXuhC3KcIrVmk2DjvJXjOlma/OwGWFSkiIKyO psZeLw+gwBYo/mQpRTldiTGv3Ijob9wpN+slfc/mdsW7weKbkrg3SpqSgy+wVYhEHX+q jXdw== X-Gm-Message-State: AOAM531n3kMJ3JqGFZwCu1uwFJh+hZJ2G0BIuLpACDoGp626N4p2n9kL gJ5d42jTz3aaTKOGO1gMVdC8GcflPepzYA== X-Received: from spirogrip.svl.corp.google.com ([2620:15c:2cb:201:1200:8c8:2819:6ab9]) (user=davidgow job=sendgmr) by 2002:a05:622a:1195:: with SMTP id m21mr4023056qtk.96.1634797706584; Wed, 20 Oct 2021 23:28:26 -0700 (PDT) Date: Wed, 20 Oct 2021 23:28:18 -0700 Message-Id: <20211021062819.1313964-1-davidgow@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.33.0.1079.g6e70778dc9-goog Subject: [PATCH 1/2] kunit: tool: Do not error on tests without test plans From: David Gow To: Brendan Higgins , Rae Moar , Daniel Latypov , Shuah Khan Cc: David Gow , kunit-dev@googlegroups.com, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The (K)TAP spec encourages test output to begin with a 'test plan': a count of the number of tests being run of the form: 1..n However, some test suites might not know the number of subtests in advance (for example, KUnit's parameterised tests use a generator function). In this case, it's not possible to print the test plan in advance. kunit_tool already parses test output which doesn't contain a plan, but reports an error. Since we want to use nested subtests with KUnit paramterised tests, remove this error. Signed-off-by: David Gow --- tools/testing/kunit/kunit_parser.py | 5 ++--- tools/testing/kunit/kunit_tool_test.py | 5 ++++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/tools/testing/kunit/kunit_parser.py b/tools/testing/kunit/kunit_parser.py index 3355196d0515..50ded55c168c 100644 --- a/tools/testing/kunit/kunit_parser.py +++ b/tools/testing/kunit/kunit_parser.py @@ -340,8 +340,8 @@ def parse_test_plan(lines: LineStream, test: Test) -> bool: """ Parses test plan line and stores the expected number of subtests in test object. Reports an error if expected count is 0. - Returns False and reports missing test plan error if fails to parse - test plan. + Returns False and sets expected_count to None if there is no valid test + plan. Accepted format: - '1..[number of subtests]' @@ -356,7 +356,6 @@ def parse_test_plan(lines: LineStream, test: Test) -> bool: match = TEST_PLAN.match(lines.peek()) if not match: test.expected_count = None - test.add_error('missing plan line!') return False test.log.append(lines.pop()) expected_count = int(match.group(1)) diff --git a/tools/testing/kunit/kunit_tool_test.py b/tools/testing/kunit/kunit_tool_test.py index 9c4126731457..bc8793145713 100755 --- a/tools/testing/kunit/kunit_tool_test.py +++ b/tools/testing/kunit/kunit_tool_test.py @@ -191,7 +191,10 @@ class KUnitParserTest(unittest.TestCase): result = kunit_parser.parse_run_tests( kunit_parser.extract_tap_lines( file.readlines())) - self.assertEqual(2, result.test.counts.errors) + # A missing test plan is not an error. + self.assertEqual(0, result.test.counts.errors) + # All tests should be accounted for. + self.assertEqual(10, result.test.counts.total()) self.assertEqual( kunit_parser.TestStatus.SUCCESS, result.status) -- 2.33.0.1079.g6e70778dc9-goog