Skip to content

Commit

Permalink
test: Add tests for Support Override sdkconfig CLI Options
Browse files Browse the repository at this point in the history
  • Loading branch information
igor udot (horw) committed Oct 30, 2023
1 parent f8b9c6a commit 7d80929
Showing 1 changed file with 80 additions and 0 deletions.
80 changes: 80 additions & 0 deletions tests/test_finder.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,86 @@ def test_with_sdkconfig_defaults_env_var_expansion(self, tmp_path, monkeypatch):
apps = find_apps('test1', 'esp32', recursive=True, config_rules_str='sdkconfig.ci.*=')
assert len(apps) == 0

def test_with_sdkconfig_override_priority_override_sdkconfig(self, tmp_path):
from idf_build_apps.app import (
App,
OverridePriority,
)
from idf_build_apps.main import (
setup_app_override_sdkconfig,
)

print(tmp_path)
create_project('test1', tmp_path)
(tmp_path / 'test1' / 'sdkconfig.defaults').write_text(
'CONFIG_IDF_TARGET=esp32s2\nCONFIG_FREERTOS_IDLE_TASK_STACKSIZE=1516', encoding='utf8'
)
(tmp_path / 'test1' / 'sdkconfig.override1').write_text('CONFIG_IDF_TARGET=esp32\nCONFIG_A=5', encoding='utf8')

setup_app_override_sdkconfig(
('CONFIG_IDF_TARGET=esp32c3', 'CONFIG_FREERTOS_IDLE_TASK_STACKSIZE=1522', 'CONFIG_A=10'),
('sdkconfig.override1',),
OverridePriority.OVERRIDE_SDKCONFIG,
)

assert len(App.override_sdkconfig) == 3
assert len(App.override_sdkconfig_file) == 1

apps = find_apps(str(tmp_path / 'test1'), 'esp32s2')
assert len(apps) == 0

apps = find_apps(str(tmp_path / 'test1'), 'esp32')
assert len(apps) == 0

apps = find_apps(str(tmp_path / 'test1'), 'esp32c3')
assert len(apps) == 1

with open(apps[0].sdkconfig_files[0]) as fr:
assert fr.readlines() == [
'CONFIG_IDF_TARGET=esp32c3\n',
'CONFIG_FREERTOS_IDLE_TASK_STACKSIZE=1522\n',
'CONFIG_A=10\n',
]

def test_with_sdkconfig_override_priority_override_sdkconfig_file(self, tmp_path):
from idf_build_apps.app import (
App,
OverridePriority,
)
from idf_build_apps.main import (
setup_app_override_sdkconfig,
)

create_project('test1', tmp_path)
(tmp_path / 'test1' / 'sdkconfig.defaults').write_text(
'CONFIG_IDF_TARGET=esp32s2\nCONFIG_FREERTOS_IDLE_TASK_STACKSIZE=1516', encoding='utf8'
)
(tmp_path / 'test1' / 'sdkconfig.override1').write_text('CONFIG_IDF_TARGET=esp32\nCONFIG_A=5', encoding='utf8')

setup_app_override_sdkconfig(
('CONFIG_IDF_TARGET=esp32c3', 'CONFIG_FREERTOS_IDLE_TASK_STACKSIZE=1522', 'CONFIG_A=10'),
('sdkconfig.override1',),
OverridePriority.OVERRIDE_SDKCONFIG_FILE,
)
assert len(App.override_sdkconfig) == 3
assert len(App.override_sdkconfig_file) == 1

apps = find_apps(str(tmp_path / 'test1'), 'esp32s2')
assert len(apps) == 0

apps = find_apps(str(tmp_path / 'test1'), 'esp32')
assert len(apps) == 1

with open(apps[0].sdkconfig_files[0]) as fr:
assert fr.readlines() == [
'CONFIG_IDF_TARGET=esp32\n',
'CONFIG_FREERTOS_IDLE_TASK_STACKSIZE=1522\n',
'CONFIG_A=5\n',
]

apps = find_apps(str(tmp_path / 'test1'), 'esp32c3')
assert len(apps) == 0

def test_config_name_in_manifest(self, tmp_path):
create_project('test1', tmp_path)

Expand Down

0 comments on commit 7d80929

Please sign in to comment.