sanitycheck: Fix --log-file option

save_reports should be one of the last tasks executed because it
closes the log file. Withouth it, other functions that use debug
functions like info and error will try to write into a close file.

This fixes the following problem:

sanitycheck -x=USE_CCACHE=0 -p native_posix -T samples/hello_world/ -b
-N --log-file sanity.log
JOBS: 8
Building initial testcase list...
1 test configurations selected, 0 configurations discarded due to filters.
Adding tasks to the queue...
total complete:    1/   1  100%  skipped:    0, failed:    0
1 of 1 tests passed (100.00%), 0 failed, 0 skipped with 0 warnings in
2.91 seconds
Traceback (most recent call last):
  File "./zephyr/scripts/sanitycheck", line 3866, in <module>
    main()
  File "./zephyr/scripts/sanitycheck", line 3854, in main
    suite.summary(options.disable_unrecognized_section_test)
  File "./zephyr/scripts/sanitycheck", line 2306, in summary
    self.duration))
  File "./zephyr/scripts/sanitycheck", line 432, in info
    log_file.write(what + "\n")
ValueError: I/O operation on closed file.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
This commit is contained in:
Flavio Ceolin 2019-10-22 14:03:48 -07:00 committed by Anas Nashif
commit ca1feea5bb

View file

@ -3838,7 +3838,6 @@ def main():
suite.misc_reports(options.compare_report, options.show_footprint,
options.all_deltas, options.footprint_threshold, options.last_metrics)
suite.save_reports()
if options.coverage:
if options.gcov_tool is None:
@ -3867,6 +3866,7 @@ def main():
if p['connected']:
print("%s (%s): %d" %(p['platform'], p.get('id', None), p['counter']))
suite.save_reports()
if suite.total_failed or (suite.warnings and options.warnings_as_errors):
sys.exit(1)