Received: by 10.223.185.116 with SMTP id b49csp8237514wrg; Thu, 1 Mar 2018 20:47:46 -0800 (PST) X-Google-Smtp-Source: AG47ELtHLrqjQFoAn5cDNRGzKzUQcstbpp/CXlDyXzSBbUt7IxDoyL+xPFCM23srGVNAXOgPW1fd X-Received: by 2002:a17:902:694c:: with SMTP id k12-v6mr4050086plt.133.1519966065956; Thu, 01 Mar 2018 20:47:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519966065; cv=none; d=google.com; s=arc-20160816; b=fOZY4yCUAZt/aIW0NkQlocYJJ34LUW0mYXK+vLmZIcYZsqngnadiq3/LSR+5uwWCfx lgkBXi3+NO6ZuUfuRszE9ilgQMvStTvJAsje/g5AUHtJCLhlwLnDsYfu6MCPPavTPvxf 6O7yEFZOahYr4Vs+BKR/4IsWYK75YRPADp9FrTdMTBia9gPvcd+EH3tBLO0PiSjJZNWK 6jq5k4n9hGhb7ZIS/ia+5fx/AY7RJ5VMTXAqRjMinIS/GYC0gVtptjS3lJIJxXckzT5B u5yMAa1eIsJ2/cXqBWnRl7HrliimbL71xcaPnCQ4rcIfhN6Q1YH98e5rnicGE4zHENfs AMmw== 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=PeVeQIJ7t2R3NqLMu1w3DN0G/A3DemmEpE+OC6wHaqg=; b=dYCor00RbsvUiMY+5PjtBpSTSj1ZxIAamjHDvogWAyRoaOvX2zZJY5cVQIbCHpYxTS 0KsdzyEVEBt55m2DhV20hzyMfgMqIeHCxydbvQ5ExoYJst1ipvMdgfWZP1plyxLpjMqq yX2SOecxgqvdtQbqnWErxCHqWX5E6MVZEL/Vj2d+s/e/nQ5WlR5YPTcYiYBEvbiQI6jO gT1ZTIJkcjBQMxAQ+CE66W/92M93xjAls6IUC+aSqmpnS8bV3X87RnCOg6sI4yj+S99G GYriswtwxYg8BBI5EhY6fby3pGr7d9VLft6YCveMBx6un7dhjlLieLExcPM3r3Q0DRo/ zMgw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=ylqVb7Ac; 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 g1-v6si4140325plt.574.2018.03.01.20.47.29; Thu, 01 Mar 2018 20:47:45 -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=ylqVb7Ac; 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 S1422739AbeCBEfe (ORCPT + 99 others); Thu, 1 Mar 2018 23:35:34 -0500 Received: from conuserg-08.nifty.com ([210.131.2.75]:53186 "EHLO conuserg-08.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1164989AbeCBEdr (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 w224WURK022085; Fri, 2 Mar 2018 13:32:37 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-08.nifty.com w224WURK022085 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1519965158; bh=PeVeQIJ7t2R3NqLMu1w3DN0G/A3DemmEpE+OC6wHaqg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ylqVb7AcFJkJmcJLYhJpa+eOCc7FGP8flwvayaGaWiNCzv71nn8J7HnNSWOP5JCD9 7gIIx2hE4DqxeGZLKRTMPea5zdzpTxO7a/j+uLz7MQ3oPBJPvLhsuJxIgeA+lzO2QY 5SPlApwroVNnFMTMwlkWj/XR0tzBFtmyb5Lpt/vq7c4sxe+MEyem5MCeGOboKH9Rg5 zEKflRgo++Hp0MwLnKu6GNlkxaukzLBPGUjQ8LQptIxko0jaiLdXwOFt/rpW9aXLsN OKRjYZBXzedNV/RA2dS3NLmLy/pdMM/SsSw30Bhn51yppVK/Mp768D9A+57noMUtHG 7j6hH6bmj81zg== 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 09/11] kconfig: unittest: test randconfig for choice in choice Date: Fri, 2 Mar 2018 13:31:59 +0900 Message-Id: <1519965121-12017-10-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 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. 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. + +Kconfig can create a choice-in-choice structure by using 'if' statement. +randconfig should correctly set randome 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 -- 2.7.4