Skip to content

Commit 1fdc6f4

Browse files
alexpantyukhinshuahkh
authored andcommitted
tools/testing/kunit/kunit.py: remove redundant double check
The build_tests function contained double checking for not success result. It is fixed in the current patch. Additional small simplifications of code like using ternary if were applied (avoid using the same operation by calculation times differ in two places). Signed-off-by: Alexander Pantyukhin <[email protected]> Reviewed-by: David Gow <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
1 parent 4ec5183 commit 1fdc6f4

File tree

1 file changed

+5
-14
lines changed

1 file changed

+5
-14
lines changed

tools/testing/kunit/kunit.py

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,8 @@ def config_tests(linux: kunit_kernel.LinuxSourceTree,
7777
config_start = time.time()
7878
success = linux.build_reconfig(request.build_dir, request.make_options)
7979
config_end = time.time()
80-
if not success:
81-
return KunitResult(KunitStatus.CONFIG_FAILURE,
82-
config_end - config_start)
83-
return KunitResult(KunitStatus.SUCCESS,
84-
config_end - config_start)
80+
status = KunitStatus.SUCCESS if success else KunitStatus.CONFIG_FAILURE
81+
return KunitResult(status, config_end - config_start)
8582

8683
def build_tests(linux: kunit_kernel.LinuxSourceTree,
8784
request: KunitBuildRequest) -> KunitResult:
@@ -92,14 +89,8 @@ def build_tests(linux: kunit_kernel.LinuxSourceTree,
9289
request.build_dir,
9390
request.make_options)
9491
build_end = time.time()
95-
if not success:
96-
return KunitResult(KunitStatus.BUILD_FAILURE,
97-
build_end - build_start)
98-
if not success:
99-
return KunitResult(KunitStatus.BUILD_FAILURE,
100-
build_end - build_start)
101-
return KunitResult(KunitStatus.SUCCESS,
102-
build_end - build_start)
92+
status = KunitStatus.SUCCESS if success else KunitStatus.BUILD_FAILURE
93+
return KunitResult(status, build_end - build_start)
10394

10495
def config_and_build_tests(linux: kunit_kernel.LinuxSourceTree,
10596
request: KunitBuildRequest) -> KunitResult:
@@ -145,7 +136,7 @@ def exec_tests(linux: kunit_kernel.LinuxSourceTree, request: KunitExecRequest) -
145136
tests = _list_tests(linux, request)
146137
if request.run_isolated == 'test':
147138
filter_globs = tests
148-
if request.run_isolated == 'suite':
139+
elif request.run_isolated == 'suite':
149140
filter_globs = _suites_from_test_list(tests)
150141
# Apply the test-part of the user's glob, if present.
151142
if '.' in request.filter_glob:

0 commit comments

Comments
 (0)