diff mbox series

kfence: test: fail fast if disabled at boot

Message ID 20210825105533.1247922-1-elver@google.com (mailing list archive)
State New
Headers show
Series kfence: test: fail fast if disabled at boot | expand

Commit Message

Marco Elver Aug. 25, 2021, 10:55 a.m. UTC
Fail kfence_test fast if KFENCE was disabled at boot, instead of each
test case trying several seconds to allocate from KFENCE and failing.
KUnit will fail all test cases if kunit_suite::init returns an error.

Even if KFENCE was disabled, we still want the test to fail, so that CI
systems that parse KUnit output will alert on KFENCE being disabled
(accidentally or otherwise).

Reported-by: Kefeng Wang <wangkefeng.wang@huawei.com>
Signed-off-by: Marco Elver <elver@google.com>
---
 mm/kfence/kfence_test.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Alexander Potapenko Aug. 25, 2021, 10:57 a.m. UTC | #1
On Wed, Aug 25, 2021 at 12:55 PM Marco Elver <elver@google.com> wrote:
>
> Fail kfence_test fast if KFENCE was disabled at boot, instead of each
> test case trying several seconds to allocate from KFENCE and failing.
> KUnit will fail all test cases if kunit_suite::init returns an error.
>
> Even if KFENCE was disabled, we still want the test to fail, so that CI
> systems that parse KUnit output will alert on KFENCE being disabled
> (accidentally or otherwise).
>
> Reported-by: Kefeng Wang <wangkefeng.wang@huawei.com>
> Signed-off-by: Marco Elver <elver@google.com>
Acked-by: Alexander Potapenko <glider@google.com>


> ---
>  mm/kfence/kfence_test.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/mm/kfence/kfence_test.c b/mm/kfence/kfence_test.c
> index eb6307c199ea..f1690cf54199 100644
> --- a/mm/kfence/kfence_test.c
> +++ b/mm/kfence/kfence_test.c
> @@ -800,6 +800,9 @@ static int test_init(struct kunit *test)
>         unsigned long flags;
>         int i;
>
> +       if (!__kfence_pool)
> +               return -EINVAL;
> +
>         spin_lock_irqsave(&observed.lock, flags);
>         for (i = 0; i < ARRAY_SIZE(observed.lines); i++)
>                 observed.lines[i][0] = '\0';
> --
> 2.33.0.rc2.250.ged5fa647cd-goog
>
Kefeng Wang Aug. 26, 2021, 4:21 a.m. UTC | #2
On 2021/8/25 18:55, Marco Elver wrote:
> Fail kfence_test fast if KFENCE was disabled at boot, instead of each
> test case trying several seconds to allocate from KFENCE and failing.
> KUnit will fail all test cases if kunit_suite::init returns an error.
>
> Even if KFENCE was disabled, we still want the test to fail, so that CI
> systems that parse KUnit output will alert on KFENCE being disabled
> (accidentally or otherwise).
>
> Reported-by: Kefeng Wang <wangkefeng.wang@huawei.com>
> Signed-off-by: Marco Elver <elver@google.com>

Finally find this, it's better, and tested, thanks
diff mbox series

Patch

diff --git a/mm/kfence/kfence_test.c b/mm/kfence/kfence_test.c
index eb6307c199ea..f1690cf54199 100644
--- a/mm/kfence/kfence_test.c
+++ b/mm/kfence/kfence_test.c
@@ -800,6 +800,9 @@  static int test_init(struct kunit *test)
 	unsigned long flags;
 	int i;
 
+	if (!__kfence_pool)
+		return -EINVAL;
+
 	spin_lock_irqsave(&observed.lock, flags);
 	for (i = 0; i < ARRAY_SIZE(observed.lines); i++)
 		observed.lines[i][0] = '\0';