[PATCH v3 11/11] kconfig: tests: test if recursive inclusion is detected

From: Masahiro Yamada
Date: Tue Mar 13 2018 - 05:15:19 EST


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 <yamada.masahiro@xxxxxxxxxxxxx>
Reviewed-by: Ulf Magnusson <ulfalizer@xxxxxxxxx>
---

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

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'
--
2.7.4