Skip to content

Commit c9aa7d8

Browse files
committed
kconfig: tests: support KCONFIG_SEED for the randconfig runner
This will help get consistent results for randconfig tests. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
1 parent 097f120 commit c9aa7d8

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

scripts/kconfig/tests/conftest.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -154,12 +154,10 @@ def defconfig(self, defconfig):
154154
defconfig_path = os.path.join(self._test_dir, defconfig)
155155
return self._run_conf('--defconfig={}'.format(defconfig_path))
156156

157-
def _allconfig(self, mode, all_config):
157+
def _allconfig(self, mode, all_config, extra_env={}):
158158
if all_config:
159159
all_config_path = os.path.join(self._test_dir, all_config)
160-
extra_env = {'KCONFIG_ALLCONFIG': all_config_path}
161-
else:
162-
extra_env = {}
160+
extra_env['KCONFIG_ALLCONFIG'] = all_config_path
163161

164162
return self._run_conf('--{}config'.format(mode), extra_env=extra_env)
165163

@@ -195,13 +193,19 @@ def alldefconfig(self, all_config=None):
195193
"""
196194
return self._allconfig('alldef', all_config)
197195

198-
def randconfig(self, all_config=None):
196+
def randconfig(self, all_config=None, seed=None):
199197
"""Run randconfig.
200198
201199
all_config: fragment config file for KCONFIG_ALLCONFIG (optional)
200+
seed: the seed for randconfig (optional)
202201
returncode: exit status of the Kconfig executable
203202
"""
204-
return self._allconfig('rand', all_config)
203+
if seed is not None:
204+
extra_env = {'KCONFIG_SEED': hex(seed)}
205+
else:
206+
extra_env = {}
207+
208+
return self._allconfig('rand', all_config, extra_env=extra_env)
205209

206210
def savedefconfig(self, dot_config):
207211
"""Run savedefconfig.

0 commit comments

Comments
 (0)