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>
This commit is contained in:
53
scripts/kconfig/tests/preprocess/variable/Kconfig
Normal file
53
scripts/kconfig/tests/preprocess/variable/Kconfig
Normal file
@@ -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))
|
8
scripts/kconfig/tests/preprocess/variable/__init__.py
Normal file
8
scripts/kconfig/tests/preprocess/variable/__init__.py
Normal file
@@ -0,0 +1,8 @@
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
"""
|
||||
Variable and user-defined function tests.
|
||||
"""
|
||||
|
||||
def test(conf):
|
||||
assert conf.oldaskconfig() == 0
|
||||
assert conf.stderr_matches('expected_stderr')
|
@@ -0,0 +1,9 @@
|
||||
Kconfig:10: SIMPLE = 1
|
||||
Kconfig:16: RECURSIVE = 2
|
||||
Kconfig:22: SIMPLE = 1 3
|
||||
Kconfig:28: RECURSIVE = 2 4
|
||||
Kconfig:35: UNDEFINED_VARIABLE = 4
|
||||
Kconfig:41: AB = 5
|
||||
Kconfig:45: Hello, my name is John.
|
||||
Kconfig:50: Hello, my name is .
|
||||
Kconfig:53: Hello, my name is John.
|
Reference in New Issue
Block a user