Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3266821ybt; Mon, 22 Jun 2020 20:31:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwIdFf4hNlQreoE/mnpT+l1xYxMO/5gkzzMaIRVrvL1DUTUsG7hrW5PxG1InVUl6gV45x6f X-Received: by 2002:a17:906:7247:: with SMTP id n7mr18410468ejk.105.1592883061172; Mon, 22 Jun 2020 20:31:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592883061; cv=none; d=google.com; s=arc-20160816; b=tilazuWsA4gBXbj3jO8DbBX0DaWL7DWFIxcfPn6dEjMQUDXzzcoex24qVcXT7cyE2X 33jyhbZ7p6ZNzBotWlc5UvPPBa1qUeEVPu3knnbtInLrcBjfhqrSv61n46aoNE5JvQtV d5lIepf4ktjpAkvsccAiUdcglHyuat9kTBTdUNm6slK7vlPrFBErv+4TsEXZimKf2fLl UH7t1pADFHFoORJW5BcbGXDUMDySSGPOJc5ZKGF0PpCy+srAM1Mfv6mWjbwF95w5JQm1 6pO4EFTYgVUDxJLIvv5mck06dRVGruwyTVcc5bZ2aqhvSyHGKVIr08QR9nmAsRUI7uLn JfwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=nO5X8az1iZdZpQgcucoRmbtaCiu8/dHvR/vuZisbGbg=; b=Emn6ag1yg9qcBtFik7QCSM2wOKLTFj6/IjiUAT7F5c1ecID/kOfibAzakKJiCyRs8o vrMIq+Bh023FUZmgR8F5Zq33oEIv/0PQcs1Prd/Lc4yhaUsd9ZcMhAEQcnMnPrmM9JjH X6yOgJiUFuI0w7HIV8NE96DhtynBci+I9xTwLEnx6oVypMpAYDJmmUIj6IKxbk9QpBZ5 +jBBH1t2/BliIVH5NvcxhDQ3Dg7jJRyRAVSKEufeR+HVHfgqglGCuLs03nqmDanzQC8c JsXybwLQR5WYDtFpERmB5JwxmyngC5/IzpNtlXRqjR6Nu3HemuWrLvhSyfcA7C5oHMN3 4x8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="ZWus7F/w"; 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 cx9si2621524ejb.25.2020.06.22.20.30.38; Mon, 22 Jun 2020 20:31: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=20161025 header.b="ZWus7F/w"; 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 S1731617AbgFWCrK (ORCPT + 99 others); Mon, 22 Jun 2020 22:47:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730456AbgFWCrJ (ORCPT ); Mon, 22 Jun 2020 22:47:09 -0400 Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4ED5DC061795 for ; Mon, 22 Jun 2020 19:47:08 -0700 (PDT) Received: by mail-wm1-x342.google.com with SMTP id t194so1602122wmt.4 for ; Mon, 22 Jun 2020 19:47:08 -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=nO5X8az1iZdZpQgcucoRmbtaCiu8/dHvR/vuZisbGbg=; b=ZWus7F/wJ5uGQya+5s5/T0SJ/pHOu6ysTi808P3JHesr4MkDHHBWSCTZWZHhFAWQ0i kiHYEDyZOdgN48Iu28wFy9/I8HN9OM6RVX8iQqkDdzJtBB3iFmeipxarIHkTfvpaY3UM C6NViwBAby8Ca5tt4udkIHQOtMSDHmwOzLD/Fqt123GRK+QyK5cmcbZ6zV8n/+jiTJDv 13D0YgnXySUirtY5wstCyg58sFZRXMVEhP+zam4kEMdP7N0gS35N3Ogg/VkF+lXGwX8N zAD5YuVZSsrKDoZHsEX6Ai2+60GP6zXJl+tT5Obi3yeL9N4d7jTcg3QILNc4Z7ZAJcDf OHgA== 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=nO5X8az1iZdZpQgcucoRmbtaCiu8/dHvR/vuZisbGbg=; b=BQJalAmcAwvlS/hT8dheuIsVLcS0hVIHbY5fhf0x24CgOa9kbc1o5geTrnwHcXYlQQ g31IluQwYHVk8lPEOQeJQ23AJIhM8qOkQB9h1Zg8KNizWh4FsR5a+pSUvOyKUKmC65bk SeBjX/w+MmCZx9Sj1iRsYiIbPjzVrfglUFb/t67m0TZN6dBuyW18V9vo5YiOYlGI7ifT QZNAcLLoqghLAnDufIZqpBV6KgjMrdzSZ7tS1jtXeuLnxpgkVvyDnn2yoarNl5o6N7et cv+1ilOTUBtTu1V2efiXyCWC79jLK3eaK7CAotMIsoexVbxDp1BQSHZuAm3jHxGhGNyL tphg== X-Gm-Message-State: AOAM530tghK7vxY2FN0vdv88uhELvEYVeqmWx0RhmB/ZBP2ZccYpiOAZ Ap9FslKPySK6ivB2MVX1NpBHFJzdK5o8Vi35x2iaKQ== X-Received: by 2002:a1c:750e:: with SMTP id o14mr21195505wmc.86.1592880426707; Mon, 22 Jun 2020 19:47:06 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: David Gow Date: Tue, 23 Jun 2020 10:46:54 +0800 Message-ID: Subject: Re: RFC: KTAP documentation - expected messages To: Frank Rowand Cc: "Bird, Tim" , "shuah@kernel.org" , "linux-kselftest@vger.kernel.org" , Brendan Higgins , Kees Cook , Paolo Bonzini , "linux-kernel@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 22, 2020 at 6:45 AM Frank Rowand wrote: > > Tim Bird started a thread [1] proposing that he document the selftest result > format used by Linux kernel tests. > > [1] https://lore.kernel.org/r/CY4PR13MB1175B804E31E502221BC8163FD830@CY4PR13MB1175.namprd13.prod.outlook.com > > The issue of messages generated by the kernel being tested (that are not > messages directly created by the tests, but are instead triggered as a > side effect of the test) came up. In this thread, I will call these > messages "expected messages". Instead of sidetracking that thread with > a proposal to handle expected messages, I am starting this new thread. Thanks for doing this: I think there are quite a few tests which could benefit from something like this. I think there were actually two separate questions: what do we do with unexpected messages (most of which I expect are useless, but some of which may end up being related to an unexpected test failure), and how to have tests "expect" a particular message to appear. I'll stick to talking about the latter for this thread, but even there there's two possible interpretations of "expected messages" we probably want to explicitly distinguish between: a message which must be present for the test to pass (which I think best fits the "expected message" name), and a message which the test is likely to produce, but which shouldn't alter the result (an "ignored message"). I don't see much use for the latter at present, but if we wanted to do more things with messages and had some otherwise very verbose tests, it could potentially be useful. The other thing I'd note here is that this proposal seems to be doing all of the actual message filtering in userspace, which makes a lot of sense for kselftest tests, but does mean that the kernel can't know if the test has passed or failed. There's definitely a tradeoff between trying to put too much needless string parsing in the kernel and having to have a userland tool determine the test results. The proposed KCSAN test suite[1] is using tracepoints to do this in the kernel. It's not the cleanest thing, but there's no reason KUnit or similar couldn't implement a nicer API around it. [1]: https://lkml.org/lkml/2020/6/22/1506 > I implemented an API for expected messages that are triggered by tests > in the Devicetree unittest code, with the expectation that the specific > details may change when the Devicetree unittest code adapts the KUnit > API. It seems appropriate to incorporate the concept of expected > messages in Tim's documentation instead of waiting to address the > subject when the Devicetree unittest code adapts the KUnit API, since > Tim's document may become the kernel selftest standard. Is having a nice way to handle expected messages the only thing holding up porting this to KUnit? > Instead of creating a very long email containing multiple objects, > I will reply to this email with a separate reply for each of: > > The "expected messages" API implemention and use can be from > drivers/of/unittest.c in the mainline kernel. > > of_unittest_expect - A proof of concept perl program to filter console > output containing expected messages output > > of_unittest_expect is also available by cloning > https://github.com/frowand/dt_tools.git > > An example raw console output with timestamps and expect messages. > > An example of console output processed by filter program > of_unittest_expect to be more human readable. The expected > messages are not removed, but are flagged. > > An example of console output processed by filter program > of_unittest_expect to be more human readable. The expected > messages are removed instead of being flagged. Cheers, -- David