kunit: tool: misc fixes (unused vars, imports, leaked files)
Drop some variables in unit tests that were unused and/or add assertions based on them. For ExitStack, it was imported, but the `es` variable wasn't used so it didn't do anything, and we were leaking the file objects. Refactor it to just use nested `with` statements to properly close them. And drop the direct use of .close() on file objects in the kunit tool unit test, as these can be leaked if test assertions fail. Signed-off-by: Daniel Latypov <dlatypov@google.com> Reviewed-by: David Gow <davidgow@google.com> Reviewed-by: Brendan Higgins <brendanhiggins@google.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
This commit is contained in:
committed by
Shuah Khan
parent
cd94fbc2ca
commit
a54ea2e057
@@ -14,10 +14,6 @@ import shutil
|
||||
import signal
|
||||
from typing import Iterator, Optional, Tuple
|
||||
|
||||
from contextlib import ExitStack
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
import kunit_config
|
||||
import kunit_parser
|
||||
import qemu_config
|
||||
@@ -168,10 +164,10 @@ class LinuxSourceTreeOperationsUml(LinuxSourceTreeOperations):
|
||||
process.wait()
|
||||
kunit_parser.print_with_timestamp(
|
||||
'Disabling broken configs to run KUnit tests...')
|
||||
with ExitStack() as es:
|
||||
config = open(get_kconfig_path(build_dir), 'a')
|
||||
disable = open(BROKEN_ALLCONFIG_PATH, 'r').read()
|
||||
config.write(disable)
|
||||
|
||||
with open(get_kconfig_path(build_dir), 'a') as config:
|
||||
with open(BROKEN_ALLCONFIG_PATH, 'r') as disable:
|
||||
config.write(disable.read())
|
||||
kunit_parser.print_with_timestamp(
|
||||
'Starting Kernel with all configs takes a few minutes...')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user