From patchwork Mon Aug 12 18:24:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brendan Higgins X-Patchwork-Id: 11090541 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 31974112C for ; Mon, 12 Aug 2019 18:25:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 234792842E for ; Mon, 12 Aug 2019 18:25:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1630420CCF; Mon, 12 Aug 2019 18:25:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 951552842E for ; Mon, 12 Aug 2019 18:25:19 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 0E9802130C4A1; Mon, 12 Aug 2019 11:27:39 -0700 (PDT) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2607:f8b0:4864:20::54a; helo=mail-pg1-x54a.google.com; envelope-from=3da9rxq4kdkidtgpfcpjkiikpuiqqing.eqonkpwz-pxfkoonkuvu.cd.qti@flex--brendanhiggins.bounces.google.com; receiver=linux-nvdimm@lists.01.org Received: from mail-pg1-x54a.google.com (mail-pg1-x54a.google.com [IPv6:2607:f8b0:4864:20::54a]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id A7F152130C4B7 for ; Mon, 12 Aug 2019 11:27:37 -0700 (PDT) Received: by mail-pg1-x54a.google.com with SMTP id a21so58204142pgv.0 for ; Mon, 12 Aug 2019 11:25:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=pX6n91rvue//sk8KO1IpvJt6DpxeU7XjD76CqyTGWp0=; b=PW4wL0bO2zcWaoW4VBI+xUgymp8BzlRorRZ+4kMiTvtbMOXu4CD6+Vhkx3f7bIyn/l pLsw0gbsjZuAKYtYbirskoMed9WDPp4N26shnobQwJEEq3q1lig6Emt7qj/0bZwhdDKk 88FASD4I+idci0XrkfHmSS8lrSGKqadp8a9AtZCcm+VZErjUDs5glJekR2PNCX5IJ7N8 SNBgmjQb7SJElKH7SGzpwvEF2+Z9W7tChui3P0v2V2IXpzNSwi985Csmo/JsWAtoyqvD nHY5JCNtmNMBiG64ZXFD8aaZ0O9rvT9/YK/Dsx7Uk1i808geGclqDhjGxosbnvpda03E fbeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=pX6n91rvue//sk8KO1IpvJt6DpxeU7XjD76CqyTGWp0=; b=Pn0LpQSlQA7Zy3HP+fhFwxcVTEehHS0yD9uQUX8bmwDhpPiuK9sT2RhaH/2t1dCeUb h252RAloieLdGNp5MmjgtD+2S9pxP9NsoPrKzqsMC4nVNRokHu3W/QWBJRI4VnPjybo4 xk0aGlczpeadxKGslyxI7YH7JeqtOp5PkEnwGgD8ls+kDU/anI4z6STK9ULvURXwioc1 dUwE0ol81uJMmruBy3P6AkLCsBgcTAjOw7BeU82fzZgCAiqhuVMVPNw5M3h8RRizeHtp gYLRzB128IoayhwJT/yfVPBMknu9cuZfRd85KBrBucFiBUDfay2C3c8AH5WpvBpjTaJr +OKw== X-Gm-Message-State: APjAAAVUgNHIkxBTLtGejKgBjad1KtQ9S+MClmYQyMQQ84HO0b0je/fs C8VmRW+5va5gLcUxHpcrZtWcuwEu282J3KVYjrEzPg== X-Google-Smtp-Source: APXvYqx78NkQYYvJHwOdsQW33ggXQhwmeI4j0d/GB9YOT+8NGxuyiQnom9juCP4EAptKpj7HoOTjDPS38ZkMc0L+89sQAA== X-Received: by 2002:a63:1743:: with SMTP id 3mr30446757pgx.435.1565634317319; Mon, 12 Aug 2019 11:25:17 -0700 (PDT) Date: Mon, 12 Aug 2019 11:24:17 -0700 In-Reply-To: <20190812182421.141150-1-brendanhiggins@google.com> Message-Id: <20190812182421.141150-15-brendanhiggins@google.com> Mime-Version: 1.0 References: <20190812182421.141150-1-brendanhiggins@google.com> X-Mailer: git-send-email 2.23.0.rc1.153.gdeed80330f-goog Subject: [PATCH v12 14/18] kunit: defconfig: add defconfigs for building KUnit tests From: Brendan Higgins To: frowand.list@gmail.com, gregkh@linuxfoundation.org, jpoimboe@redhat.com, keescook@google.com, kieran.bingham@ideasonboard.com, mcgrof@kernel.org, peterz@infradead.org, robh@kernel.org, sboyd@kernel.org, shuah@kernel.org, tytso@mit.edu, yamada.masahiro@socionext.com X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pmladek@suse.com, linux-doc@vger.kernel.org, amir73il@gmail.com, Brendan Higgins , dri-devel@lists.freedesktop.org, Alexander.Levin@microsoft.com, linux-kselftest@vger.kernel.org, linux-nvdimm@lists.01.org, khilman@baylibre.com, knut.omang@oracle.com, wfg@linux.intel.com, joel@jms.id.au, rientjes@google.com, jdike@addtoit.com, dan.carpenter@oracle.com, devicetree@vger.kernel.org, linux-kbuild@vger.kernel.org, Tim.Bird@sony.com, linux-um@lists.infradead.org, rostedt@goodmis.org, julia.lawall@lip6.fr, kunit-dev@googlegroups.com, richard@nod.at, rdunlap@infradead.org, linux-kernel@vger.kernel.org, daniel@ffwll.ch, mpe@ellerman.id.au, linux-fsdevel@vger.kernel.org Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Virus-Scanned: ClamAV using ClamSMTP Add defconfig for UML and a fragment that can be used to configure other architectures for building KUnit tests. Add option to kunit_tool to use a defconfig to create the kunitconfig. Signed-off-by: Brendan Higgins Reviewed-by: Greg Kroah-Hartman Reviewed-by: Logan Gunthorpe --- arch/um/configs/kunit_defconfig | 8 ++++++ tools/testing/kunit/configs/all_tests.config | 8 ++++++ tools/testing/kunit/kunit.py | 28 +++++++++++++++++--- tools/testing/kunit/kunit_kernel.py | 3 ++- 4 files changed, 42 insertions(+), 5 deletions(-) create mode 100644 arch/um/configs/kunit_defconfig create mode 100644 tools/testing/kunit/configs/all_tests.config diff --git a/arch/um/configs/kunit_defconfig b/arch/um/configs/kunit_defconfig new file mode 100644 index 0000000000000..bfe49689038f1 --- /dev/null +++ b/arch/um/configs/kunit_defconfig @@ -0,0 +1,8 @@ +CONFIG_OF=y +CONFIG_OF_UNITTEST=y +CONFIG_OF_OVERLAY=y +CONFIG_I2C=y +CONFIG_I2C_MUX=y +CONFIG_KUNIT=y +CONFIG_KUNIT_TEST=y +CONFIG_KUNIT_EXAMPLE_TEST=y diff --git a/tools/testing/kunit/configs/all_tests.config b/tools/testing/kunit/configs/all_tests.config new file mode 100644 index 0000000000000..bfe49689038f1 --- /dev/null +++ b/tools/testing/kunit/configs/all_tests.config @@ -0,0 +1,8 @@ +CONFIG_OF=y +CONFIG_OF_UNITTEST=y +CONFIG_OF_OVERLAY=y +CONFIG_I2C=y +CONFIG_I2C_MUX=y +CONFIG_KUNIT=y +CONFIG_KUNIT_TEST=y +CONFIG_KUNIT_EXAMPLE_TEST=y diff --git a/tools/testing/kunit/kunit.py b/tools/testing/kunit/kunit.py index da11bd62a4b82..0944dea5c3211 100755 --- a/tools/testing/kunit/kunit.py +++ b/tools/testing/kunit/kunit.py @@ -11,6 +11,7 @@ import argparse import sys import os import time +import shutil from collections import namedtuple from enum import Enum, auto @@ -21,7 +22,7 @@ import kunit_parser KunitResult = namedtuple('KunitResult', ['status','result']) -KunitRequest = namedtuple('KunitRequest', ['raw_output','timeout', 'jobs', 'build_dir']) +KunitRequest = namedtuple('KunitRequest', ['raw_output','timeout', 'jobs', 'build_dir', 'defconfig']) class KunitStatus(Enum): SUCCESS = auto() @@ -29,8 +30,16 @@ class KunitStatus(Enum): BUILD_FAILURE = auto() TEST_FAILURE = auto() +def create_default_kunitconfig(): + if not os.path.exists(kunit_kernel.KUNITCONFIG_PATH): + shutil.copyfile('arch/um/configs/kunit_defconfig', + kunit_kernel.KUNITCONFIG_PATH) + def run_tests(linux: kunit_kernel.LinuxSourceTree, request: KunitRequest) -> KunitResult: + if request.defconfig: + create_default_kunitconfig() + config_start = time.time() success = linux.build_reconfig(request.build_dir) config_end = time.time() @@ -72,7 +81,7 @@ def run_tests(linux: kunit_kernel.LinuxSourceTree, else: return KunitResult(KunitStatus.SUCCESS, test_result) -def main(argv, linux): +def main(argv, linux=None): parser = argparse.ArgumentParser( description='Helps writing and running KUnit tests.') subparser = parser.add_subparsers(dest='subcommand') @@ -99,13 +108,24 @@ def main(argv, linux): 'directory.', type=str, default=None, metavar='build_dir') + run_parser.add_argument('--defconfig', + help='Uses a default kunitconfig.', + action='store_true') + cli_args = parser.parse_args(argv) if cli_args.subcommand == 'run': + if cli_args.defconfig: + create_default_kunitconfig() + + if not linux: + linux = kunit_kernel.LinuxSourceTree() + request = KunitRequest(cli_args.raw_output, cli_args.timeout, cli_args.jobs, - cli_args.build_dir) + cli_args.build_dir, + cli_args.defconfig) result = run_tests(linux, request) if result.status != KunitStatus.SUCCESS: sys.exit(1) @@ -113,4 +133,4 @@ def main(argv, linux): parser.print_help() if __name__ == '__main__': - main(sys.argv[1:], kunit_kernel.LinuxSourceTree()) + main(sys.argv[1:]) diff --git a/tools/testing/kunit/kunit_kernel.py b/tools/testing/kunit/kunit_kernel.py index 07c0abf2f47df..bf38768353313 100644 --- a/tools/testing/kunit/kunit_kernel.py +++ b/tools/testing/kunit/kunit_kernel.py @@ -14,6 +14,7 @@ import os import kunit_config KCONFIG_PATH = '.config' +KUNITCONFIG_PATH = 'kunitconfig' class ConfigError(Exception): """Represents an error trying to configure the Linux kernel.""" @@ -81,7 +82,7 @@ class LinuxSourceTree(object): def __init__(self): self._kconfig = kunit_config.Kconfig() - self._kconfig.read_from_file('kunitconfig') + self._kconfig.read_from_file(KUNITCONFIG_PATH) self._ops = LinuxSourceTreeOperations() def clean(self):