|
21 | 21 |
|
22 | 22 | KCONFIG_PATH = '.config'
|
23 | 23 | KUNITCONFIG_PATH = '.kunitconfig'
|
| 24 | +OLD_KUNITCONFIG_PATH = 'last_used_kunitconfig' |
24 | 25 | DEFAULT_KUNITCONFIG_PATH = 'tools/testing/kunit/configs/default.config'
|
25 | 26 | BROKEN_ALLCONFIG_PATH = 'tools/testing/kunit/configs/broken_on_uml.config'
|
26 | 27 | OUTFILE_PATH = 'test.log'
|
@@ -179,6 +180,9 @@ def get_kconfig_path(build_dir) -> str:
|
179 | 180 | def get_kunitconfig_path(build_dir) -> str:
|
180 | 181 | return get_file_path(build_dir, KUNITCONFIG_PATH)
|
181 | 182 |
|
| 183 | +def get_old_kunitconfig_path(build_dir) -> str: |
| 184 | + return get_file_path(build_dir, OLD_KUNITCONFIG_PATH) |
| 185 | + |
182 | 186 | def get_outfile_path(build_dir) -> str:
|
183 | 187 | return get_file_path(build_dir, OUTFILE_PATH)
|
184 | 188 |
|
@@ -289,24 +293,38 @@ def build_config(self, build_dir, make_options) -> bool:
|
289 | 293 | except ConfigError as e:
|
290 | 294 | logging.error(e)
|
291 | 295 | return False
|
292 |
| - return self.validate_config(build_dir) |
| 296 | + if not self.validate_config(build_dir): |
| 297 | + return False |
| 298 | + |
| 299 | + old_path = get_old_kunitconfig_path(build_dir) |
| 300 | + if os.path.exists(old_path): |
| 301 | + os.remove(old_path) # write_to_file appends to the file |
| 302 | + self._kconfig.write_to_file(old_path) |
| 303 | + return True |
| 304 | + |
| 305 | + def _kunitconfig_changed(self, build_dir: str) -> bool: |
| 306 | + old_path = get_old_kunitconfig_path(build_dir) |
| 307 | + if not os.path.exists(old_path): |
| 308 | + return True |
| 309 | + |
| 310 | + old_kconfig = kunit_config.parse_file(old_path) |
| 311 | + return old_kconfig.entries() != self._kconfig.entries() |
293 | 312 |
|
294 | 313 | def build_reconfig(self, build_dir, make_options) -> bool:
|
295 | 314 | """Creates a new .config if it is not a subset of the .kunitconfig."""
|
296 | 315 | kconfig_path = get_kconfig_path(build_dir)
|
297 |
| - if os.path.exists(kconfig_path): |
298 |
| - existing_kconfig = kunit_config.parse_file(kconfig_path) |
299 |
| - self._ops.make_arch_qemuconfig(self._kconfig) |
300 |
| - if not self._kconfig.is_subset_of(existing_kconfig): |
301 |
| - print('Regenerating .config ...') |
302 |
| - os.remove(kconfig_path) |
303 |
| - return self.build_config(build_dir, make_options) |
304 |
| - else: |
305 |
| - return True |
306 |
| - else: |
| 316 | + if not os.path.exists(kconfig_path): |
307 | 317 | print('Generating .config ...')
|
308 | 318 | return self.build_config(build_dir, make_options)
|
309 | 319 |
|
| 320 | + existing_kconfig = kunit_config.parse_file(kconfig_path) |
| 321 | + self._ops.make_arch_qemuconfig(self._kconfig) |
| 322 | + if self._kconfig.is_subset_of(existing_kconfig) and not self._kunitconfig_changed(build_dir): |
| 323 | + return True |
| 324 | + print('Regenerating .config ...') |
| 325 | + os.remove(kconfig_path) |
| 326 | + return self.build_config(build_dir, make_options) |
| 327 | + |
310 | 328 | def build_kernel(self, alltests, jobs, build_dir, make_options) -> bool:
|
311 | 329 | try:
|
312 | 330 | if alltests:
|
|
0 commit comments