diff options
author | Masahiro Yamada <yamada.masahiro@socionext.com> | 2018-05-28 18:21:57 +0900 |
---|---|---|
committer | Masahiro Yamada <yamada.masahiro@socionext.com> | 2018-05-29 03:31:19 +0900 |
commit | 2bece88f89faad8d2e5499652e2bd5f2045ec92a (patch) | |
tree | 9e327ae63fc7449e44d65da043c4ecec9ccf1d24 /scripts/kconfig/tests/preprocess/variable/Kconfig | |
parent | 316d55d55f49eca442e4fd948f5fa92bab0c8312 (diff) | |
download | linux-stable-2bece88f89faad8d2e5499652e2bd5f2045ec92a.tar.gz linux-stable-2bece88f89faad8d2e5499652e2bd5f2045ec92a.tar.bz2 linux-stable-2bece88f89faad8d2e5499652e2bd5f2045ec92a.zip |
kconfig: test: add Kconfig macro language tests
Here are the test cases I used for developing the text expansion
feature.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Diffstat (limited to 'scripts/kconfig/tests/preprocess/variable/Kconfig')
-rw-r--r-- | scripts/kconfig/tests/preprocess/variable/Kconfig | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/scripts/kconfig/tests/preprocess/variable/Kconfig b/scripts/kconfig/tests/preprocess/variable/Kconfig new file mode 100644 index 000000000000..9ce2f95cbd24 --- /dev/null +++ b/scripts/kconfig/tests/preprocess/variable/Kconfig @@ -0,0 +1,53 @@ +# SPDX-License-Identifier: GPL-2.0 + +# Shorthand +warning = $(warning-if,y,$(1)) + +# Simply expanded variable. +X := 1 +SIMPLE := $(X) +X := 2 +$(warning,SIMPLE = $(SIMPLE)) + +# Recursively expanded variable. +X := 1 +RECURSIVE = $(X) +X := 2 +$(warning,RECURSIVE = $(RECURSIVE)) + +# Append something to a simply expanded variable. +Y := 3 +SIMPLE += $(Y) +Y := 4 +$(warning,SIMPLE = $(SIMPLE)) + +# Append something to a recursively expanded variable. +Y := 3 +RECURSIVE += $(Y) +Y := 4 +$(warning,RECURSIVE = $(RECURSIVE)) + +# Use += operator to an undefined variable. +# This works as a recursively expanded variable. +Y := 3 +UNDEFINED_VARIABLE += $(Y) +Y := 4 +$(warning,UNDEFINED_VARIABLE = $(UNDEFINED_VARIABLE)) + +# You can use variable references for the lefthand side of assignment statement. +X := A +Y := B +$(X)$(Y) := 5 +$(warning,AB = $(AB)) + +# User-defined function. +greeting = $(1), my name is $(2). +$(warning,$(greeting,Hello,John)) + +# The number of arguments is not checked for user-defined functions. +# If some arguments are optional, it is useful to pass fewer parameters. +# $(2) will be blank in this case. +$(warning,$(greeting,Hello)) + +# Unreferenced parameters are just ignored. +$(warning,$(greeting,Hello,John,ignored,ignored)) |