When running "python setup.py test" on Windows, the following failure is
reported:
======================================================================
ERROR: test_platform_invalid (tests.software.test_cs.TestPlatformChipsecCs)
----------------------------------------------------------------------
Traceback (most recent call last):
File "d:\a\chipsec\chipsec\tests\software\cs.py", line 46, in tearDown
os.remove(self.log_file)
PermissionError: [WinError 32] The process cannot access the file
because it is being used by another process:
'C:\\Users\\RUNNER~1\\AppData\\Local\\Temp\\tmpg5_6bcaz'
This is because when `_cs.init()` (in `tests/software/cs.py`) throws an
exception, the temporary log file is not closed. Then the function
`TestChipsecUtil.tearDown` attempts to remove the temporary file with
`os.remove(self.log_file)` and it fails, as it is still used by the
logger.
Fix this by putting `_cs.init()` inside a `try`/`finally` construction
which always calls `logger.logger().close()` when an exception happens.
While at it, use `with open(...) as log` instead of `log.open()` +
`log.close()`, which is a more usual way of reading files in Python.
Updated mock_helper to use BaseHelper
Updated util harness to correctly override helper with testhelper
Signed-off-by: BrentHoltsclaw <brent.holtsclaw@intel.com>