Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp6866398yba; Tue, 14 May 2019 15:22:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqxW034qLV/0CJcULCn3Aff6kFx1nRTdVqyn4TlLZY2gCSNqZb2YhpHeweHEgaXOtFphP/hc X-Received: by 2002:a65:5588:: with SMTP id j8mr40502783pgs.306.1557872569921; Tue, 14 May 2019 15:22:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557872569; cv=none; d=google.com; s=arc-20160816; b=GknRIG3mMKqPBhOKFzISP0gC/wRc4OkSHNg9RhwNuXOgpEs6hfMLvjLaY9Rj3RnrpP ZhMirCVloPt3g6RKgopmBMn8/HvPuXqvTFEAJ3Kr3LRkirmFW0e9ueXaov04Cs9LyAB9 zThfZxvrqoN0g1ZiTg9aZzacjCbNVTnhvPSYLthSPnnBpFGg9v4HZKYrGUIcXqe2rB14 FyQTqDiMRoSH0/2vURSPh80IcYdtX9DM2uken6EzvpEFym6SwSSgdKT/v+O9rkwCEG1f bx6xtXc9eagJ8/JH3w5JCKqe6Gjzbkwqbu57BsKMoMNBjaQ4sI9sYGDdwdDp5tivVzmr zlmQ== 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:references :mime-version:message-id:in-reply-to:date:dkim-signature; bh=A9vF5ks8OoQZOvkqahZ7WGJYbSmWAhAF5wYZd8NRVmE=; b=pGSytsiPUymYtu/PloAtW6M/pjHAKeAXfWfIWEKaCrSB7iO9OixEOj4WeIDpYfLUqT 6lTtoTiKl8T2JrZ+bNbZVFP6f3wBrGKF9xDW8d84kjxYSsnIDmY4s8/ZontEVzclJ3Ri +ZFjPXxv+D8lAugLJikbp2mZMGVYUStKAKLAtNxrbHzfZvr5exnog3FvsvmWTsW/ziAV HBGozx9bnAq1PFULre0fZweKfV3UqykCiCfpvjyHi/z3+MKYv33kN0xrIUlHI6nUNMRB FdBBYMP7YDXWtLd3dTU8pfJGyP6e4pt8N7c2GkFGHJ9lilhuIEqxDVW/ci/NRTrbBGDe mpyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=jYjj8jKu; 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 77si67545pgb.237.2019.05.14.15.22.35; Tue, 14 May 2019 15:22:49 -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=jYjj8jKu; 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 S1727009AbfENWTb (ORCPT + 99 others); Tue, 14 May 2019 18:19:31 -0400 Received: from mail-ot1-f74.google.com ([209.85.210.74]:55490 "EHLO mail-ot1-f74.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726994AbfENWTa (ORCPT ); Tue, 14 May 2019 18:19:30 -0400 Received: by mail-ot1-f74.google.com with SMTP id f18so223814otf.22 for ; Tue, 14 May 2019 15:19:29 -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=A9vF5ks8OoQZOvkqahZ7WGJYbSmWAhAF5wYZd8NRVmE=; b=jYjj8jKu/dQvrzvd+x7xkfyxnYHwV47Dr/iDweDMz+l9I/09A4NF8Ujd2o/5WKf4FD GBicHUaLKQ0mgUfuydmxnIgxCMCPRDXtxlxbDP4zFqv08lPor+QnGBdlvjAkyI09+4sU trtthmthnyg1MPXwAiMSS+Yw55Hr18XLibX/3y1gyp7Fw0xsmIJ0W2SX1LO8nHh0i6xa HYww/HIEl0OnnEm9BflpNh2YcpM2FbScQJ1F9iIgUDfMz+QwSTuJPKhFAh+ktggSm6hu +MI6GFhF1DIRuy3UEZJhpBc/MWraf0ptq44s5qyYO/xo1zMQze+sY3eKneWsfXtzx+WJ 2nNw== 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=A9vF5ks8OoQZOvkqahZ7WGJYbSmWAhAF5wYZd8NRVmE=; b=f3OLS8DzxG9NP/r1CzHwMGND9HKK78ZVJEaAL/r66acUtfZ3btebjKQTlQfnYF3IqW SuiwfqL+EP/PzWaB3Qx6joKZIBveJFZXjVia4FmmkFCEfzsxTE2HYFlaS+eLxdLR52yC g/9r5e8zLemQZk6lbPi5NweasKtwoDQ71WaDgUlOHF+vLEWRCP66PNWODsnSVWZkxxnT +mZtD3wCjJ1qwW466UjkyYFKbEtHWzlhAU6JAaukfeS0wT5wNLVbw/uh537urJJqBhHr bXA71KeEmSH2Dt2X2ygekTaVLap/p+yqn/H8/Iyqj2mo6eJADEM4/I2LKih3m65rG64d OfQg== X-Gm-Message-State: APjAAAV6IXs3OyJ5YSd0t41VvSUT2Pcxz7qwEbdrlHMyCj8OVNUKT9JA 08TFhuPM0KhgfhEHhupgSgeuRqNDoLEkT1aKFa7rCQ== X-Received: by 2002:aca:e8c5:: with SMTP id f188mr4212385oih.132.1557872368837; Tue, 14 May 2019 15:19:28 -0700 (PDT) Date: Tue, 14 May 2019 15:17:07 -0700 In-Reply-To: <20190514221711.248228-1-brendanhiggins@google.com> Message-Id: <20190514221711.248228-15-brendanhiggins@google.com> Mime-Version: 1.0 References: <20190514221711.248228-1-brendanhiggins@google.com> X-Mailer: git-send-email 2.21.0.1020.gf2820cf01a-goog Subject: [PATCH v4 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 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 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 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 | 18 ++++++++++++++++-- tools/testing/kunit/kunit_kernel.py | 3 ++- 4 files changed, 34 insertions(+), 3 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 85ed1c32a6c48..956326f87101f 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() @@ -99,13 +108,18 @@ 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': 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) 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): -- 2.21.0.1020.gf2820cf01a-goog