ANDROID: make memory initialization tests panic on failure

This is a patch specific to android-common-4.14 where lib/test_meminit.c
and lib/test_stackinit.c are built into the kernel.

Call panic() to make the test failures more visible.

Bug: 144999193

Change-Id: Iaa9459f4bf63753c5ac1cf51c9691bf62b3924e9
Signed-off-by: Alexander Potapenko <glider@google.com>
This commit is contained in:
Alexander Potapenko 2020-02-14 01:20:10 +01:00
parent 62772abfd9
commit d1ac78ab13
2 changed files with 16 additions and 5 deletions

View File

@ -397,11 +397,16 @@ static int __init test_meminit_init(void)
num_tests += test_kmemcache(&failures);
num_tests += test_rcu_persistent(&failures);
if (failures == 0)
if (failures == 0) {
pr_info("all %d tests passed!\n", num_tests);
else
} else {
pr_info("failures: %d out of %d\n", failures, num_tests);
/*
* Android 4.14 only: if this test is built as part of the
* kernel, make the failure visible.
*/
panic("Test failed!\n");
}
return failures ? -EINVAL : 0;
}
module_init(test_meminit_init);

View File

@ -371,10 +371,16 @@ static int __init test_stackinit_init(void)
/* STRUCTLEAK will only cover this. */
failures += test_user();
if (failures == 0)
if (failures == 0) {
pr_info("all tests passed!\n");
else
} else {
pr_err("failures: %u\n", failures);
/*
* Android 4.14 only: if this test is built as part of the
* kernel, make the failure visible.
*/
panic("Test failed!\n");
}
return failures ? -EINVAL : 0;
}