History

kconfig: fix randconfig for choice blocks

Ingo Molnar reported that 'make randconfig' was not covering choice blocks properly, resulting in certain config options being left out of randconfig testing altogether. With the following patch we: - properly randomize choice value for normal choice blocks - properly randomize for multi choice blocks - added several comments to explain what is going on The root cause of the bug was that SYMBOL_VALID was set on the symbol representing the choice block so clearing this did the trick initially. But testign revealed a few more issues that is now fixed.

Sam Ravnborg committed 17 years ago

Commit 184832c1 parent 5bee17f1 file · +36 −15Browse files

Unified · Split

scripts/kconfig/confdata.c+36−15
@@ -843,7 +843,7 @@ void conf_set_all_new_symbols(enum conf_def_mode mode) · 842 unmodified lines
843843 default:
844844 continue;
845845 }
846− if (!sym_is_choice(sym) || mode != def_random)
846+ if (!(sym_is_choice(sym) && mode == def_random))
847847 sym->flags |= SYMBOL_DEF_USER;
848848 break;
849849 default:
@@ -856,28 +856,49 @@ void conf_set_all_new_symbols(enum conf_def_mode mode) · 6 unmodified lines
856856
857857 if (mode != def_random)
858858 return;
859−
859+ /*
860+ * We have different type of choice blocks.
861+ * If curr.tri equal to mod then we can select several
862+ * choice symbols in one block.
863+ * In this case we do nothing.
864+ * If curr.tri equal yes then only one symbol can be
865+ * selected in a choice block and we set it to yes,
866+ * and the rest to no.
867+ */
860868 for_all_symbols(i, csym) {
861869 if (sym_has_value(csym) || !sym_is_choice(csym))
862870 continue;
863871
864872 sym_calc_value(csym);
873+
874+ if (csym->curr.tri != yes)
875+ continue;
876+
865877 prop = sym_get_choice_prop(csym);
866− def = -1;
867− while (1) {
868− cnt = 0;
869− expr_list_for_each_sym(prop->expr, e, sym) {
870− if (sym->visible == no)
871− continue;
872− if (def == cnt++) {
873− csym->def[S_DEF_USER].val = sym;
874− break;
875− }
878+
879+ /* count entries in choice block */
880+ cnt = 0;
881+ expr_list_for_each_sym(prop->expr, e, sym)
882+ cnt++;
883+
884+ /*
885+ * find a random value and set it to yes,
886+ * set the rest to no so we have only one set
887+ */
888+ def = (rand() % cnt);
889+
890+ cnt = 0;
891+ expr_list_for_each_sym(prop->expr, e, sym) {
892+ if (def == cnt++) {
893+ sym->def[S_DEF_USER].tri = yes;
894+ csym->def[S_DEF_USER].val = sym;
895+ }
896+ else {
897+ sym->def[S_DEF_USER].tri = no;
876898 }
877− if (def >= 0 || cnt < 2)
878− break;
879− def = (rand() % cnt) + 1;
880899 }
881900 csym->flags |= SYMBOL_DEF_USER;
901+ /* clear VALID to get value calculated */
902+ csym->flags &= ~(SYMBOL_VALID);
882903 }
883904 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t