Received: by 2002:ac0:aa62:0:0:0:0:0 with SMTP id w31-v6csp349225ima; Wed, 24 Oct 2018 02:16:12 -0700 (PDT) X-Google-Smtp-Source: AJdET5d4kjRProEgJGTs36Bs0DKkKWXSqkPkfxdiU/7uD2mUXs6UhBaMgzi9nHq/G4ZMIpMiE96z X-Received: by 2002:a62:5016:: with SMTP id e22-v6mr1911383pfb.30.1540372572074; Wed, 24 Oct 2018 02:16:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540372572; cv=none; d=google.com; s=arc-20160816; b=I5IJKj2uUsxFRMOEORGVxj6Mr2YqjuUPFsR6c0MXH2dCMqs1amAJ2ka05N1yqpHSRK JjBbRBk6iziT0a12RTl9kdCfAKLMN9qgZu2AC4DHMAE3RSlutb8L4yKD6tBgA4PMFhcM lap8CRKMJOkWt2jFXzIIQmT5tPi2+ocrrNwofDTb27Msp0f7Oo/xPFmKFvtX87zhlVR3 cI9TeLVcNlbnO0TD8eU/L03GtYZkp/viNuKIkjXhhZJFW6ryPC9QgyuPuGA+m1wgH9VE XLJwTA2zFgpyRPvTCEO2UBN1cPobBVAx3JBYElhMDJpbCz9PJnoJXiVi/o8JKB8a2p0c 9nlw== 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:mail-followup-to :message-id:subject:cc:to:from:date:dkim-signature; bh=Rll5fRjdmRFE9SuJ9NXDroqWqJU9sfTs/EaQEL0iybE=; b=ovl/xKq26ysA7kR6BC/TKVtolJ5cQtiu0m0xTEnNr/gzgzzHOHTQvIQSuWNxRJhRtF pTSQpW8n8SRkybPtF6HQ6yNpQuE3RvPWGI7Msf/P4osZZhc1mP2myDG9q9KWXRSf4iH8 ams7VKiLkL2YLgOfAJpdjYgibiJ3akxLC0cZRQkNNefAdXu0f7aSf4aPKJZkE3acF+zX opKv9GL9RwLPFpkzcEOaRNVr+yutAAtpGC4AOcn8UKCbxz+olzg9B6iZpMqnKAn1Cjnp 50x044HoEAH0MkqzMAz9KrlWybB19h40xiIiswjT45couS9XfUhVaVvUzPOCBuSU3QnA 97zQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@ffwll.ch header.s=google header.b=B+Ih6l3B; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w22-v6si1076282pgk.214.2018.10.24.02.15.55; Wed, 24 Oct 2018 02:16:12 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@ffwll.ch header.s=google header.b=B+Ih6l3B; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727874AbeJXRmM (ORCPT + 99 others); Wed, 24 Oct 2018 13:42:12 -0400 Received: from mail-ed1-f67.google.com ([209.85.208.67]:41412 "EHLO mail-ed1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726256AbeJXRmM (ORCPT ); Wed, 24 Oct 2018 13:42:12 -0400 Received: by mail-ed1-f67.google.com with SMTP id x31-v6so4312635edd.8 for ; Wed, 24 Oct 2018 02:14:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=sender:date:from:to:cc:subject:message-id:mail-followup-to :references:mime-version:content-disposition:in-reply-to:user-agent; bh=Rll5fRjdmRFE9SuJ9NXDroqWqJU9sfTs/EaQEL0iybE=; b=B+Ih6l3Bihp1w/AiucB+nR7l2NAkAXqODlTecCLDhGQO7uhbVf2hb+rzCdoH8+rZEQ ozN+WOUnovPJwV4e0wcqqhlc3yn0bgTmCbXPWkmiofzDPsGVx/BQo3clLcNdn2PtBmLj hIhsrdjRxCZMn6f7VXy0abJt2NLxmg1MKsgJo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :in-reply-to:user-agent; bh=Rll5fRjdmRFE9SuJ9NXDroqWqJU9sfTs/EaQEL0iybE=; b=tjVpCzG4cF7aV7h8/8kHt3f65v0H5pvB7m+X8LBs8PPYVjwAAQf9ZbNUKktcsu4581 0qnZBnGP4rdAHzzBznJbkArICNiWpNMer0g5roDmh4hkxclR2gTk1HUtjAyFYRPB5kWF Z1nM1X0EKaQRQAEprHxoyPEX+HmvO5Oxn/xDzgtT9J3XHXgLS+AR85iXupWNDoDsEYoL dH2ag+u0lXw3b6FfCB1WAnmhl5p6Qm7kxmY92wJgGcaSizPuTkusLrafdBsIPVwuANhU GNI80jWQoF/d9YRyBO/4ccLOqHyHwW2myEkxmyBM+7iGUo8NjLgSWDgGUeZuBSWNxmcD cfvQ== X-Gm-Message-State: AGRZ1gJv3Yhe6xbNAPEj9s6djPKRmA7oRuEQeE6Gjg7Q/fwpKXCuGMKu XH5pQRUM2ejHmHR2lNKsSuM6Wg== X-Received: by 2002:a17:906:454:: with SMTP id e20-v6mr936856eja.167.1540372492540; Wed, 24 Oct 2018 02:14:52 -0700 (PDT) Received: from phenom.ffwll.local ([2a02:168:569e:0:3106:d637:d723:e855]) by smtp.gmail.com with ESMTPSA id p13-v6sm867903ejg.57.2018.10.24.02.14.50 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 24 Oct 2018 02:14:51 -0700 (PDT) Date: Wed, 24 Oct 2018 11:14:49 +0200 From: Daniel Vetter To: Brendan Higgins Cc: gregkh@linuxfoundation.org, keescook@google.com, mcgrof@kernel.org, shuah@kernel.org, joel@jms.id.au, mpe@ellerman.id.au, joe@perches.com, brakmo@fb.com, rostedt@goodmis.org, Tim.Bird@sony.com, khilman@baylibre.com, julia.lawall@lip6.fr, linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com, linux-kernel@vger.kernel.org, jdike@addtoit.com, richard@nod.at, linux-um@lists.infradead.org, daniel@ffwll.ch, dri-devel@lists.freedesktop.org, robh@kernel.org, dan.j.williams@intel.com, linux-nvdimm@lists.01.org, kieran.bingham@ideasonboard.com Subject: Re: [RFC v2 00/14] kunit: introduce KUnit, the Linux kernel unit testing framework Message-ID: <20181024091449.GL324@phenom.ffwll.local> Mail-Followup-To: Brendan Higgins , gregkh@linuxfoundation.org, keescook@google.com, mcgrof@kernel.org, shuah@kernel.org, joel@jms.id.au, mpe@ellerman.id.au, joe@perches.com, brakmo@fb.com, rostedt@goodmis.org, Tim.Bird@sony.com, khilman@baylibre.com, julia.lawall@lip6.fr, linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com, linux-kernel@vger.kernel.org, jdike@addtoit.com, richard@nod.at, linux-um@lists.infradead.org, dri-devel@lists.freedesktop.org, robh@kernel.org, dan.j.williams@intel.com, linux-nvdimm@lists.01.org, kieran.bingham@ideasonboard.com References: <20181023235750.103146-1-brendanhiggins@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181023235750.103146-1-brendanhiggins@google.com> X-Operating-System: Linux phenom 4.18.0-2-amd64 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, Oct 23, 2018 at 04:57:36PM -0700, Brendan Higgins wrote: > This patch set proposes KUnit, a lightweight unit testing and mocking > framework for the Linux kernel. > > Unlike Autotest and kselftest, KUnit is a true unit testing framework; > it does not require installing the kernel on a test machine or in a VM > and does not require tests to be written in userspace running on a host > kernel. Additionally, KUnit is fast: From invocation to completion KUnit > can run several dozen tests in under a second. Currently, the entire > KUnit test suite for KUnit runs in under a second from the initial > invocation (build time excluded). > > KUnit is heavily inspired by JUnit, Python's unittest.mock, and > Googletest/Googlemock for C++. KUnit provides facilities for defining > unit test cases, grouping related test cases into test suites, providing > common infrastructure for running tests, mocking, spying, and much more. > > ## What's so special about unit testing? > > A unit test is supposed to test a single unit of code in isolation, > hence the name. There should be no dependencies outside the control of > the test; this means no external dependencies, which makes tests orders > of magnitudes faster. Likewise, since there are no external dependencies, > there are no hoops to jump through to run the tests. Additionally, this > makes unit tests deterministic: a failing unit test always indicates a > problem. Finally, because unit tests necessarily have finer granularity, > they are able to test all code paths easily solving the classic problem > of difficulty in exercising error handling code. > > ## Is KUnit trying to replace other testing frameworks for the kernel? > > No. Most existing tests for the Linux kernel are end-to-end tests, which > have their place. A well tested system has lots of unit tests, a > reasonable number of integration tests, and some end-to-end tests. KUnit > is just trying to address the unit test space which is currently not > being addressed. > > ## More information on KUnit > > There is a bunch of documentation near the end of this patch set that > describes how to use KUnit and best practices for writing unit tests. > For convenience I am hosting the compiled docs here: > https://google.github.io/kunit-docs/third_party/kernel/docs/ > > ## Changes Since Last Version > > - Updated patchset to apply cleanly on 4.19. > - Stripped down patchset to focus on just the core features (I dropped > mocking, spying, and the MMIO stuff for now; you can find these > patches here: https://kunit-review.googlesource.com/c/linux/+/1132), > as suggested by Rob. > - Cleaned up some of the commit messages and tweaked commit order a > bit based on suggestions. Do you have some example unit tests somewhere? The docs are all neat, but real example helps a lot with the tried&true art of copypasting :-) I'd like to give this a test spin with some of the unit tests we already have in drm. And especially figuring out how we could integrate this with our existing infrastructure. -Daniel -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch