Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1115014pxb; Wed, 29 Sep 2021 17:42:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxGbarRxoeVJoMkayMeGTg9qpvLrFzvFIiRvwIwf/Dcx4717t3/pYXcYZxtQi2VuyRSp+PY X-Received: by 2002:a17:906:700f:: with SMTP id n15mr3269406ejj.319.1632962555646; Wed, 29 Sep 2021 17:42:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632962555; cv=none; d=google.com; s=arc-20160816; b=w7qZkXM2niHoJGKKWSby/5sYPMQCOlRkYDosbSKRbhaiSlw4OknHBKEKJHUkguu7yJ l9k13GXIHhHHdGzEF6OqAPU4woP2mVbCDkO5wMP/Rf2QqTt45Gzr29ZdQPoA2clRFH7X WrMDGTan8I8oMJ7yENzjDsvtNJGVy8gklptDpWjtH5xq6RUw4i1tz1+Qk/EN9qcXrkBz Ay73BXfileBeANXQLcxyQei68emTqMyM1f5kAZMnO2Bg/GN98kfgiRdsOhSvAkj2m6Ny +wWI+w3glyrjgcYGuM1ZQTbiWqyN1LI3IRWWjJWjAwfmGVfiZ7F2CsypIbmrCDDiYUei r/BQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=JSQkVSiN1+zP+Jeqk9BsuAYII2lwHRa7BSBYUWDZKe0=; b=O8JScZGulZ9qSIgl3xcTOCXKdc25ZTseRS0Vw9pG2Xug1/jOi7IO2/N/bVJyRwdUak oUAGTgkBZhwRgD+ulgKuruFgd5uYAbZhM69A93pxKPtZKKxg+smznhaR7fJV5v0Hho+E ylQLBhf7C8Q8U8JEsCyBeaTKKYfsaXWpLF5h/nuya0OsWFcUzm7G+8veITv32jbO069R 3b8ENLmMPCsUd2OBQge/+XxWREUx/wKUh187f8edkFrKRY3jmxQWhc93P9/TVCjAMS3s oym2pHYQI+2khq8OVtXiljW1FUpvCqg+tiXOrIqOKuVb/mV11k8gNctSd4emBnbTbIon w01w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b="eJ/CBXGR"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id mp24si2052471ejc.731.2021.09.29.17.42.10; Wed, 29 Sep 2021 17:42:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b="eJ/CBXGR"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1346608AbhI3AZU (ORCPT + 99 others); Wed, 29 Sep 2021 20:25:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39590 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346619AbhI3AZT (ORCPT ); Wed, 29 Sep 2021 20:25:19 -0400 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 07874C061769 for ; Wed, 29 Sep 2021 17:23:36 -0700 (PDT) Received: by mail-wr1-x436.google.com with SMTP id d26so7043626wrb.6 for ; Wed, 29 Sep 2021 17:23:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=JSQkVSiN1+zP+Jeqk9BsuAYII2lwHRa7BSBYUWDZKe0=; b=eJ/CBXGRPaT/0t3P0rvayDkW3i5f7uHQlPxkcRC4+AuoWanUPnHeVSYIdmbqnFCnHe n5ZwkX8cZCRwtEv75FZ48p4mtQu9cnUZd+aOx8EdmGoslP/JJs+ubY2Pq78mNaerPcsd tSEaFCAdxggIHWByzJOWnzgtgCpFn6WnUG6Eripd0k3gnPq1QlVU5c8XPJ6wYpUmNYoJ ia2Ycou8Ow1Bsv4XhJDoI19xf8g1A5x+Ooyiqdqs2XdD05hDPKdWVQWJBtEAARAwAn0Y LHsCSN7ZvLfmMdyxWdcj/ZtqlNQPNlvE0a4lIzbuVfCpcq2jYAn49En3k0jdv0DprcgF N6dg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=JSQkVSiN1+zP+Jeqk9BsuAYII2lwHRa7BSBYUWDZKe0=; b=xU3ZsHwSoZ7RST4nR01p6szTs0d8/v/d279TcxEzpVbYWMRSPSbEtmNN0omuPTvkRQ z391ReXGxKUfmtviKbQ+OJVAywkzU6ptG9BOX5qlzhsIY/n5G55HdI7dSMTHu8TMgGVR 9bZ8UUJ7TmpWwSWnTanX7BDG0NsTkjF9CGfveJRgMdpfc6jF+5XsXUxyM2kpl+W/ngOm n8UqWT8BOTV5V0/bebGmCkj/mUAUTYAkE/bu9lrEDdvpvCrtGF/Iv+h55AEQF3RUKSbb +AVOr2fSlV93hpgjqSHBWIyGIc0J5xnUegT5IusTG2eot4VL5azlC7IF3T3yuHXyOenT fn1A== X-Gm-Message-State: AOAM530J9/xu8fDMAdRP0ZX3Za37BrlAax7lPvlsZlhYNUPN3Xv8OREd Nq8SkHzK34gI57oxBIOXgBk7SIDu6JZzncnpsU3y0Q== X-Received: by 2002:adf:f6c7:: with SMTP id y7mr2999746wrp.44.1632961414281; Wed, 29 Sep 2021 17:23:34 -0700 (PDT) MIME-Version: 1.0 References: <20210929232534.1433720-1-dlatypov@google.com> In-Reply-To: <20210929232534.1433720-1-dlatypov@google.com> From: David Gow Date: Thu, 30 Sep 2021 08:23:23 +0800 Message-ID: Subject: Re: [PATCH] kunit: tool: show list of valid --arch options when invalid To: Daniel Latypov Cc: Brendan Higgins , Linux Kernel Mailing List , KUnit Development , "open list:KERNEL SELFTEST FRAMEWORK" , Shuah Khan Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 30, 2021 at 7:26 AM Daniel Latypov wrote: > > Consider this attempt to run KUnit in QEMU: > $ ./tools/testing/kunit/kunit.py run --arch=x86 > > Before you'd get this error message: > kunit_kernel.ConfigError: x86 is not a valid arch > > After: > kunit_kernel.ConfigError: x86 is not a valid arch, options are ['alpha', 'arm', 'arm64', 'i386', 'powerpc', 'riscv', 's390', 'sparc', 'x86_64'] > > This should make it a bit easier for people to notice when they make > typos, etc. Currently, one would have to dive into the python code to > figure out what the valid set is. > > Signed-off-by: Daniel Latypov > --- This is really nice, particularly given that we've had to reproduce that list in lots of talks, documentation, etc. and it could get out-of-date. Reviewed-by: David Gow [FYI: this didn't seem to apply cleanly to kselftest/kunit head, but it was a pretty minor issue with kunit_tool_test.py.] Thanks, -- David > tools/testing/kunit/kunit_kernel.py | 5 +++-- > tools/testing/kunit/kunit_tool_test.py | 4 ++++ > 2 files changed, 7 insertions(+), 2 deletions(-) > > diff --git a/tools/testing/kunit/kunit_kernel.py b/tools/testing/kunit/kunit_kernel.py > index 1870e75ff153..a6b3cee3f0d0 100644 > --- a/tools/testing/kunit/kunit_kernel.py > +++ b/tools/testing/kunit/kunit_kernel.py > @@ -198,8 +198,9 @@ def get_source_tree_ops(arch: str, cross_compile: Optional[str]) -> LinuxSourceT > return LinuxSourceTreeOperationsUml(cross_compile=cross_compile) > elif os.path.isfile(config_path): > return get_source_tree_ops_from_qemu_config(config_path, cross_compile)[1] > - else: > - raise ConfigError(arch + ' is not a valid arch') > + > + options = [f[:-3] for f in os.listdir(QEMU_CONFIGS_DIR) if f.endswith('.py')] > + raise ConfigError(arch + ' is not a valid arch, options are ' + str(sorted(options))) > > def get_source_tree_ops_from_qemu_config(config_path: str, > cross_compile: Optional[str]) -> Tuple[ > diff --git a/tools/testing/kunit/kunit_tool_test.py b/tools/testing/kunit/kunit_tool_test.py > index cad37a98e599..2ae72f04cbe0 100755 > --- a/tools/testing/kunit/kunit_tool_test.py > +++ b/tools/testing/kunit/kunit_tool_test.py > @@ -289,6 +289,10 @@ class LinuxSourceTreeTest(unittest.TestCase): > pass > kunit_kernel.LinuxSourceTree('', kunitconfig_path=dir) > > + def test_invalid_arch(self): > + with self.assertRaisesRegex(kunit_kernel.ConfigError, 'not a valid arch, options are.*x86_64'): > + kunit_kernel.LinuxSourceTree('', arch='invalid') > + > # TODO: add more test cases. > > > > base-commit: 865a0a8025ee0b54d1cc74834c57197d184a441e > -- > 2.33.0.685.g46640cef36-goog >