Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp3096389ybz; Mon, 27 Apr 2020 09:53:58 -0700 (PDT) X-Google-Smtp-Source: APiQypIgJICwWHhp31sBw/bOGJAgLOeaUFNZPQ7iby3UxfaGoJy5mIV4MB2B3+lbIeHNc+1DWIlM X-Received: by 2002:a50:e8c7:: with SMTP id l7mr18761028edn.309.1588006438668; Mon, 27 Apr 2020 09:53:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588006438; cv=none; d=google.com; s=arc-20160816; b=UHw6f0Pt76e2FRNIbhtjI5FzhfXralDdE+iwRal85HYxxo3ngW3r5t61oQ188rTfRo TkUl1v1oEW4lf6w4i6K0s656xwkLeiyB3leeNwViS6Vz7mXsYwP6euWmvw6ZHj3J/s6W rgCmMEEFd417F4hIqEx755bSYEpxXBNBOeHI86Eai/OjQhw5WAu0/Br7xqe+Kh/ZlYYw EQPDRMMJtdZPahgFB8J0Uosvgle7JKOc0CEvl6E0D/jdhc47RClRQDR+ech5neAOGFoS fguAAZumbduidrFhrbMkVNybS2qVXic2LNWfy7EKYZX4DxlRnp4Hm5+x5fTGAgXbN9OC jRvw== 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:reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=OtBcOYsWExj6TGSE8Lx2l+3BYV0OL+MKS6AIwQ7aHxA=; b=SwiIS+1BX5B7wh+uNGAeHzkC/+GXtB9w/bEkNXOG5KOCRVNbjz3YEwHzQni6wZgM8J M6EAsFD33w6YWR9XVbSK7Rj3DBl7mOC1REnQfmkmliDMYCv+C6sSVuOdNjxDVQZsCXKE R0eqW8hly43LSEX++4VwyoZCOeQrFKxO0PzO9bkMmJkQwjLT7NSlG5sdqIYgKOF+EiSB /QL0ZnzN09ovILYlyYaZlH7W2C6UKyDlstxQlZNa4iTrQgynxtpAVtIe28j+lT46lkyJ SGSwFcBny02Kex6XiBTv6TWiPkXLWptFwNIlshfMjWLeJQ0lOc6gmROmrIDf0ej2DENm 7KfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=c+phBkdh; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q25si83832ejb.274.2020.04.27.09.53.35; Mon, 27 Apr 2020 09:53:58 -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=@kernel.org header.s=default header.b=c+phBkdh; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726328AbgD0Qtc (ORCPT + 99 others); Mon, 27 Apr 2020 12:49:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:33756 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726248AbgD0Qtc (ORCPT ); Mon, 27 Apr 2020 12:49:32 -0400 Received: from paulmck-ThinkPad-P72.home (50-39-105-78.bvtn.or.frontiernet.net [50.39.105.78]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9BEEA2080C; Mon, 27 Apr 2020 16:49:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588006171; bh=cGK5USlSVI+WhkX1qfyNm4MqOaOFLQJLMbJ62b/4oxw=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=c+phBkdhzVE7i8QZOqE9Lpni6t77kp2t6FsLoNiBQeUaJzZNOaZlVsbW5JgxNKZCH ZRDgkXaMBYAL1pfVLpuQcrPgnvzEyj6cE0m3k0Lp+m8TMOOIU7d2wZePBbeb7t+Kfp F4at1xkQo/c3W1K96x7BMBDuzYyyd3CTsCPzEgz8= Received: by paulmck-ThinkPad-P72.home (Postfix, from userid 1000) id 753AE35226DB; Mon, 27 Apr 2020 09:49:31 -0700 (PDT) Date: Mon, 27 Apr 2020 09:49:31 -0700 From: "Paul E. McKenney" To: Marco Elver Cc: kunit-dev@googlegroups.com, Brendan Higgins , Dmitry Vyukov , Alexander Potapenko , Andrey Konovalov , kasan-dev , LKML Subject: Re: [PATCH] kcsan: Add test suite Message-ID: <20200427164931.GF7560@paulmck-ThinkPad-P72> Reply-To: paulmck@kernel.org References: <20200427143507.49654-1-elver@google.com> <20200427153744.GA7560@paulmck-ThinkPad-P72> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Apr 27, 2020 at 06:43:21PM +0200, Marco Elver wrote: > On Mon, 27 Apr 2020 at 17:37, Paul E. McKenney wrote: > > > > On Mon, Apr 27, 2020 at 05:23:23PM +0200, Marco Elver wrote: > > > On Mon, 27 Apr 2020 at 16:35, Marco Elver wrote: > > > > > > > > This adds KCSAN test focusing on behaviour of the integrated runtime. > > > > Tests various race scenarios, and verifies the reports generated to > > > > console. Makes use of KUnit for test organization, and the Torture > > > > framework for test thread control. > > > > > > > > Signed-off-by: Marco Elver > > > > --- > > > > > > +KUnit devs > > > We had some discussions on how to best test sanitizer runtimes, and we > > > believe that this test is what testing sanitizer runtimes should > > > roughly look like. Note that, for KCSAN there are various additional > > > complexities like multiple threads, and report generation isn't > > > entirely deterministic (need to run some number of iterations to get > > > reports, may get multiple reports, etc.). > > > > > > The main thing, however, is that we want to verify the actual output > > > (or absence of it) to console. This is what the KCSAN test does using > > > the 'console' tracepoint. Could KUnit provide some generic > > > infrastructure to check console output, like is done in the test here? > > > Right now I couldn't say what the most useful generalization of this > > > would be (without it just being a wrapper around the console > > > tracepoint), because the way I've decided to capture and then match > > > console output is quite test-specific. For now we can replicate this > > > logic on a per-test basis, but it would be extremely useful if there > > > was a generic interface that KUnit could provide in future. > > > > > > Thoughts? > > > > What I do in rcutorture is to run in a VM, dump the console output > > to a file, then parse that output after the run completes. For example, > > the admittedly crude script here: > > > > tools/testing/selftests/rcutorture/bin/parse-console.sh > > That was on the table at one point, but discarded. We debated when I > started this if I should do module + script, or all as one module. > Here is some of the reasoning we went through, just for the record: > > We wanted to use KUnit, to be able to benefit from all the > infrastructure it provides. Wanting to use KUnit meant that we cannot > have a 2-step test (module + script), because KUnit immediately prints > success/fail after each test-case and doesn't run any external scripts > (AFAIK). There are several benefits to relying on KUnit, such as: > 1. Common way to set up and run test cases. No need to roll our own. > 2. KUnit has a standardized way to assert, report test status, > success, etc., which can be parsed by CI systems > (https://testanything.org). > 3. There are plans to set up KUnit CI systems, that just load and run > all existing KUnit tests on boot. The sanitizer tests can become part > of these automated test runs. > 4. If KUnit eventually has a way to check output to console, our > sanitizer tests will be simplified even further. > > The other argument is that doing module + script is probably more complex: > 1. The test would have to explicitly delimit test cases in a custom > way, which a script could then extract. > 2. We need to print the function names, and sizes + addresses of the > variables used in the races, to then be parsed by the script, and > finally match the access information. > 3. Re-running the test without shutting down the system would require > clearing the kernel log or some other way to delimit tests. > > We'd still need the same logic, one way or another, to check what was > printed to console. In the end, I came to the conclusion that it's > significantly simpler to just have everything integrated in the > module: > 1. No need to delimit test cases, and parse based on delimiters. Just > check what the console tracepoint last captured. > 2. Can just refer to the functions, and variables directly and no need > to parse this. > 3. Re-running the test works out of the box. > > Therefore, the conclusion is that for the sanitizers this is hopefully > the best approach. Fair enough! Perhaps I should look into KUnit. I don't recommend holding your breath waiting, though, inertia being what it is. ;-) Thanx, Paul