Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp576393ybl; Wed, 4 Dec 2019 07:31:26 -0800 (PST) X-Google-Smtp-Source: APXvYqwoRuMBM6I/jsKrwlGG58JmFa8OGIMRIvilPPPkjZdw1e8LHsl9Z5EpoRr7sHAUyr98+HJx X-Received: by 2002:aca:5a45:: with SMTP id o66mr3118507oib.114.1575473486697; Wed, 04 Dec 2019 07:31:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575473486; cv=none; d=google.com; s=arc-20160816; b=hvLnJe304LYLJWfRdbN8cwc4jRN5xBp+IQpztQGTlAgzjgdrFL1G84pEhiPXOwomyA t/orTG3OMfXoKuJRfP4WUPQG1PzJzRDZGB95wrrcuqnrmXP6DYMEF2GjWbqtCOzCtzJI 9Upb0TyAaoYweEYfSgflTCqlelIDF57rQITSWSyGPPXjaDjcYOHrJWExDKVsANh9+Jx6 kXTqtAzaNYC+m8sPxtDDBQNTCSe5IDqKo2po5NrfWRXrqqoOJd2P2W4geaJeNT8YRQeN 0iVnM6xxMQAV3Jn5JOba3m664uzybuBVcWAAwpYpblBW6+o3tt15gNEffq0TwXrHhfXG cJ4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=FMTka2tq0Ww+f56DW10Z393U8mQlGGQbjP9PPcNcr+w=; b=R6Sk2FXNlWa6tpQnZXGdCM8rsf8iX8iw+RG1d52MZ9bFF98ttSOu7rkoCXalJAhLgo G5rKXCwRvVcXoBYDXBQfzxT+PC1s0CowHaEP0cQEQUKT72Etshfv9aXAe3MDgu3/G+rK eL2L3/yeO51vyDsj1o56NG3ObuX2Ega5HiF2DkLewnmF9mZJjhZ529uzwm2MMkL3RAFi YkVylPVyJunaGiE4/oX3vzHCph9PxujXbVGwFN4ex9G6JS+fpwqlXdK9LX0B3JdqkF/m LkRVUr3kIk3ALTYt8KhenjkqvcLTmEZqosd11bu8DUEZBKE3IGRq5lWaWsEXMgRcxVI2 hueg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2019-08-05 header.b=WJVPmm99; 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=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k19si3390128otr.52.2019.12.04.07.31.14; Wed, 04 Dec 2019 07:31:26 -0800 (PST) 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=@oracle.com header.s=corp-2019-08-05 header.b=WJVPmm99; 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=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728465AbfLDP3t (ORCPT + 99 others); Wed, 4 Dec 2019 10:29:49 -0500 Received: from userp2120.oracle.com ([156.151.31.85]:45898 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728388AbfLDP3s (ORCPT ); Wed, 4 Dec 2019 10:29:48 -0500 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id xB4FO9rZ104465; Wed, 4 Dec 2019 15:28:23 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2019-08-05; bh=FMTka2tq0Ww+f56DW10Z393U8mQlGGQbjP9PPcNcr+w=; b=WJVPmm99RigEZl9a0LBPVFtyqZYrTJwFqlTXmcod8RXlLftr49Uv9irkSqUrLdmaukTw a3zPzMxDapqR7O/aGs0vm2bxmfKXnFfyZm799Hg0VNNWk5lktmcmssdrmL7LMrhtPk+i j0+PaV37PeWLiz/ioIg17so4/8kbIVy+wtnrcv3HgLFWlgXHD2KbjFqVGQsltCWmb5zF xgY0k1nX2YiTIpFqXvl7CB5QwnsQhDFzqa8JPBJtCq4w7fr99vboIDelvWMuQJ31KtKF NVj5QyZ+BFPBdgkIsROK7KNDs4r63wSm5jt0qBth3x4iwHn+IPgOHLX7W5Kguo/MsJKv /g== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 2wkh2rf0b3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 04 Dec 2019 15:28:23 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id xB4FOCdq049750; Wed, 4 Dec 2019 15:28:22 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3020.oracle.com with ESMTP id 2wp20c5wpr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 04 Dec 2019 15:28:22 +0000 Received: from abhmp0005.oracle.com (abhmp0005.oracle.com [141.146.116.11]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id xB4FSJik027653; Wed, 4 Dec 2019 15:28:20 GMT Received: from dhcp-10-175-179-22.vpn.oracle.com (/10.175.179.22) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 04 Dec 2019 07:28:19 -0800 From: Alan Maguire To: brendanhiggins@google.com, linux-kselftest@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kunit-dev@googlegroups.com, keescook@chromium.org, yzaikin@google.com, akpm@linux-foundation.org, yamada.masahiro@socionext.com, catalin.marinas@arm.com, joe.lawrence@redhat.com, penguin-kernel@i-love.sakura.ne.jp, urezki@gmail.com, andriy.shevchenko@linux.intel.com, corbet@lwn.net, davidgow@google.com, adilger.kernel@dilger.ca, tytso@mit.edu, mcgrof@kernel.org, linux-doc@vger.kernel.org, Alan Maguire , Knut Omang Subject: [PATCH v6 linux-kselftest-test 5/6] kunit: allow kunit to be loaded as a module Date: Wed, 4 Dec 2019 15:27:13 +0000 Message-Id: <1575473234-5443-6-git-send-email-alan.maguire@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1575473234-5443-1-git-send-email-alan.maguire@oracle.com> References: <1575473234-5443-1-git-send-email-alan.maguire@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9461 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=3 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1911140001 definitions=main-1912040128 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9461 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=3 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1911140001 definitions=main-1912040128 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Making kunit itself buildable as a module allows for "always-on" kunit configuration; specifying CONFIG_KUNIT=m means the module is built but only used when loaded. Kunit test modules will load kunit.ko as an implicit dependency, so simply running "modprobe my-kunit-tests" will load the tests along with the kunit module and run them. Co-developed-by: Knut Omang Signed-off-by: Knut Omang Signed-off-by: Alan Maguire Reviewed-by: Brendan Higgins --- lib/kunit/Kconfig | 2 +- lib/kunit/Makefile | 4 +++- lib/kunit/test.c | 13 +++++++++++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/lib/kunit/Kconfig b/lib/kunit/Kconfig index 9ebd5e6..065aa16 100644 --- a/lib/kunit/Kconfig +++ b/lib/kunit/Kconfig @@ -3,7 +3,7 @@ # menuconfig KUNIT - bool "KUnit - Enable support for unit tests" + tristate "KUnit - Enable support for unit tests" help Enables support for kernel unit tests (KUnit), a lightweight unit testing and mocking framework for the Linux kernel. These tests are diff --git a/lib/kunit/Makefile b/lib/kunit/Makefile index bc6e5e54..fab5564 100644 --- a/lib/kunit/Makefile +++ b/lib/kunit/Makefile @@ -1,4 +1,6 @@ -obj-$(CONFIG_KUNIT) += test.o \ +obj-$(CONFIG_KUNIT) += kunit.o + +kunit-objs += test.o \ string-stream.o \ assert.o \ try-catch.o diff --git a/lib/kunit/test.c b/lib/kunit/test.c index 87b5cf1..9242f93 100644 --- a/lib/kunit/test.c +++ b/lib/kunit/test.c @@ -486,3 +486,16 @@ void kunit_cleanup(struct kunit *test) } } EXPORT_SYMBOL_GPL(kunit_cleanup); + +static int __init kunit_init(void) +{ + return 0; +} +late_initcall(kunit_init); + +static void __exit kunit_exit(void) +{ +} +module_exit(kunit_exit); + +MODULE_LICENSE("GPL v2"); -- 1.8.3.1