[PATCH] [v6] fwts: skip the wake alarm suite if the feature is not implemented

Ivan Hu ivan.hu at canonical.com
Mon Aug 18 02:59:36 UTC 2025


Thanks for the patch.

On Sun, Aug 10, 2025 at 12:17 AM Al Korv <alkorv at posteo.uk> wrote:

> The wake alarm may be not implemented on a non-x86 platform
> thus the calls to the RTC alarm interface may legitimately
> fail. Although the wake alarm test suite appears to antici-
> pate this and skips the first test on a non-x86 platform if
> fwts_wakealarm_get() fails, the subsequent tests fail in this
> case, contrary to the error message printed in the non-x86
> branch of the routine wakealarm_test1(). Here's an excerpt
> from the FWTS results log obtained in such an environmemnt:
>
>  wakealarm: ACPI Wakealarm tests.
>  ---------------------------------------------------------
>  Test 1 of 5: Test existence of RTC with alarm interface.
>  Cannot read Real Time Clock Alarm with ioctl RTC_ALM_READ
>  /dev/rtc0.
>  non-x86 devices sometimes do not have an RTC wake alarm that
>  is normally controlled by the RTC alarm ioctl() interface.
>  This interface does not exist, so the wake alarm tests will
>  be skipped.
>
>  Test 2 of 5: Trigger wakealarm for 1 seconds in the future.
>  Trigger wakealarm for 1 seconds in the future.
>  Cannot enable alarm interrupts on Real Time Clock device
>  /dev/rtc0.
>  FAILED [MEDIUM] WakeAlarmNotTriggeredTest2: Test 2, RTC
>  wakealarm did not trigger.
>
>  Test 3 of 5: Test if wakealarm is fired.
>  Cannot enable alarm interrupts on Real Time Clock device
>  /dev/rtc0.
>  FAILED [MEDIUM] WakeAlarmNotTriggeredTest3: Test 3, Failed
>  to trigger and fire wakealarm.
>
>  Test 4 of 5: Multiple wakealarm firing tests.
>  Trigger wakealarm for 1 seconds in the future.
>  Cannot enable alarm interrupts on Real Time Clock device
>  /dev/rtc0.
>  FAILED [MEDIUM] WakeAlarmNotTriggeredTest4: Test 4, Failed
>  to trigger and fire wakealarm.
>
>  Test 5 of 5: Reset wakealarm time.
>  Cannot set Real Time Clock Alarm with ioctl RTC_ALM_SET /dev/rtc0.
>  FAILED [MEDIUM] WakeAlarmNotResetTest5: Test 5, RTC wakealarm
>  failed to be reset back to original time.
>
>  =================================================================
>  0 passed, 4 failed, 0 warning, 0 aborted, 0 skipped, 0 info only.
>  =================================================================
>
> This happens because the routine fwts_framework_run_test() stops
> performing the suite only if its test returns FWTS_ABORTED or its
> init callback returns FWTS_SKIP while neither is the case here.
>
> The patch fixes the issue by introducing the initialization call-
> back for the suite, the callback checks on a non-x86 platform whe-
> ther the attribute 'wakealarm' of the device rtc0 is exposed via
> sysfs; if the attribute is absent, then the suite will be skip-
> ped. The wakealarm suite report looks as follows after the patch
> is applied:
>
>  wakealarm: ACPI Wakealarm tests.
>  ------------------------------------------------------------
>  Cannot read Real Time Clock Alarm with ioctl RTC_ALM_READ
>  /dev/rtc0.
>  non-x86 devices sometimes do not have an RTC wake alarm that
>  is normally controlled by the RTC alarm ioctl() interface.
>  This interface does not exist, so the wake alarm tests will
>  be skipped.
>  =================================================================
>  0 passed, 0 failed, 0 warning, 0 aborted, 5 skipped, 0 info only.
>  =================================================================
>
> Signed-off-by: Al Korv <alkorv at posteo.uk>
> ---
>  src/acpi/wakealarm/wakealarm.c | 15 +++++++++++++++
>  1 file changed, 15 insertions(+)
>
> diff --git a/src/acpi/wakealarm/wakealarm.c
> b/src/acpi/wakealarm/wakealarm.c
> index 89512540..0566de2f 100644
> --- a/src/acpi/wakealarm/wakealarm.c
> +++ b/src/acpi/wakealarm/wakealarm.c
> @@ -32,6 +32,20 @@
>
>  static struct rtc_time rtc_tm;
>
> +static int wakealarm_test_init(fwts_framework *fw)
>

minor, maybe only wakealarm_init


> +{
> +       (void)fw;
>

you can use the  FWTS_UNUSED(fw);


> +#ifndef FWTS_ARCH_INTEL
> +       struct stat st;
> +       if (stat("/sys/class/rtc/rtc0/wakealarm", &st) == -1) {
> +               fwts_log_info(fw, "An RTC wake alarm is not available.");
> +               return FWTS_SKIP;
> +       }

+
> +#endif
> +       return FWTS_OK;
> +}
>

I think the current problem is that test1 has the ability to check and skip
itself, but tests 2–5 don’t skip properly.
It might be simpler to just add a variable to handle the skip check, as
your v3 patch does, rather than creating an additional init function for
checking again.

Cheers,
Ivan

** it adjusts the routines wakealarm_test[2-5]() to return
*>*    FWTS_SKIP if the 1st test is skipped.*



> +
>  static int wakealarm_test1(fwts_framework *fw)
>  {
>         if (fwts_wakealarm_get(fw, &rtc_tm) == FWTS_OK) {
> @@ -172,6 +186,7 @@ static fwts_framework_minor_test wakealarm_tests[] = {
>
>  static fwts_framework_ops wakealarm_ops = {
>         .description = "ACPI Wakealarm tests.",
> +       .init = wakealarm_test_init,
>         .minor_tests = wakealarm_tests
>  };
>
> --
> 2.39.5
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/fwts-devel/attachments/20250818/9c067db1/attachment.html>


More information about the fwts-devel mailing list