Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

kunit: fix executor OOM error handling logic on non-UML

The existing logic happens to work fine on UML, but is not correct when
running on other arches.

1. We didn't initialize `int err`, and kunit_filter_suites() doesn't
explicitly set it to 0 on success. So we had false "failures".
Note: it doesn't happen on UML, causing this to get overlooked.
2. If we error out, we do not call kunit_handle_shutdown().
This makes kunit.py timeout when using a non-UML arch, since the QEMU
process doesn't ever exit.

Fixes: a02353f49162 ("kunit: bail out of test filtering logic quicker if OOM")
Signed-off-by: Daniel Latypov <dlatypov@google.com>
Reviewed-by: Brendan Higgins <brendanhiggins@google.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>

authored by

Daniel Latypov and committed by
Shuah Khan
1b11063d 8a7ccad3

+5 -4
+5 -4
lib/kunit/executor.c
··· 247 247 .start = __kunit_suites_start, 248 248 .end = __kunit_suites_end, 249 249 }; 250 - int err; 250 + int err = 0; 251 251 252 252 if (filter_glob_param) { 253 253 suite_set = kunit_filter_suites(&suite_set, filter_glob_param, &err); 254 254 if (err) { 255 255 pr_err("kunit executor: error filtering suites: %d\n", err); 256 - return err; 256 + goto out; 257 257 } 258 258 } 259 259 ··· 268 268 kunit_free_suite_set(suite_set); 269 269 } 270 270 271 - kunit_handle_shutdown(); 272 271 273 - return 0; 272 + out: 273 + kunit_handle_shutdown(); 274 + return err; 274 275 } 275 276 276 277 #if IS_BUILTIN(CONFIG_KUNIT_TEST)