| f2fd2aad | 20-Mar-2024 |
Masahiro Yamada <[email protected]> |
kconfig: tests: test dependency after shuffling choices
Commit c8fb7d7e48d1 ("kconfig: fix broken dependency in randconfig- generated .config") fixed the issue, but I did not add a test case.
This
kconfig: tests: test dependency after shuffling choices
Commit c8fb7d7e48d1 ("kconfig: fix broken dependency in randconfig- generated .config") fixed the issue, but I did not add a test case.
This commit adds a test case that emulates the reported situation. The test would fail without c8fb7d7e48d1.
To handle the choice "choose X", FOO must be calculated beforehand. FOO depends on A, which is a member of another choice "choose A or B". Kconfig _temporarily_ assumes the value of A to proceed. The choice "choose A or B" will be shuffled later, but the result may or may not meet "FOO depends on A". Kconfig should invalidate the symbol values and recompute them.
In the real example for ARCH=arm64, the choice "Instrumentation type" needs the value of CPU_BIG_ENDIAN. The choice "Endianness" will be shuffled later.
Signed-off-by: Masahiro Yamada <[email protected]>
show more ...
|
| 47ad1689 | 20-Mar-2024 |
Masahiro Yamada <[email protected]> |
kconfig: tests: add a test for randconfig with dependent choices
Since commit 3b9a19e08960 ("kconfig: loop as long as we changed some symbols in randconfig"), conf_set_all_new_symbols() is repeated
kconfig: tests: add a test for randconfig with dependent choices
Since commit 3b9a19e08960 ("kconfig: loop as long as we changed some symbols in randconfig"), conf_set_all_new_symbols() is repeated until there is no more choice left to be shuffled. The motivation was to shuffle a choice nested in another choice.
Although commit 09d5873e4d1f ("kconfig: allow only 'config', 'comment', and 'if' inside 'choice'") disallowed the nested choice structure, we must still keep 3b9a19e08960 because there are still cases where conf_set_all_new_symbols() must iterate.
scripts/kconfig/tests/choice_randomize/Kconfig is the test case. The second choice depends on 'B', which is the member of the first choice.
With 3b9a19e08960 reverted, we would never get the pattern specified by scripts/kconfig/tests/choice_randomize/expected_config2.
A real example can be found in lib/Kconfig.debug. Without 3b9a19e08960, the randconfig would not shuffle the "Compressed Debug information" choice, which depends on DEBUG_INFO, which is derived from another choice "Debug information".
My goal is to refactor Kconfig so that randconfig will work more simply, without using the loop.
For now, let's add a test case to ensure all dependent choices are shuffled, as it is a somewhat tricky case for the current Kconfig.
Signed-off-by: Masahiro Yamada <[email protected]>
show more ...
|
| f498926c | 15-Aug-2018 |
Masahiro Yamada <[email protected]> |
kconfig: improve the recursive dependency report
This commit improves the messages of the recursive dependency. Currently, sym->dir_dep.expr is not checked. Hence, any dependency in property visibi
kconfig: improve the recursive dependency report
This commit improves the messages of the recursive dependency. Currently, sym->dir_dep.expr is not checked. Hence, any dependency in property visibility is regarded as the dependency of the symbol.
[Test Code 1]
config A bool "a" depends on B
config B bool "b" depends on A
[Test Code 2]
config A bool "a" if B
config B bool "b" depends on A
For both cases above, the same message is displayed:
symbol B depends on A symbol A depends on B
This commit changes the message for the latter, like this:
symbol B depends on A symbol A prompt is visible depending on B
Also, 'select' and 'imply' are distinguished.
Signed-off-by: Masahiro Yamada <[email protected]> Tested-by: Dirk Gouders <[email protected]>
show more ...
|
| 5e8c5299 | 15-Aug-2018 |
Masahiro Yamada <[email protected]> |
kconfig: report recursive dependency involving 'imply'
Currently, Kconfig does not complain about the recursive dependency where 'imply' keywords are involved.
[Test Code]
config A boo
kconfig: report recursive dependency involving 'imply'
Currently, Kconfig does not complain about the recursive dependency where 'imply' keywords are involved.
[Test Code]
config A bool "a"
config B bool "b" imply A depends on A
In the code above, Kconfig cannot calculate the symbol values correctly due to the circular dependency. For example, allyesconfig followed by syncconfig results in an odd behavior because CONFIG_B becomes visible in syncconfig.
$ make allyesconfig scripts/kconfig/conf --allyesconfig Kconfig # # configuration written to .config # $ cat .config # # Automatically generated file; DO NOT EDIT. # Main menu # CONFIG_A=y $ make syncconfig scripts/kconfig/conf --syncconfig Kconfig * * Restart config... * * * Main menu * a (A) [Y/n/?] y b (B) [N/y/?] (NEW)
To detect this correctly, sym_check_expr_deps() should recurse to not only sym->rev_dep.expr but also sym->implied.expr .
At this moment, sym_check_print_recursive() cannot distinguish 'select' and 'imply' since it does not know the precise context where the recursive dependency has been hit. This will be solved by the next commit.
In fact, even the document and the unit-test are confused. Using 'imply' does not solve recursive dependency since 'imply' addresses the unmet direct dependency, which 'select' could cause.
Signed-off-by: Masahiro Yamada <[email protected]> Tested-by: Dirk Gouders <[email protected]>
show more ...
|
| 32a94b8b | 22-Mar-2018 |
Masahiro Yamada <[email protected]> |
kconfig: remove duplicated file name and lineno of recursive inclusion
As in the unit test, the error message for the recursive inclusion looks like this:
Kconfig.inc1:4: recursive inclusion dete
kconfig: remove duplicated file name and lineno of recursive inclusion
As in the unit test, the error message for the recursive inclusion looks like this:
Kconfig.inc1:4: recursive inclusion detected. Inclusion path: current file : 'Kconfig.inc1' included from: 'Kconfig.inc3:1' included from: 'Kconfig.inc2:3' included from: 'Kconfig.inc1:4'
The 'Kconfig.inc1:4' is duplicated in the first and last lines. Also, the single quotes do not help readability.
Change the message like follows:
Recursive inclusion detected. Inclusion path: current file : Kconfig.inc1 included from: Kconfig.inc3:1 included from: Kconfig.inc2:3 included from: Kconfig.inc1:4
Signed-off-by: Masahiro Yamada <[email protected]>
show more ...
|
| e2c75e76 | 13-Mar-2018 |
Masahiro Yamada <[email protected]> |
kconfig: tests: test if recursive inclusion is detected
If recursive inclusion is detected, it should fail with error messages. Test this.
This also tests the line numbers in the error message, fi
kconfig: tests: test if recursive inclusion is detected
If recursive inclusion is detected, it should fail with error messages. Test this.
This also tests the line numbers in the error message, fixed by commit 5ae6fcc4bb82 ("kconfig: fix line number in recursive inclusion error message").
Signed-off-by: Masahiro Yamada <[email protected]> Reviewed-by: Ulf Magnusson <[email protected]>
show more ...
|
| 3e4888c2 | 13-Mar-2018 |
Masahiro Yamada <[email protected]> |
kconfig: tests: test randconfig for choice in choice
Commit 3b9a19e08960 ("kconfig: loop as long as we changed some symbols in randconfig") fixed randconfig where a choice contains a sub-choice. Pri
kconfig: tests: test randconfig for choice in choice
Commit 3b9a19e08960 ("kconfig: loop as long as we changed some symbols in randconfig") fixed randconfig where a choice contains a sub-choice. Prior to that commit, the sub-choice values were not set.
I am not sure whether this is an intended feature or just something people discovered works, but it is used in the real world; drivers/usb/gadget/legacy/Kconfig is source'd in a choice context, then creates a sub-choice in it.
For the test case in this commit, there are 3 possible results.
Case 1: CONFIG_A=y # CONFIG_B is not set
Case 2: # CONFIG_A is not set CONFIG_B=y CONFIG_C=y # CONFIG_D is not set
Case 3: # CONFIG_A is not set CONFIG_B=y # CONFIG_C is not set CONFIG_D=y CONFIG_E=y
So, this test iterates several times, and checks if the result is either of the three.
Signed-off-by: Masahiro Yamada <[email protected]> Reviewed-by: Ulf Magnusson <[email protected]>
show more ...
|
| beaaddb6 | 13-Mar-2018 |
Masahiro Yamada <[email protected]> |
kconfig: tests: test defconfig when two choices interact
Commit fbe98bb9ed3d ("kconfig: Fix defconfig when one choice menu selects options that another choice menu depends on") fixed defconfig when
kconfig: tests: test defconfig when two choices interact
Commit fbe98bb9ed3d ("kconfig: Fix defconfig when one choice menu selects options that another choice menu depends on") fixed defconfig when two choices interact (i.e. calculating the visibility of a choice requires to calculate another choice).
The test code in that commit log was based on the real world example, and complicated. So, I shrunk it down to the following:
defconfig.choice: ---8<--- CONFIG_CHOICE_VAL0=y ---8<---
---8<--- config MODULES def_bool y option modules
choice prompt "Choice"
config CHOICE_VAL0 tristate "Choice 0"
config CHOICE_VAL1 tristate "Choice 1"
endchoice
choice prompt "Another choice" depends on CHOICE_VAL0
config DUMMY bool "dummy"
endchoice ---8<---
Prior to commit fbe98bb9ed3d,
$ scripts/kconfig/conf --defconfig=defconfig.choice Kconfig.choice
resulted in:
CONFIG_MODULES=y CONFIG_CHOICE_VAL0=m # CONFIG_CHOICE_VAL1 is not set CONFIG_DUMMY=y
where the expected result would be:
CONFIG_MODULES=y CONFIG_CHOICE_VAL0=y # CONFIG_CHOICE_VAL1 is not set CONFIG_DUMMY=y
Roughly, this weird behavior happened like this:
Symbols are calculated a couple of times. First, all symbols are calculated in conf_read(). The first 'choice' is evaluated to 'y' due to the SYMBOL_DEF_USER flag, but sym_calc_choice() clears it unless all of its choice values are explicitly set by the user.
conf_set_all_new_symbols() clears all SYMBOL_VALID flags. Then, only choices are calculated. Here, the SYMBOL_DEF_USER for the first choice has been forgotten, so it is evaluated to 'm'. set_all_choice_values() sets SYMBOL_DEF_USER again to choice symbols.
When calculating the second choice, due to 'depends on CHOICE_VAL0', it triggers the calculation of CHOICE_VAL0. As a result, SYMBOL_VALID is set for CHOICE_VAL0.
Symbols except choices get the final chance of re-calculation in conf_write(). In a normal case, CHOICE_VAL0 would be re-calculated, then the first choice would be indirectly re-calculated with the SYMBOL_DEF_USER which has been recalled by set_all_choice_values(), which would be evaluated to 'y'. But, in this case, CHOICE_VAL0 has already been marked as SYMBOL_VALID, so this re-calculation does not happen. Then, =m from the conf_set_all_new_symbols() phase is written out to the .config file.
Add a unit test for this naive case.
Signed-off-by: Masahiro Yamada <[email protected]> Reviewed-by: Ulf Magnusson <[email protected]>
show more ...
|
| ee236610 | 13-Mar-2018 |
Masahiro Yamada <[email protected]> |
kconfig: tests: check visibility of tristate choice values in y choice
If tristate choice values depend on symbols set to 'm', they should be hidden when the choice containing them is changed from '
kconfig: tests: check visibility of tristate choice values in y choice
If tristate choice values depend on symbols set to 'm', they should be hidden when the choice containing them is changed from 'm' to 'y' (i.e. exclusive choice).
This issue was fixed by commit fa64e5f6a35e ("kconfig/symbol.c: handle choice_values that depend on 'm' symbols").
Add a test case to avoid regression.
For the input in this unit test, there is a room for argument if "# CONFIG_CHOICE1 is not set" should be written to the .config file.
After commit fa64e5f6a35e, this line was written to the .config file.
With commit cb67ab2cd2b8 ("kconfig: do not write choice values when their dependency becomes n"), it is not written now.
In this test, "# CONFIG_CHOICE1 is not set" is don't care.
Signed-off-by: Masahiro Yamada <[email protected]> Reviewed-by: Ulf Magnusson <[email protected]>
show more ...
|