Received: by 10.223.185.116 with SMTP id b49csp8921542wrg; Fri, 2 Mar 2018 10:10:41 -0800 (PST) X-Google-Smtp-Source: AG47ELsOfvonXoIasn90XoUL2XYrTDoUcYson0eYkXtutZjqx6OjnXZf49kRMKnqk/h3X9Sqj9Cd X-Received: by 10.99.113.94 with SMTP id b30mr5202291pgn.228.1520014241506; Fri, 02 Mar 2018 10:10:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520014241; cv=none; d=google.com; s=arc-20160816; b=WXXst7C/VQFdiIH/q7FOdfB/HBgKkWPHQOKUtYmwC13z8kIBu/DqkoRyAfGROQRfOI jqeCvysTXweHG2ZaG6Q7tlxc7syUKqXFXgGSRYSA5K2SXez7qg3fGea0i/3jdLofSFZV TX7YxBJzeXpOY0cTywOmQ9dSjFJPuyYLklbdqezBTUCffKVO0FKgcoO6UUwnWQAKqK8y b5hKI5AOjhu/1o+nUSbpaGJmhIZk2Rl0i7wrWCqr1Way+2N4HkF4X2HYBuKqi7yvS60v AEwldQexrArOHoyYLeLasebzTdMMJQP9LsQ1x+dTF6EB3ESjfri5M+aGsFzOuXpkWO0y vrNQ== 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=ag1b1ogIu+Wa5Z9/TWYpMWAMJfd6U6qypJl0VrJ98oA=; b=brknHfbiFGGh+8iaJIHubUs3xI9rUd5qWiAGdoIOpiEeJ+UaHeTxqQab8/JAasSfiF liIOkWGNnl1/kMyB1niju4gVpsMCBbAVZsCUOqqDnCIIrsgA2+ZAfX0om9M0sIbEXRr3 VHq9KnieeX/smaAz+E+etOmjPKVUETqkFFKM0WBxVzx3sWCeeLt+Fu9gXr2//M3Z0w+x Up8qMlGomL6tVymj2wuCu+yiq5BHzfA+WLyJQfyKIIegwKu1R24DXsEyeik0oreh5/5t I+wPhlfCShCgn9B/sS4vtrvPhMZYEE4VXPVno2nH1vDtI5YBlNI0LA0DElEyAqu/E9Hx 9YuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=U5sCI4cT; 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 w20-v6si2325167plq.486.2018.03.02.10.10.26; Fri, 02 Mar 2018 10:10:41 -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=U5sCI4cT; 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 S1427012AbeCBLPF (ORCPT + 99 others); Fri, 2 Mar 2018 06:15:05 -0500 Received: from mail-ua0-f196.google.com ([209.85.217.196]:42827 "EHLO mail-ua0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1423672AbeCBLOk (ORCPT ); Fri, 2 Mar 2018 06:14:40 -0500 Received: by mail-ua0-f196.google.com with SMTP id b23so5826863uak.9; Fri, 02 Mar 2018 03:14:40 -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=ag1b1ogIu+Wa5Z9/TWYpMWAMJfd6U6qypJl0VrJ98oA=; b=U5sCI4cTJucOk5Fib9dZr1sNbh2RrOuUw8KIkSh0/gnAQVynDB+htEJ5R1x/SIeu9T 2T83Tu9iyYcxp/rUY+B+LyZP7zQY8nV3zksZEpT7WZo8rOGeEuJEmrUH5jzjhuH3M0vZ zZzlOfEMRbzqQWWSsugGCHYaPBNsXRrUqV532aBMlTzS5UrgKvRVQ73hkk3l02g8PcMV tORdhc8tZnvIFYzLisueky+X+M2xA5ZtlolDuGfmgGlYz44Zuj+q0k0GURt2Sz1FL3oV 0t2mpxe9k44nBGZ6GyYl/cRngUzYHxGq5XtRwwMB95eMDmBT5UEiQjXQT1D2XRzqpzzU PApw== 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=ag1b1ogIu+Wa5Z9/TWYpMWAMJfd6U6qypJl0VrJ98oA=; b=DEnGeVDXj5Caa8KJBMEhWbNpO26lXP69Wka8dl/nCQvRXu4u+m7AUOOg+I3qk3L87N C3ClZn4lFImkwBOULla43RsszhwShRZBRD+bb0LQjeLfO/53Mpv/EoIbf8X8xH0HcAZw mENGN/ubamS0/iAfzq9Eqh5e9X/cvKSabztaxxwfutXGACFapd8tp2Z3RE/tawYDappv 76NTJ02gcgZYqrBOevIBvyl3tIv+uFCAhAVPIh5+mcx/Y45/Pq+5t9riflGLqvV3UW98 4oYVRfL01q51YZ1fC9nd7QFNwEu5ExcdZqpc8EIAQpj8b4QYevKWIqz7YOGq8uZUgAzi iGag== X-Gm-Message-State: APf1xPBvlGWhOeAv9UR9Wz0Rt/uzYfJ6TQGaDfH3uOLhoX5ZcDwcCZWc HRUcnRcKMFz5jD5iU62YA3j/697JkRr24wMW05c= X-Received: by 10.176.80.186 with SMTP id c55mr3575602uaa.42.1519989279964; Fri, 02 Mar 2018 03:14:39 -0800 (PST) MIME-Version: 1.0 Received: by 10.103.220.145 with HTTP; Fri, 2 Mar 2018 03:14:39 -0800 (PST) In-Reply-To: <1519965121-12017-10-git-send-email-yamada.masahiro@socionext.com> References: <1519965121-12017-1-git-send-email-yamada.masahiro@socionext.com> <1519965121-12017-10-git-send-email-yamada.masahiro@socionext.com> From: Ulf Magnusson Date: Fri, 2 Mar 2018 12:14:39 +0100 Message-ID: Subject: Re: [PATCH v2 09/11] kconfig: unittest: test randconfig for choice in choice To: Masahiro Yamada Cc: Linux Kbuild mailing list , Sam Ravnborg , Michal Marek , Randy Dunlap , "Luis R . Rodriguez" , 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 Fri, Mar 2, 2018 at 5:31 AM, Masahiro Yamada wrote: > Commit 3b9a19e08960 ("kconfig: loop as long as we changed some symbols > in randconfig") fixed randconfig where a choice contains a sub-choice. > Prior to that commit, the sub-choice values were not set. > > This is complicated usage, but it is still used in the real world; > drivers/usb/gadget/legacy/Kconfig is source'd in a choice context, > then creates a sub-choice in it. That file is the only one that does all that weird choice stuff btw. It's an optional choice with the choice symbols source'd from a separate file, containing non-symbol items and symbols that end up in implicit submenus and aren't considered choice symbols. It's as if it was written to make use of as much obscure Kconfig stuff as possible. :P > > For the test case in this commit, there are 3 possible results. > > Case 1: > CONFIG_A=y > # CONFIG_B is not set > > Case 2: > # CONFIG_A is not set > CONFIG_B=y > CONFIG_C=y > # CONFIG_D is not set > > Case 3: > # CONFIG_A is not set > CONFIG_B=y > # CONFIG_C is not set > CONFIG_D=y > CONFIG_E=y > > So, this test iterates several times, and checks if the result is > either of the three. > > Signed-off-by: Masahiro Yamada > --- > > Changes in v2: > - Newly added > > scripts/kconfig/tests/rand_nested_choice/Kconfig | 33 ++++++++++++++++++++++ > .../kconfig/tests/rand_nested_choice/__init__.py | 16 +++++++++++ > .../tests/rand_nested_choice/expected_stdout0 | 2 ++ > .../tests/rand_nested_choice/expected_stdout1 | 4 +++ > .../tests/rand_nested_choice/expected_stdout2 | 5 ++++ > 5 files changed, 60 insertions(+) > create mode 100644 scripts/kconfig/tests/rand_nested_choice/Kconfig > create mode 100644 scripts/kconfig/tests/rand_nested_choice/__init__.py > create mode 100644 scripts/kconfig/tests/rand_nested_choice/expected_stdout0 > create mode 100644 scripts/kconfig/tests/rand_nested_choice/expected_stdout1 > create mode 100644 scripts/kconfig/tests/rand_nested_choice/expected_stdout2 > > diff --git a/scripts/kconfig/tests/rand_nested_choice/Kconfig b/scripts/kconfig/tests/rand_nested_choice/Kconfig > new file mode 100644 > index 0000000..c591d51 > --- /dev/null > +++ b/scripts/kconfig/tests/rand_nested_choice/Kconfig > @@ -0,0 +1,33 @@ > +choice > + prompt "choice" > + > +config A > + bool "A" > + > +config B > + bool "B" > + > +if B > +choice > + prompt "sub choice" > + > +config C > + bool "C" > + > +config D > + bool "D" > + > +if D > +choice > + prompt "subsub choice" > + > +config E > + bool "E" > + > +endchoice > +endif # D > + > +endchoice > +endif # B > + > +endchoice > diff --git a/scripts/kconfig/tests/rand_nested_choice/__init__.py b/scripts/kconfig/tests/rand_nested_choice/__init__.py > new file mode 100644 > index 0000000..9ceadf6 > --- /dev/null > +++ b/scripts/kconfig/tests/rand_nested_choice/__init__.py > @@ -0,0 +1,16 @@ > +""" > +Set random values resursively in netsted choices. Two small typos: recursively, nested > + > +Kconfig can create a choice-in-choice structure by using 'if' statement. > +randconfig should correctly set randome choice values. Typo: random > + > +Related Linux commit: 3b9a19e08960e5cdad5253998637653e592a3c29 > +""" > + > + > +def test(conf): > + for i in range(20): > + assert conf.randconfig() == 0 > + assert (conf.config_contains('expected_stdout0') or > + conf.config_contains('expected_stdout1') or > + conf.config_contains('expected_stdout2')) > diff --git a/scripts/kconfig/tests/rand_nested_choice/expected_stdout0 b/scripts/kconfig/tests/rand_nested_choice/expected_stdout0 > new file mode 100644 > index 0000000..05450f3 > --- /dev/null > +++ b/scripts/kconfig/tests/rand_nested_choice/expected_stdout0 > @@ -0,0 +1,2 @@ > +CONFIG_A=y > +# CONFIG_B is not set > diff --git a/scripts/kconfig/tests/rand_nested_choice/expected_stdout1 b/scripts/kconfig/tests/rand_nested_choice/expected_stdout1 > new file mode 100644 > index 0000000..37ab295 > --- /dev/null > +++ b/scripts/kconfig/tests/rand_nested_choice/expected_stdout1 > @@ -0,0 +1,4 @@ > +# CONFIG_A is not set > +CONFIG_B=y > +CONFIG_C=y > +# CONFIG_D is not set > diff --git a/scripts/kconfig/tests/rand_nested_choice/expected_stdout2 b/scripts/kconfig/tests/rand_nested_choice/expected_stdout2 > new file mode 100644 > index 0000000..849ff47 > --- /dev/null > +++ b/scripts/kconfig/tests/rand_nested_choice/expected_stdout2 > @@ -0,0 +1,5 @@ > +# CONFIG_A is not set > +CONFIG_B=y > +# CONFIG_C is not set > +CONFIG_D=y > +CONFIG_E=y > -- > 2.7.4 > Reviewed-by: Ulf Magnusson Cheers, Ulf