Received: by 10.223.185.116 with SMTP id b49csp8238332wrg; Thu, 1 Mar 2018 20:49:05 -0800 (PST) X-Google-Smtp-Source: AG47ELsVLy5fci4euVuDpJh6Euu2MoqoEOTQMDeHeQzQlpl7UGaWHO+siWmNN47hXkFeg0m0YTy9 X-Received: by 10.99.116.69 with SMTP id e5mr3612786pgn.437.1519966145545; Thu, 01 Mar 2018 20:49:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519966145; cv=none; d=google.com; s=arc-20160816; b=JLnda22giUMoUsIhx+k8AnNbEha+u+SfHzcYWi0Y7Ee5Vgxpbmi0C1Wcsrg/lyd+/8 72AKp/X7SUayUrfli3a0YiuAdW/tZ2j8ukCkp1LeuLmwZ/l0YBDk4j2EP8SnoleDE+gk L2YsbCnVIVFa5c72lF8fvwQNu3qwFHwYEoVlyU4a2f55+ZOGjsVevc7H2pzy+MHnPp8P +OLYpwG9FcvhwOg5fWZNV55fJL6Kg04PVgy/P2rhgey33xKwondVq9b2WBMrH5JRP89/ yK4thhKF3++bITUnWe8V7jMWYf4hznP8J9kdMrC2NcxJCrw11+c4ZhhpMDHPPQoE3S83 j5gA== 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=zSrVCPJ+iYN1cnbLE0MBiGiPcElRE3AhAH1ywAQxF7Q=; b=BcDVbItrFZFJPVSCaXR0k/xrLx9cOf3uf/Ks4f218BtdHuBZQMQyqkTA1OalDWkLuz vWPAsrn1AhmBU9emS48NuvBD+wx0FGjuTCMOouSyrzhcn0K1IvCoWeBCHqomZbSS8Hfn oDenRZO8q0r7vgTY7w1hIkezarCtdPXcp4ZUXvcyvilNkJSYJVrTvLv6uluU/oHw9Lu8 oEb0LqolIDzvr/uvH/COOjI7iy3Bvf2vK+OT8szHdQjK2zFIAQdVCk2SIa0GLUsxoIsL Ol2xRDkNakk3F6hrnbZSS2KZrBAS+8fpkyIG5PW8ZgHNBWPAyny6RWtc7/DsNP1oChCj sg5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=i5x1Nf78; 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 q14-v6si4278659plk.632.2018.03.01.20.48.50; Thu, 01 Mar 2018 20:49:05 -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=i5x1Nf78; 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 S1422708AbeCBEfb (ORCPT + 99 others); Thu, 1 Mar 2018 23:35:31 -0500 Received: from conuserg-08.nifty.com ([210.131.2.75]:53189 "EHLO conuserg-08.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1164990AbeCBEdr (ORCPT ); Thu, 1 Mar 2018 23:33:47 -0500 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-08.nifty.com with ESMTP id w224WURF022085; Fri, 2 Mar 2018 13:32:34 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-08.nifty.com w224WURF022085 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1519965154; bh=zSrVCPJ+iYN1cnbLE0MBiGiPcElRE3AhAH1ywAQxF7Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=i5x1Nf78zQ7YsnU8KcXUhJcxMItunErtduHwmkk0L1RLgIwq0YdPd6qGSl5wsYIvq J3UEALzX7GGk4RZwH6mASsvdJpFgL0fO2Tsrg+s3dl5xmkxsHz9b0RwCvfxlXy9+3H VSs6SRWl0YvgN9RuVe3Mt29+Gavt7sucVKH+z8OtI8eDKXhUAFQ+Q7Til8hnuRpacS 2eCf3YtBpvqXVWFCyFzeML/mB2/SZDfoRwwRLV6tX0LKo32u3QUIxJpvdp9l5/Edqc tR/sIxcvGxlB7/YHfcAALZ6Szml5w2RN0WjyaIKY5Fe/QqJXM+8+kj7XFUN38xAgvy Jlov/dFAD0CTQ== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Sam Ravnborg , Michal Marek , Ulf Magnusson , Randy Dunlap , "Luis R . Rodriguez" , Masahiro Yamada , 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 Message-Id: <1519965121-12017-5-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1519965121-12017-1-git-send-email-yamada.masahiro@socionext.com> References: <1519965121-12017-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 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 Reviewed-by: Ulf Magnusson --- 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