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
45 changes: 45 additions & 0 deletions test/test_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,39 @@ def test_kconfig_add_inline_set_to_no(self, linux, output_dir):
config = output_dir / "config"
assert "CONFIG_FOO=n\n" in config.read_text()

def test_kconfig_add_inline_set_to_int(self, linux, output_dir):
build(
tree=linux,
targets=["config"],
kconfig_add=["CONFIG_FOO=1", "CONFIG_BAR=0", "CONFIG_BAZ=128"],
output_dir=output_dir,
)
config = output_dir / "config"
text = config.read_text()
assert "CONFIG_FOO=1\n" in text
assert "CONFIG_BAR=0\n" in text
assert "CONFIG_BAZ=128\n" in text

def test_kconfig_add_inline_set_to_hex(self, linux, output_dir):
build(
tree=linux,
targets=["config"],
kconfig_add=["CONFIG_FOO=0xdeadbeef"],
output_dir=output_dir,
)
config = output_dir / "config"
assert "CONFIG_FOO=0xdeadbeef\n" in config.read_text()

def test_kconfig_add_inline_set_to_string(self, linux, output_dir):
build(
tree=linux,
targets=["config"],
kconfig_add=['CONFIG_FOO="hello world"'],
output_dir=output_dir,
)
config = output_dir / "config"
assert 'CONFIG_FOO="hello world"\n' in config.read_text()

def test_kconfig_add_in_tree(self, linux, output_dir):
build(
tree=linux,
Expand Down Expand Up @@ -247,6 +280,18 @@ def test_kconfig_add_invalid(self, linux):
with pytest.raises(tuxmake.exceptions.UnsupportedKconfigFragment):
build(tree=linux, targets=["config"], kconfig_add=["foo"])

def test_kconfig_add_rejects_missing_prefix(self, linux):
with pytest.raises(tuxmake.exceptions.UnsupportedKconfigFragment):
build(tree=linux, targets=["config"], kconfig_add=["FOO=m"])

def test_kconfig_add_rejects_empty_name(self, linux):
with pytest.raises(tuxmake.exceptions.UnsupportedKconfigFragment):
build(tree=linux, targets=["config"], kconfig_add=["CONFIG_=y"])

def test_kconfig_add_rejects_empty_value(self, linux):
with pytest.raises(tuxmake.exceptions.UnsupportedKconfigFragment):
build(tree=linux, targets=["config"], kconfig_add=["CONFIG_FOO="])

def test_kconfig_from_source_tree(self, linux):
b = build(tree=linux, targets=["config"], kconfig="config/test.config")
config = b.output_dir / "config"
Expand Down
15 changes: 5 additions & 10 deletions tuxmake/target.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,16 +258,11 @@ def handle_in_tree_config(self, t):
return False

def handle_inline_fragment(self, config, frag):
accepted_patterns = [
r"^CONFIG_\w+=[ymn]$",
r"^#\s*CONFIG_\w+\s*is\s*not\s*set\s*$",
]
accepted = False
for pattern in accepted_patterns:
if re.match(pattern, frag):
accepted = True

if not accepted:
# Syntax-only check: kconfig (olddefconfig / merge_config.sh) is the real validator.
if not (
re.match(r"^CONFIG_\w+=.+$", frag)
or re.match(r"^#\s*CONFIG_\w+\s*is\s*not\s*set\s*$", frag)
):
return False

with config.open("a") as f:
Expand Down
Loading