From patchwork Tue Mar 13 09:12:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 131416 Delivered-To: patch@linaro.org Received: by 10.46.84.17 with SMTP id i17csp484071ljb; Tue, 13 Mar 2018 02:15:35 -0700 (PDT) X-Google-Smtp-Source: AG47ELsJujTdoXsN620jONV3WzvTfrrJWGHLiWLKcY6IXpmxrd76LBtbD9cWyQN/qcoDCPs/jRvm X-Received: by 10.101.91.133 with SMTP id i5mr8994067pgr.20.1520932534918; Tue, 13 Mar 2018 02:15:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520932534; cv=none; d=google.com; s=arc-20160816; b=kMVCwqcnpNvenw+Kt8AzNi1+x2tZdvHe6Ul7oxgl0w3qkLJ0nrdIW0f4loSP3wkTJa 3dDxSObLyq7GbJyUAtK+fAn4rQk5TDJkqS2CUe8HsdXmjgD3OsjRsHK5Zxsvc3mqfHQ1 a8Fw3nY6CX+CHE8IRJbTmUvw7PrvVWi4Sy4smQFQ+awtQBU54iOGzohhr3owT+ZVnWqT F4+e9xH0LPxaWOp8MZfP1F4U/a4fXg1CTwZmroVd16rKosIz6ihSUwCayjCjiAUZXPEB njTP6/4RmLS1T6ypDnEVrPclO/i1XYDibFgAeUNfenvI9C+dqZ8/S5jYmeO37B1layur oNIA== 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=np1j6RbdUMDb93B9SiA8k8CVTNrHiT4q6fGXnxB71rM=; b=f7Yg/8fFWYL+DSByN8x4dzi0U543IrzSUwHvA71/K3SLs7ZAu1PcUX472MyfW5Y5xP HGPbHft/gFpy2V6C5z/J35DVqz5ZQ7rUYZ3sIlNiOTDwpxWGWoKmIhcfMCM0Jbni4okH iz4Me3wEMobGsJCmB1VvLZipyDqY4XVqcpdHvV3N5D+a0pUldtU3EIMDKdrmSmMIfgAg 0c2jisTl/Rr/ZqzLAnQ96hEtde+4Q0lD+CEPk+58PA0lPwuT9SmeitKR/phWtg0rvf2Z tL+N+wGHUt/bEPoq/6d/XujNaMui4XJEJ7oxY2oID12YPClm1zzgs2yi4Yp7iCa20GAQ kBuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=FLmgk4IW; 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 m10si6294091pgq.417.2018.03.13.02.15.34; Tue, 13 Mar 2018 02:15:34 -0700 (PDT) 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=FLmgk4IW; 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 S932527AbeCMJPa (ORCPT + 28 others); Tue, 13 Mar 2018 05:15:30 -0400 Received: from conuserg-07.nifty.com ([210.131.2.74]:41800 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752483AbeCMJOB (ORCPT ); Tue, 13 Mar 2018 05:14:01 -0400 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-07.nifty.com with ESMTP id w2D9CIoA016505; Tue, 13 Mar 2018 18:12:25 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com w2D9CIoA016505 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1520932346; bh=np1j6RbdUMDb93B9SiA8k8CVTNrHiT4q6fGXnxB71rM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FLmgk4IWB+mHbMbDDK93RnDxjhOq2AYFRVEo7M3TAd+i/xLAZ7i0MQKUW1aNfU0Sw gbNV36xz0mU+fjnpzWrSicvoE6V8K08dMn4uVji4e5fa5m6X0eB3sBQpZlAsdIrL1F BmTsb5kMmMe6MpXjoa3RkUbXGUr3kcY8D1TqFHq0wNVhAffoPzuGqrJmowa3DOjbI4 W/7n66qLQdBfYET6pLFNaYwJWaTM6LyTprsWM09fBmeXR/v86jQvr1KOsQ0NNFierr XMcejmEhfKNj6rdEzQ2S8N2txgLjE733oHtWVF1WvIIcOCLQsV7yqTIJA2TwuuQ2vR i0WnbAfP12pCA== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Sam Ravnborg , Ulf Magnusson , Randy Dunlap , "Luis R . Rodriguez" , Tony Luck , Masahiro Yamada , linux-kernel@vger.kernel.org Subject: [PATCH v3 09/11] kconfig: tests: test randconfig for choice in choice Date: Tue, 13 Mar 2018 18:12:10 +0900 Message-Id: <1520932332-2449-10-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1520932332-2449-1-git-send-email-yamada.masahiro@socionext.com> References: <1520932332-2449-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 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. I am not sure whether this is an intended feature or just something people discovered works, but it is used in the real world; drivers/usb/gadget/legacy/Kconfig is source'd in a choice context, then creates a sub-choice in it. 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 Reviewed-by: Ulf Magnusson --- Changes in v3: - Fix typos 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 -- 2.7.4 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..e729a4e --- /dev/null +++ b/scripts/kconfig/tests/rand_nested_choice/__init__.py @@ -0,0 +1,16 @@ +""" +Set random values recursively in nested choices. + +Kconfig can create a choice-in-choice structure by using 'if' statement. +randconfig should correctly set random choice values. + +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