Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp14622imm; Tue, 16 Oct 2018 16:55:39 -0700 (PDT) X-Google-Smtp-Source: ACcGV60vUW8Qtoe3AnZp34bzPf8dhdaXXLAwPSjw4vY+ZGoK1BO3AX8beWez5Hrws9zPBkYPuqRk X-Received: by 2002:a17:902:e08e:: with SMTP id cb14-v6mr23004116plb.196.1539734139719; Tue, 16 Oct 2018 16:55:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539734139; cv=none; d=google.com; s=arc-20160816; b=f1M8s3HdhmRS2NMr5Uh/sCBEQ54fEsuXGkLG/EPiJogvZ+ITcs3UbbegO/fpz6lGOK ZuwNbPlkBP/O58NXhG1s8KKeeUVTCE+JJN1vDDRHoxYZM+cbEyRoj1FGfdws3FNnPFo8 ywatMPgcK5aeHIO9C26zas25YfGpUE87qqIKNxkhU1WzllguwkFaL8z2aL69ZPqCzO4+ jgsxnM8Gkp7spq/XREZVmjE/7/rCyGOS9lsuJvyCTYJzOtvNRHIRxih07YxEonUi7/qh B/+sppOa6iBPaaZvOQ+gtf4qnA6q75XNBxwVCFzSyM0hGrrDRzmsC4jxx6Ci/Tm8GuwL Wk0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:mime-version :message-id:date:dkim-signature; bh=gQdq5fFuo7J9iL+wWi/DYDZLWnOLQeSM2bBV4pqEMaU=; b=Knlpx0AHZaTFKmFzVy5+7oD/6JqyveE+eYX/fhUHOR++HeE/LbtIbKt6OHxwWApK4k cPRPkTmFKxXPKht50rPaqmG0VzulGq/7abm/7ApQROBWK6qo//4wpPmwGJKmrOHUxTCZ DnpsgKAjOTdHBX/GCJyPmC73FwCWzGXi65IA/A16utb5Xh/wMUCNwa5eOE/zg4Cpz9F3 9MApIbWqqUGc/Vm07r+92DUFmdQtH8N6yjSX1VZhr9wnRTgZ/qiSOUWhmOkAqQqQi1oj KEAnE4WmWXipg8JteMyTSUCxoo++AaPpmglZj21vcYrZG2oNyoBakmPOKmauVqk1PxCL 4HxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=u7sM1dfw; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n11-v6si14932480plk.333.2018.10.16.16.55.23; Tue, 16 Oct 2018 16:55:39 -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=pass header.i=@google.com header.s=20161025 header.b=u7sM1dfw; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727289AbeJQHqP (ORCPT + 99 others); Wed, 17 Oct 2018 03:46:15 -0400 Received: from mail-qt1-f202.google.com ([209.85.160.202]:56215 "EHLO mail-qt1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727097AbeJQHqP (ORCPT ); Wed, 17 Oct 2018 03:46:15 -0400 Received: by mail-qt1-f202.google.com with SMTP id 4-v6so25589071qtt.22 for ; Tue, 16 Oct 2018 16:53:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=gQdq5fFuo7J9iL+wWi/DYDZLWnOLQeSM2bBV4pqEMaU=; b=u7sM1dfw3W6YLtoL2O1mN3AkSjvkrHRDFsdiv3JxZ70XRYQo2/vGFQvAcYCK8DPx0B uxahW/Pvcr9RGuWdh29GATWj8ZnxmzHutuM90DLwgn9CTt2QrLn93j4zIwyXInYjYV7I DM1jOBXynBdZQuqKtlRh76DPZ1EPukEZapzU0hq20BAMCl1CApBsrHRdTaEG55I5bBXh 1h48qJV7HWjKvXe5MErtT4ufNipg2YcD0OQYV0AYPnO9rrDXPSoH5LMJhFthGRFSqNOf QoSWFQEh3PQX+JIftNoyKafCvUzcEBzM0mqb34HR458N921ITPegfQn08OKLuwihxjrh +eXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=gQdq5fFuo7J9iL+wWi/DYDZLWnOLQeSM2bBV4pqEMaU=; b=j5X/P/a/7dsEIKuMH0rO2NnV6iIaIpxjoBNeJzqmte/Q6gxfLmU4Rya/MvfG2YTcKI zJh+GtIzYW5IZpe9NJp5A0lVYNptw+IR50WW9V2fPVEs21cEc/ZoE0e+3ZnSY0HSqfX/ NPVZoQzcInc2+R1AKA7IK3P2c2F8MvQ2yenN7uiG+f1mNxxIg+ZjY5+fWuKN6Xl1ZzwS s1RvoC7M1OFgH8SBLv99ISK57OHFmjhGzNF45hsXjtwygWAEjTAdLDGIJyyJSCEPsaXX 0dmBLwZhWC3YsxU2OrR2Lb1jnoiMgqOXKY0ggddogvMzCFR+kUodroxXPn5/JavHJBMC 4bgA== X-Gm-Message-State: ABuFfoh/ot8z+WsAJsDIxH9JgONAdqLzjUeslaywiUtUphf37t1B7Vbx a786u8UhU3h0Clmp6l/0rzsoWI/dN3PUWipqaRfZKg== X-Received: by 2002:aed:23ac:: with SMTP id j41-v6mr18937185qtc.5.1539734006237; Tue, 16 Oct 2018 16:53:26 -0700 (PDT) Date: Tue, 16 Oct 2018 16:50:49 -0700 Message-Id: <20181016235120.138227-1-brendanhiggins@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.19.1.331.ge82ca0e54c-goog Subject: [RFC v1 00/31] kunit: Introducing KUnit, the Linux kernel unit testing framework From: Brendan Higgins To: gregkh@linuxfoundation.org, keescook@google.com, mcgrof@kernel.org, shuah@kernel.org Cc: 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, Brendan Higgins 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 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/ -- 2.19.1.331.ge82ca0e54c-goog