Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1420940pxj; Fri, 4 Jun 2021 14:06:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwuEjDc0yk2qVpYSfEQgR8N1oB2CaUce412PnlM+74wkHNrPZG6oF+qZbpMsq9qcoEFoVvX X-Received: by 2002:a05:6402:344:: with SMTP id r4mr6709514edw.226.1622840773822; Fri, 04 Jun 2021 14:06:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622840773; cv=none; d=google.com; s=arc-20160816; b=CEVi8PpZ0JNqBOgzME25p8lKABKaBDDZCE17+FMwJP9F9vVPfBqN+n6K1lLOusWlMx OWPlV78vBZPeVKdZYJr0zWxmYFSxb8xfkjQQJStggGTLYhxTfLoni6snU9TuHIjr4k32 h2CBpWyxUV7ZFj4Ceo8Wbo0YDwmA38ZvvkO2o8IN3Yw3OGlxjoyBLXw6Nk+w+03Zxm+5 I7ZMY9aEcAk+UYC8VhsZbyKV59x29I+bwuSlVvjFg5nz0v9W9qRbvUIjR4pUpvUFaRhj YBvf8En34XSzFeUxiwAZtK6A2YIIvXFJ27i130bLriAZYs+sRENA0yyPexjZuzzCPOI6 PGKA== 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=rDhLv97E2DQUPuoqpwMPEvyKe4QzBUBFor31yGtCwjM=; b=PBs3W/bc5C5FYsBKGo+Gkn5drjxHR8oe7MVLrDtnbJt/FVvavV4lb7sW1Kwj6q4n5X MkBiS/aOKEaGGfA2EmAreC8WEfWo9qM2PgR6oRKGBmccUApgwEM5Yn3d0h7xY3RkSc3x x+747/rfE3GPL812fhLyZPp/6GLziMqXKKdUlK+r+IOdcT1XNK/MeZY02QVHNL1Jhe91 jZeH+mEMpo1gK2zT1AXkYbjV6o13RfohPZoq74dJJKOHP80D7lWegCaaa/X68G+vbU1R H6+AHN08vD5V2ZLWhVCG9HRLHIpX02sS06sq071jd3bZjWULr5xpK8V7TfTyauTzamab 2o8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Q9GyhGWT; 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 bl4si6561577ejb.17.2021.06.04.14.05.49; Fri, 04 Jun 2021 14:06:13 -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=20161025 header.b=Q9GyhGWT; 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 S230177AbhFDVGp (ORCPT + 99 others); Fri, 4 Jun 2021 17:06:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50210 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229906AbhFDVGo (ORCPT ); Fri, 4 Jun 2021 17:06:44 -0400 Received: from mail-pf1-x42a.google.com (mail-pf1-x42a.google.com [IPv6:2607:f8b0:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 11119C061766 for ; Fri, 4 Jun 2021 14:04:58 -0700 (PDT) Received: by mail-pf1-x42a.google.com with SMTP id u126so4348807pfu.13 for ; Fri, 04 Jun 2021 14:04:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=rDhLv97E2DQUPuoqpwMPEvyKe4QzBUBFor31yGtCwjM=; b=Q9GyhGWTAKnh7t7JfYv/78Exr1BZPtx2xBqGF06ejPcRb6rXhZfUPhNV4+D9MPybNV KJ4Nx9EGiZDPPBZSAr9LylkvVYgISv3qERJEZCjO+CddZ22oeaLf6IndtiEVSyCD1WG8 42iZbgT8eqxmEEV2v2HyWU92T21ClG04PB3O14Fl1Gu0xDGDOH2Nj2BNRhEpFXK1Pg8b 1ufNXXMADY0mNfxeK9j2/jIIlZH7O24Fti4VW84oIqLHvTFuk4o3NcaRERM/NNIKuzNh kpmJwMrufjJ67c+k5IzOfTY6nqosTZ8ff8IxBU4fagP8IMEtlSTB04Smnkh7OsLgCpbE yi2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=rDhLv97E2DQUPuoqpwMPEvyKe4QzBUBFor31yGtCwjM=; b=Tr0DY4X4Y8P+HFNmQ1CgiscmwvyGClBAnBHhH6QM4hYzWNfh+Sz2V2CtbcCqfat+Jj TPu2ZOjz3Yc3ZaBK2pDOTq4WtjUXEL0MVen7LTacASrABgjlCu2XOqfk6kJ17HRWhSdw Rqbfll82Hfn8cRnRlk1NzuD+9jmhmBDdGb6BZ+qFlvtHtEQb4tdZtmQk2/b+tDl/72zs ZHmay++wTdShDOOxyZEoNqgN1w9GRT1PrEDa/yDDdhPiKcRdeJAjXNQKGM4eekA8INiC XFcs55BYH5ebd5uDAoVH/hRgHH+5ep7iEHFo5lr7Wk9I83TMiVnxpxYTeabP9RHF7id5 kNGw== X-Gm-Message-State: AOAM530XD8RlH7aRu4Em96LWrzvgvNWzQXrsJbKAoYWxH/KVjp0wMHe7 JLtz6NZEMnOFAx3rkgCFIUQ9G/l0zatKuSafFUdVXg== X-Received: by 2002:a63:1559:: with SMTP id 25mr7006094pgv.384.1622840697130; Fri, 04 Jun 2021 14:04:57 -0700 (PDT) MIME-Version: 1.0 References: <20210528075932.347154-1-davidgow@google.com> In-Reply-To: <20210528075932.347154-1-davidgow@google.com> From: Brendan Higgins Date: Fri, 4 Jun 2021 14:04:45 -0700 Message-ID: Subject: Re: [PATCH v2 1/4] kunit: Support skipped tests To: David Gow Cc: Alan Maguire , Daniel Latypov , Shuah Khan , Marco Elver , KUnit Development , "open list:KERNEL SELFTEST FRAMEWORK" , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, May 28, 2021 at 12:59 AM David Gow wrote: > > The kunit_mark_skipped() macro marks the current test as "skipped", with > the provided reason. The kunit_skip() macro will mark the test as > skipped, and abort the test. > > The TAP specification supports this "SKIP directive" as a comment after > the "ok" / "not ok" for a test. See the "Directives" section of the TAP > spec for details: > https://testanything.org/tap-specification.html#directives > > The 'success' field for KUnit tests is replaced with a kunit_status > enum, which can be SUCCESS, FAILURE, or SKIPPED, combined with a > 'status_comment' containing information on why a test was skipped. > > A new 'kunit_status' test suite is added to test this. > > Signed-off-by: David Gow > Tested-by: Marco Elver > Reviewed-by: Daniel Latypov One fairly minor nit below. Other than that, looks great! Reviewed-by: Brendan Higgins > --- [...] > diff --git a/include/kunit/test.h b/include/kunit/test.h > index b68c61348121..1401c620ac5e 100644 > --- a/include/kunit/test.h > +++ b/include/kunit/test.h > @@ -105,6 +105,18 @@ struct kunit; > #define KUNIT_SUBTEST_INDENT " " > #define KUNIT_SUBSUBTEST_INDENT " " > > +/** > + * enum kunit_status - Type of result for a test or test suite > + * @KUNIT_SUCCESS: Denotes the test suite has not failed nor been skipped > + * @KUNIT_FAILURE: Denotes the test has failed. > + * @KUNIT_SKIPPED: Denotes the test has been skipped. > + */ > +enum kunit_status { > + KUNIT_SUCCESS, > + KUNIT_FAILURE, > + KUNIT_SKIPPED, > +}; > + > /** > * struct kunit_case - represents an individual test case. > * > @@ -148,13 +160,20 @@ struct kunit_case { > const void* (*generate_params)(const void *prev, char *desc); > > /* private: internal use only. */ > - bool success; > + enum kunit_status status; > char *log; > }; > > -static inline char *kunit_status_to_string(bool status) > +static inline char *kunit_status_to_ok_not_ok(enum kunit_status status) > { > - return status ? "ok" : "not ok"; > + switch (status) { > + case KUNIT_SKIPPED: > + case KUNIT_SUCCESS: > + return "ok"; > + case KUNIT_FAILURE: > + return "not ok"; > + } > + return "invalid"; > } > > /** > @@ -212,6 +231,7 @@ struct kunit_suite { > struct kunit_case *test_cases; > > /* private: internal use only */ > + char status_comment[256]; nit: How about we make the 256 a constant since you use it in a number of places? If not, at least when you reference the struct, you might want to use ARRAY_SIZE(...). > struct dentry *debugfs; > char *log; > }; [...]