From patchwork Tue Feb 6 00:34:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 126941 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp2442373ljc; Mon, 5 Feb 2018 16:40:48 -0800 (PST) X-Google-Smtp-Source: AH8x224q7bXZENfzOEfqljk5aAKyjtwki194n7lmMEWt8vRn8SsbXKvxmf0rxUvDClx5R6PZYNv+ X-Received: by 2002:a17:902:a612:: with SMTP id u18-v6mr588554plq.129.1517877648749; Mon, 05 Feb 2018 16:40:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517877648; cv=none; d=google.com; s=arc-20160816; b=DqkXSbdtnTxcGg92WKWJUQ84CtGCSP9PoiiLRindUbxfoNZD1D1PlhshHbRbW0GX6P r1cjQW4mXtc6R/OHVeUU0sPed4G7eMrYU3R5XE1YK3qLfJUkDtQWcHTXg2ppIBzxjfVg MtLelnxFEq06slL88afLr+fW+pgwNnJEUEXtu0Zd0a79ZvZ0cBQp244h7tOT0LrefRqQ ncgsOwQLQCySzsIYwafEnmFJ5zzpA/9ynpWcDbJvfK6TYYKV+smqkZaCNiap1h3gH8F5 OIlZxRAk2eSbLWAKDOg4Dleqa+x+EnJ+m7Mgafq6kumZuDCKlKd2D0HMc4eMgjSGWKdp i6SQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter :arc-authentication-results; bh=YfS+uMzbjxqGOtPrlZt5FSJaqfha9h1IgjnvvpHbUwo=; b=k2tzLWh3P9QLkkGqrxc5jmRRONuaSidzl9E2EQiD0GYbu/NJbHrrq3u2yAgMxkgmGh 8ROZfiY/bvXLyBKdo3c6/ftScbSre6xlTkjWv1d6H7O4mSmrvXS5obBC8bPRZ24vBjVl 6ODRYARcE0oT01xNGP3oQGYWoPDYX9RY7j8tSL9XdqzTBCq7StWW/rJ2pRTUz3RNidQ8 tPYKpDnXBcbFwPIseC05iPGQiv8s+8jYpkCsn/tkEWzDmpaQt38OJe8n3TRR+nV6FAHI jj1UmarNCSNKiHe+nvRZZ0nXPI0U9bkiqGLq++tbh2pwwOZ+TzpUAd8fhPQIiUUIzlgd gDog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=Iqw4E5Vb; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x63si709625pfk.335.2018.02.05.16.40.48; Mon, 05 Feb 2018 16:40:48 -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=@nifty.com header.s=dec2015msa header.b=Iqw4E5Vb; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752731AbeBFAkq (ORCPT + 21 others); Mon, 5 Feb 2018 19:40:46 -0500 Received: from conuserg-07.nifty.com ([210.131.2.74]:39798 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752264AbeBFAh4 (ORCPT ); Mon, 5 Feb 2018 19:37:56 -0500 Received: from grover.sesame (FL1-125-199-20-195.osk.mesh.ad.jp [125.199.20.195]) (authenticated) by conuserg-07.nifty.com with ESMTP id w160ZHAn011351; Tue, 6 Feb 2018 09:35:26 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com w160ZHAn011351 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1517877326; bh=YfS+uMzbjxqGOtPrlZt5FSJaqfha9h1IgjnvvpHbUwo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Iqw4E5VbOs99Ew8Wb4eISijVSlkl29Ay73wVV8X0XCatjZC//4TKh16jS47EGnY+S DMLo/vVk7NJ2yIPA7Foa7VSM3RBaTdr+eo2XX5kcwanKikOJqM0UHR+2mhAI8vGQFy Ho1e/JTYU0cciDYJieKJOahOJSrSJh/r5NAGOvqY3rxLfdfdoOUD7/j5xwifITdx3G amnaVPjcuTQgqsD2sAD5sjzVQ6QkkqVg8PbnrMLDoPhC3sM4QTaacfV5XMV2FQLW3V Qzy2chbyYV8lepERI+IkhFblQPK+WLm7QxjQb5FA9yn6FOuDiWyEa+BhoEzzqFcxL8 QwOqgpcl3gZ+w== X-Nifty-SrcIP: [125.199.20.195] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Greg Kroah-Hartman , Andrew Morton , Nicolas Pitre , "Luis R . Rodriguez" , Randy Dunlap , Ulf Magnusson , Sam Ravnborg , Michal Marek , Linus Torvalds , Masahiro Yamada , linux-kernel@vger.kernel.org Subject: [PATCH 08/14] kconfig: test: add basic 'choice' tests Date: Tue, 6 Feb 2018 09:34:48 +0900 Message-Id: <1517877294-4826-9-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1517877294-4826-1-git-send-email-yamada.masahiro@socionext.com> References: <1517877294-4826-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 -- 2.7.4 Reviewed-by: Ulf Magnusson 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/?]