diff --git a/test/test_build.py b/test/test_build.py index 162117c..cc713e2 100644 --- a/test/test_build.py +++ b/test/test_build.py @@ -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, @@ -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" diff --git a/tuxmake/target.py b/tuxmake/target.py index 3f59239..6495ce5 100644 --- a/tuxmake/target.py +++ b/tuxmake/target.py @@ -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: