Commit 1903c511905984685e0a299421bc4c8b6fc1344b
1 parent
022a4bf6b5
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>
Showing 9 changed files with 149 additions and 0 deletions Side-by-side Diff
- scripts/kconfig/tests/choice/Kconfig
- scripts/kconfig/tests/choice/__init__.py
- scripts/kconfig/tests/choice/alldef_expected_config
- scripts/kconfig/tests/choice/allmod_expected_config
- scripts/kconfig/tests/choice/allno_expected_config
- scripts/kconfig/tests/choice/allyes_expected_config
- scripts/kconfig/tests/choice/oldask0_expected_stdout
- scripts/kconfig/tests/choice/oldask1_config
- scripts/kconfig/tests/choice/oldask1_expected_stdout
scripts/kconfig/tests/choice/Kconfig
1 | +config MODULES | |
2 | + bool "Enable loadable module support" | |
3 | + option modules | |
4 | + default y | |
5 | + | |
6 | +choice | |
7 | + prompt "boolean choice" | |
8 | + default BOOL_CHOICE1 | |
9 | + | |
10 | +config BOOL_CHOICE0 | |
11 | + bool "choice 0" | |
12 | + | |
13 | +config BOOL_CHOICE1 | |
14 | + bool "choice 1" | |
15 | + | |
16 | +endchoice | |
17 | + | |
18 | +choice | |
19 | + prompt "optional boolean choice" | |
20 | + optional | |
21 | + default OPT_BOOL_CHOICE1 | |
22 | + | |
23 | +config OPT_BOOL_CHOICE0 | |
24 | + bool "choice 0" | |
25 | + | |
26 | +config OPT_BOOL_CHOICE1 | |
27 | + bool "choice 1" | |
28 | + | |
29 | +endchoice | |
30 | + | |
31 | +choice | |
32 | + prompt "tristate choice" | |
33 | + default TRI_CHOICE1 | |
34 | + | |
35 | +config TRI_CHOICE0 | |
36 | + tristate "choice 0" | |
37 | + | |
38 | +config TRI_CHOICE1 | |
39 | + tristate "choice 1" | |
40 | + | |
41 | +endchoice | |
42 | + | |
43 | +choice | |
44 | + prompt "optional tristate choice" | |
45 | + optional | |
46 | + default OPT_TRI_CHOICE1 | |
47 | + | |
48 | +config OPT_TRI_CHOICE0 | |
49 | + tristate "choice 0" | |
50 | + | |
51 | +config OPT_TRI_CHOICE1 | |
52 | + tristate "choice 1" | |
53 | + | |
54 | +endchoice |
scripts/kconfig/tests/choice/__init__.py
1 | +""" | |
2 | +Basic choice tests. | |
3 | + | |
4 | +The handling of 'choice' is a bit complicated part in Kconfig. | |
5 | + | |
6 | +The behavior of 'y' choice is intuitive. If choice values are tristate, | |
7 | +the choice can be 'm' where each value can be enabled independently. | |
8 | +Also, if a choice is marked as 'optional', the whole choice can be | |
9 | +invisible. | |
10 | +""" | |
11 | + | |
12 | + | |
13 | +def test_oldask0(conf): | |
14 | + assert conf.oldaskconfig() == 0 | |
15 | + assert conf.stdout_contains('oldask0_expected_stdout') | |
16 | + | |
17 | + | |
18 | +def test_oldask1(conf): | |
19 | + assert conf.oldaskconfig('oldask1_config') == 0 | |
20 | + assert conf.stdout_contains('oldask1_expected_stdout') | |
21 | + | |
22 | + | |
23 | +def test_allyes(conf): | |
24 | + assert conf.allyesconfig() == 0 | |
25 | + assert conf.config_contains('allyes_expected_config') | |
26 | + | |
27 | + | |
28 | +def test_allmod(conf): | |
29 | + assert conf.allmodconfig() == 0 | |
30 | + assert conf.config_contains('allmod_expected_config') | |
31 | + | |
32 | + | |
33 | +def test_allno(conf): | |
34 | + assert conf.allnoconfig() == 0 | |
35 | + assert conf.config_contains('allno_expected_config') | |
36 | + | |
37 | + | |
38 | +def test_alldef(conf): | |
39 | + assert conf.alldefconfig() == 0 | |
40 | + assert conf.config_contains('alldef_expected_config') |
scripts/kconfig/tests/choice/alldef_expected_config
scripts/kconfig/tests/choice/allmod_expected_config
scripts/kconfig/tests/choice/allno_expected_config
scripts/kconfig/tests/choice/allyes_expected_config
scripts/kconfig/tests/choice/oldask0_expected_stdout
1 | +Enable loadable module support (MODULES) [Y/n/?] (NEW) | |
2 | +boolean choice | |
3 | + 1. choice 0 (BOOL_CHOICE0) (NEW) | |
4 | +> 2. choice 1 (BOOL_CHOICE1) (NEW) | |
5 | +choice[1-2?]: | |
6 | +optional boolean choice [N/y/?] (NEW) | |
7 | +tristate choice [M/y/?] (NEW) | |
8 | + choice 0 (TRI_CHOICE0) [N/m/?] (NEW) | |
9 | + choice 1 (TRI_CHOICE1) [N/m/?] (NEW) | |
10 | +optional tristate choice [N/m/y/?] (NEW) |
scripts/kconfig/tests/choice/oldask1_config
scripts/kconfig/tests/choice/oldask1_expected_stdout
1 | +Enable loadable module support (MODULES) [N/y/?] | |
2 | +boolean choice | |
3 | + 1. choice 0 (BOOL_CHOICE0) (NEW) | |
4 | +> 2. choice 1 (BOOL_CHOICE1) (NEW) | |
5 | +choice[1-2?]: | |
6 | +optional boolean choice [Y/n/?] (NEW) | |
7 | +optional boolean choice | |
8 | +> 1. choice 0 (OPT_BOOL_CHOICE0) | |
9 | + 2. choice 1 (OPT_BOOL_CHOICE1) (NEW) | |
10 | +choice[1-2?]: | |
11 | +tristate choice | |
12 | + 1. choice 0 (TRI_CHOICE0) (NEW) | |
13 | +> 2. choice 1 (TRI_CHOICE1) (NEW) | |
14 | +choice[1-2?]: | |
15 | +optional tristate choice [N/y/?] |