kunit: bail out of test filtering logic quicker if OOM
When filtering what tests to run (suites and/or cases) via kunit.filter_glob (e.g. kunit.py run <glob>), we allocate copies of suites. These allocations can fail, and we largely don't handle that. Note: realistically, this probably doesn't matter much. We're not allocating much memory and this happens early in boot, so if we can't do that, then there's likely far bigger problems. This patch makes us immediately bail out from the top-level function (kunit_filter_suites) with -ENOMEM if any of the underlying kmalloc() calls return NULL. Implementation note: we used to return NULL pointers from some functions to indicate either that all suites/tests were filtered out or there was an error allocating the new array. We'll log a short error in this case and not run any tests or print a TAP header. From a kunit.py user's perspective, they'll get a message about missing/invalid TAP output and have to dig into the test.log to see it. Since hitting this error seems so unlikely, it's probably fine to not invent a way to plumb this error message more visibly. See also: https://lore.kernel.org/linux-kselftest/20220329103919.2376818-1-lv.ruyi@zte.com.cn/ Signed-off-by:Daniel Latypov <dlatypov@google.com> Reported-by:
Zeal Robot <zealci@zte.com.cn> Reported-by:
Lv Ruyi <lv.ruyi@zte.com.cn> Reviewed-by:
Brendan Higgins <brendanhiggins@google.com> Signed-off-by:
Shuah Khan <skhan@linuxfoundation.org>
-
mentioned in commit b47aae6d
-
mentioned in commit dc517250
-
mentioned in commit bb8ef7ad
-
mentioned in commit 94681e28
-
mentioned in commit 2d9ca5eb
-
mentioned in commit 86c69529
-
mentioned in commit a1418719
-
mentioned in commit 668b8ce4
-
mentioned in commit 76e7a87c
-
mentioned in commit 0b8bbfa3
-
mentioned in commit 18b0f173
-
mentioned in commit 582a5c12
-
mentioned in commit 95e5bccc
-
mentioned in commit 648fd085
-
mentioned in commit f30e9b70
-
mentioned in commit 6970145f