Received: by 10.223.176.5 with SMTP id f5csp1260628wra; Wed, 7 Feb 2018 15:58:08 -0800 (PST) X-Google-Smtp-Source: AH8x227O9x7o9h5eRsqa/T98RGh9EX7+vP1Uen7kybuzjYGhRGVY1QaMP07wIR73BGVdaiR09pzP X-Received: by 2002:a17:902:6186:: with SMTP id u6-v6mr7520662plj.390.1518047888385; Wed, 07 Feb 2018 15:58:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518047888; cv=none; d=google.com; s=arc-20160816; b=R/3hFQORZ8t6hNlJ3OgrkhGs8SjV3UWsuxADjszVjcknCqMHBFr5ryRqGYBB5xBZuQ cKu8GcC057BRxsvvnvIRfmSP9jHbp1fYRotT2wxbA71dbSTdPUolmdAS/rT24amVWwGg 1hkcMh5PYKd/Vr0NRwyg0HMPwoOyR1ZCAP6lEkLkOGiv/AYnV/5W7XUPLbBBxfP+l5fv 2ZlQTY673e6jwwcH/kky3uAHddgHu8mMdPVFUVlBUtcjiD5iVK2u4/8rtPojVmxBNI8d fJtTOv4/UvxIEhJCClSi9+PiOFF4cAwnLcLC/t73U8BMUSHqKK3b6z5qlGCCdptbOt2n GerA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=5yqcdVUVD3gDoEipYjAd5MvS4tCC8WchoCLYolwH3Qk=; b=pSLJkOmpQqZgZBF6cS7B/zSynhy5KwiKm60uIdN7SxgGEL22CwDPNu2yb9rqf3VqhI 6nhnCmDJNpd/VhLCa3uWl9dCSEVdxrzqL+Q60wSa3yHeSA489FkXv5MYn4ebxc+weMMU aOggsVjArnAGjmb8IHPIl3ymO7uIeX3R6040ho4u9birTRVACHWZEHO4irTDZ+9QHN7M G8O+Vp1xNbmr+DELTvkg/X8RQkqsDz0MLCYbyR5cxMVkkadDurJUS6IeC+ds11ucYyZc xxnokvUIg+Fs/ucqP8bw9Ort95lqVpuYjlL1y335I2GZzkzqeySXx40bkNn/ZVsODBD+ l4NQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Hyl0oKA+; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a9si430419pgf.39.2018.02.07.15.57.54; Wed, 07 Feb 2018 15:58:08 -0800 (PST) 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=@gmail.com header.s=20161025 header.b=Hyl0oKA+; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751319AbeBGX5R (ORCPT + 99 others); Wed, 7 Feb 2018 18:57:17 -0500 Received: from mail-ua0-f194.google.com ([209.85.217.194]:35011 "EHLO mail-ua0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750736AbeBGX5P (ORCPT ); Wed, 7 Feb 2018 18:57:15 -0500 Received: by mail-ua0-f194.google.com with SMTP id n1so1768538uaa.2; Wed, 07 Feb 2018 15:57:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=5yqcdVUVD3gDoEipYjAd5MvS4tCC8WchoCLYolwH3Qk=; b=Hyl0oKA+FhcaWch7paMKbvPsiGSmznAvxxlqixt2BVkKFZVcMdvZM1BOLAQfgMQynp vLRn3KZs+EzEAoHHsqBCw1Km9mBd+iSjtJIbo3b4zGepECEHj9vp0IlxrOzikkO70/Lo gRxvrQp+zfnIj67+17iDqbxNwqQItbu3bhZCP3PEks90NM6Xlru3mZAYs7gz1ccoet/f MqsO977qP0qkEcZFgMhZ8LKx278VEjLfdbhxHPU/HHuUsLNg8jUD3JtbOZLDU7qNDzfh 6StCpLLMzCh7Yxmz6OtlND9YBkHs2f9lOwUQy98MWWOJu7D8Tvv+gF7eT9srpOF0r28w U3tQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=5yqcdVUVD3gDoEipYjAd5MvS4tCC8WchoCLYolwH3Qk=; b=MtUtgmXa/Hmfg9H0QWn4mcNFYhi5qIFHfvh6UY/lFMU2RHsP/F9sRYkl9MSM/PXJLL xLGDnrWdCGd/XmYJEBhAncD4VDoBeG6R1o370N3siaMlKFwUfWnM529VG9La03QyNN0p YSHZlvv+KpcOT9kg0xxw/QuFVZPk57/T0ICCy8RFcgnIT2RedlvRXa3Lz385FeuC+3Qi /Bod7GC6boKSNG5z65uDkLTCZfkYEEZQA+YluS1Vn7wCnXZ2XNfixNbFoJzmuNCUg/Aw Ac8jjBtyfYvGS7eB5f3wwMIu1kotjNz0ZdFlK6LdXo/EO6ceTvpC4eoegbn5ut9PCW1a Aivg== X-Gm-Message-State: APf1xPA3kFQFcHqSMYWpZyZiqZZGiliQSyGouFt2y4FkmnC8ZMNWfdHf 9V9GkkZswLfJtskMhUynvr0vkXTPUmr/+LrvsGf5T1J7uoM= X-Received: by 10.176.80.101 with SMTP id z34mr6600253uaz.188.1518047834602; Wed, 07 Feb 2018 15:57:14 -0800 (PST) MIME-Version: 1.0 Received: by 10.103.70.21 with HTTP; Wed, 7 Feb 2018 15:57:14 -0800 (PST) In-Reply-To: <1517877294-4826-9-git-send-email-yamada.masahiro@socionext.com> References: <1517877294-4826-1-git-send-email-yamada.masahiro@socionext.com> <1517877294-4826-9-git-send-email-yamada.masahiro@socionext.com> From: Ulf Magnusson Date: Thu, 8 Feb 2018 00:57:14 +0100 Message-ID: Subject: Re: [PATCH 08/14] kconfig: test: add basic 'choice' tests To: Masahiro Yamada Cc: Linux Kbuild mailing list , Greg Kroah-Hartman , Andrew Morton , Nicolas Pitre , "Luis R . Rodriguez" , Randy Dunlap , Sam Ravnborg , Michal Marek , Linus Torvalds , Linux Kernel Mailing List 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 On Tue, Feb 6, 2018 at 1:34 AM, Masahiro Yamada wrote: > The calculation of 'choice' is a bit complicated part in Kconfig. > > The behavior of 'y' choice is intuitive. If choice values are tristate, > the choice can be 'm' where each value can be enabled independently. > Also, if a choice is marked as 'optional', the whole choice can be > invisible. > > Test basic functionality of choice. > > Signed-off-by: Masahiro Yamada > --- > > scripts/kconfig/tests/choice/Kconfig | 54 ++++++++++++++++++++++ > scripts/kconfig/tests/choice/__init__.py | 37 +++++++++++++++ > .../kconfig/tests/choice/alldef_expected_config | 5 ++ > .../kconfig/tests/choice/allmod_expected_config | 9 ++++ > scripts/kconfig/tests/choice/allno_expected_config | 5 ++ > .../kconfig/tests/choice/allyes_expected_config | 9 ++++ > .../kconfig/tests/choice/oldask0_expected_stdout | 10 ++++ > scripts/kconfig/tests/choice/oldask1_config | 2 + > .../kconfig/tests/choice/oldask1_expected_stdout | 15 ++++++ > 9 files changed, 146 insertions(+) > create mode 100644 scripts/kconfig/tests/choice/Kconfig > create mode 100644 scripts/kconfig/tests/choice/__init__.py > create mode 100644 scripts/kconfig/tests/choice/alldef_expected_config > create mode 100644 scripts/kconfig/tests/choice/allmod_expected_config > create mode 100644 scripts/kconfig/tests/choice/allno_expected_config > create mode 100644 scripts/kconfig/tests/choice/allyes_expected_config > create mode 100644 scripts/kconfig/tests/choice/oldask0_expected_stdout > create mode 100644 scripts/kconfig/tests/choice/oldask1_config > create mode 100644 scripts/kconfig/tests/choice/oldask1_expected_stdout > > diff --git a/scripts/kconfig/tests/choice/Kconfig b/scripts/kconfig/tests/choice/Kconfig > new file mode 100644 > index 0000000..cc60e9c > --- /dev/null > +++ b/scripts/kconfig/tests/choice/Kconfig > @@ -0,0 +1,54 @@ > +config MODULES > + bool "Enable loadable module support" > + option modules > + default y > + > +choice > + prompt "boolean choice" > + default BOOL_CHOICE1 > + > +config BOOL_CHOICE0 > + bool "choice 0" > + > +config BOOL_CHOICE1 > + bool "choice 1" > + > +endchoice > + > +choice > + prompt "optional boolean choice" > + optional > + default OPT_BOOL_CHOICE1 > + > +config OPT_BOOL_CHOICE0 > + bool "choice 0" > + > +config OPT_BOOL_CHOICE1 > + bool "choice 1" > + > +endchoice > + > +choice > + prompt "tristate choice" > + default TRI_CHOICE1 > + > +config TRI_CHOICE0 > + tristate "choice 0" > + > +config TRI_CHOICE1 > + tristate "choice 1" > + > +endchoice > + > +choice > + prompt "optional tristate choice" > + optional > + default OPT_TRI_CHOICE1 > + > +config OPT_TRI_CHOICE0 > + tristate "choice 0" > + > +config OPT_TRI_CHOICE1 > + tristate "choice 1" > + > +endchoice > diff --git a/scripts/kconfig/tests/choice/__init__.py b/scripts/kconfig/tests/choice/__init__.py > new file mode 100644 > index 0000000..42022ac > --- /dev/null > +++ b/scripts/kconfig/tests/choice/__init__.py > @@ -0,0 +1,37 @@ > +""" > +Basic choice tests > +================== > + > +The handling of 'choice' is a bit complicated part in Kconfig. > + > +The behavior of 'y' choice is intuitive. If choice values are tristate, > +the choice can be 'm' where each value can be enabled independently. > +Also, if a choice is marked as 'optional', the whole choice can be > +invisible. > + > +Test basic functionality of choice. > +""" > + > +def test_oldask0(conf): > + assert conf.oldaskconfig() == 0 > + assert conf.stdout_contains('oldask0_expected_stdout') > + > +def test_oldask1(conf): > + assert conf.oldaskconfig('oldask1_config') == 0 > + assert conf.stdout_contains('oldask1_expected_stdout') > + > +def test_allyes(conf): > + assert conf.allyesconfig() == 0 > + assert conf.config_contains('allyes_expected_config') > + > +def test_allmod(conf): > + assert conf.allmodconfig() == 0 > + assert conf.config_contains('allmod_expected_config') > + > +def test_allno(conf): > + assert conf.allnoconfig() == 0 > + assert conf.config_contains('allno_expected_config') > + > +def test_alldef(conf): > + assert conf.alldefconfig() == 0 > + assert conf.config_contains('alldef_expected_config') > diff --git a/scripts/kconfig/tests/choice/alldef_expected_config b/scripts/kconfig/tests/choice/alldef_expected_config > new file mode 100644 > index 0000000..7a754bf > --- /dev/null > +++ b/scripts/kconfig/tests/choice/alldef_expected_config > @@ -0,0 +1,5 @@ > +CONFIG_MODULES=y > +# CONFIG_BOOL_CHOICE0 is not set > +CONFIG_BOOL_CHOICE1=y > +# CONFIG_TRI_CHOICE0 is not set > +# CONFIG_TRI_CHOICE1 is not set > diff --git a/scripts/kconfig/tests/choice/allmod_expected_config b/scripts/kconfig/tests/choice/allmod_expected_config > new file mode 100644 > index 0000000..f1f5dcd > --- /dev/null > +++ b/scripts/kconfig/tests/choice/allmod_expected_config > @@ -0,0 +1,9 @@ > +CONFIG_MODULES=y > +# CONFIG_BOOL_CHOICE0 is not set > +CONFIG_BOOL_CHOICE1=y > +# CONFIG_OPT_BOOL_CHOICE0 is not set > +CONFIG_OPT_BOOL_CHOICE1=y > +CONFIG_TRI_CHOICE0=m > +CONFIG_TRI_CHOICE1=m > +CONFIG_OPT_TRI_CHOICE0=m > +CONFIG_OPT_TRI_CHOICE1=m > diff --git a/scripts/kconfig/tests/choice/allno_expected_config b/scripts/kconfig/tests/choice/allno_expected_config > new file mode 100644 > index 0000000..b88ee7a > --- /dev/null > +++ b/scripts/kconfig/tests/choice/allno_expected_config > @@ -0,0 +1,5 @@ > +# CONFIG_MODULES is not set > +# CONFIG_BOOL_CHOICE0 is not set > +CONFIG_BOOL_CHOICE1=y > +# CONFIG_TRI_CHOICE0 is not set > +CONFIG_TRI_CHOICE1=y > diff --git a/scripts/kconfig/tests/choice/allyes_expected_config b/scripts/kconfig/tests/choice/allyes_expected_config > new file mode 100644 > index 0000000..e5a062a > --- /dev/null > +++ b/scripts/kconfig/tests/choice/allyes_expected_config > @@ -0,0 +1,9 @@ > +CONFIG_MODULES=y > +# CONFIG_BOOL_CHOICE0 is not set > +CONFIG_BOOL_CHOICE1=y > +# CONFIG_OPT_BOOL_CHOICE0 is not set > +CONFIG_OPT_BOOL_CHOICE1=y > +# CONFIG_TRI_CHOICE0 is not set > +CONFIG_TRI_CHOICE1=y > +# CONFIG_OPT_TRI_CHOICE0 is not set > +CONFIG_OPT_TRI_CHOICE1=y > diff --git a/scripts/kconfig/tests/choice/oldask0_expected_stdout b/scripts/kconfig/tests/choice/oldask0_expected_stdout > new file mode 100644 > index 0000000..b251bba > --- /dev/null > +++ b/scripts/kconfig/tests/choice/oldask0_expected_stdout > @@ -0,0 +1,10 @@ > +Enable loadable module support (MODULES) [Y/n/?] (NEW) > +boolean choice > + 1. choice 0 (BOOL_CHOICE0) (NEW) > +> 2. choice 1 (BOOL_CHOICE1) (NEW) > +choice[1-2?]: > +optional boolean choice [N/y/?] (NEW) > +tristate choice [M/y/?] (NEW) > + choice 0 (TRI_CHOICE0) [N/m/?] (NEW) > + choice 1 (TRI_CHOICE1) [N/m/?] (NEW) > +optional tristate choice [N/m/y/?] (NEW) > diff --git a/scripts/kconfig/tests/choice/oldask1_config b/scripts/kconfig/tests/choice/oldask1_config > new file mode 100644 > index 0000000..b67bfe3 > --- /dev/null > +++ b/scripts/kconfig/tests/choice/oldask1_config > @@ -0,0 +1,2 @@ > +# CONFIG_MODULES is not set > +CONFIG_OPT_BOOL_CHOICE0=y > diff --git a/scripts/kconfig/tests/choice/oldask1_expected_stdout b/scripts/kconfig/tests/choice/oldask1_expected_stdout > new file mode 100644 > index 0000000..c2125e9b > --- /dev/null > +++ b/scripts/kconfig/tests/choice/oldask1_expected_stdout > @@ -0,0 +1,15 @@ > +Enable loadable module support (MODULES) [N/y/?] > +boolean choice > + 1. choice 0 (BOOL_CHOICE0) (NEW) > +> 2. choice 1 (BOOL_CHOICE1) (NEW) > +choice[1-2?]: > +optional boolean choice [Y/n/?] (NEW) > +optional boolean choice > +> 1. choice 0 (OPT_BOOL_CHOICE0) > + 2. choice 1 (OPT_BOOL_CHOICE1) (NEW) > +choice[1-2?]: > +tristate choice > + 1. choice 0 (TRI_CHOICE0) (NEW) > +> 2. choice 1 (TRI_CHOICE1) (NEW) > +choice[1-2?]: > +optional tristate choice [N/y/?] > -- > 2.7.4 > Reviewed-by: Ulf Magnusson