From patchwork Tue Mar 13 09:12:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 131420 Delivered-To: patch@linaro.org Received: by 10.46.84.17 with SMTP id i17csp485176ljb; Tue, 13 Mar 2018 02:16:53 -0700 (PDT) X-Google-Smtp-Source: AG47ELsAV/h6VnHN92Fr9/ChWK04rLkzA6E16AmFeLxKIfcy7crrMZuRIsUxJOFLM3LJ9iy3duA2 X-Received: by 2002:a17:902:8d87:: with SMTP id v7-v6mr11113290plo.146.1520932613565; Tue, 13 Mar 2018 02:16:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520932613; cv=none; d=google.com; s=arc-20160816; b=kgmb3a2PSHLhyktg47PWJIJsBY6ivFDlF6pywdXF+5k1JdncCWugI/HyGj691nU8Ty rDk01ueBMSJLWfrHkw2LcfEK8oOevL2MtYsmrRUtOfZlWFh+Zf+oqkpQyITOKYd0lGuY 9ZmWNXgpnAQyriheQqq1irShGI/iYfZFFzlKB9xNKJ0LrHBFo+ZmR6yGIezZytJbEB1H ZqFKSMvqs58HbJYvd767AgAkw24k68P5Ve+mC/6gvvaYh/vRVxcNSZTjXbpImIPzafvH hEHYPrP1l+1aa1yD5ZsYNQ3fG4+vl8rVX+EMOwCP94VgpFHUqaGzHtiFEGuWBcmO3/ja sFiw== 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=uVZpVmz+OOBd3qoL/yP203TDWbvn86FxgDbftaI9fcI=; b=aJ8unljgx7kfeDuyG3ySo9/haHuDgj/DuiKh7xCfUMjCQA0l8JVcUuYEusLkWLJ7k6 uf/jXVZTwSvfgbncgGhppMH73me5IFTLBRv1I7OauxxWjYqixkBqM5cXGh2ywHZzGQxa xa+A8bFVbiFq0TS5QdB6G731HMnOJsdlOPTAlyvEKr847kGWTN89JSWF3DexHsuzRZer 6uSri+rVqduB8d6dwT/OGKNJPDRrbc7EyNXpnd7Ly5ZYIvUHv+eknbCMovUHtnLQpUwj rtsLXfm92gEauiz8SSjs/Z5Go95SQVwX4iwRcZEQWzHZEOeURR4vw1qhsk/LtYvY/+Gr v09Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=LPKBNofB; 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 z1si6209853pgv.563.2018.03.13.02.16.53; Tue, 13 Mar 2018 02:16:53 -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=LPKBNofB; 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 S1752505AbeCMJOA (ORCPT + 28 others); Tue, 13 Mar 2018 05:14:00 -0400 Received: from conuserg-07.nifty.com ([210.131.2.74]:41660 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752302AbeCMJN4 (ORCPT ); Tue, 13 Mar 2018 05:13:56 -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 w2D9CIo2016505; Tue, 13 Mar 2018 18:12:19 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com w2D9CIo2016505 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1520932339; bh=uVZpVmz+OOBd3qoL/yP203TDWbvn86FxgDbftaI9fcI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LPKBNofBJQeu+xBLEwC9nylNgJYL7mHTNuR5lbnS4AXTgUQaJFkfJWBIJJAiCZgvw D3cAfxUxxKlzzItlUv4dL/44pUU5IqUeIImsOVFxghOa8gd2HEAsDbElT516EcRwND CxQlmqj0qPnACku5G0mFHN4UsNlqXKci+T8oKveKul2LXT71PFg3eIw6dq4j5vp4MW uC4K7Il/vWg6we+yzExvxCaF8+u5yVkWzBBC695sEvH8iAswkvgJjF8tdWhQjEOCi8 drv0by5SDsvHCHvGj7UNBDiLY/BjhYpYRnPzeSRUFkj3IQnRbhhrIQKrcHmoL0jul/ lr6YmT7gLBgsg== 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 , Michal Marek , linux-kernel@vger.kernel.org Subject: [PATCH v3 01/11] kbuild: add PYTHON2 and PYTHON3 variables Date: Tue, 13 Mar 2018 18:12:02 +0900 Message-Id: <1520932332-2449-2-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 The variable 'PYTHON' allows users to specify a proper executable name in case the default 'python' does not work. However, this does not address the case where both Python 2.x and 3.x scripts are used in one source tree. PEP 394 (https://www.python.org/dev/peps/pep-0394/) provides a convention for Python scripts portability. Here is a quotation: In order to tolerate differences across platforms, all new code that needs to invoke the Python interpreter should not specify 'python', but rather should specify either 'python2' or 'python3'. This distinction should be made in shebangs, when invoking from a shell script, when invoking via the system() call, or when invoking in any other context. One exception to this is scripts that are deliberately written to be source compatible with both Python 2.x and 3.x. Such scripts may continue to use python on their shebang line without affecting their portability. To meet this requirement, this commit adds new variables 'PYTHON2' and 'PYTHON3'. arch/ia64/scripts/unwcheck.py is the only script that has ever used $(PYTHON). Recent commit bd5edbe67794 ("ia64: convert unwcheck.py to python3") converted it to be compatible with both Python 2.x and 3.x, so this is the exceptional case where the use of 'python' is allowed. So, I did not touch arch/ia64/Makefile. tools/perf/Makefile.config sets PYTHON and PYTHON2 by itself, so it is not affected by this commit. Signed-off-by: Masahiro Yamada --- Changes in v3: - Keep PYTHON as-is because ia64 recently converted its script compatible with Python 3.x Changes in v2: - Add backward compatibility for PYTHON Makefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) -- 2.7.4 diff --git a/Makefile b/Makefile index e02d092..7a5f85e 100644 --- a/Makefile +++ b/Makefile @@ -385,6 +385,8 @@ INSTALLKERNEL := installkernel DEPMOD = /sbin/depmod PERL = perl PYTHON = python +PYTHON2 = python2 +PYTHON3 = python3 CHECK = sparse CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \ @@ -430,7 +432,7 @@ GCC_PLUGINS_CFLAGS := export ARCH SRCARCH CONFIG_SHELL HOSTCC HOSTCFLAGS CROSS_COMPILE AS LD CC export CPP AR NM STRIP OBJCOPY OBJDUMP HOSTLDFLAGS HOST_LOADLIBES -export MAKE LEX YACC AWK GENKSYMS INSTALLKERNEL PERL PYTHON UTS_MACHINE +export MAKE LEX YACC AWK GENKSYMS INSTALLKERNEL PERL PYTHON PYTHON2 PYTHON3 UTS_MACHINE export HOSTCXX HOSTCXXFLAGS LDFLAGS_MODULE CHECK CHECKFLAGS export KBUILD_CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS LDFLAGS From patchwork Tue Mar 13 09:12:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 131422 Delivered-To: patch@linaro.org Received: by 10.46.84.17 with SMTP id i17csp485631ljb; Tue, 13 Mar 2018 02:17:29 -0700 (PDT) X-Google-Smtp-Source: AG47ELuqlLiZTf1ETFfkGQZZnjp+Ch685MtRT9jAj0QvUlUGWFet0D2LycL/i4FCOh5GuUJg5enN X-Received: by 10.99.180.2 with SMTP id s2mr3551135pgf.26.1520932649064; Tue, 13 Mar 2018 02:17:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520932649; cv=none; d=google.com; s=arc-20160816; b=WAAbHxnI3cyLbXwKYEl++fP/GPELdkl5yNYO8Q1yHA4+33x54YHUwgOV3mM6r8lVMK wV5e7riCYg0QDMhlMi75CQd1UcDGVhQjjH7TTUeTXeI6oqz2o2CxevDrGMusb5b4Yobk homSHKsdHh7SIkaQldjiN25WKclgDFgSLWpDkQmaSsAvX7GaeCHX28gkP+Tv6RnTMJFt bLHt8ivdycRu/JrWVrU12ioms0d4eKF3touFGi2urVHURBR4eo+dUSFcuuRUxCF7tx5d 3sJm0/slcMxAtnrk3nPYnxel0SNJfMEgMxMkEGpnak8q7BbPpvARbFrd0+TfJXC4qDft EVdQ== 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=B5HkizdL7kl7WCc/yuhv27TUnC72pluNFomvD03QqUY=; b=Ap+wj/L+WmRmyO+Tg+qsEwzmVgSU3B4Vs+ryNdWrUkQTKbS9NssSr98v7hdb2Hhmku gAFAes9tdEg01t9OH0FB14iQ+VHkj5//uPOr6IsP7jT1U+4zJ8b2tqQy6J4C41aFhKbK 01yN1c+ZRBCCAT/SCXb1VwQv7zbLSJ+YJnBlfkfYv2g1kA0lDz9uaMu3NQlGLWMsqa9y 8FkjtaoSXfjK6dRDYK4kWawsPiTPfxH82ioqpaJPp1w/5rOzP6zowQWA6eLNB67+dY3+ bJNBh3nwaz2X1IomkfNgLdObVPvqhFF2bIEIaotqE1vX+04KCm3gsW8xrmde8A4bCjRc UuGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=l6uMZlnH; 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 31-v6si2886364plg.227.2018.03.13.02.17.28; Tue, 13 Mar 2018 02:17:29 -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=l6uMZlnH; 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 S1752605AbeCMJR0 (ORCPT + 28 others); Tue, 13 Mar 2018 05:17:26 -0400 Received: from conuserg-07.nifty.com ([210.131.2.74]:41654 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752218AbeCMJN4 (ORCPT ); Tue, 13 Mar 2018 05:13:56 -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 w2D9CIo3016505; Tue, 13 Mar 2018 18:12:20 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com w2D9CIo3016505 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1520932340; bh=B5HkizdL7kl7WCc/yuhv27TUnC72pluNFomvD03QqUY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=l6uMZlnHUwyVts7prmmE+F1kuEW1REDRLxf0nzqFxt10b6ZcoLNXFED94tyhClO8F se8bG6BIRar9MPPlayrKOPKZKNEMFrmL/Zgw7nYEMSDFPtLHAXOlrtgJ23UyieRYB0 SIaePvej+/yw9yaCmCXq8x39U5hWR0f0YXaw94bKjRfYRNli4mwyw/P5G6wG0nkKRh ph8FGk6+vGn/OuTAoxlaC1UURED+3m0vBR6pfqqSUCWNac9De6q/wDtt7Eo2X7jI/P +OX+SkRAYD4GRFhqMERiofdEaVS6ZYvEAn7SPXErutYvWlFYuNkUJ4Wvea1FRYjKM4 m4jsNxOiBP0jw== 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 02/11] kconfig: tests: add framework for Kconfig unit testing Date: Tue, 13 Mar 2018 18:12:03 +0900 Message-Id: <1520932332-2449-3-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 Many parts in Kconfig are so cryptic and need refactoring. However, its complexity prevents us from moving forward. There are several naive corner cases where it is difficult to notice breakage. If those are covered by unit tests, we will be able to touch the code with more confidence. Here is a simple test framework based on pytest. The conftest.py provides a fixture useful to run commands such as 'oldaskconfig' etc. and to compare the resulted .config, stdout, stderr with expectations. How to add test cases? ---------------------- For each test case, you should create a subdirectory under scripts/kconfig/tests/ (so test cases are separated from each other). Every test case directory should contain the following files: - __init__.py: describes test functions - Kconfig: the top level Kconfig file for the test To do a useful job, test cases generally need additional data like input .config and information about expected results. How to run tests? ----------------- You need python3 and pytest. Then, run "make testconfig". O= option is supported. If V=1 is given, detailed logs captured during tests are displayed. Signed-off-by: Masahiro Yamada Reviewed-by: Ulf Magnusson --- Changes in v3: None Changes in v2: - Add 'randconfig' support - Add docstring - Fix various style errors detected by 'pep8' and 'pep257' scripts/kconfig/Makefile | 8 ++ scripts/kconfig/tests/conftest.py | 291 ++++++++++++++++++++++++++++++++++++++ scripts/kconfig/tests/pytest.ini | 7 + 3 files changed, 306 insertions(+) create mode 100644 scripts/kconfig/tests/conftest.py create mode 100644 scripts/kconfig/tests/pytest.ini -- 2.7.4 diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile index cb3ec53..c5d1d1a 100644 --- a/scripts/kconfig/Makefile +++ b/scripts/kconfig/Makefile @@ -135,6 +135,14 @@ PHONY += tinyconfig tinyconfig: $(Q)$(MAKE) -f $(srctree)/Makefile allnoconfig tiny.config +# CHECK: -o cache_dir= working? +PHONY += testconfig +testconfig: $(obj)/conf + $(PYTHON3) -B -m pytest $(srctree)/$(src)/tests \ + -o cache_dir=$(abspath $(obj)/tests/.cache) \ + $(if $(findstring 1,$(KBUILD_VERBOSE)),--capture=no) +clean-dirs += tests/.cache + # Help text used by make help help: @echo ' config - Update current config utilising a line-oriented program' diff --git a/scripts/kconfig/tests/conftest.py b/scripts/kconfig/tests/conftest.py new file mode 100644 index 0000000..0345ef6 --- /dev/null +++ b/scripts/kconfig/tests/conftest.py @@ -0,0 +1,291 @@ +# SPDX-License-Identifier: GPL-2.0 +# +# Copyright (C) 2018 Masahiro Yamada +# + +""" +Kconfig unit testing framework. + +This provides fixture functions commonly used from test files. +""" + +import os +import pytest +import shutil +import subprocess +import tempfile + +CONF_PATH = os.path.abspath(os.path.join('scripts', 'kconfig', 'conf')) + + +class Conf: + """Kconfig runner and result checker. + + This class provides methods to run text-based interface of Kconfig + (scripts/kconfig/conf) and retrieve the resulted configuration, + stdout, and stderr. It also provides methods to compare those + results with expectations. + """ + + def __init__(self, request): + """Create a new Conf instance. + + request: object to introspect the requesting test module + """ + # the directory of the test being run + self._test_dir = os.path.dirname(str(request.fspath)) + + # runners + def _run_conf(self, mode, dot_config=None, out_file='.config', + interactive=False, in_keys=None, extra_env={}): + """Run text-based Kconfig executable and save the result. + + mode: input mode option (--oldaskconfig, --defconfig= etc.) + dot_config: .config file to use for configuration base + out_file: file name to contain the output config data + interactive: flag to specify the interactive mode + in_keys: key inputs for interactive modes + extra_env: additional environments + returncode: exit status of the Kconfig executable + """ + command = [CONF_PATH, mode, 'Kconfig'] + + # Override 'srctree' environment to make the test as the top directory + extra_env['srctree'] = self._test_dir + + # Run Kconfig in a temporary directory. + # This directory is automatically removed when done. + with tempfile.TemporaryDirectory() as temp_dir: + + # if .config is given, copy it to the working directory + if dot_config: + shutil.copyfile(os.path.join(self._test_dir, dot_config), + os.path.join(temp_dir, '.config')) + + ps = subprocess.Popen(command, + stdin=subprocess.PIPE, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + cwd=temp_dir, + env=dict(os.environ, **extra_env)) + + # If input key sequence is given, feed it to stdin. + if in_keys: + ps.stdin.write(in_keys.encode('utf-8')) + + while ps.poll() is None: + # For interactive modes such as oldaskconfig, oldconfig, + # send 'Enter' key until the program finishes. + if interactive: + ps.stdin.write(b'\n') + + self.retcode = ps.returncode + self.stdout = ps.stdout.read().decode() + self.stderr = ps.stderr.read().decode() + + # Retrieve the resulted config data only when .config is supposed + # to exist. If the command fails, the .config does not exist. + # 'listnewconfig' does not produce .config in the first place. + if self.retcode == 0 and out_file: + with open(os.path.join(temp_dir, out_file)) as f: + self.config = f.read() + else: + self.config = None + + # Logging: + # Pytest captures the following information by default. In failure + # of tests, the captured log will be displayed. This will be useful to + # figure out what has happened. + + print("[command]\n{}\n".format(' '.join(command))) + + print("[retcode]\n{}\n".format(self.retcode)) + + print("[stdout]") + print(self.stdout) + + print("[stderr]") + print(self.stderr) + + if self.config is not None: + print("[output for '{}']".format(out_file)) + print(self.config) + + return self.retcode + + def oldaskconfig(self, dot_config=None, in_keys=None): + """Run oldaskconfig. + + dot_config: .config file to use for configuration base (optional) + in_key: key inputs (optional) + returncode: exit status of the Kconfig executable + """ + return self._run_conf('--oldaskconfig', dot_config=dot_config, + interactive=True, in_keys=in_keys) + + def oldconfig(self, dot_config=None, in_keys=None): + """Run oldconfig. + + dot_config: .config file to use for configuration base (optional) + in_key: key inputs (optional) + returncode: exit status of the Kconfig executable + """ + return self._run_conf('--oldconfig', dot_config=dot_config, + interactive=True, in_keys=in_keys) + + def olddefconfig(self, dot_config=None): + """Run olddefconfig. + + dot_config: .config file to use for configuration base (optional) + returncode: exit status of the Kconfig executable + """ + return self._run_conf('--olddefconfig', dot_config=dot_config) + + def defconfig(self, defconfig): + """Run defconfig. + + defconfig: defconfig file for input + returncode: exit status of the Kconfig executable + """ + defconfig_path = os.path.join(self._test_dir, defconfig) + return self._run_conf('--defconfig={}'.format(defconfig_path)) + + def _allconfig(self, mode, all_config): + if all_config: + all_config_path = os.path.join(self._test_dir, all_config) + extra_env = {'KCONFIG_ALLCONFIG': all_config_path} + else: + extra_env = {} + + return self._run_conf('--{}config'.format(mode), extra_env=extra_env) + + def allyesconfig(self, all_config=None): + """Run allyesconfig. + + all_config: fragment config file for KCONFIG_ALLCONFIG (optional) + returncode: exit status of the Kconfig executable + """ + return self._allconfig('allyes', all_config) + + def allmodconfig(self, all_config=None): + """Run allmodconfig. + + all_config: fragment config file for KCONFIG_ALLCONFIG (optional) + returncode: exit status of the Kconfig executable + """ + return self._allconfig('allmod', all_config) + + def allnoconfig(self, all_config=None): + """Run allnoconfig. + + all_config: fragment config file for KCONFIG_ALLCONFIG (optional) + returncode: exit status of the Kconfig executable + """ + return self._allconfig('allno', all_config) + + def alldefconfig(self, all_config=None): + """Run alldefconfig. + + all_config: fragment config file for KCONFIG_ALLCONFIG (optional) + returncode: exit status of the Kconfig executable + """ + return self._allconfig('alldef', all_config) + + def randconfig(self, all_config=None): + """Run randconfig. + + all_config: fragment config file for KCONFIG_ALLCONFIG (optional) + returncode: exit status of the Kconfig executable + """ + return self._allconfig('rand', all_config) + + def savedefconfig(self, dot_config): + """Run savedefconfig. + + dot_config: .config file for input + returncode: exit status of the Kconfig executable + """ + return self._run_conf('--savedefconfig', out_file='defconfig') + + def listnewconfig(self, dot_config=None): + """Run listnewconfig. + + dot_config: .config file to use for configuration base (optional) + returncode: exit status of the Kconfig executable + """ + return self._run_conf('--listnewconfig', dot_config=dot_config, + out_file=None) + + # checkers + def _read_and_compare(self, compare, expected): + """Compare the result with expectation. + + compare: function to compare the result with expectation + expected: file that contains the expected data + """ + with open(os.path.join(self._test_dir, expected)) as f: + expected_data = f.read() + return compare(self, expected_data) + + def _contains(self, attr, expected): + return self._read_and_compare( + lambda s, e: getattr(s, attr).find(e) >= 0, + expected) + + def _matches(self, attr, expected): + return self._read_and_compare(lambda s, e: getattr(s, attr) == e, + expected) + + def config_contains(self, expected): + """Check if resulted configuration contains expected data. + + expected: file that contains the expected data + returncode: True if result contains the expected data, False otherwise + """ + return self._contains('config', expected) + + def config_matches(self, expected): + """Check if resulted configuration exactly matches expected data. + + expected: file that contains the expected data + returncode: True if result matches the expected data, False otherwise + """ + return self._matches('config', expected) + + def stdout_contains(self, expected): + """Check if resulted stdout contains expected data. + + expected: file that contains the expected data + returncode: True if result contains the expected data, False otherwise + """ + return self._contains('stdout', expected) + + def stdout_matches(self, expected): + """Check if resulted stdout exactly matches expected data. + + expected: file that contains the expected data + returncode: True if result matches the expected data, False otherwise + """ + return self._matches('stdout', expected) + + def stderr_contains(self, expected): + """Check if resulted stderr contains expected data. + + expected: file that contains the expected data + returncode: True if result contains the expected data, False otherwise + """ + return self._contains('stderr', expected) + + def stderr_matches(self, expected): + """Check if resulted stderr exactly matches expected data. + + expected: file that contains the expected data + returncode: True if result matches the expected data, False otherwise + """ + return self._matches('stderr', expected) + + +@pytest.fixture(scope="module") +def conf(request): + """Create a Conf instance and provide it to test functions.""" + return Conf(request) diff --git a/scripts/kconfig/tests/pytest.ini b/scripts/kconfig/tests/pytest.ini new file mode 100644 index 0000000..85d7ce8 --- /dev/null +++ b/scripts/kconfig/tests/pytest.ini @@ -0,0 +1,7 @@ +[pytest] +addopts = --verbose + +# Pytest requires that test files have unique names, because pytest imports +# them as top-level modules. It is silly to prefix or suffix a test file with +# the directory name that contains it. Use __init__.py for all test files. +python_files = __init__.py From patchwork Tue Mar 13 09:12:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 131418 Delivered-To: patch@linaro.org Received: by 10.46.84.17 with SMTP id i17csp484795ljb; Tue, 13 Mar 2018 02:16:28 -0700 (PDT) X-Google-Smtp-Source: AG47ELvTG2w6jAusFuk7iYx4FTt+h/AD4ZROp2XaqZfpBZQr5P/k1rYd94zoOggG4uRav12k9E1f X-Received: by 10.98.21.200 with SMTP id 191mr10931186pfv.166.1520932588469; Tue, 13 Mar 2018 02:16:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520932588; cv=none; d=google.com; s=arc-20160816; b=qIehWBQGtLluQuBV6VEN3JLZ5AFy5rjSYKOE77QRGq4T+/WCNKhMWCCWZI4XM9UQ4y kVumpmQ3t6rASY19Me1xWZUtV/M6Bgw/QJyk/kRYUePJ6Op5mF2zRtBVgEtAhzURA9u7 exk9G7fHd1XPjf2hN32pHWYSgfCamQx+bhPv7fKfBPa+nOw3ZVrQ34H/OQLA1xU8oX+X 42hbX0x6CrVBYevyxIRXIXQPBPgki8n48XujxwruqWNU0qhDse28CVloPVgmpCh6hxrT uI9qyaLBJDdejXh6MYZCYnR6dAttsvJ2aV4Mlxuh+HNsAHhoTClKEEHRmtYFK8QEl35t +Ahw== 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=Fwodea/JNvkYoFby5ODVYe1zlReJP0KJ1f2ZiDqULGc=; b=w1BmL1fbBLdIh0OWZIwC/L7wFr6uJJpu2Hxme0qQlxHqplRjWvkj9Zv5XZPQ1pP8ga 9+dL1vq9xD6R2vc7EbId5ORbtoW2Y089trgT6dDm3zEpWYB+HPC7HICd4c+YT8Wa1vNi WNWg2+pADf/SqppixE8o89bVWu1Z9hkdQKWb4rGE5o1qLJsKSJG+CGBPLvQGg8KiJBsq 0auF+Qc3rCGf6pxukDp6DEoTuoZgDa6EUQMBq0Hcntr4GMk/wscX401axPIvL8N+2LAz P/mh2WXuikYmPkujdcJfXz/NNusgqSUi/l9hPlbI/XjYFTOEcET3FXkNWsQa86p+D3zp Yxiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=lo7jbVn+; 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 x4si6370531pgq.11.2018.03.13.02.16.28; Tue, 13 Mar 2018 02:16:28 -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=lo7jbVn+; 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 S1752639AbeCMJP2 (ORCPT + 28 others); Tue, 13 Mar 2018 05:15:28 -0400 Received: from conuserg-07.nifty.com ([210.131.2.74]:41798 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752486AbeCMJOB (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 w2D9CIo4016505; Tue, 13 Mar 2018 18:12:21 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com w2D9CIo4016505 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1520932341; bh=Fwodea/JNvkYoFby5ODVYe1zlReJP0KJ1f2ZiDqULGc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lo7jbVn+w+AaF1SWSA/P37t1+E9lVTrPKD9G+4KZx/o4ERKCMcUo8vE8w4DLm9Adu vMOm+TkPhpzlf8PGxK5y9O01p71DMtkFsNCZs6fx2mMfEVSURKHLWfEpsMFL28fPcE EIm00mux/u/J3OPQZM4HcpeTyVy8Ucr4snF325UKwGMhKJsSKEyZSczfahnPPDXwNW H++Ku+5i/EpjvZ1Gq0gwLxIngDiTxreom7cfAclm9aemy9O0gGp7Vx3V5qYlrvPe8H /9ufkfMFcMsdas+NtKCVyVGuNjSIMCt0HXwRnR8HftlD0mBsTWVI4Lclvmf7w7p6m6 emgZ85gIhPV9g== 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 03/11] kconfig: tests: add basic choice tests Date: Tue, 13 Mar 2018 18:12:04 +0900 Message-Id: <1520932332-2449-4-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 The calculation of 'choice' is a bit complicated part in Kconfig. The behavior of 'y' choice is intuitive. If choice values are tristate, the choice can be 'm' where each value can be enabled independently. Also, if a choice is marked as 'optional', the whole choice can be invisible. Test basic functionality of choice. Signed-off-by: Masahiro Yamada Reviewed-by: Ulf Magnusson --- Changes in v3: None Changes in v2: - coding style clean-up based on PEP8, PEP257 scripts/kconfig/tests/choice/Kconfig | 54 ++++++++++++++++++++++ scripts/kconfig/tests/choice/__init__.py | 40 ++++++++++++++++ .../kconfig/tests/choice/alldef_expected_config | 5 ++ .../kconfig/tests/choice/allmod_expected_config | 9 ++++ scripts/kconfig/tests/choice/allno_expected_config | 5 ++ .../kconfig/tests/choice/allyes_expected_config | 9 ++++ .../kconfig/tests/choice/oldask0_expected_stdout | 10 ++++ scripts/kconfig/tests/choice/oldask1_config | 2 + .../kconfig/tests/choice/oldask1_expected_stdout | 15 ++++++ 9 files changed, 149 insertions(+) create mode 100644 scripts/kconfig/tests/choice/Kconfig create mode 100644 scripts/kconfig/tests/choice/__init__.py create mode 100644 scripts/kconfig/tests/choice/alldef_expected_config create mode 100644 scripts/kconfig/tests/choice/allmod_expected_config create mode 100644 scripts/kconfig/tests/choice/allno_expected_config create mode 100644 scripts/kconfig/tests/choice/allyes_expected_config create mode 100644 scripts/kconfig/tests/choice/oldask0_expected_stdout create mode 100644 scripts/kconfig/tests/choice/oldask1_config create mode 100644 scripts/kconfig/tests/choice/oldask1_expected_stdout -- 2.7.4 diff --git a/scripts/kconfig/tests/choice/Kconfig b/scripts/kconfig/tests/choice/Kconfig new file mode 100644 index 0000000..cc60e9c --- /dev/null +++ b/scripts/kconfig/tests/choice/Kconfig @@ -0,0 +1,54 @@ +config MODULES + bool "Enable loadable module support" + option modules + default y + +choice + prompt "boolean choice" + default BOOL_CHOICE1 + +config BOOL_CHOICE0 + bool "choice 0" + +config BOOL_CHOICE1 + bool "choice 1" + +endchoice + +choice + prompt "optional boolean choice" + optional + default OPT_BOOL_CHOICE1 + +config OPT_BOOL_CHOICE0 + bool "choice 0" + +config OPT_BOOL_CHOICE1 + bool "choice 1" + +endchoice + +choice + prompt "tristate choice" + default TRI_CHOICE1 + +config TRI_CHOICE0 + tristate "choice 0" + +config TRI_CHOICE1 + tristate "choice 1" + +endchoice + +choice + prompt "optional tristate choice" + optional + default OPT_TRI_CHOICE1 + +config OPT_TRI_CHOICE0 + tristate "choice 0" + +config OPT_TRI_CHOICE1 + tristate "choice 1" + +endchoice diff --git a/scripts/kconfig/tests/choice/__init__.py b/scripts/kconfig/tests/choice/__init__.py new file mode 100644 index 0000000..9edcc52 --- /dev/null +++ b/scripts/kconfig/tests/choice/__init__.py @@ -0,0 +1,40 @@ +""" +Basic choice tests. + +The handling of 'choice' is a bit complicated part in Kconfig. + +The behavior of 'y' choice is intuitive. If choice values are tristate, +the choice can be 'm' where each value can be enabled independently. +Also, if a choice is marked as 'optional', the whole choice can be +invisible. +""" + + +def test_oldask0(conf): + assert conf.oldaskconfig() == 0 + assert conf.stdout_contains('oldask0_expected_stdout') + + +def test_oldask1(conf): + assert conf.oldaskconfig('oldask1_config') == 0 + assert conf.stdout_contains('oldask1_expected_stdout') + + +def test_allyes(conf): + assert conf.allyesconfig() == 0 + assert conf.config_contains('allyes_expected_config') + + +def test_allmod(conf): + assert conf.allmodconfig() == 0 + assert conf.config_contains('allmod_expected_config') + + +def test_allno(conf): + assert conf.allnoconfig() == 0 + assert conf.config_contains('allno_expected_config') + + +def test_alldef(conf): + assert conf.alldefconfig() == 0 + assert conf.config_contains('alldef_expected_config') diff --git a/scripts/kconfig/tests/choice/alldef_expected_config b/scripts/kconfig/tests/choice/alldef_expected_config new file mode 100644 index 0000000..7a754bf --- /dev/null +++ b/scripts/kconfig/tests/choice/alldef_expected_config @@ -0,0 +1,5 @@ +CONFIG_MODULES=y +# CONFIG_BOOL_CHOICE0 is not set +CONFIG_BOOL_CHOICE1=y +# CONFIG_TRI_CHOICE0 is not set +# CONFIG_TRI_CHOICE1 is not set diff --git a/scripts/kconfig/tests/choice/allmod_expected_config b/scripts/kconfig/tests/choice/allmod_expected_config new file mode 100644 index 0000000..f1f5dcd --- /dev/null +++ b/scripts/kconfig/tests/choice/allmod_expected_config @@ -0,0 +1,9 @@ +CONFIG_MODULES=y +# CONFIG_BOOL_CHOICE0 is not set +CONFIG_BOOL_CHOICE1=y +# CONFIG_OPT_BOOL_CHOICE0 is not set +CONFIG_OPT_BOOL_CHOICE1=y +CONFIG_TRI_CHOICE0=m +CONFIG_TRI_CHOICE1=m +CONFIG_OPT_TRI_CHOICE0=m +CONFIG_OPT_TRI_CHOICE1=m diff --git a/scripts/kconfig/tests/choice/allno_expected_config b/scripts/kconfig/tests/choice/allno_expected_config new file mode 100644 index 0000000..b88ee7a --- /dev/null +++ b/scripts/kconfig/tests/choice/allno_expected_config @@ -0,0 +1,5 @@ +# CONFIG_MODULES is not set +# CONFIG_BOOL_CHOICE0 is not set +CONFIG_BOOL_CHOICE1=y +# CONFIG_TRI_CHOICE0 is not set +CONFIG_TRI_CHOICE1=y diff --git a/scripts/kconfig/tests/choice/allyes_expected_config b/scripts/kconfig/tests/choice/allyes_expected_config new file mode 100644 index 0000000..e5a062a --- /dev/null +++ b/scripts/kconfig/tests/choice/allyes_expected_config @@ -0,0 +1,9 @@ +CONFIG_MODULES=y +# CONFIG_BOOL_CHOICE0 is not set +CONFIG_BOOL_CHOICE1=y +# CONFIG_OPT_BOOL_CHOICE0 is not set +CONFIG_OPT_BOOL_CHOICE1=y +# CONFIG_TRI_CHOICE0 is not set +CONFIG_TRI_CHOICE1=y +# CONFIG_OPT_TRI_CHOICE0 is not set +CONFIG_OPT_TRI_CHOICE1=y diff --git a/scripts/kconfig/tests/choice/oldask0_expected_stdout b/scripts/kconfig/tests/choice/oldask0_expected_stdout new file mode 100644 index 0000000..b251bba --- /dev/null +++ b/scripts/kconfig/tests/choice/oldask0_expected_stdout @@ -0,0 +1,10 @@ +Enable loadable module support (MODULES) [Y/n/?] (NEW) +boolean choice + 1. choice 0 (BOOL_CHOICE0) (NEW) +> 2. choice 1 (BOOL_CHOICE1) (NEW) +choice[1-2?]: +optional boolean choice [N/y/?] (NEW) +tristate choice [M/y/?] (NEW) + choice 0 (TRI_CHOICE0) [N/m/?] (NEW) + choice 1 (TRI_CHOICE1) [N/m/?] (NEW) +optional tristate choice [N/m/y/?] (NEW) diff --git a/scripts/kconfig/tests/choice/oldask1_config b/scripts/kconfig/tests/choice/oldask1_config new file mode 100644 index 0000000..b67bfe3 --- /dev/null +++ b/scripts/kconfig/tests/choice/oldask1_config @@ -0,0 +1,2 @@ +# CONFIG_MODULES is not set +CONFIG_OPT_BOOL_CHOICE0=y diff --git a/scripts/kconfig/tests/choice/oldask1_expected_stdout b/scripts/kconfig/tests/choice/oldask1_expected_stdout new file mode 100644 index 0000000..c2125e9b --- /dev/null +++ b/scripts/kconfig/tests/choice/oldask1_expected_stdout @@ -0,0 +1,15 @@ +Enable loadable module support (MODULES) [N/y/?] +boolean choice + 1. choice 0 (BOOL_CHOICE0) (NEW) +> 2. choice 1 (BOOL_CHOICE1) (NEW) +choice[1-2?]: +optional boolean choice [Y/n/?] (NEW) +optional boolean choice +> 1. choice 0 (OPT_BOOL_CHOICE0) + 2. choice 1 (OPT_BOOL_CHOICE1) (NEW) +choice[1-2?]: +tristate choice + 1. choice 0 (TRI_CHOICE0) (NEW) +> 2. choice 1 (TRI_CHOICE1) (NEW) +choice[1-2?]: +optional tristate choice [N/y/?] From patchwork Tue Mar 13 09:12:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 131417 Delivered-To: patch@linaro.org Received: by 10.46.84.17 with SMTP id i17csp484439ljb; Tue, 13 Mar 2018 02:16:01 -0700 (PDT) X-Google-Smtp-Source: AG47ELth0AWxIl12MoPeECbj2p7s2OyR7M9EmjlS24C1tez36t5Zi0fuy7kl5McJA4ONWP1CrjuF X-Received: by 10.101.87.201 with SMTP id q9mr4910808pgr.215.1520932561129; Tue, 13 Mar 2018 02:16:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520932561; cv=none; d=google.com; s=arc-20160816; b=THKzzB78EbJ71bDoE04x4adKWuBjbGJqqOVEVOCaQQjMmFwwesTGEXJW/janD93Fct 74FTHO6diVbH6PtpRvww8zXIP5L7aE8AUMYoPTxCk0lgm8zz94grNKSn67I7osxX0r8u jqaYHZEGr9rdLH7EvoX87YVabU8xtILZzhYk4G8NRQlhBSr18/TBAxpBIuppNTJnnBcD drMohPtewVNNYzoKa5HUmQYOo/JWzDy5WnoboDhDMZfDHRqRJz2xkkMg5HdTNpyaoVWH 7UKWng3R0BG5mS0L9YxR4gzYIu7rqQgKsm5F2eMFJKPUupvM78bdvvrBWOnPFcPm4jxi 2fIA== 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=0sNXwR/AFUvRTxtAIC+XUzonrWt0bW64IesI7iNccLI=; b=HY3xtY0MF2z0ny33dgJkocSHWmDqlusx49CVu7k8zpwj71x2MOHfQu0G7SJUPRZH25 3+4kUeCEnz3RufpCHXjYmafHvA207AIxqMtpiW+NgW8gu95hQwlWv53pE1IgRjlDZp9+ Xa+ybmd37VSYd7AU5IF/j8quO+jAQk5RdNpygyC4JVkhPwoQ66S+ZCH5q5DL0I6NEGNB nPXWSUyoVHILG4ZE/qqlnvJnLb0vOa6nvnF+B/rwtf7jtSbfec8kcYts0ZFsYM+DTPIz fsgyuXkXEuBjcYb+G0+uOx52uNO0i5YpQMMKB+zw9+MWIPBQGBTqZiiQITTp/G/DYsLA AZ/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=nfITK7lU; 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 f1-v6si7496998plb.73.2018.03.13.02.16.00; Tue, 13 Mar 2018 02:16:01 -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=nfITK7lU; 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 S1752655AbeCMJP3 (ORCPT + 28 others); Tue, 13 Mar 2018 05:15:29 -0400 Received: from conuserg-07.nifty.com ([210.131.2.74]:41799 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752485AbeCMJOB (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 w2D9CIo5016505; Tue, 13 Mar 2018 18:12:21 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com w2D9CIo5016505 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1520932342; bh=0sNXwR/AFUvRTxtAIC+XUzonrWt0bW64IesI7iNccLI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nfITK7lUK0EMu5dvMQbNtJq2q20601wwN0EZLMgoHCg/UaOp63QF93fqm2FEaCJ2w WXdj+BkBKv32ceA3y1VXdBV8MOB8NATskBOMt2aVc9ie9lzyyQlULRVB3/ph088swz q6dBQu/NO+nLD6St/xp0KiqbfCLjMNHwTgMelzdzuvEJ4zcZcDtUw6M3XYkmCNE1rS 8SKm0WgIINrE175wytr1lVQtWVpEDflW3JfhwHc39WoebFZJaUKMkcSI2yFbP6nITg xgeSJhofECnZluaaz7Ajajqyhg7dO5BFidlQKMSYv/rAALeSyTmsOkg5sjYDPbI7x3 cewUFr2B7e5uQ== 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 04/11] kconfig: tests: test automatic submenu creation Date: Tue, 13 Mar 2018 18:12:05 +0900 Message-Id: <1520932332-2449-5-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 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 v3: None 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 -- 2.7.4 diff --git a/scripts/kconfig/tests/auto_submenu/Kconfig b/scripts/kconfig/tests/auto_submenu/Kconfig new file mode 100644 index 0000000..c17bf2ca --- /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 can/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) From patchwork Tue Mar 13 09:12:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 131421 Delivered-To: patch@linaro.org Received: by 10.46.84.17 with SMTP id i17csp485465ljb; Tue, 13 Mar 2018 02:17:17 -0700 (PDT) X-Google-Smtp-Source: AG47ELssCS6Jxxef4Qp7BUFNmPSOzQm9bgd+q36zT9AYqFG+nwuJpUYlkflFDhSyAg1lHoFHdG5/ X-Received: by 2002:a17:902:d20a:: with SMTP id t10-v6mr659185ply.123.1520932637257; Tue, 13 Mar 2018 02:17:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520932637; cv=none; d=google.com; s=arc-20160816; b=D8BfMf7bJZEIIAvJoKwcmdU3hPer2Lj4I1a+xpnke4qqGroF4YMDtITBmxbnr8elAo 6A2lPmp54jdK0Dl/1Sw4zxH0pyfHgarQbdVWzFW18mPFWzVYMi5q0sMMFFXBSMMKFRYC UwhgMNqb7LVpMAsinRVngnwGiAR6Sf5KAtyutb0hay8CMxU0Lh9ME+ZvKgnv1nnX2TnE hYj1qbFo0+KZXYftIo6skFyBc1kzNFB6hx30RbQdTBge9VTXeWY5UvBA42zzpJROhFq9 75Qt9C0U49c8MqkXBJqT7c3vahl5qGmV+/nYsn+++iaueSLJGSghnfGPLBfUWoqR5YnG u8tw== 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=NBfDUTGshqF16/Fu4cko8hlBSaBEN8pk433MZY+9Ilw=; b=erBVijsMQ6f4HQngx/cNfSo3Jt1mAv9p0sIVuXy6JEaGxvxvj5MgBTtUEhNDSl0Edb CxstZ/rdMs0SU/B3N1pq+M2YDqOOorkAX6WSx2tI1ecGl5myZcCg1AW5kYhe5IUCsWvb kcX3SKI3wT+U3oJnPDo8/vnXlQMOULHHMLH8N776R8bHyS7CB1muVuuG1FRHQljA/+4z 90h1kDrIUkLJWmAfTbyC9rqYq/Vkp0vwHdqewOvRy/04fBQMkSB0JbyqrpLmgTbk4zhB uq0SrBD/gTKm3zEXfMTBPY1ucfoBRhHwDQMQxwSt2Q9h3Xq/+sZdZgKyLgUrXL5yel3o zbUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=N1nJ21bM; 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 z10si6260368pgz.803.2018.03.13.02.17.16; Tue, 13 Mar 2018 02:17:17 -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=N1nJ21bM; 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 S1752435AbeCMJN6 (ORCPT + 28 others); Tue, 13 Mar 2018 05:13:58 -0400 Received: from conuserg-07.nifty.com ([210.131.2.74]:41662 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752074AbeCMJN4 (ORCPT ); Tue, 13 Mar 2018 05:13:56 -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 w2D9CIo6016505; Tue, 13 Mar 2018 18:12:22 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com w2D9CIo6016505 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1520932343; bh=NBfDUTGshqF16/Fu4cko8hlBSaBEN8pk433MZY+9Ilw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=N1nJ21bMFAKkY/xZA4UAsdvO1iNV+ajhiM0XaNakXssUzpgHR9VzC+jIUnxicPrUa noXHxb8dOkI9LhEWgTYA1ZNEGzGSDr2wJlzzmsq8eU4O8x0iwC9yrQwkZR6Dq+vnnv GjntpeD1zfCDNsFUY/MPIymGjnppCq3Qux/isjJq0zd0f0tweIeJ96A2bv1x8dmoUI QAJ0Mq59iLzeW0wug1BNRBnAb4Ktw0un+jy/F/WB06faOWMaXl4buBmSWsTAYVctmN 8JVAbMqFYL9vRXKVTHwhosUUmZtK3cCC8YuosoMCXgm91C5mqpj00cleQEMajbaikq xYfCXDbioQH9g== 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 05/11] kconfig: tests: test if new symbols in choice are asked Date: Tue, 13 Mar 2018 18:12:06 +0900 Message-Id: <1520932332-2449-6-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 If new choice values are added with new dependency, and they become visible during user configuration, oldconfig should recognize them as (NEW), and ask the user for choice. This issue was fixed by commit 5d09598d488f ("kconfig: fix new choices being skipped upon config update"). This is a subtle corner case. Add a test case to avoid breakage. Signed-off-by: Masahiro Yamada Reviewed-by: Ulf Magnusson --- Changes in v3: None Changes in v2: - coding style clean-up based on PEP8, PEP257 scripts/kconfig/tests/new_choice_with_dep/Kconfig | 37 ++++++++++++++++++++++ .../kconfig/tests/new_choice_with_dep/__init__.py | 14 ++++++++ scripts/kconfig/tests/new_choice_with_dep/config | 3 ++ .../tests/new_choice_with_dep/expected_stdout | 10 ++++++ 4 files changed, 64 insertions(+) create mode 100644 scripts/kconfig/tests/new_choice_with_dep/Kconfig create mode 100644 scripts/kconfig/tests/new_choice_with_dep/__init__.py create mode 100644 scripts/kconfig/tests/new_choice_with_dep/config create mode 100644 scripts/kconfig/tests/new_choice_with_dep/expected_stdout -- 2.7.4 diff --git a/scripts/kconfig/tests/new_choice_with_dep/Kconfig b/scripts/kconfig/tests/new_choice_with_dep/Kconfig new file mode 100644 index 0000000..53ef1b8 --- /dev/null +++ b/scripts/kconfig/tests/new_choice_with_dep/Kconfig @@ -0,0 +1,37 @@ +config A + bool "A" + help + This is a new symbol. + +choice + prompt "Choice ?" + depends on A + help + "depends on A" has been newly added. + +config CHOICE_B + bool "Choice B" + +config CHOICE_C + bool "Choice C" + help + This is a new symbol, so should be asked. + +endchoice + +choice + prompt "Choice2 ?" + +config CHOICE_D + bool "Choice D" + +config CHOICE_E + bool "Choice E" + +config CHOICE_F + bool "Choice F" + depends on A + help + This is a new symbol, so should be asked. + +endchoice diff --git a/scripts/kconfig/tests/new_choice_with_dep/__init__.py b/scripts/kconfig/tests/new_choice_with_dep/__init__.py new file mode 100644 index 0000000..f0e0ead --- /dev/null +++ b/scripts/kconfig/tests/new_choice_with_dep/__init__.py @@ -0,0 +1,14 @@ +""" +Ask new choice values when they become visible. + +If new choice values are added with new dependency, and they become +visible during user configuration, oldconfig should recognize them +as (NEW), and ask the user for choice. + +Related Linux commit: 5d09598d488f081e3be23f885ed65cbbe2d073b5 +""" + + +def test(conf): + assert conf.oldconfig('config', 'y') == 0 + assert conf.stdout_contains('expected_stdout') diff --git a/scripts/kconfig/tests/new_choice_with_dep/config b/scripts/kconfig/tests/new_choice_with_dep/config new file mode 100644 index 0000000..47ef95d --- /dev/null +++ b/scripts/kconfig/tests/new_choice_with_dep/config @@ -0,0 +1,3 @@ +CONFIG_CHOICE_B=y +# CONFIG_CHOICE_D is not set +CONFIG_CHOICE_E=y diff --git a/scripts/kconfig/tests/new_choice_with_dep/expected_stdout b/scripts/kconfig/tests/new_choice_with_dep/expected_stdout new file mode 100644 index 0000000..74dc0bc --- /dev/null +++ b/scripts/kconfig/tests/new_choice_with_dep/expected_stdout @@ -0,0 +1,10 @@ +A (A) [N/y/?] (NEW) y + Choice ? + > 1. Choice B (CHOICE_B) + 2. Choice C (CHOICE_C) (NEW) + choice[1-2?]: +Choice2 ? + 1. Choice D (CHOICE_D) +> 2. Choice E (CHOICE_E) + 3. Choice F (CHOICE_F) (NEW) +choice[1-3?]: From patchwork Tue Mar 13 09:12:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 131415 Delivered-To: patch@linaro.org Received: by 10.46.84.17 with SMTP id i17csp483694ljb; Tue, 13 Mar 2018 02:15:08 -0700 (PDT) X-Google-Smtp-Source: AG47ELvulx6S1oVQP3ai30qz0lVkliwJB9divVry8w1XL5zT3SY5BKKX2GrQPy4uPm3Tvh8h0pqW X-Received: by 10.98.25.10 with SMTP id 10mr10872298pfz.136.1520932507928; Tue, 13 Mar 2018 02:15:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520932507; cv=none; d=google.com; s=arc-20160816; b=s4I3gFsaJhU8rIGEiEag5nkwwd/MxOmUQZ2YX+E0ejGIk8q7xOirqBdRg/+KPRs4oA 4kZABkAfvopLYza9Z9zGTkv8rnUA1fPdm/WFp1R83g+AWMGqKRfv1Tw+ehvh0HM7MDd+ ea3PbrTq920UNt1S4TFK3421cwDpNPcGRNQLw3nYi3JW7/8QHYlrJOF1qrFWyFCpd6Uu p81fGw77+HEx5l9kneQwYm/K0EeIbJkml2bEY2pAXF8ijYnW7Wungrkk2j3WIrnkUt78 7SddfnOJFUAmB3mlieCfqVGzTp6hhIOeFz6kbIZQNNNpNop1hE2onwsIZJgeDHa/iyiG ezKw== 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=tUux/rAgM8Vq2kda7UvIS8vONG/OaP5yiipXGtRpvwk=; b=YFLLwNpx3L2tr9tOUm3Oi63feL21Afc0gna0N6sd7jAzX+bC1hmPpoD8XHWKtd2lDf hzDFGzpmrGLLb8dqO2io+3G9nPr082sJ8SgHBH/plff32au+iaCdoYdv5Z+7Mq/I8wQH /+xtsAWtpt4FLlrJ5SuA2O3FuvzgSHEEQNZLEsVDzyS55iTWUH0y38VWtGw61OLJMZK1 KAW58iVxsvdo7gsiVnOlEytw6BbuooSK0KmvWizLWK4/LVT2ekMX2qkUKiSjPlh1NsKv OsoeK5i2iJgqR1c4AfAPbQnRvEaWbrxS8lxQ5OojmWe03BrGdb4Ge3ZXC+z7kYW5UEAp e55Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=cICmmhPc; 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 a15-v6si5656630pln.421.2018.03.13.02.15.07; Tue, 13 Mar 2018 02:15:07 -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=cICmmhPc; 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 S1752595AbeCMJOQ (ORCPT + 28 others); Tue, 13 Mar 2018 05:14:16 -0400 Received: from conuserg-07.nifty.com ([210.131.2.74]:41835 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752511AbeCMJOB (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 w2D9CIo7016505; Tue, 13 Mar 2018 18:12:23 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com w2D9CIo7016505 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1520932343; bh=tUux/rAgM8Vq2kda7UvIS8vONG/OaP5yiipXGtRpvwk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cICmmhPc629+M7kgmBSVKT+ywfdg857usrrrYBQKM2w7Dg4GBeLg2lw2YsGKew5ZN scS0I2h5pETnYNx2UJlkUXReb2ahQfGNVAwGZUAlc1rqXr/BSNPwGOuxkiQkITN6dK 4pck8y2bxQbFirPqziDwYDtG06tETuUPeK3qeUjpFey+9O57YuLG+ak6w27vsuSJ6L vE1JDaDtKrXebAIzZx7xEPcF5XRLX2J7iS3RhZpuLqNr+JNtOFuvPEWFAElEPswcqA dRz6dbrD/MFhDVjJot9apooEqQAQ1BXWOmV/gWF/ouQuOZLVGhGSozSz/tf7fGJLiF cBvcXBx1ZwMcQ== 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 06/11] kconfig: tests: check unneeded "is not set" with unmet dependency Date: Tue, 13 Mar 2018 18:12:07 +0900 Message-Id: <1520932332-2449-7-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 cb67ab2cd2b8 ("kconfig: do not write choice values when their dependency becomes n") fixed a problem where "# CONFIG_... is not set" for choice values are wrongly written into the .config file when they are once visible, then become invisible later. Add a test for this naive case. Signed-off-by: Masahiro Yamada Reviewed-by: Ulf Magnusson --- Changes in v3: None Changes in v2: - coding style clean-up based on PEP8, PEP257 scripts/kconfig/tests/no_write_if_dep_unmet/Kconfig | 14 ++++++++++++++ .../kconfig/tests/no_write_if_dep_unmet/__init__.py | 19 +++++++++++++++++++ scripts/kconfig/tests/no_write_if_dep_unmet/config | 1 + .../tests/no_write_if_dep_unmet/expected_config | 5 +++++ 4 files changed, 39 insertions(+) create mode 100644 scripts/kconfig/tests/no_write_if_dep_unmet/Kconfig create mode 100644 scripts/kconfig/tests/no_write_if_dep_unmet/__init__.py create mode 100644 scripts/kconfig/tests/no_write_if_dep_unmet/config create mode 100644 scripts/kconfig/tests/no_write_if_dep_unmet/expected_config -- 2.7.4 diff --git a/scripts/kconfig/tests/no_write_if_dep_unmet/Kconfig b/scripts/kconfig/tests/no_write_if_dep_unmet/Kconfig new file mode 100644 index 0000000..c00b8fe --- /dev/null +++ b/scripts/kconfig/tests/no_write_if_dep_unmet/Kconfig @@ -0,0 +1,14 @@ +config A + bool "A" + +choice + prompt "Choice ?" + depends on A + +config CHOICE_B + bool "Choice B" + +config CHOICE_C + bool "Choice C" + +endchoice diff --git a/scripts/kconfig/tests/no_write_if_dep_unmet/__init__.py b/scripts/kconfig/tests/no_write_if_dep_unmet/__init__.py new file mode 100644 index 0000000..207261b --- /dev/null +++ b/scripts/kconfig/tests/no_write_if_dep_unmet/__init__.py @@ -0,0 +1,19 @@ +""" +Do not write choice values to .config if the dependency is unmet. + +"# CONFIG_... is not set" should not be written into the .config file +for symbols with unmet dependency. + +This was not working correctly for choice values because choice needs +a bit different symbol computation. + +This checks that no unneeded "# COFIG_... is not set" is contained in +the .config file. + +Related Linux commit: cb67ab2cd2b8abd9650292c986c79901e3073a59 +""" + + +def test(conf): + assert conf.oldaskconfig('config', 'n') == 0 + assert conf.config_matches('expected_config') diff --git a/scripts/kconfig/tests/no_write_if_dep_unmet/config b/scripts/kconfig/tests/no_write_if_dep_unmet/config new file mode 100644 index 0000000..abd280e --- /dev/null +++ b/scripts/kconfig/tests/no_write_if_dep_unmet/config @@ -0,0 +1 @@ +CONFIG_A=y diff --git a/scripts/kconfig/tests/no_write_if_dep_unmet/expected_config b/scripts/kconfig/tests/no_write_if_dep_unmet/expected_config new file mode 100644 index 0000000..0d15e41 --- /dev/null +++ b/scripts/kconfig/tests/no_write_if_dep_unmet/expected_config @@ -0,0 +1,5 @@ +# +# Automatically generated file; DO NOT EDIT. +# Linux Kernel Configuration +# +# CONFIG_A is not set From patchwork Tue Mar 13 09:12:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 131411 Delivered-To: patch@linaro.org Received: by 10.46.84.17 with SMTP id i17csp482843ljb; Tue, 13 Mar 2018 02:14:02 -0700 (PDT) X-Google-Smtp-Source: AG47ELsUDct2TVrXR5oK178BPqXOGCg00nyvi/csxsSMIGgn49WP8Yq0wMmZXSP3aIDM+HSsNuZo X-Received: by 10.98.28.202 with SMTP id c193mr10997981pfc.109.1520932442372; Tue, 13 Mar 2018 02:14:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520932442; cv=none; d=google.com; s=arc-20160816; b=tKFcCwM4fv0VkuV93Ph6cHt0QbWw90HJQR3XiDQAs0XdSWXmp4svH8bZ7K5dvMV+2U mAWedg7eQBakayPoR3pLdIkDFkEk/LNj9M//Xkvuj00gPInknYoxkgahEkwzw1d0zbQ/ ChpzNvEZHFedMVBPYgpuIbpQPbJKZ6rN0nw4zi8r1E6k1oifwxIjUDU95xBVbqeI6VCn vfLcIQN16I5ERrKV3Rn0WkUGGJfrewzMQ+C8fNHF55LAIMYtvELoEhDdq8YoN3gZXl47 0bXEDKard7f/uj5sCmQOjlk5kUvlp0XNwMnyD+0q9FcT6AtrBzFcn7SvxupyVMoOBQbw +u+w== 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=pPPUXuP/OavNIYDfLQH0wMWarHU7wLntc30/ogFJGW0=; b=f3Yv3SQxM2+uUffz7T4gGvPvsvKJiHELCO92QPgB0udo3M0JX4kQz8M4hqiLUwm8OF 1axIAeASL8SJO7qUJMGKW2MGSUdgYRyJF2Rk87Gi7jiIN/rJ3HgF1KN3DLVa96aXfMOZ 2zZs99FU2+RjKGk5p6w7wk/w8/AveoOXyB8gcVXyODbRFLbqLF+J7HFo9iUxk3Z1yQTd /z3dOkTWIefoNVmq52H/S3CEKk2oewWLZ3CgxszqLAcyI2M4hOjqN2hHy+P3cX1ClXEj V6U/Rxnq5e3BBnzxNPtBXeQ4CwOlNdZYO6YUhlnV4rMeEdvb/riFSRz6VIqMcLuFgaaF 97DA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=xn1dn2h8; 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 38-v6si7479115pln.397.2018.03.13.02.14.02; Tue, 13 Mar 2018 02:14:02 -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=xn1dn2h8; 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 S1752474AbeCMJN7 (ORCPT + 28 others); Tue, 13 Mar 2018 05:13:59 -0400 Received: from conuserg-07.nifty.com ([210.131.2.74]:41661 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752188AbeCMJN4 (ORCPT ); Tue, 13 Mar 2018 05:13:56 -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 w2D9CIo8016505; Tue, 13 Mar 2018 18:12:24 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com w2D9CIo8016505 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1520932344; bh=pPPUXuP/OavNIYDfLQH0wMWarHU7wLntc30/ogFJGW0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xn1dn2h8ijA9YXQD02qTTfyk2EriMfO39m7GKewVqbTxGLarYISglF580wI1h/lRZ BfYx0nJU5qVz0876uqgGsPYYRNADZGnULfmE4eZsChFaRu5Ls77IJBjULYUSNMemtk e2s3kpuv+wboyL1fEf1r9+tc8RJ1KYIG7SAJ1Z7LHJV8Dn43q0Ac3WXS0CvFecTCFo dDtbW7YUoR/bWbmpPkIX49yKkIQjgEIYRTekRRNRX30RtiluQUYs6oTAd8uEZXascf UUQCtjxVJC2+PUX6Tu5H1wbVc1M07JZ8M5he9ik1zUyBQ1gItkwRGR6Cidc4v1Ev5R euHA265djBeLw== 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 07/11] kconfig: tests: check visibility of tristate choice values in y choice Date: Tue, 13 Mar 2018 18:12:08 +0900 Message-Id: <1520932332-2449-8-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 If tristate choice values depend on symbols set to 'm', they should be hidden when the choice containing them is changed from 'm' to 'y' (i.e. exclusive choice). This issue was fixed by commit fa64e5f6a35e ("kconfig/symbol.c: handle choice_values that depend on 'm' symbols"). Add a test case to avoid regression. For the input in this unit test, there is a room for argument if "# CONFIG_CHOICE1 is not set" should be written to the .config file. After commit fa64e5f6a35e, this line was written to the .config file. With commit cb67ab2cd2b8 ("kconfig: do not write choice values when their dependency becomes n"), it is not written now. In this test, "# CONFIG_CHOICE1 is not set" is don't care. Signed-off-by: Masahiro Yamada Reviewed-by: Ulf Magnusson --- Changes in v3: None Changes in v2: - coding style clean-up based on PEP8, PEP257 scripts/kconfig/tests/choice_value_with_m_dep/Kconfig | 19 +++++++++++++++++++ .../kconfig/tests/choice_value_with_m_dep/__init__.py | 15 +++++++++++++++ scripts/kconfig/tests/choice_value_with_m_dep/config | 2 ++ .../tests/choice_value_with_m_dep/expected_config | 3 +++ .../tests/choice_value_with_m_dep/expected_stdout | 4 ++++ 5 files changed, 43 insertions(+) create mode 100644 scripts/kconfig/tests/choice_value_with_m_dep/Kconfig create mode 100644 scripts/kconfig/tests/choice_value_with_m_dep/__init__.py create mode 100644 scripts/kconfig/tests/choice_value_with_m_dep/config create mode 100644 scripts/kconfig/tests/choice_value_with_m_dep/expected_config create mode 100644 scripts/kconfig/tests/choice_value_with_m_dep/expected_stdout -- 2.7.4 diff --git a/scripts/kconfig/tests/choice_value_with_m_dep/Kconfig b/scripts/kconfig/tests/choice_value_with_m_dep/Kconfig new file mode 100644 index 0000000..11ac25c --- /dev/null +++ b/scripts/kconfig/tests/choice_value_with_m_dep/Kconfig @@ -0,0 +1,19 @@ +config MODULES + def_bool y + option modules + +config DEP + tristate + default m + +choice + prompt "Tristate Choice" + +config CHOICE0 + tristate "Choice 0" + +config CHOICE1 + tristate "Choice 1" + depends on DEP + +endchoice diff --git a/scripts/kconfig/tests/choice_value_with_m_dep/__init__.py b/scripts/kconfig/tests/choice_value_with_m_dep/__init__.py new file mode 100644 index 0000000..f8d728c --- /dev/null +++ b/scripts/kconfig/tests/choice_value_with_m_dep/__init__.py @@ -0,0 +1,15 @@ +""" +Hide tristate choice values with mod dependency in y choice. + +If tristate choice values depend on symbols set to 'm', they should be +hidden when the choice containing them is changed from 'm' to 'y' +(i.e. exclusive choice). + +Related Linux commit: fa64e5f6a35efd5e77d639125d973077ca506074 +""" + + +def test(conf): + assert conf.oldaskconfig('config', 'y') == 0 + assert conf.config_contains('expected_config') + assert conf.stdout_contains('expected_stdout') diff --git a/scripts/kconfig/tests/choice_value_with_m_dep/config b/scripts/kconfig/tests/choice_value_with_m_dep/config new file mode 100644 index 0000000..3a126b7 --- /dev/null +++ b/scripts/kconfig/tests/choice_value_with_m_dep/config @@ -0,0 +1,2 @@ +CONFIG_CHOICE0=m +CONFIG_CHOICE1=m diff --git a/scripts/kconfig/tests/choice_value_with_m_dep/expected_config b/scripts/kconfig/tests/choice_value_with_m_dep/expected_config new file mode 100644 index 0000000..4d07b44 --- /dev/null +++ b/scripts/kconfig/tests/choice_value_with_m_dep/expected_config @@ -0,0 +1,3 @@ +CONFIG_MODULES=y +CONFIG_DEP=m +CONFIG_CHOICE0=y diff --git a/scripts/kconfig/tests/choice_value_with_m_dep/expected_stdout b/scripts/kconfig/tests/choice_value_with_m_dep/expected_stdout new file mode 100644 index 0000000..2b50ab6 --- /dev/null +++ b/scripts/kconfig/tests/choice_value_with_m_dep/expected_stdout @@ -0,0 +1,4 @@ +Tristate Choice [M/y/?] y +Tristate Choice +> 1. Choice 0 (CHOICE0) +choice[1]: 1 From patchwork Tue Mar 13 09:12:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 131419 Delivered-To: patch@linaro.org Received: by 10.46.84.17 with SMTP id i17csp484982ljb; Tue, 13 Mar 2018 02:16:41 -0700 (PDT) X-Google-Smtp-Source: AG47ELvCjMeBsvOhMxwk3vYlX09j6DxGN2gcLLIM9MKg7RtJjcZPy3FwETXpwS92ZnBnVQnMfuBE X-Received: by 10.99.158.9 with SMTP id s9mr859185pgd.64.1520932601393; Tue, 13 Mar 2018 02:16:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520932601; cv=none; d=google.com; s=arc-20160816; b=IRGlYRQ3je0q4Z8D5W0DRKGC2S4UE5mjENrXwZRdjSRvBC+K302DZN7ottfh20uJXa YZ8wQYkAWHagOqzH3X7c0zTlv9BH28A9Bu+VtQIDK4pXLOlObJo07642H2Tmke4Tn6dj vYTn69mmReTn7qTChU9TevP92aogBzjjmwgWzs13rTtAplAGjQXoJVRSEBxMw2FKnsfo MwSvrF4hjt1DHWMduJRrVf09gnl6ljxuePeHnY1b2VpAy5qscB865AKycW0fuM/cMbjf leMMdxWHhM8qB3XdF+C8O9NpejkzxFJhp4NOMEiAfD2OnaI1Cu4tJREyrcl6k+3POft4 K+8w== 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=2vORxESz0zbS14YMrcdfprrqUkp3JAvmRF89Udr0tmE=; b=KOorM7qIP4VodAStrZocvba8oS3JxA/HUtnKoLp4nrMCCh7JmqxeZUDWnUBPEsyson Q3MnjZFyUhT7sz7yADmMZVqiskzM7AgZ9x1OPOJUmPdNGFq6eJ295eI294RGWcrKSpQ0 lVxcUPQfSR/zpCh5a6oYFar6ErpDE/u0CAVft+Ha6pBj3uhAATM2PBZxvRLYznOYZIGG HGHfEoNY14ngS8JHuRABZeCHyZX+c1aJsDpAW5MCJsrJw+iixmo/U20ZxF2gW/Blhp+F XU/b1nRLyOUsFRNymlFWwS0UTqXPvGpqE/Jvm9maRMAjnz4mh+ZBksEmKWVKkVfQxIBJ 8GrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=ZlqxY9bG; 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 g13si2097627pgr.471.2018.03.13.02.16.41; Tue, 13 Mar 2018 02:16:41 -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=ZlqxY9bG; 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 S1752673AbeCMJQi (ORCPT + 28 others); Tue, 13 Mar 2018 05:16:38 -0400 Received: from conuserg-07.nifty.com ([210.131.2.74]:41802 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752484AbeCMJOB (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 w2D9CIo9016505; Tue, 13 Mar 2018 18:12:25 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com w2D9CIo9016505 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1520932345; bh=2vORxESz0zbS14YMrcdfprrqUkp3JAvmRF89Udr0tmE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZlqxY9bG92KmmVHpP5ynXaOa+LGA69Bu7P2gUYH+P8Bqqi3jimylrtFyytjCiUx37 8Hx6IQ4myTPBBe2cvTjAFTpCXGL1jEZ4YXygli7Nei6F03Dsn05PanniorSqAMd8y7 4gCJFAjslqbxJLekCr/s/9AIXwENP2dGhMvQ/J06y+D8g+nmpusyLmmZmMq0otvffJ VdA9YkDgMUtoFYY4/JHQ2RnKwkj9OD5UQ/6AUrYdlrEtDfrN+doCgH0Vxznm3DPaLR uj5gpH6bz5CrTtt6fxKCxtlPKRotburhE4pD6gpR6amta8EQLo9tWRN1PDbRkEeLPj z/uS4ynRp683Q== 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 08/11] kconfig: tests: test defconfig when two choices interact Date: Tue, 13 Mar 2018 18:12:09 +0900 Message-Id: <1520932332-2449-9-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 fbe98bb9ed3d ("kconfig: Fix defconfig when one choice menu selects options that another choice menu depends on") fixed defconfig when two choices interact (i.e. calculating the visibility of a choice requires to calculate another choice). The test code in that commit log was based on the real world example, and complicated. So, I shrunk it down to the following: defconfig.choice: ---8<--- CONFIG_CHOICE_VAL0=y ---8<--- ---8<--- config MODULES def_bool y option modules choice prompt "Choice" config CHOICE_VAL0 tristate "Choice 0" config CHOICE_VAL1 tristate "Choice 1" endchoice choice prompt "Another choice" depends on CHOICE_VAL0 config DUMMY bool "dummy" endchoice ---8<--- Prior to commit fbe98bb9ed3d, $ scripts/kconfig/conf --defconfig=defconfig.choice Kconfig.choice resulted in: CONFIG_MODULES=y CONFIG_CHOICE_VAL0=m # CONFIG_CHOICE_VAL1 is not set CONFIG_DUMMY=y where the expected result would be: CONFIG_MODULES=y CONFIG_CHOICE_VAL0=y # CONFIG_CHOICE_VAL1 is not set CONFIG_DUMMY=y Roughly, this weird behavior happened like this: Symbols are calculated a couple of times. First, all symbols are calculated in conf_read(). The first 'choice' is evaluated to 'y' due to the SYMBOL_DEF_USER flag, but sym_calc_choice() clears it unless all of its choice values are explicitly set by the user. conf_set_all_new_symbols() clears all SYMBOL_VALID flags. Then, only choices are calculated. Here, the SYMBOL_DEF_USER for the first choice has been forgotten, so it is evaluated to 'm'. set_all_choice_values() sets SYMBOL_DEF_USER again to choice symbols. When calculating the second choice, due to 'depends on CHOICE_VAL0', it triggers the calculation of CHOICE_VAL0. As a result, SYMBOL_VALID is set for CHOICE_VAL0. Symbols except choices get the final chance of re-calculation in conf_write(). In a normal case, CHOICE_VAL0 would be re-calculated, then the first choice would be indirectly re-calculated with the SYMBOL_DEF_USER which has been recalled by set_all_choice_values(), which would be evaluated to 'y'. But, in this case, CHOICE_VAL0 has already been marked as SYMBOL_VALID, so this re-calculation does not happen. Then, =m from the conf_set_all_new_symbols() phase is written out to the .config file. Add a unit test for this naive case. Signed-off-by: Masahiro Yamada Reviewed-by: Ulf Magnusson --- Changes in v3: - Use def_bool for MODULES Changes in v2: - Newly added scripts/kconfig/tests/inter_choice/Kconfig | 23 ++++++++++++++++++++++ scripts/kconfig/tests/inter_choice/__init__.py | 14 +++++++++++++ scripts/kconfig/tests/inter_choice/defconfig | 1 + scripts/kconfig/tests/inter_choice/expected_config | 4 ++++ 4 files changed, 42 insertions(+) create mode 100644 scripts/kconfig/tests/inter_choice/Kconfig create mode 100644 scripts/kconfig/tests/inter_choice/__init__.py create mode 100644 scripts/kconfig/tests/inter_choice/defconfig create mode 100644 scripts/kconfig/tests/inter_choice/expected_config -- 2.7.4 diff --git a/scripts/kconfig/tests/inter_choice/Kconfig b/scripts/kconfig/tests/inter_choice/Kconfig new file mode 100644 index 0000000..e44449f --- /dev/null +++ b/scripts/kconfig/tests/inter_choice/Kconfig @@ -0,0 +1,23 @@ +config MODULES + def_bool y + option modules + +choice + prompt "Choice" + +config CHOICE_VAL0 + tristate "Choice 0" + +config CHOIVE_VAL1 + tristate "Choice 1" + +endchoice + +choice + prompt "Another choice" + depends on CHOICE_VAL0 + +config DUMMY + bool "dummy" + +endchoice diff --git a/scripts/kconfig/tests/inter_choice/__init__.py b/scripts/kconfig/tests/inter_choice/__init__.py new file mode 100644 index 0000000..5c7fc36 --- /dev/null +++ b/scripts/kconfig/tests/inter_choice/__init__.py @@ -0,0 +1,14 @@ +""" +Do not affect user-assigned choice value by another choice. + +Handling of state flags for choices is complecated. In old days, +the defconfig result of a choice could be affected by another choice +if those choices interact by 'depends on', 'select', etc. + +Related Linux commit: fbe98bb9ed3dae23e320c6b113e35f129538d14a +""" + + +def test(conf): + assert conf.defconfig('defconfig') == 0 + assert conf.config_contains('expected_config') diff --git a/scripts/kconfig/tests/inter_choice/defconfig b/scripts/kconfig/tests/inter_choice/defconfig new file mode 100644 index 0000000..162c414 --- /dev/null +++ b/scripts/kconfig/tests/inter_choice/defconfig @@ -0,0 +1 @@ +CONFIG_CHOICE_VAL0=y diff --git a/scripts/kconfig/tests/inter_choice/expected_config b/scripts/kconfig/tests/inter_choice/expected_config new file mode 100644 index 0000000..5dceefb --- /dev/null +++ b/scripts/kconfig/tests/inter_choice/expected_config @@ -0,0 +1,4 @@ +CONFIG_MODULES=y +CONFIG_CHOICE_VAL0=y +# CONFIG_CHOIVE_VAL1 is not set +CONFIG_DUMMY=y 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 From patchwork Tue Mar 13 09:12:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 131414 Delivered-To: patch@linaro.org Received: by 10.46.84.17 with SMTP id i17csp483045ljb; Tue, 13 Mar 2018 02:14:20 -0700 (PDT) X-Google-Smtp-Source: AG47ELuDT5Gq1MjmjgA3BeT5qIhgxPOvxJ+tbNtRPL6xa3lqtqNFBlQfyquFa2HnZLu0yZU65ix8 X-Received: by 10.98.12.82 with SMTP id u79mr11053403pfi.192.1520932460325; Tue, 13 Mar 2018 02:14:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520932460; cv=none; d=google.com; s=arc-20160816; b=zoGGAobjEu/kFueY1IYpDTov5lywVuBe6Ej2QBt2i8Z1k++LzQpRPqgA3gTzbWBnhG Px3B28jPUoTGkaxntpyAstX501+2+bz9IbDNXosQxuPqiePVn5Y96p/CsD8mwtmSwSrA K7BVjGySRXiDqcMBJF25P0Vuo+3JonwG2XBmM5nyNmrndKXWkRFO5twuSgqWeNkT8Q93 we9a0IQXdvDeiDklVVLDQ8aE+40DfWKgQ5PR6G79gmU1dURGVsOTO1Gww/uge8kVWSmP Ytt08vqRXEuXnLAQAgCzLJ9nMltt2D2r7QWeSY3yFHBX/0sHLTo76Rm0NFh3c3jzlsVP Z2sA== 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=i5RVMFP5eZLVq0Us8WhBjUfqWNJ2ofQXk7usvJBEckw=; b=shPJpN4Th1wiwSFsGZ3YfCJ+05cjyQK9Mly78QkUyNMuf2C5GGiASHQapalxTs+1lK 2zyveVj1SH/lJ0Q4FlKLEWBjC1FvNU4oJi6Bm8n3zykFuI/poaImuvBzTIU1SRvAVR2z Qw97Gb60lQVnSonQXCZj0jkVjpTI2O4q50S6z/CO/e5+lXK32Izyivo5ajUqpaQsFTuS YwMPbPL3I9IA801OGXQUGGB3QAL28voz8/OpnZCCz2fkZv3Hd6V+hjZC1lCbXwcGI00C 1L/XNl+NeS1VLN+DKoRGLcKqa0JN5egx+SzSwx/hkAt2UDKYD9N0ihyr8ba+qAZKSRiK zFqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=p6awXAPu; 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 4-v6si1334564plb.205.2018.03.13.02.14.19; Tue, 13 Mar 2018 02:14:20 -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=p6awXAPu; 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 S932312AbeCMJOR (ORCPT + 28 others); Tue, 13 Mar 2018 05:14:17 -0400 Received: from conuserg-07.nifty.com ([210.131.2.74]:41805 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752488AbeCMJOB (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 w2D9CIoB016505; Tue, 13 Mar 2018 18:12:26 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com w2D9CIoB016505 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1520932347; bh=i5RVMFP5eZLVq0Us8WhBjUfqWNJ2ofQXk7usvJBEckw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=p6awXAPuDR3inGZYWiiOT8NL/bcVe1o2mFwWK4e2yRxg99CePfpytyQRHT5BJemPf mSBCj6GuZD7XCPeb/Rccrv3IqbZbZ36Roof/f6sDtTLM/BGvPWMmt1JujF6faE8GTi oTOWhFCbPHrmeAEMlYSeF3zymFF99sTJBZaPcxibMryV5ErgMdu0A3raUKBU61dl/N us8gQI104MoAeT1p9NijrIKv6y/bw/wr9oRvrBSfKfa2nYFl8d3TWKUjl4l3NASyRL CobGocKJ9436r0qJELwgRMqS3YwXFMAsZ94XH6D8AluisymhSxtK3/w2yYF0NFRsxV WrD3UZE8cD8CA== 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 10/11] kconfig: tests: test if recursive dependencies are detected Date: Tue, 13 Mar 2018 18:12:11 +0900 Message-Id: <1520932332-2449-11-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 Recursive dependency should be detected and warned. Test this. This indirectly tests the line number increments. Signed-off-by: Masahiro Yamada Reviewed-by: Ulf Magnusson --- Changes in v3: None Changes in v2: - Fix missing end quote - coding style clean-up based on PEP8, PEP257 scripts/kconfig/tests/warn_recursive_dep/Kconfig | 62 ++++++++++++++++++++++ .../kconfig/tests/warn_recursive_dep/__init__.py | 9 ++++ .../tests/warn_recursive_dep/expected_stderr | 30 +++++++++++ 3 files changed, 101 insertions(+) create mode 100644 scripts/kconfig/tests/warn_recursive_dep/Kconfig create mode 100644 scripts/kconfig/tests/warn_recursive_dep/__init__.py create mode 100644 scripts/kconfig/tests/warn_recursive_dep/expected_stderr -- 2.7.4 diff --git a/scripts/kconfig/tests/warn_recursive_dep/Kconfig b/scripts/kconfig/tests/warn_recursive_dep/Kconfig new file mode 100644 index 0000000..a65bfcb --- /dev/null +++ b/scripts/kconfig/tests/warn_recursive_dep/Kconfig @@ -0,0 +1,62 @@ +# depends on itself + +config A + bool "A" + depends on A + +# select itself + +config B + bool + select B + +# depends on each other + +config C1 + bool "C1" + depends on C2 + +config C2 + bool "C2" + depends on C1 + +# depends on and select + +config D1 + bool "D1" + depends on D2 + select D2 + +config D2 + bool + +# depends on and imply +# This is not recursive dependency + +config E1 + bool "E1" + depends on E2 + imply E2 + +config E2 + bool "E2" + +# property + +config F1 + bool "F1" + default F2 + +config F2 + bool "F2" + depends on F1 + +# menu + +menu "menu depending on its content" + depends on G + +config G + bool "G" + +endmenu diff --git a/scripts/kconfig/tests/warn_recursive_dep/__init__.py b/scripts/kconfig/tests/warn_recursive_dep/__init__.py new file mode 100644 index 0000000..adb2195 --- /dev/null +++ b/scripts/kconfig/tests/warn_recursive_dep/__init__.py @@ -0,0 +1,9 @@ +""" +Warn recursive inclusion. + +Recursive dependency should be warned. +""" + +def test(conf): + assert conf.oldaskconfig() == 0 + assert conf.stderr_contains('expected_stderr') diff --git a/scripts/kconfig/tests/warn_recursive_dep/expected_stderr b/scripts/kconfig/tests/warn_recursive_dep/expected_stderr new file mode 100644 index 0000000..3de807d --- /dev/null +++ b/scripts/kconfig/tests/warn_recursive_dep/expected_stderr @@ -0,0 +1,30 @@ +Kconfig:9:error: recursive dependency detected! +Kconfig:9: symbol B is selected by B +For a resolution refer to Documentation/kbuild/kconfig-language.txt +subsection "Kconfig recursive dependency limitations" + +Kconfig:3:error: recursive dependency detected! +Kconfig:3: symbol A depends on A +For a resolution refer to Documentation/kbuild/kconfig-language.txt +subsection "Kconfig recursive dependency limitations" + +Kconfig:15:error: recursive dependency detected! +Kconfig:15: symbol C1 depends on C2 +Kconfig:19: symbol C2 depends on C1 +For a resolution refer to Documentation/kbuild/kconfig-language.txt +subsection "Kconfig recursive dependency limitations" + +Kconfig:30:error: recursive dependency detected! +Kconfig:30: symbol D2 is selected by D1 +Kconfig:25: symbol D1 depends on D2 +For a resolution refer to Documentation/kbuild/kconfig-language.txt +subsection "Kconfig recursive dependency limitations" + +Kconfig:59:error: recursive dependency detected! +Kconfig:59: symbol G depends on G +For a resolution refer to Documentation/kbuild/kconfig-language.txt +subsection "Kconfig recursive dependency limitations" + +Kconfig:50:error: recursive dependency detected! +Kconfig:50: symbol F2 depends on F1 +Kconfig:48: symbol F1 default value contains F2 From patchwork Tue Mar 13 09:12:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 131413 Delivered-To: patch@linaro.org Received: by 10.46.84.17 with SMTP id i17csp483010ljb; Tue, 13 Mar 2018 02:14:17 -0700 (PDT) X-Google-Smtp-Source: AG47ELsR9IBOFcrxPU1g4eOhyayaACUXA4CwTcIsFR1C2YJT/wyWTD5D19oD6x841SToHzA5YCoY X-Received: by 10.99.117.76 with SMTP id f12mr9344341pgn.410.1520932457682; Tue, 13 Mar 2018 02:14:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520932457; cv=none; d=google.com; s=arc-20160816; b=z7ftRuLjuT8ku7QUNX3wKCrL6WZCOLVQ1ju9CHyOtgMdvaIDVa6Y2haMzBAg2IBGCL bmmK8Lavz6cPh5fY4twGPCezm3/7XNhl2GLOlYLDN+7X9cIkLBBR8ce8LpMbhQ7JtTjt R3JMVwYt6dOEBWNO0eyPTQ5P68GjcNraOTfRBdbQ4j4idYkubCcd4ihSRVCsdIYpoqxy h84Ty/mlnmC65YmGqXubPLzp/zLe/oCwyzqO3wY6KcWvrfKQMNx7VYYGCFLmxT92vcpN pDRcAyTmo+D71KDgWU2r/5GM64811Wli2Wejt1S99IInNaUt1r5oHMBl2h7O8aC6pnn3 foGg== 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=98IaRAfWA0Ot0LakJPD7ReKuTfpTbSHOVIAs/wKQwjE=; b=0im/eaptk6NNShkWSTIlJUE5TR3iO8zkxScOglVKohMh3Adam3q1YpaSyNymcwR8Nn dpXZMG2+JEb0Zgx/b0Z6qxpqCtRi+czuGDYZRieDS1Bptfz4PkUWlpeEbt+4GhdAx2Xu SfgI/zE8ngFGom78HDeZN+K7Wfy56puvo9uXJj1W2MuV5ZevWuFQQcPquDnZgvnK3idr AFR+QVhElBOhxhIBFeB7XLOn9tU7U+r1tLSJ4Doa/7y5lbyfH3gA402hd8NDmtVppXgC M7uKwZM2tMApCrNHcAs1R5s1C2qGDfX6krQ4xn5RFKZZquw28AyDgmSW5fRv+OmeHx0t /daw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=M18W/8df; 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 4-v6si1334564plb.205.2018.03.13.02.14.17; Tue, 13 Mar 2018 02:14:17 -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=M18W/8df; 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 S1752566AbeCMJOO (ORCPT + 28 others); Tue, 13 Mar 2018 05:14:14 -0400 Received: from conuserg-07.nifty.com ([210.131.2.74]:41840 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752302AbeCMJOB (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 w2D9CIoC016505; Tue, 13 Mar 2018 18:12:27 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com w2D9CIoC016505 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1520932347; bh=98IaRAfWA0Ot0LakJPD7ReKuTfpTbSHOVIAs/wKQwjE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=M18W/8df9+58JUVM2Quj2vyLZjpxiNZaQVmZ4jAUJ1JHH9XU0PKMSC0OXlYMPYS6z bBobsSg84AznztCCtiXedaQ+/9qfF/r2Rx2fvQcNQWuRh9q5w+FLFqqvhK0JIDQe6H sfa5RX343DSlphXqhlrfoXfzsKWuHsagR1SbuNAzBSr1hZkv/wJPFylD0Uaa3JWD7m 36E1onzaKW/POm9unUBIlJRBc1JQ5SamRbfCYxUQZF4IrXMPSBcpIan5S5PI7kNQc6 0EvEOH+zy18GCfHCevoj+MIUwFURQYxg6SWTpFXYBBjELs11ACcz3CZJCsvjhZ41l6 jJL6dMDzU1g5Q== 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 11/11] kconfig: tests: test if recursive inclusion is detected Date: Tue, 13 Mar 2018 18:12:12 +0900 Message-Id: <1520932332-2449-12-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 If recursive inclusion is detected, it should fail with error messages. Test this. This also tests the line numbers in the error message, fixed by commit 5ae6fcc4bb82 ("kconfig: fix line number in recursive inclusion error message"). Signed-off-by: Masahiro Yamada Reviewed-by: Ulf Magnusson --- Changes in v3: - Replace the test code with the one used by commit Changes in v2: - coding style clean-up based on PEP8, PEP257 scripts/kconfig/tests/err_recursive_inc/Kconfig | 1 + scripts/kconfig/tests/err_recursive_inc/Kconfig2 | 1 + scripts/kconfig/tests/err_recursive_inc/Kconfig3 | 1 + scripts/kconfig/tests/err_recursive_inc/__init__.py | 10 ++++++++++ scripts/kconfig/tests/err_recursive_inc/expected_stderr | 5 +++++ 5 files changed, 18 insertions(+) create mode 100644 scripts/kconfig/tests/err_recursive_inc/Kconfig create mode 100644 scripts/kconfig/tests/err_recursive_inc/Kconfig2 create mode 100644 scripts/kconfig/tests/err_recursive_inc/Kconfig3 create mode 100644 scripts/kconfig/tests/err_recursive_inc/__init__.py create mode 100644 scripts/kconfig/tests/err_recursive_inc/expected_stderr -- 2.7.4 diff --git a/scripts/kconfig/tests/err_recursive_inc/Kconfig b/scripts/kconfig/tests/err_recursive_inc/Kconfig new file mode 100644 index 0000000..f21c890 --- /dev/null +++ b/scripts/kconfig/tests/err_recursive_inc/Kconfig @@ -0,0 +1 @@ +source "Kconfig2" diff --git a/scripts/kconfig/tests/err_recursive_inc/Kconfig2 b/scripts/kconfig/tests/err_recursive_inc/Kconfig2 new file mode 100644 index 0000000..b341502 --- /dev/null +++ b/scripts/kconfig/tests/err_recursive_inc/Kconfig2 @@ -0,0 +1 @@ +source "Kconfig3" diff --git a/scripts/kconfig/tests/err_recursive_inc/Kconfig3 b/scripts/kconfig/tests/err_recursive_inc/Kconfig3 new file mode 100644 index 0000000..1fab1c1 --- /dev/null +++ b/scripts/kconfig/tests/err_recursive_inc/Kconfig3 @@ -0,0 +1 @@ +source "Kconfig" diff --git a/scripts/kconfig/tests/err_recursive_inc/__init__.py b/scripts/kconfig/tests/err_recursive_inc/__init__.py new file mode 100644 index 0000000..0e4c839 --- /dev/null +++ b/scripts/kconfig/tests/err_recursive_inc/__init__.py @@ -0,0 +1,10 @@ +""" +Detect recursive inclusion error. + +If recursive inclusion is detected, it should fail with error messages. +""" + + +def test(conf): + assert conf.oldaskconfig() != 0 + assert conf.stderr_contains('expected_stderr') diff --git a/scripts/kconfig/tests/err_recursive_inc/expected_stderr b/scripts/kconfig/tests/err_recursive_inc/expected_stderr new file mode 100644 index 0000000..84cc0a1 --- /dev/null +++ b/scripts/kconfig/tests/err_recursive_inc/expected_stderr @@ -0,0 +1,5 @@ +Kconfig:1: recursive inclusion detected. Inclusion path: + current file : 'Kconfig' + included from: 'Kconfig3:1' + included from: 'Kconfig2:1' + included from: 'Kconfig:1'