Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
fail-fast: false
matrix:
# NOTE: Windows runs only headless tests (no kernel tree, no Unix
# shell). Linux/macOS run selftests, compatibility tests, and
# shell). Linux/macOS run selftests, conformance tests, and
# example scripts.
target:
- python: '3.12'
Expand Down Expand Up @@ -93,15 +93,22 @@ jobs:
if: ${{ matrix.target.headless-only != true }}
working-directory: ${{ matrix.target.headless-only && '.' || 'Kconfiglib' }}
run: |
python -m pytest tests/ -v --tb=short --ignore=tests/test_compat.py
python -m pytest tests/ -v --tb=short --ignore=tests/test_conformance.py

- name: Apply Linux Kconfig Makefile patch
# Skip for Windows (headless-only mode)
if: ${{ matrix.target.headless-only != true }}
run: |
git apply Kconfiglib/makefile.patch

- name: Run compatibility tests and example scripts
- name: Build kernel C kconfig tools
if: ${{ matrix.target.headless-only != true }}
run: |
${MAKE:-make} -j"$(getconf _NPROCESSORS_ONLN)" ARCH=x86 ${LD:+LD=$LD} allnoconfig
test -x scripts/kconfig/conf
rm -f .config .config.old

- name: Run conformance tests and example scripts
# Skip for Windows (headless-only mode)
if: ${{ matrix.target.headless-only != true }}
run: |
Expand Down
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,6 @@ The following Kconfig extensions are available:
Some projects (such as the Linux kernel) use multiple Kconfig trees with many shared Kconfig files,
which can result in intentionally undefined symbol references.
However, `KCONFIG_WARN_UNDEF` can be very useful in projects with a single Kconfig tree.
`KCONFIG_STRICT` is an older alias for `KCONFIG_WARN_UNDEF`, retained for backward compatibility.

- `KCONFIG_WARN_UNDEF_ASSIGN`: If set to `y`, a warning is generated for any assignment to an undefined symbol in a `.config` file.
By default, no such warnings are generated.
Expand Down Expand Up @@ -458,7 +457,7 @@ The self-tests can be run from the project root with [pytest](https://docs.pytes
python -m pytest tests/ -v
```

To run the full suite -- self-tests, compatibility tests against the C Kconfig tools, and example scripts -- use
To run the full suite -- self-tests, conformance tests against the C Kconfig tools, and example scripts -- use
[tests/reltest](tests/reltest) from the top-level kernel directory (requires the Makefile patch):
```shell
Kconfiglib/tests/reltest python
Expand All @@ -473,12 +472,12 @@ Kconfiglib/tests/reltest python 2>/dev/null
except for `allnoconfig.py`, `allnoconfig_simpler.py`, and `allyesconfig.py`,
where it has no time to warm up because those scripts are invoked via `make scriptconfig`.

Note: Forgetting to apply the Makefile patch will cause some compatibility tests that compare generated configurations to fail.
Note: Forgetting to apply the Makefile patch will cause some conformance tests that compare generated configurations to fail.

Note: The compatibility tests overwrite `.config` in the kernel root, so make sure to back it up.
Note: The conformance tests overwrite `.config` in the kernel root, so make sure to back it up.

The test suite consists of self-tests (under [tests/](tests/)) and compatibility tests
([tests/test_compat.py](tests/test_compat.py)) that compare configurations generated by Kconfiglib
The test suite consists of self-tests (under [tests/](tests/)) and conformance tests
([tests/test_conformance.py](tests/test_conformance.py)) that compare configurations generated by Kconfiglib
with those generated by the C tools across various scenarios.

Occasionally, the C tools' output may change slightly (for example, due to a [recent change](https://www.spinics.net/lists/linux-kbuild/msg17074.html)).
Expand Down
12 changes: 7 additions & 5 deletions allmodconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@ def main():
kconf.warn = False

for sym in kconf.unique_defined_syms:
# Skip choice member symbols -- conf_set_all_new_symbols() in
# scripts/kconfig/conf.c (Linux) never sets SYMBOL_DEF_USER on
# choice values, leaving the choice selection logic to pick the
# default.
if sym.choice:
continue
if sym.orig_type == kconfiglib.BOOL:
# 'bool' choice symbols get their default value, as determined by
# e.g. 'default's on the choice
if not sym.choice:
# All other bool symbols get set to 'y', like for allyesconfig
sym.set_value(2)
sym.set_value(2)
elif sym.orig_type == kconfiglib.TRISTATE:
sym.set_value(1)

Expand Down
6 changes: 6 additions & 0 deletions allnoconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ def main():
kconf.warn = False
try:
for sym in kconf.unique_defined_syms:
# Skip choice member symbols -- conf_set_all_new_symbols() in
# scripts/kconfig/conf.c (Linux) never sets SYMBOL_DEF_USER on
# choice values, leaving the choice selection logic to pick the
# default.
if sym.choice:
continue
sym.set_value(2 if sym.is_allnoconfig_y else 0)
finally:
kconf.warn = True
Expand Down
19 changes: 7 additions & 12 deletions allyesconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,13 @@ def main():
# Assigning 0/1/2 to non-bool/tristate symbols has no effect (int/hex
# symbols still take a string, because they preserve formatting).
for sym in kconf.unique_defined_syms:
# Set choice symbols to 'm'. This value will be ignored for choices in
# 'y' mode (the "normal" mode), which will instead just get their
# default selection, but will set all symbols in m-mode choices to 'm',
# which is as high as they can go.
#
# Here's a convoluted example of how you might get an m-mode choice
# even during allyesconfig:
#
# choice
# tristate "weird choice"
# depends on m
sym.set_value(1 if sym.choice else 2)
# Skip choice member symbols -- conf_set_all_new_symbols() in
# scripts/kconfig/conf.c (Linux) never sets SYMBOL_DEF_USER on
# choice values, leaving the choice selection logic to pick the
# default.
if sym.choice:
continue
sym.set_value(2)

# Set all choices to the highest possible mode
for choice in kconf.unique_choices:
Expand Down
3 changes: 1 addition & 2 deletions examples/dumpvars.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
# together with their values, as a list of assignments.
#
# Note: This only works for environment variables referenced via the $(FOO)
# preprocessor syntax. The older $FOO syntax is maintained for backwards
# compatibility.
# preprocessor syntax.

import os
import sys
Expand Down
9 changes: 3 additions & 6 deletions genconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,7 @@ def main():
Write a list of all environment variables referenced in Kconfig files to
OUTPUT_FILE, with one variable per line. Each line has the format NAME=VALUE.
Only environment variables referenced with the preprocessor $(VAR) syntax are
included, and not variables referenced with the older $VAR syntax (which is
only supported for backwards compatibility).
included.
""",
)

Expand All @@ -121,10 +120,8 @@ def main():
elif "KCONFIG_AUTOHEADER" in os.environ:
kconf.write_autoconf()
else:
# Kconfiglib defaults to include/generated/autoconf.h to be
# compatible with the C tools. 'config.h' is used here instead for
# backwards compatibility. It's probably a saner default for tools
# as well.
# Kconfiglib defaults to include/generated/autoconf.h to match the
# C tools. 'config.h' is used here as a standalone-tool default.
kconf.write_autoconf("config.h")

if args.config_out is not None:
Expand Down
Loading