From: Brendan Higgins <brendanhiggins@google.com> 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 Cc: devicetree@vger.kernel.org, dri-devel@lists.freedesktop.org, kunit-dev@googlegroups.com, linux-doc@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-nvdimm@lists.01.org, linux-um@lists.infradead.org, Alexander.Levin@microsoft.com, Tim.Bird@sony.com, amir73il@gmail.com, dan.carpenter@oracle.com, daniel@ffwll.ch, jdike@addtoit.com, joel@jms.id.au, julia.lawall@lip6.fr, khilman@baylibre.com, knut.omang@oracle.com, logang@deltatee.com, mpe@ellerman.id.au, pmladek@suse.com, rdunlap@infradead.org, richard@nod.at, rientjes@google.com, rostedt@goodmis.org, wfg@linux.intel.com, Brendan Higgins <brendanhiggins@google.com> Subject: [PATCH v15 14/18] kunit: defconfig: add defconfigs for building KUnit tests Date: Fri, 23 Aug 2019 18:34:21 -0700 [thread overview] Message-ID: <20190824013425.175645-15-brendanhiggins@google.com> (raw) In-Reply-To: <20190824013425.175645-1-brendanhiggins@google.com> 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 <brendanhiggins@google.com> Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Reviewed-by: Logan Gunthorpe <logang@deltatee.com> Reviewed-by: Stephen Boyd <sboyd@kernel.org> --- arch/um/configs/kunit_defconfig | 3 +++ tools/testing/kunit/configs/all_tests.config | 3 +++ tools/testing/kunit/kunit.py | 28 +++++++++++++++++--- tools/testing/kunit/kunit_kernel.py | 3 ++- 4 files changed, 32 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 000000000000..9235b7d42d38 --- /dev/null +++ b/arch/um/configs/kunit_defconfig @@ -0,0 +1,3 @@ +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 000000000000..9235b7d42d38 --- /dev/null +++ b/tools/testing/kunit/configs/all_tests.config @@ -0,0 +1,3 @@ +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 da11bd62a4b8..0944dea5c321 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 07c0abf2f47d..bf3876835331 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): -- 2.23.0.187.g17f5b7556c-goog
next prev parent reply other threads:[~2019-08-24 1:35 UTC|newest] Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-08-24 1:34 [PATCH v15 00/18] kunit: introduce KUnit, the Linux kernel unit testing framework Brendan Higgins 2019-08-24 1:34 ` [PATCH v15 01/18] kunit: test: add KUnit test runner core Brendan Higgins 2019-08-24 1:34 ` [PATCH v15 02/18] kunit: test: add test resource management API Brendan Higgins 2019-08-24 1:34 ` [PATCH v15 03/18] kunit: test: add string_stream a std::stream like string builder Brendan Higgins 2019-08-24 1:34 ` [PATCH v15 04/18] kunit: test: add assertion printing library Brendan Higgins 2019-08-24 1:34 ` [PATCH v15 05/18] kunit: test: add the concept of expectations Brendan Higgins 2019-08-24 1:34 ` [PATCH v15 06/18] kbuild: enable building KUnit Brendan Higgins 2019-08-24 1:34 ` [PATCH v15 07/18] kunit: test: add initial tests Brendan Higgins 2019-08-24 1:34 ` [PATCH v15 08/18] objtool: add kunit_try_catch_throw to the noreturn list Brendan Higgins 2019-08-24 1:34 ` [PATCH v15 09/18] kunit: test: add support for test abort Brendan Higgins 2019-08-24 1:34 ` [PATCH v15 10/18] kunit: test: add tests for kunit " Brendan Higgins 2019-08-24 1:34 ` [PATCH v15 11/18] kunit: test: add the concept of assertions Brendan Higgins 2019-08-24 1:34 ` [PATCH v15 12/18] kunit: test: add tests for KUnit managed resources Brendan Higgins 2019-08-24 1:34 ` [PATCH v15 13/18] kunit: tool: add Python wrappers for running KUnit tests Brendan Higgins 2019-08-24 1:34 ` Brendan Higgins [this message] 2019-08-24 1:34 ` [PATCH v15 15/18] Documentation: kunit: add documentation for KUnit Brendan Higgins 2019-08-24 1:34 ` [PATCH v15 16/18] MAINTAINERS: add entry for KUnit the unit testing framework Brendan Higgins 2019-08-24 1:34 ` [PATCH v15 17/18] kernel/sysctl-test: Add null pointer test for sysctl.c:proc_dointvec() Brendan Higgins 2019-08-24 1:34 ` [PATCH v15 18/18] MAINTAINERS: add proc sysctl KUnit test to PROC SYSCTL section Brendan Higgins 2019-08-24 17:29 ` [PATCH v15 00/18] kunit: introduce KUnit, the Linux kernel unit testing framework shuah
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20190824013425.175645-15-brendanhiggins@google.com \ --to=brendanhiggins@google.com \ --cc=Alexander.Levin@microsoft.com \ --cc=Tim.Bird@sony.com \ --cc=amir73il@gmail.com \ --cc=dan.carpenter@oracle.com \ --cc=daniel@ffwll.ch \ --cc=devicetree@vger.kernel.org \ --cc=dri-devel@lists.freedesktop.org \ --cc=frowand.list@gmail.com \ --cc=gregkh@linuxfoundation.org \ --cc=jdike@addtoit.com \ --cc=joel@jms.id.au \ --cc=jpoimboe@redhat.com \ --cc=julia.lawall@lip6.fr \ --cc=keescook@google.com \ --cc=khilman@baylibre.com \ --cc=kieran.bingham@ideasonboard.com \ --cc=knut.omang@oracle.com \ --cc=kunit-dev@googlegroups.com \ --cc=linux-doc@vger.kernel.org \ --cc=linux-fsdevel@vger.kernel.org \ --cc=linux-kbuild@vger.kernel.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-kselftest@vger.kernel.org \ --cc=linux-nvdimm@lists.01.org \ --cc=linux-um@lists.infradead.org \ --cc=logang@deltatee.com \ --cc=mcgrof@kernel.org \ --cc=mpe@ellerman.id.au \ --cc=peterz@infradead.org \ --cc=pmladek@suse.com \ --cc=rdunlap@infradead.org \ --cc=richard@nod.at \ --cc=rientjes@google.com \ --cc=robh@kernel.org \ --cc=rostedt@goodmis.org \ --cc=sboyd@kernel.org \ --cc=shuah@kernel.org \ --cc=tytso@mit.edu \ --cc=wfg@linux.intel.com \ --cc=yamada.masahiro@socionext.com \ --subject='Re: [PATCH v15 14/18] kunit: defconfig: add defconfigs for building KUnit tests' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).