aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/kconfig/tests
diff options
context:
space:
mode:
authorMasahiro Yamada <yamada.masahiro@socionext.com>2018-03-13 05:12:04 -0400
committerMasahiro Yamada <yamada.masahiro@socionext.com>2018-03-25 13:04:02 -0400
commit1903c511905984685e0a299421bc4c8b6fc1344b (patch)
tree807f25bfa59362cebbb9b7d787d30c47a9f35bc0 /scripts/kconfig/tests
parent022a4bf6b59dfdb192ca8aef291c7346f984e511 (diff)
kconfig: tests: add basic choice tests
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 <yamada.masahiro@socionext.com> Reviewed-by: Ulf Magnusson <ulfalizer@gmail.com>
Diffstat (limited to 'scripts/kconfig/tests')
-rw-r--r--scripts/kconfig/tests/choice/Kconfig54
-rw-r--r--scripts/kconfig/tests/choice/__init__.py40
-rw-r--r--scripts/kconfig/tests/choice/alldef_expected_config5
-rw-r--r--scripts/kconfig/tests/choice/allmod_expected_config9
-rw-r--r--scripts/kconfig/tests/choice/allno_expected_config5
-rw-r--r--scripts/kconfig/tests/choice/allyes_expected_config9
-rw-r--r--scripts/kconfig/tests/choice/oldask0_expected_stdout10
-rw-r--r--scripts/kconfig/tests/choice/oldask1_config2
-rw-r--r--scripts/kconfig/tests/choice/oldask1_expected_stdout15
9 files changed, 149 insertions, 0 deletions
diff --git a/scripts/kconfig/tests/choice/Kconfig b/scripts/kconfig/tests/choice/Kconfig
new file mode 100644
index 000000000000..cc60e9ce2c03
--- /dev/null
+++ b/scripts/kconfig/tests/choice/Kconfig
@@ -0,0 +1,54 @@
1config MODULES
2 bool "Enable loadable module support"
3 option modules
4 default y
5
6choice
7 prompt "boolean choice"
8 default BOOL_CHOICE1
9
10config BOOL_CHOICE0
11 bool "choice 0"
12
13config BOOL_CHOICE1
14 bool "choice 1"
15
16endchoice
17
18choice
19 prompt "optional boolean choice"
20 optional
21 default OPT_BOOL_CHOICE1
22
23config OPT_BOOL_CHOICE0
24 bool "choice 0"
25
26config OPT_BOOL_CHOICE1
27 bool "choice 1"
28
29endchoice
30
31choice
32 prompt "tristate choice"
33 default TRI_CHOICE1
34
35config TRI_CHOICE0
36 tristate "choice 0"
37
38config TRI_CHOICE1
39 tristate "choice 1"
40
41endchoice
42
43choice
44 prompt "optional tristate choice"
45 optional
46 default OPT_TRI_CHOICE1
47
48config OPT_TRI_CHOICE0
49 tristate "choice 0"
50
51config OPT_TRI_CHOICE1
52 tristate "choice 1"
53
54endchoice
diff --git a/scripts/kconfig/tests/choice/__init__.py b/scripts/kconfig/tests/choice/__init__.py
new file mode 100644
index 000000000000..9edcc5262134
--- /dev/null
+++ b/scripts/kconfig/tests/choice/__init__.py
@@ -0,0 +1,40 @@
1"""
2Basic choice tests.
3
4The handling of 'choice' is a bit complicated part in Kconfig.
5
6The behavior of 'y' choice is intuitive. If choice values are tristate,
7the choice can be 'm' where each value can be enabled independently.
8Also, if a choice is marked as 'optional', the whole choice can be
9invisible.
10"""
11
12
13def test_oldask0(conf):
14 assert conf.oldaskconfig() == 0
15 assert conf.stdout_contains('oldask0_expected_stdout')
16
17
18def test_oldask1(conf):
19 assert conf.oldaskconfig('oldask1_config') == 0
20 assert conf.stdout_contains('oldask1_expected_stdout')
21
22
23def test_allyes(conf):
24 assert conf.allyesconfig() == 0
25 assert conf.config_contains('allyes_expected_config')
26
27
28def test_allmod(conf):
29 assert conf.allmodconfig() == 0
30 assert conf.config_contains('allmod_expected_config')
31
32
33def test_allno(conf):
34 assert conf.allnoconfig() == 0
35 assert conf.config_contains('allno_expected_config')
36
37
38def test_alldef(conf):
39 assert conf.alldefconfig() == 0
40 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 000000000000..7a754bf4be94
--- /dev/null
+++ b/scripts/kconfig/tests/choice/alldef_expected_config
@@ -0,0 +1,5 @@
1CONFIG_MODULES=y
2# CONFIG_BOOL_CHOICE0 is not set
3CONFIG_BOOL_CHOICE1=y
4# CONFIG_TRI_CHOICE0 is not set
5# 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 000000000000..f1f5dcdb7923
--- /dev/null
+++ b/scripts/kconfig/tests/choice/allmod_expected_config
@@ -0,0 +1,9 @@
1CONFIG_MODULES=y
2# CONFIG_BOOL_CHOICE0 is not set
3CONFIG_BOOL_CHOICE1=y
4# CONFIG_OPT_BOOL_CHOICE0 is not set
5CONFIG_OPT_BOOL_CHOICE1=y
6CONFIG_TRI_CHOICE0=m
7CONFIG_TRI_CHOICE1=m
8CONFIG_OPT_TRI_CHOICE0=m
9CONFIG_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 000000000000..b88ee7a43136
--- /dev/null
+++ b/scripts/kconfig/tests/choice/allno_expected_config
@@ -0,0 +1,5 @@
1# CONFIG_MODULES is not set
2# CONFIG_BOOL_CHOICE0 is not set
3CONFIG_BOOL_CHOICE1=y
4# CONFIG_TRI_CHOICE0 is not set
5CONFIG_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 000000000000..e5a062a1157c
--- /dev/null
+++ b/scripts/kconfig/tests/choice/allyes_expected_config
@@ -0,0 +1,9 @@
1CONFIG_MODULES=y
2# CONFIG_BOOL_CHOICE0 is not set
3CONFIG_BOOL_CHOICE1=y
4# CONFIG_OPT_BOOL_CHOICE0 is not set
5CONFIG_OPT_BOOL_CHOICE1=y
6# CONFIG_TRI_CHOICE0 is not set
7CONFIG_TRI_CHOICE1=y
8# CONFIG_OPT_TRI_CHOICE0 is not set
9CONFIG_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 000000000000..b251bba9698b
--- /dev/null
+++ b/scripts/kconfig/tests/choice/oldask0_expected_stdout
@@ -0,0 +1,10 @@
1Enable loadable module support (MODULES) [Y/n/?] (NEW)
2boolean choice
3 1. choice 0 (BOOL_CHOICE0) (NEW)
4> 2. choice 1 (BOOL_CHOICE1) (NEW)
5choice[1-2?]:
6optional boolean choice [N/y/?] (NEW)
7tristate choice [M/y/?] (NEW)
8 choice 0 (TRI_CHOICE0) [N/m/?] (NEW)
9 choice 1 (TRI_CHOICE1) [N/m/?] (NEW)
10optional 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 000000000000..b67bfe3c641f
--- /dev/null
+++ b/scripts/kconfig/tests/choice/oldask1_config
@@ -0,0 +1,2 @@
1# CONFIG_MODULES is not set
2CONFIG_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 000000000000..c2125e9bf96a
--- /dev/null
+++ b/scripts/kconfig/tests/choice/oldask1_expected_stdout
@@ -0,0 +1,15 @@
1Enable loadable module support (MODULES) [N/y/?]
2boolean choice
3 1. choice 0 (BOOL_CHOICE0) (NEW)
4> 2. choice 1 (BOOL_CHOICE1) (NEW)
5choice[1-2?]:
6optional boolean choice [Y/n/?] (NEW)
7optional boolean choice
8> 1. choice 0 (OPT_BOOL_CHOICE0)
9 2. choice 1 (OPT_BOOL_CHOICE1) (NEW)
10choice[1-2?]:
11tristate choice
12 1. choice 0 (TRI_CHOICE0) (NEW)
13> 2. choice 1 (TRI_CHOICE1) (NEW)
14choice[1-2?]:
15optional tristate choice [N/y/?]