summaryrefslogtreecommitdiff
path: root/testsuite.py
AgeCommit message (Collapse)Author
2018-07-20Add KCONFIG_STRICT flag for flagging refs. to undefined symsUlf Magnusson
Settings KCONFIG_STRICT to y in the environment turns on warnings for all references to undefined symbols within Kconfig files (with the only gotcha that hex literals must be prefixed by 0x or 0X, to make it possible to distinguish them from undefined references). Always flagging undefined references gets awkward, as some projects (e.g. the Linux kernel) use multiple Kconfig trees with shared files, leading to some safe undefined references. It's helpful for other projects though. Having KCONFIG_STRICT as an environment variable is handy when multiple tools are involved. Piggyback a small README change re. warnings. Kconfiglib now has many more warnings than the C tools.
2018-07-18Add def_int, def_hex, and def_string keywordsUlf Magnusson
Analogous to def_bool and def_tristate, setting the type and adding a default at the same time. This is a Kconfiglib extension. These keywords can be useful in projects that make use of symbols defined in multiple locations, and remove some Kconfig inconsistency.
2018-07-15Switch to more sensible globbing statements (w/ backwards compatibility)Ulf Magnusson
Instead of having 'source' and 'gsource', have 'source' always glob, but require the pattern to match at least one file, throwing KconfigError otherwise. Have separate 'osource' and 'orsource' statements (the o is for "optional") for cases where it's okay for the pattern to not match any files. This is analogous to 'include' and '-include' in Make. The biggest flaw with 'gsource' was that there was no way to do a globbing match while requiring something to match, possibly leading to subtle failures. Preserve backwards compatibility by having "gsource" and "grsource" be aliases for "osource" and "orsource", respectively. Also include some related changes: - Kconfig.srctree is now set to the empty string if $srctree is unset, rather than to None. This gives nice behavior with os.path.join() and os.path.relpath(), which treat the empty string as the current directory (without adding './', for os.path.join()). - When $srctree is set, Kconfig files in the current directory will no longer override Kconfig files in $srctree when the relative paths match. This was likely a bug all along in the C tools, and probably only makes sense for .config files. I've seen it cause breakage in Zephyr. - Clarify the behavior of $srctree in the Kconfig.__init__() docstring. - Make MenuNode.filename be relative to $srctree for the Kconfig file passed to Kconfig.__init__(). This makes it consistent. The major version will be bumped later due to the small Kconfig.srctree API change.
2018-07-13Fix absolute $srctree prefixes showing up on gsource'd filesUlf Magnusson
When using gsource with $srctree set to an absolute path, the $srctree prefix would show up in MenuNode.filename, trickling its way into e.g. generated documentation. This was due to a broken test: os.path.isabs() was checked after joining the pattern with $srctree, making it mistake an absolute $srctree for an absolute path in the Kconfig file. Fix the test.
2018-07-10Warn if int/hex 'default' is outside active 'range'Ulf Magnusson
Only out-of-range user values generated warnings before. The C tools warn for neither of them.
2018-07-10Add Kconfig preprocessorUlf Magnusson
Implement the Kconfig preprocessor described in https://github.com/torvalds/linux/blob/master/Documentation/kbuild/kconfig-macro-language.txt (which is now in linux-next and will appear in Linux 4.18). A new Kconfig.variables property holds all the preprocessor variables so that they can be inspected programmatically. Preprocessor variables are represented by a new Variable class. With the preprocessor, environment variables are referenced with $(FOO) instead of $FOO. For backwards compatibility, $FOO is accepted as well for now (and leaves "$FOO" as-is if FOO doesn't exist). The $FOO syntax might be dropped at some point in the future (together with a major version increase). It should be supported for a few months at least. Some internals were cleaned up too, mostly related to parsing. Some outdated documentation was fixed as well.
2018-07-02Refactor tokenization a bitUlf Magnusson
Have _tokenize() take the string to tokenize and return a list of tokens, and handle all the token list management outside. Simplifies the internal logic a bit. Likely faster too.
2018-06-22Turn MenuNode/Symbol/Choice.referenced() into a @propertyUlf Magnusson
Having it as a function is inconsistent, since all other read-only fields use properties. Oversight. Major version will be bumped to 7, though the function version wasn't in for long.
2018-06-22Add Symbol/Choice.referenced() convenience methodsUlf Magnusson
Returns the union of the MenuNode.referenced() sets for all the menu nodes of the symbol/choice.
2018-06-20Rename KconfigSyntaxError to KconfigErrorUlf Magnusson
This exception is generated for semantic errors and e.g. when dependency loops are detected as well, so the name is bad. Keep the old name as an alias for now for backwards compatibility.
2018-06-19Add dependency loop detectionUlf Magnusson
Pretty long overdue. Until now, dependency loops have raised a hard-to-debug Python RecursionError during evaluation. A Kconfiglib exception is raised now instead, with a message that lists all the items in the loop. See the comment at the start of _check_dep_loop_sym() for an overview of the algorithm. At a high level, it's loop detection in a directed graph by keeping track of unvisited/visited nodes during depth-first search. (A third "visited, known to not be in a dependency loop" state is used as well.) Choices complicate things, as they're inherently loopy: The choice depends on the choice symbols and vice versa, and the choice symbols in a sense all depend on each other. Add the choice-to-choice-symbol dependencies separately after dependency loop detection, so that there's just the choice-symbol-to-choice dependencies to deal with. It simplifies things, as it makes it possible to tell dependencies from 'prompt' and 'default' conditions on the choice from choice symbol dependencies. Do some flag shenanigans to prevent the choice from being "re-entered" while looping through the choice symbols. Maybe this could be cleaned up a bit somehow... Example exception message: Dependency loop =============== A (defined at tests/Kdeploop10:1), with definition... config A bool depends on B ...depends on B (defined at tests/Kdeploop10:5), with definition... config B bool depends on C = 7 ...depends on C (defined at tests/Kdeploop10:9), with definition... config C int range D 8 ...depends on D (defined at tests/Kdeploop10:13), with definition... config D int default 3 if E default 8 ...depends on E (defined at tests/Kdeploop10:18), with definition... config E bool (select-related dependencies: F && G) ...depends on G (defined at tests/Kdeploop10:25), with definition... config G bool depends on H ...depends on the choice symbol H (defined at tests/Kdeploop10:32), with definition... config H bool prompt "H" if I && <choice> depends on I && <choice> ...depends on the choice symbol I (defined at tests/Kdeploop10:41), with definition... config I bool prompt "I" if <choice> depends on <choice> ...depends on <choice> (defined at tests/Kdeploop10:38), with definition... choice bool prompt "choice" if J ...depends on J (defined at tests/Kdeploop10:46), with definition... config J bool depends on A ...depends again on A (defined at tests/Kdeploop10:1)
2018-06-14Test property ordering on nested multi.def. choicesUlf Magnusson
This case wasn't covered.
2018-06-14Fix MenuNode.referenced() on Kconfig.top_nodeUlf Magnusson
The property lists weren't created for Kconfig.top_node, making referenced() crash. Add a MenuNode constructor and create the property lists there instead of in _parse_properties().
2018-06-14Fix incorrectly ordered properties for some nested multi.def. symbolsUlf Magnusson
_propagate_deps() visits menu nodes roughly breadth-first, meaning properties on symbols and choices defined in multiple locations could end up in the wrong order when copied from the menu node for some unlucky if/menu nestings. Fix it by moving the menu-node-to-symbol/choice property copying in _finalize_tree() so that it's guaranteed to happen in definition order. This bug was introduced by commit 63a4418 ("Record which MenuNode has each property").
2018-06-13Add MenuNode function that returns referenced itemsUlf Magnusson
MenuNode.referenced() returns all symbols (and choices, for choice symbols) referenced in the properties (prompt, defaults, selects, ranges, etc.) and property conditions of the menu node. Handy e.g. when generating cross-references.
2018-06-11Add a function for getting all items in an expressionUlf Magnusson
Handy e.g. when searching.
2018-05-31Reorder compatibility testsUlf Magnusson
The defconfig tests tend to find any issue quickly, so keep those first. Go alldefconfig -> allnoconfig -> allmodconfig -> allyesconfig after that, and do the sanity checks at the end.
2018-05-30Add an allmodconfig implementationUlf Magnusson
Verified to produce identical output to 'make allmodconfig', for all arches. Will be packaged.
2018-05-30Add an alldefconfig.py scriptUlf Magnusson
Will be packaged. Piggyback test suite cleanups to make test names match the name of the script being tested.
2018-05-30Add tool helper for selecting the top-level KconfigUlf Magnusson
standard_kconfig() gets the top-level Kconfig file from the first command-line argument, defaulting to "Kconfig". This removes some boilerplate from tools.
2018-05-30allyesconfig: Prepare for packagingUlf Magnusson
Move to the root, simplify a bit, provide an entry point function (for setuptools's entry_points).
2018-05-27Provide lists with all menus and commentsUlf Magnusson
Handy e.g. when implementing advanced search features.
2018-05-27Make Kconfig._choices publicUlf Magnusson
Useful in various places outside the library, e.g. in the upcoming packaged allyesconfig implementation, and when generating documentation.
2018-05-27allnoconfig: Move from examples/ to rootUlf Magnusson
Put to-be-packaged stuff in the root. Use allnoconfig_simpler.py, and rename allnoconfig.py to allnoconfig_walk.py and keep it as an example.
2018-05-27Simplify error exitsUlf Magnusson
Had missed sys.exit(msg).
2018-05-27Get rid of the predefined UNAME_RELEASE symbolUlf Magnusson
Commit cbf32e2 ("Expand environment variables in strings directly") added direct expansion of environment variables is strings, with commit b9384a1 ("Restore compatibility with $UNAME_RELEASE") adding a hack to restore compatibility with the predefined $UNAME_RELEASE symbol, used by DEFCONFIG_LIST in the Linux kernel. With the compatibility hack in place, there's no longer any need to define UNAME_RELEASE as a proper symbol. Remove it.
2018-05-26Micro-optimize _parse_help() loopUlf Magnusson
Shaves ~6% off the _parse_help() runtime for the x86 Kconfigs in cProfile.
2018-05-16Record which MenuNode has each propertyUlf Magnusson
This allows accurate documentation to be generated for symbols and choices defined in multiple locations. There are now MenuNode.defaults, MenuNode.selects, etc., lists that mirror the corresponding Symbol/Choice lists. Symbol/Choice.__str__() now correctly show property locations as well, by simply concatenating the strings returned by MenuNode.__str__() for each node. _parse_properties() was modified to add all properties directly to the menu node instead of adding them to the contained symbol or choice. The properties are then copied up to symbols and choices in _finalize_tree(). Dependency propagation is handled at the same time. As a side effect, this cleans up the code a bit and de-bloats _parse_properties(). Update the menuconfig implementation to use the new functionality. It now lists the menu nodes for symbols and choices with the correct properties for each node (previously, all defaults, selects, implies, and ranges appeared on the first definition).
2018-05-16Expand environment variables in strings directlyUlf Magnusson
Make "$FOO" directly reference the environment variable $FOO in e.g. 'source' statements, instead of the symbol FOO. Use os.path.expandvars() to expand strings (which preserves "$FOO" as-is if no environment variable FOO exists). This gets rid of the 'option env' "bounce" symbols, which are mostly just spam and are buggy in the C tools (dependencies aren't always respected, due to parsing and evaluation getting mixed up). The same change will probably appear soon in the C tools as well. Keep accepting 'option env' to preserve some backwards compatibility, but ignore it when expanding strings. For compatibility with the C tools, bounce symbols will need to be named the same as the environment variables they reference (which is the case for the Linux kernel). This is a compatibility break, so the major version will be bumped to 6 at the next release. The main motivation for adding this now is to allow recording properties on each MenuNode in a clean way. 'option env' symbols interact badly with delayed dependency propagation. Side note: I have a feeling that recording environment variable values might be redundant to trigger rebuilds if sync_deps() is run at each compile. It should detect all changes to symbol values due to environment variables changing value.
2018-05-01Make warnings available in a listUlf Magnusson
Also make printing of warnings to stderr optional. It's on by default, since it's almost always what you want. This makes printing and processing of warnings more flexible, compared to always printing warnings to stderr as soon as they're generated. It was inspired by wanting to promote certain warnings to errors in Zephyr, which previously required capturing stderr.
2018-04-11Add helper for splitting expressionsUlf Magnusson
I've had to implement the logic for walking reverse dependencies (from select) a couple of times now, and it's always a bit tricky to get right. Reduce code duplication and simplify things by adding a helper function split_expr() that splits an expression into a list of either its AND or OR operands. A nice side effect is that e.g. the warning generated for selecting a symbol with unsatisfied direct dependencies now lists the selecting symbols in the order that they appear in the Kconfig files. split_expr() might be helpful for splitting other types of expressions as well, e.g. to put operands on separate lines when generating documentation.
2018-04-05Set is_menuconfig True on the top menuUlf Magnusson
Oversight
2018-04-04Generalize is_menuconfig to non-symbol itemsUlf Magnusson
Extending the scope of is_menuconfig so that it's True for all items whose children should be displayed in a separate menu turns out to be handy when implementing menuconfig-like functionality. Keep the old name for backwards compatibility. It's good enough.
2018-03-28Parenthesize && expressions within || expressionsUlf Magnusson
This is redundant from an evaluation perspective, as && has higher precedence than ||, but is easier to read. A && B || C && D is now rendered as "(A && B) || (C && D)".
2018-03-26Refactor expr_str() casesUlf Magnusson
- Detect Symbol directly instead of as (not tuple) + (not choice) - Test explicitly for a tuple (non-Symbol) in NOT - Add some tests to get better coverage for NOT and parentheses
2018-03-23testsuite.py: Remove redundant enable_warnings() callUlf Magnusson
The Kconfig object is replaced immediately after it.
2018-03-23Warn if user (.config) value is outside of 'range'Ulf Magnusson
Example warning: warning: user value 0x100 on the hex symbol HEX (defined at Kconfig:18) ignored due to being outside the active range ([0x13, 0x73]) -- falling back on defaults This is a Kconfiglib-exclusive warning. It might be tricky to implement in the C tools, due to weird two-phase handling of int/hex symbols. There is unfortunately no easy way to map the warning back to a .config line, as the active 'range' can't be known in general until the entire configuration has been read (consider 'range 0 10 if FOO' for example). Instead, the warning is generated when the symbol value is calculated.
2018-03-17Remove TILE architecture from test suiteUlf Magnusson
Removed in linux-next.
2018-03-13Test grsource with nonexistent fileUlf Magnusson
Just for completeness.
2018-03-13Add a globbing source statementUlf Magnusson
'gsource' works like 'source', but takes a glob pattern and sources all matching files. Works as a no-op if no files match, and hence doubles as an include-if-exists function, similar to '-include' in 'make'. Add a 'grsource' statement as well, mirroring 'rsource'. Came up in https://github.com/ulfalizer/Kconfiglib/pull/40.
2018-03-11Add minimal configuration file generation supportUlf Magnusson
Works like 'make savedefconfig' in the C tools. Call it write_min_config() rather than write_defconfig() to be a bit more explicit. Add a test similar to test_defconfig that compares Kconfiglib minimal configuration output against the C implementation, for all defconfig files. Disable the tests for now. The C tools have a bug that causes an incorrect configuration to be generated for tristate choices in some cases. They will be re-enabled once those are fixed.
2018-03-10testsuite.py: Break out a defconfig_files() helperUlf Magnusson
defconfig_files() yields all the defconfig files for a particular arch/ subdirectory. This will allow reuse when savedefconfig is tested. Also simplify the code a bit.
2018-03-09testsuite.py: Don't count defconfig filesUlf Magnusson
Not that important of a stat, plus there might be more tests that process defconfig files soon, making it kinda meaningless.
2018-03-06Simplify test suite loggingUlf Magnusson
No great need to log timestamps anymore.
2018-03-06Avoid shadowing test_defconfig() 'srcarch' parameterUlf Magnusson
The 'for' overrode 'srcarch', which is currently harmless, but ugly.
2018-03-06testsuite.py: Use 'srcarch' instead of '_arch' in test_defconfig()Ulf Magnusson
Makes sense as SRCARCH holds the arch/ subdirectory and _arch might be confused for ARCH.
2018-03-06testsuite.py: Refactor run_compatibility_tests()Ulf Magnusson
Get rid of the compare_configs flag and just do the comparison from the test functions themselves with a helper. Also get rid of the test_load() test. That's indirectly tested through the other tests, and test_alldefconfig() runs first and is speedy.
2018-02-28Add support for incremental buildsUlf Magnusson
Implement a scheme from the C tools where symbols get corresponding files that are touch'ed whenever the symbol's value changes. This can be used to add e.g. Makefile dependencies between source files and particular symbols. See the docstring of the new sync_deps() function for more information. Piggyback a small sanity check for write_autoconf().
2018-02-27testsuite.py: Remove write_and_verify_header()Ulf Magnusson
Unused leftover from Kconfiglib 1.
2018-02-27Implement 'rsource' statement ('source' with relative path)Roman
The 'rsource' statement works like 'source', but looks relative to the Kconfig file that has the 'rsource' rather than relative to the base Kconfig file. Using 'rsource' makes it possible to move subtrees with Kconfig files around without breaking references to other Kconfig files. So far, this is a Kconfiglib-exclusive feature.