Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp391393ybt; Wed, 24 Jun 2020 01:43:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyCX2pY2EL/21KcBwXK+VYGJ00zr8XDd8yG5qni7pcsWjrL89C0tOFML3JLA3WrKiCdDRVy X-Received: by 2002:a17:906:fcba:: with SMTP id qw26mr10830318ejb.112.1592988211048; Wed, 24 Jun 2020 01:43:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592988211; cv=none; d=google.com; s=arc-20160816; b=b+Y+SclDE0PCkYRU2DxWKrpKfAllN5vCCXdjA2243CQDTarZPixoEOzV6H0AhylImN BVxuF0VL75TxGJmxy4llWYh5dW0JTMBycjw99+Y2O0H8u/Buctogs4ETKHtvCrE+DV+8 MIOwcTgV6EStBzgFnrpf9Y6zj6BfC+jYLw+Ju2PENvOtq1YqSOvMQnovoAEfcCwcEiLn dpA+kk8sKP/6/9iraw6oHtVSplR3ijwicWCI/Dif1QQMcbp5y8S+1ASPRfUNlreqBXVN C8Pj58xSHdzrTY9X0A9G5vw87+HyWd1t10AwcP2AhjxIfhcQqRfdqjVEuMj8XWdVTfwU B50w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=xIB5GGb/vEHtVFf6OhkKlOA+uqEuKDZA3z0jMJd45Os=; b=IH0bKY1fz75tujGnIVoo5rBkQjE9/Ti0xKWwwQB+q+MhWC+QZM5mrJioS/k3KIx0Cv /lpTmeGNoBEGe2AOOUVAkcvVzpvkQTR0cBd0/ZcAxziTbYAi8Is9VOapya/pVVtpnaq1 w9tM3DeHPUCVUlbfp8yDzYxIzyINDhhv8UFXBHAw/zRdUEkzNLQ6axQbHqBCudbALjRA R2QxV2O0VGIj1f4uv0qQRBF05JiP8vsztr79Oiq1rOm5hhlWsKNDN9UYtJ/eG0t9/o/n pjNmTbOy7CI0rrpYx8bpsqy2z4vFl78hygwYNgRgVJloFEhWu0yTm/qnlEbyx4qjDp9b BJMA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y12si13095112edt.9.2020.06.24.01.43.07; Wed, 24 Jun 2020 01:43:31 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389533AbgFXIj6 (ORCPT + 99 others); Wed, 24 Jun 2020 04:39:58 -0400 Received: from mx2.suse.de ([195.135.220.15]:60224 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388836AbgFXIj6 (ORCPT ); Wed, 24 Jun 2020 04:39:58 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id EBB7BAC2E; Wed, 24 Jun 2020 08:39:55 +0000 (UTC) Date: Wed, 24 Jun 2020 10:39:55 +0200 From: Petr Mladek To: Joe Lawrence Cc: Naresh Kamboju , Michael Ellerman , "open list:KERNEL SELFTEST FRAMEWORK" , open list , Kees Cook , Anders Roxell , Daniel =?iso-8859-1?Q?D=EDaz?= , Justin Cook , lkft-triage@lists.linaro.org, Miroslav Benes , Shuah Khan Subject: Re: [PATCH 1/2] selftests/lkdtm: Don't clear dmesg when running tests Message-ID: <20200624083955.GF8444@alley> References: <20200508065356.2493343-1-mpe@ellerman.id.au> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue 2020-06-23 23:48:36, Joe Lawrence wrote: > On 6/22/20 4:51 AM, Naresh Kamboju wrote: > > On Fri, 8 May 2020 at 12:23, Michael Ellerman wrote: > > > > > > It is Very Rude to clear dmesg in test scripts. That's because the > > > script may be part of a larger test run, and clearing dmesg > > > potentially destroys the output of other tests. > > > > > > We can avoid using dmesg -c by saving the content of dmesg before the > > > test, and then using diff to compare that to the dmesg afterward, > > > producing a log with just the added lines. > > > > > > > > > diff --git a/tools/testing/selftests/lkdtm/run.sh b/tools/testing/selftests/lkdtm/run.sh > > > index dadf819148a4..0b409e187c7b 100755 > > > --- a/tools/testing/selftests/lkdtm/run.sh > > > +++ b/tools/testing/selftests/lkdtm/run.sh > > > # Record and dump the results > > > -dmesg -c >"$LOG" > > > +dmesg | diff --changed-group-format='%>' --unchanged-group-format='' "$DMESG" - > "$LOG" || true > > > > We are facing problems with the diff `=%>` part of the option. > > This report is from the OpenEmbedded environment. > > We have the same problem from livepatch_testcases. > > > > # selftests lkdtm BUG.sh > > lkdtm: BUG.sh_ # > > # diff unrecognized option '--changed-group-format=%>' > > unrecognized: option_'--changed-group-format=%>' # > > # BusyBox v1.27.2 (2020-03-30 164108 UTC) multi-call binary. > > v1.27.2: (2020-03-30_164108 # > > # > > : _ # > > # Usage diff [-abBdiNqrTstw] [-L LABEL] [-S FILE] [-U LINES] FILE1 FILE2 > > diff: [-abBdiNqrTstw]_[-L # > > # BUG missing 'kernel BUG at' [FAIL] > > > > Full test output log, > > https://qa-reports.linaro.org/lkft/linux-next-oe/build/next-20200621/testrun/2850083/suite/kselftest/test/lkdtm_BUG.sh/log > > > > D'oh! Using diff's changed/unchanged group format was a nice trick to > easily fetch the new kernel log messages. > > I can't think of any simple alternative off the top of my head, so here's a > kludgy tested-once awk script: > > SAVED_DMESG="$(dmesg | tail -n1)" > ... tests ... > NEW_DMESG=$(dmesg | awk -v last="$SAVED_DMESG" 'p; $0 == last{p=1}') > > I think timestamps should make each log line unique, but this probably won't > handle kernel log buffer overflow. The test would fail anyway if there was log buffer overflow. We could check if the last line was still there and suggest to increase the log buffer size in the error message. > Maybe it would be easier to log a known unique test delimiter msg and then > fetch all new messages after that? The timestamp should be enough to distinguish any message. But some visual separator between each test is useful anyway. And it might include some random string... Best Regards, Petr