Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp4029153ybb; Mon, 23 Mar 2020 12:07:43 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvkiBYxtcSWW/EothO2voEg925/WS6lhyZrRA3A7Xilj3Vc3qTn9/8r5spSnu7dZLMZFU0R X-Received: by 2002:a05:6830:1f0c:: with SMTP id u12mr18702420otg.59.1584990462892; Mon, 23 Mar 2020 12:07:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584990462; cv=none; d=google.com; s=arc-20160816; b=EG9XlnTYutsBX/6EzZTFd/glC4SimTdg1iH8cV7Ohz8nZOWER6amuujXgcSVoGgbFl 1gyRYkOTMpBRnPUyz0KrP8KbeoDlGPDDDZf95UAQvn7o6bGOV9YJZRp7jkli5H76qoBX QPSojoOqK79VZf6VbyfjV9bRz1NcMvcJJx9UBF8U7PZ+8nbOlX45AyrfbOUyL2SoUwcA hTVw+7i3nj7vnWpBDu+XY2x4CKMmohW8fWsiNJdL8S42QNoZBKx6q0TEtxBORUZZAXqW UuBzzAeWIs6QAo7UtSOhcFhLaHlkWcDzOnec5DvB3xE4AaeT8vPdSLD9D2JzOa5zAA3Y mywA== 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=62ODFo7fgtXrZQirhZFriVDxWJbpN32F85/2VefFryo=; b=QMk0Yk5rJOJjGSFYERIl5KpMIfqCC1X9lUlLZpc+SttR/nENYi+cUiDQdGzk9csONQ wuvv5CST4cEz/vw6WvPmVURfhPc3d8g0CkRdxJS45ZQfpsZz2YvlZFfBhBhq0o55uUd2 22zeSB6kZmCS00L6y4RwoyGrzx6cpcd47Amh/vESkPkKGeJxt6WweO0SvD8KfyOcZb83 tNe+EswLZQy1hFVAs/WOWs7cY62REpmLV33rkr4LS4Vuaj8SySDFyU/HOGo9GYrwI62d eu8f0siVl5X0cR5eUESO0d0ol55EZlFTiaDKvZZ9Mm7QWtxU9yD2A0Jsvf4eJ7iOqSZ3 /oCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="rlLq4n/m"; 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 a11si7907841oid.121.2020.03.23.12.07.27; Mon, 23 Mar 2020 12:07:42 -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="rlLq4n/m"; 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 S1727835AbgCWTFH (ORCPT + 99 others); Mon, 23 Mar 2020 15:05:07 -0400 Received: from mail-pf1-f201.google.com ([209.85.210.201]:55180 "EHLO mail-pf1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727218AbgCWTFH (ORCPT ); Mon, 23 Mar 2020 15:05:07 -0400 Received: by mail-pf1-f201.google.com with SMTP id t19so11954937pfq.21 for ; Mon, 23 Mar 2020 12:05:06 -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=62ODFo7fgtXrZQirhZFriVDxWJbpN32F85/2VefFryo=; b=rlLq4n/miZ/WNYaR8D0o1QhJuCKChqbKhtqfObtqtHzh3ZK09KPXexT576LOjSw3qH MrHnfw7INxbbdsjnuJy+239bqBeW/7MV9P98a8o70j95TzgbbxBYPny55hqrBM5l/Yo8 wSeImOAGWwY6yzb5U5KFsBEbf+zmK7NrrnUROgF4wS5a4pa5LbSPUU/iwXNYUBeWz16T LwfqL3FR2iQTKHan5y65vPha46ce5jMsQ8qam1pNx3zq+CyaOFjiPKY5aqibqdv+Lceg kk/fUCQZjTJW8+MEGeocQphtfjQ/+5O1TwgcAwkbi7UzM3VcpJF/AM97lQXYXAYa+6Cg 9fDA== 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=62ODFo7fgtXrZQirhZFriVDxWJbpN32F85/2VefFryo=; b=YXrNwj6+6QIVMPY+Ac6kyZhQeKGXECyMeQ75F/5c6Nv/qvnaMSIV6UcuIDL26FUTz2 CO7HaFEbDvETxrgD9TzGfhU17jeI+BBSvktX7Mbe+Kf83s9tBokg7ejFefREYouV3+T9 GH9rh7DXeuDlmpBdyFh9N30YW+W3Zdneae/F++qSn21uq26ziPYzi7F0tJkJzQaRyQZB p1eqILWY7I3bhylL6Jejq6w4E1vXYZniCZM+1mjZVUDFWRd2zGOibx+mH1+mfVrznPzm n6hwTFZTi/rxIeT+tMnKcYiRSnKZjgoStHntut5rDURLfFosnVb99s+wWupM4R/OD608 bAdg== X-Gm-Message-State: ANhLgQ0J3NxwODP3QjPdRQPy7JdmzrgG7yvI/LwYvdeur99amt/AcNjM +6MASUrjnz15l9xIw/jRGCDbQS3qSo3hpOOcyMiEdg== X-Received: by 2002:a17:90b:14cb:: with SMTP id jz11mr910275pjb.142.1584990305331; Mon, 23 Mar 2020 12:05:05 -0700 (PDT) Date: Mon, 23 Mar 2020 12:04:59 -0700 Message-Id: <20200323190459.64737-1-brendanhiggins@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.25.1.696.g5e7596f4ac-goog Subject: [PATCH rebase v2] kunit: add --make_options From: Brendan Higgins To: shuah@kernel.org, gthelen@google.com, natechancellor@gmail.com Cc: linux-kselftest@vger.kernel.org, davidgow@google.com, kunit-dev@googlegroups.com, clang-built-linux@googlegroups.com, linux-kernel@vger.kernel.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 From: Greg Thelen The kunit.py utility builds an ARCH=um kernel and then runs it. Add optional --make_options flag to kunit.py allowing for the operator to specify extra build options. This allows use of the clang compiler for kunit: tools/testing/kunit/kunit.py run --defconfig \ --make_options CC=clang --make_options HOSTCC=clang Signed-off-by: Greg Thelen Reviewed-by: Brendan Higgins Reviewed-by: Nathan Chancellor Tested-by: David Gow Signed-off-by: Brendan Higgins --- tools/testing/kunit/kunit.py | 14 ++++++++++---- tools/testing/kunit/kunit_kernel.py | 24 ++++++++++++++---------- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/tools/testing/kunit/kunit.py b/tools/testing/kunit/kunit.py index 650bb4cfc544..7dca74774dd2 100755 --- a/tools/testing/kunit/kunit.py +++ b/tools/testing/kunit/kunit.py @@ -24,7 +24,7 @@ KunitResult = namedtuple('KunitResult', ['status','result']) KunitRequest = namedtuple('KunitRequest', ['raw_output','timeout', 'jobs', 'build_dir', 'defconfig', - 'alltests']) + 'alltests', 'make_options']) KernelDirectoryPath = sys.argv[0].split('tools/testing/kunit/')[0] @@ -49,7 +49,7 @@ def get_kernel_root_path(): def run_tests(linux: kunit_kernel.LinuxSourceTree, request: KunitRequest) -> KunitResult: config_start = time.time() - success = linux.build_reconfig(request.build_dir) + success = linux.build_reconfig(request.build_dir, request.make_options) config_end = time.time() if not success: return KunitResult(KunitStatus.CONFIG_FAILURE, 'could not configure kernel') @@ -59,7 +59,8 @@ def run_tests(linux: kunit_kernel.LinuxSourceTree, build_start = time.time() success = linux.build_um_kernel(request.alltests, request.jobs, - request.build_dir) + request.build_dir, + request.make_options) build_end = time.time() if not success: return KunitResult(KunitStatus.BUILD_FAILURE, 'could not build kernel') @@ -125,6 +126,10 @@ def main(argv, linux=None): help='Run all KUnit tests through allyesconfig', action='store_true') + run_parser.add_argument('--make_options', + help='X=Y make option, can be repeated.', + action='append') + cli_args = parser.parse_args(argv) if cli_args.subcommand == 'run': @@ -149,7 +154,8 @@ def main(argv, linux=None): cli_args.jobs, cli_args.build_dir, cli_args.defconfig, - cli_args.alltests) + cli_args.alltests, + cli_args.make_options) 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 415d8f3c4fe4..63dbda2d029f 100644 --- a/tools/testing/kunit/kunit_kernel.py +++ b/tools/testing/kunit/kunit_kernel.py @@ -40,8 +40,10 @@ class LinuxSourceTreeOperations(object): except subprocess.CalledProcessError as e: raise ConfigError(e.output) - def make_olddefconfig(self, build_dir): + def make_olddefconfig(self, build_dir, make_options): command = ['make', 'ARCH=um', 'olddefconfig'] + if make_options: + command.extend(make_options) if build_dir: command += ['O=' + build_dir] try: @@ -68,8 +70,10 @@ class LinuxSourceTreeOperations(object): kunit_parser.print_with_timestamp( 'Starting Kernel with all configs takes a few minutes...') - def make(self, jobs, build_dir): + def make(self, jobs, build_dir, make_options): command = ['make', 'ARCH=um', '--jobs=' + str(jobs)] + if make_options: + command.extend(make_options) if build_dir: command += ['O=' + build_dir] try: @@ -128,19 +132,19 @@ class LinuxSourceTree(object): return False return True - def build_config(self, build_dir): + def build_config(self, build_dir, make_options): kconfig_path = get_kconfig_path(build_dir) if build_dir and not os.path.exists(build_dir): os.mkdir(build_dir) self._kconfig.write_to_file(kconfig_path) try: - self._ops.make_olddefconfig(build_dir) + self._ops.make_olddefconfig(build_dir, make_options) except ConfigError as e: logging.error(e) return False return self.validate_config(build_dir) - def build_reconfig(self, build_dir): + def build_reconfig(self, build_dir, make_options): """Creates a new .config if it is not a subset of the .kunitconfig.""" kconfig_path = get_kconfig_path(build_dir) if os.path.exists(kconfig_path): @@ -149,19 +153,19 @@ class LinuxSourceTree(object): if not self._kconfig.is_subset_of(existing_kconfig): print('Regenerating .config ...') os.remove(kconfig_path) - return self.build_config(build_dir) + return self.build_config(build_dir, make_options) else: return True else: print('Generating .config ...') - return self.build_config(build_dir) + return self.build_config(build_dir, make_options) - def build_um_kernel(self, alltests, jobs, build_dir): + def build_um_kernel(self, alltests, jobs, build_dir, make_options): if alltests: self._ops.make_allyesconfig() try: - self._ops.make_olddefconfig(build_dir) - self._ops.make(jobs, build_dir) + self._ops.make_olddefconfig(build_dir, make_options) + self._ops.make(jobs, build_dir, make_options) except (ConfigError, BuildError) as e: logging.error(e) return False base-commit: f90ead0534f28c96dd8149ca13408d167bed9209 -- 2.25.1.696.g5e7596f4ac-goog