When running rtc_lib_test ("lib_test" before my "[PATCH] rtc: Rename
lib_test to rtc_lib_test") on m68k/ARAnyM:

    KTAP version 1
    1..1
        KTAP version 1
        # Subtest: rtc_lib_test_cases
        # module: rtc_lib_test
        1..2
        # rtc_time64_to_tm_test_date_range_1000: Test should be marked slow 
(runtime: 3.222371420s)
        ok 1 rtc_time64_to_tm_test_date_range_1000
        # rtc_time64_to_tm_test_date_range_160000: try timed out
        # rtc_time64_to_tm_test_date_range_160000: test case timed out
        # rtc_time64_to_tm_test_date_range_160000.speed: slow
        not ok 2 rtc_time64_to_tm_test_date_range_160000
    # rtc_lib_test_cases: pass:1 fail:1 skip:0 total:2
    # Totals: pass:1 fail:1 skip:0 total:2
    not ok 1 rtc_lib_test_cases

Commit 02c2d0c2a84172c3 ("kunit: Add speed attribute") added the notion
of "very slow" tests, but this is further unused and unhandled.

Hence:
  1. Introduce KUNIT_CASE_VERY_SLOW(),
  2. Increase timeout by ten; ideally this should only be done for very
     slow tests, but I couldn't find how to access kunit_case.attr.case
     from kunit_try_catch_run(),
  3. Mark rtc_time64_to_tm_test_date_range_1000 slow,
  4. Mark rtc_time64_to_tm_test_date_range_160000 very slow.

Afterwards:

    KTAP version 1
    1..1
        KTAP version 1
        # Subtest: rtc_lib_test_cases
        # module: rtc_lib_test
        1..2
        # rtc_time64_to_tm_test_date_range_1000.speed: slow
        ok 1 rtc_time64_to_tm_test_date_range_1000
        # rtc_time64_to_tm_test_date_range_160000.speed: very_slow
        ok 2 rtc_time64_to_tm_test_date_range_160000
    # rtc_lib_test_cases: pass:2 fail:0 skip:0 total:2
    # Totals: pass:2 fail:0 skip:0 total:2
    ok 1 rtc_lib_test_cases

Signed-off-by: Geert Uytterhoeven <ge...@linux-m68k.org>
---
 drivers/rtc/rtc_lib_test.c |  4 ++--
 include/kunit/test.h       | 11 +++++++++++
 lib/kunit/try-catch.c      |  3 ++-
 3 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/drivers/rtc/rtc_lib_test.c b/drivers/rtc/rtc_lib_test.c
index c30c759662e39b48..fd3210e39d37dbc6 100644
--- a/drivers/rtc/rtc_lib_test.c
+++ b/drivers/rtc/rtc_lib_test.c
@@ -85,8 +85,8 @@ static void rtc_time64_to_tm_test_date_range_1000(struct 
kunit *test)
 }
 
 static struct kunit_case rtc_lib_test_cases[] = {
-       KUNIT_CASE(rtc_time64_to_tm_test_date_range_1000),
-       KUNIT_CASE_SLOW(rtc_time64_to_tm_test_date_range_160000),
+       KUNIT_CASE_SLOW(rtc_time64_to_tm_test_date_range_1000),
+       KUNIT_CASE_VERY_SLOW(rtc_time64_to_tm_test_date_range_160000),
        {}
 };
 
diff --git a/include/kunit/test.h b/include/kunit/test.h
index 9b773406e01f3c43..4e3c1cae5b41466e 100644
--- a/include/kunit/test.h
+++ b/include/kunit/test.h
@@ -183,6 +183,17 @@ static inline char *kunit_status_to_ok_not_ok(enum 
kunit_status status)
                { .run_case = test_name, .name = #test_name,    \
                  .attr.speed = KUNIT_SPEED_SLOW, .module_name = KBUILD_MODNAME}
 
+/**
+ * KUNIT_CASE_VERY_SLOW - A helper for creating a &struct kunit_case
+ * with the very slow attribute
+ *
+ * @test_name: a reference to a test case function.
+ */
+
+#define KUNIT_CASE_VERY_SLOW(test_name)                        \
+               { .run_case = test_name, .name = #test_name,    \
+                 .attr.speed = KUNIT_SPEED_VERY_SLOW, .module_name = 
KBUILD_MODNAME}
+
 /**
  * KUNIT_CASE_PARAM - A helper for creation a parameterized &struct kunit_case
  *
diff --git a/lib/kunit/try-catch.c b/lib/kunit/try-catch.c
index 6bbe0025b0790bd2..92099c67bb21d0a4 100644
--- a/lib/kunit/try-catch.c
+++ b/lib/kunit/try-catch.c
@@ -56,7 +56,8 @@ static unsigned long kunit_test_timeout(void)
         * If tests timeout due to exceeding sysctl_hung_task_timeout_secs,
         * the task will be killed and an oops generated.
         */
-       return 300 * msecs_to_jiffies(MSEC_PER_SEC); /* 5 min */
+       // FIXME times ten for KUNIT_SPEED_VERY_SLOW?
+       return 10 * 300 * msecs_to_jiffies(MSEC_PER_SEC); /* 5 min */
 }
 
 void kunit_try_catch_run(struct kunit_try_catch *try_catch, void *context)
-- 
2.43.0


Reply via email to