linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Masahiro Yamada <yamada.masahiro@socionext.com>
To: linux-kbuild@vger.kernel.org
Cc: Sam Ravnborg <sam@ravnborg.org>,
	Michal Marek <michal.lkml@markovi.net>,
	Ulf Magnusson <ulfalizer@gmail.com>,
	Randy Dunlap <rdunlap@infradead.org>,
	"Luis R . Rodriguez" <mcgrof@kernel.org>,
	Masahiro Yamada <yamada.masahiro@socionext.com>,
	linux-kernel@vger.kernel.org
Subject: [PATCH v2 04/11] kconfig: unittest: test automatic submenu creation
Date: Fri,  2 Mar 2018 13:31:54 +0900	[thread overview]
Message-ID: <1519965121-12017-5-git-send-email-yamada.masahiro@socionext.com> (raw)
In-Reply-To: <1519965121-12017-1-git-send-email-yamada.masahiro@socionext.com>

If a symbols has dependency on the preceding symbol, the menu entry
should become the submenu of the preceding one, and displayed with
deeper indentation.

This is done by restructuring the menu tree in menu_finalize().
It is a bit complicated computation, so let's add a test case.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Ulf Magnusson <ulfalizer@gmail.com>
---

Changes in v2:
  - shorten directory name  'auto_submenu_creation' -> 'auto_submenu'
  - coding style clean-up based on PEP8, PEP257

 scripts/kconfig/tests/auto_submenu/Kconfig         | 50 ++++++++++++++++++++++
 scripts/kconfig/tests/auto_submenu/__init__.py     | 12 ++++++
 scripts/kconfig/tests/auto_submenu/expected_stdout | 10 +++++
 3 files changed, 72 insertions(+)
 create mode 100644 scripts/kconfig/tests/auto_submenu/Kconfig
 create mode 100644 scripts/kconfig/tests/auto_submenu/__init__.py
 create mode 100644 scripts/kconfig/tests/auto_submenu/expected_stdout

diff --git a/scripts/kconfig/tests/auto_submenu/Kconfig b/scripts/kconfig/tests/auto_submenu/Kconfig
new file mode 100644
index 0000000..9e11502
--- /dev/null
+++ b/scripts/kconfig/tests/auto_submenu/Kconfig
@@ -0,0 +1,50 @@
+config A
+	bool "A"
+	default y
+
+config A0
+	bool "A0"
+	depends on A
+	default y
+	help
+	  This depends on A, so should be a submenu of A.
+
+config A0_0
+	bool "A1_0"
+	depends on A0
+	help
+	  Submenus are created recursively.
+	  This should be a submenu of A0.
+
+config A1
+	bool "A1"
+	depends on A
+	default y
+	help
+	  This should line up with A0.
+
+choice
+	prompt "choice"
+	depends on A1
+	help
+	  Choice should become a submenu as well.
+
+config A1_0
+	bool "A1_0"
+
+config A1_1
+	bool "A1_1"
+
+endchoice
+
+config B
+	bool "B"
+	help
+	  This is independent of A.
+
+config C
+	bool "C"
+	depends on A
+	help
+	  This depends on A, but not a consecutive item, so should not
+	  be a submenu.
diff --git a/scripts/kconfig/tests/auto_submenu/__init__.py b/scripts/kconfig/tests/auto_submenu/__init__.py
new file mode 100644
index 0000000..32e79b8
--- /dev/null
+++ b/scripts/kconfig/tests/auto_submenu/__init__.py
@@ -0,0 +1,12 @@
+"""
+Create submenu for symbols that depend on the preceding one.
+
+If a symbols has dependency on the preceding symbol, the menu entry
+should become the submenu of the preceding one, and displayed with
+deeper indentation.
+"""
+
+
+def test(conf):
+    assert conf.oldaskconfig() == 0
+    assert conf.stdout_contains('expected_stdout')
diff --git a/scripts/kconfig/tests/auto_submenu/expected_stdout b/scripts/kconfig/tests/auto_submenu/expected_stdout
new file mode 100644
index 0000000..bf5236f
--- /dev/null
+++ b/scripts/kconfig/tests/auto_submenu/expected_stdout
@@ -0,0 +1,10 @@
+A (A) [Y/n/?] (NEW) 
+  A0 (A0) [Y/n/?] (NEW) 
+    A1_0 (A0_0) [N/y/?] (NEW) 
+  A1 (A1) [Y/n/?] (NEW) 
+    choice
+    > 1. A1_0 (A1_0) (NEW)
+      2. A1_1 (A1_1) (NEW)
+    choice[1-2?]: 
+B (B) [N/y/?] (NEW) 
+C (C) [N/y/?] (NEW) 
-- 
2.7.4

  parent reply	other threads:[~2018-03-02  4:35 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-02  4:31 [PATCH v2 00/11] Add Kconfig unit tests Masahiro Yamada
2018-03-02  4:31 ` [PATCH v2 01/11] kbuild: define PYTHON2 and PYTHON3 variables instead of PYTHON Masahiro Yamada
2018-03-06 17:16   ` Tony Luck
2018-03-07  2:22     ` Masahiro Yamada
2018-03-02  4:31 ` [PATCH v2 02/11] kconfig: unittest: add framework for Kconfig unit testing Masahiro Yamada
2018-03-02  4:31 ` [PATCH v2 03/11] kconfig: unittest: add basic 'choice' tests Masahiro Yamada
2018-03-02  4:31 ` Masahiro Yamada [this message]
2018-03-02  4:31 ` [PATCH v2 05/11] kconfig: unittest: test if new symbols in choice are asked Masahiro Yamada
2018-03-02  4:31 ` [PATCH v2 06/11] kconfig: unittest: check unneeded "is not set" with unmet dependency Masahiro Yamada
2018-03-02  4:31 ` [PATCH v2 07/11] kconfig: unittest: check visibility of tri-choice values in y choice Masahiro Yamada
2018-03-02  4:31 ` [PATCH v2 08/11] kconfig: unittest: test defconfig when two choices interact Masahiro Yamada
2018-03-02 10:41   ` Ulf Magnusson
2018-03-06  9:21     ` Masahiro Yamada
2018-03-02  4:31 ` [PATCH v2 09/11] kconfig: unittest: test randconfig for choice in choice Masahiro Yamada
2018-03-02 11:14   ` Ulf Magnusson
     [not found]     ` <CAB=NE6V+5MK-ytS+-QBppSBLz7T4hRQV8eMA2Vv9-crcbj7NYg@mail.gmail.com>
2018-03-03  9:34       ` Ulf Magnusson
2018-03-06  9:36         ` Masahiro Yamada
2018-03-02  4:32 ` [PATCH v2 10/11] kconfig: unittest: test if recursive dependencies are detected Masahiro Yamada
2018-03-02  4:32 ` [PATCH v2 11/11] kconfig: unittest: test if recursive inclusion is detected Masahiro Yamada
2018-03-02  7:08   ` Masahiro Yamada

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1519965121-12017-5-git-send-email-yamada.masahiro@socionext.com \
    --to=yamada.masahiro@socionext.com \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mcgrof@kernel.org \
    --cc=michal.lkml@markovi.net \
    --cc=rdunlap@infradead.org \
    --cc=sam@ravnborg.org \
    --cc=ulfalizer@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).