diff options
Diffstat (limited to 'scripts/kconfig/tests/preprocess/builtin_func')
4 files changed, 42 insertions, 0 deletions
diff --git a/scripts/kconfig/tests/preprocess/builtin_func/Kconfig b/scripts/kconfig/tests/preprocess/builtin_func/Kconfig new file mode 100644 index 000000000000..baa328827911 --- /dev/null +++ b/scripts/kconfig/tests/preprocess/builtin_func/Kconfig | |||
| @@ -0,0 +1,27 @@ | |||
| 1 | # SPDX-License-Identifier: GPL-2.0 | ||
| 2 | |||
| 3 | # 'info' prints the argument to stdout. | ||
| 4 | $(info,hello world 0) | ||
| 5 | |||
| 6 | # 'warning-if', if the first argument is y, sends the second argument to stderr, | ||
| 7 | # and the message is prefixed with the current file name and line number. | ||
| 8 | $(warning-if,y,hello world 1) | ||
| 9 | |||
| 10 | # 'error-if' is similar, but it terminates the parsing immediately. | ||
| 11 | # The following is just no-op since the first argument is not y. | ||
| 12 | $(error-if,n,this should not be printed) | ||
| 13 | |||
| 14 | # Shorthand | ||
| 15 | warning = $(warning-if,y,$(1)) | ||
| 16 | |||
| 17 | # 'shell' executes a command, and returns its stdout. | ||
| 18 | $(warning,$(shell,echo hello world 3)) | ||
| 19 | |||
| 20 | # Every newline in the output is replaced with a space, | ||
| 21 | # but any trailing newlines are deleted. | ||
| 22 | $(warning,$(shell,printf 'hello\nworld\n\n4\n\n\n')) | ||
| 23 | |||
| 24 | # 'filename' is expanded to the currently parsed file name, | ||
| 25 | # 'lineno' to the line number. | ||
| 26 | $(warning,filename=$(filename)) | ||
| 27 | $(warning,lineno=$(lineno)) | ||
diff --git a/scripts/kconfig/tests/preprocess/builtin_func/__init__.py b/scripts/kconfig/tests/preprocess/builtin_func/__init__.py new file mode 100644 index 000000000000..2e53ba08fca1 --- /dev/null +++ b/scripts/kconfig/tests/preprocess/builtin_func/__init__.py | |||
| @@ -0,0 +1,9 @@ | |||
| 1 | # SPDX-License-Identifier: GPL-2.0 | ||
| 2 | """ | ||
| 3 | Built-in function tests. | ||
| 4 | """ | ||
| 5 | |||
| 6 | def test(conf): | ||
| 7 | assert conf.oldaskconfig() == 0 | ||
| 8 | assert conf.stdout_contains('expected_stdout') | ||
| 9 | assert conf.stderr_matches('expected_stderr') | ||
diff --git a/scripts/kconfig/tests/preprocess/builtin_func/expected_stderr b/scripts/kconfig/tests/preprocess/builtin_func/expected_stderr new file mode 100644 index 000000000000..33ea9ca38400 --- /dev/null +++ b/scripts/kconfig/tests/preprocess/builtin_func/expected_stderr | |||
| @@ -0,0 +1,5 @@ | |||
| 1 | Kconfig:8: hello world 1 | ||
| 2 | Kconfig:18: hello world 3 | ||
| 3 | Kconfig:22: hello world 4 | ||
| 4 | Kconfig:26: filename=Kconfig | ||
| 5 | Kconfig:27: lineno=27 | ||
diff --git a/scripts/kconfig/tests/preprocess/builtin_func/expected_stdout b/scripts/kconfig/tests/preprocess/builtin_func/expected_stdout new file mode 100644 index 000000000000..82de3a7e97de --- /dev/null +++ b/scripts/kconfig/tests/preprocess/builtin_func/expected_stdout | |||
| @@ -0,0 +1 @@ | |||
| hello world 0 | |||
