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

Al Korv alkorv at posteo.uk
Sat Aug 2 18:01:36 UTC 2025


On Friday, 25 July 2025 14:07:31 BST Al Korv 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 routine doesn't detect that
> the wake alarm is not implemented thus the 1st test passes
> and the remaining tests fail if it is the case. Here's an
> excerpt from the FWTS results log obtained in such an envi-
> ronmemnt:
> 
>  wakealarm: ACPI Wakealarm tests.
>  ---------------------------------------------------------
>  Test 1 of 5: Test existence of RTC with alarm interface.
>  PASSED: Test 1, RTC with a RTC alarm ioctl() interface
>  found.
> 
>  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.
>  PASSED: Test 5, RTC wakealarm set.
>  FAILED [MEDIUM] WakeAlarmNotResetTest5: Test 5, RTC wakealarm
>  failed to be reset back to original time.
> 
> Even if the routine fwts_wakealarm_get() is adjusted to re-
> turn the error if the wake alarm is not implemented then
> the 1st test will be skipped while the remaining tests will
> fail, contrary to the error message printed in the non-x86
> branch of the routine wakealarm_test1(); that happens because
> the routine fwts_framework_run_test() stops performing the
> suite only if its test returns FWTS_ABORTED or its init call-
> back returns FWTS_SKIP.
> 
> The patch fixes the issue as follows:
> 
>  * it adjusts the routine fwts_wakealarm_get() to use the
>    ioctl RTC_WKALM_RD instead of RTC_ALM_READ to detect
>    that the wake alarm is available and return the error
>    if it is not;
> 
>  * it adjusts the routines wakealarm_test[2-5]() to return
>    FWTS_SKIP if the 1st test is skipped.
> 
> The wakealarm suite report looks as follows after the patch
> is applied:
> 
>  wakealarm: ACPI Wakealarm tests.
>  ------------------------------------------------------------
>  Test 1 of 5: Test existence of RTC with alarm interface.
>  The wake alarm is not supported.
>  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.
> 
>  Test 3 of 5: Test if wakealarm is fired.
> 
>  Test 4 of 5: Multiple wakealarm firing tests.
> 
>  Test 5 of 5: Reset wakealarm time.
> 
> Signed-off-by: Al Korv <alkorv at posteo.uk>
> ---
>  src/acpi/wakealarm/wakealarm.c | 19 +++++++++++++++++++
>  src/lib/src/fwts_wakealarm.c   |  9 ++++++++-
>  2 files changed, 27 insertions(+), 1 deletion(-)
> 
> diff --git a/src/acpi/wakealarm/wakealarm.c b/src/acpi/wakealarm/wakealarm.c
> index 89512540..14b405c4 100644
> --- a/src/acpi/wakealarm/wakealarm.c
> +++ b/src/acpi/wakealarm/wakealarm.c
> @@ -31,6 +31,7 @@
>  #include <linux/rtc.h>
> 
>  static struct rtc_time rtc_tm;
> +static bool skip_suite = false;
> 
>  static int wakealarm_test1(fwts_framework *fw)
>  {
> @@ -47,6 +48,8 @@ static int wakealarm_test1(fwts_framework *fw)
>  			"does not exist, so the wake alarm tests 
will be aborted.");
>  		return FWTS_ABORTED;
>  #else
> +		skip_suite = true;
> +
>  		fwts_log_info(fw,
>  			"non-x86 devices sometimes do not have an 
RTC wake alarm that "
>  			"is normally controlled by the RTC alarm 
ioctl() interface. This "
> @@ -59,6 +62,10 @@ static int wakealarm_test1(fwts_framework *fw)
> 
>  static int wakealarm_test2(fwts_framework *fw)
>  {
> +	if (skip_suite) {
> +		return FWTS_SKIP;
> +	}
> +
>  	fwts_log_info(fw, "Trigger wakealarm for 1 seconds in the 
future.");
>  	if (fwts_wakealarm_trigger(fw, 1)) {
>  		fwts_failed(fw, LOG_LEVEL_MEDIUM, 
"WakeAlarmNotTriggeredTest2",
> @@ -77,6 +84,10 @@ static int wakealarm_test3(fwts_framework *fw)
>  {
>  	int ret;
> 
> +	if (skip_suite) {
> +		return FWTS_SKIP;
> +	}
> +
>  	ret = fwts_wakealarm_test_firing(fw, 2);
>  	if (ret < 0) {
>  		fwts_failed(fw, LOG_LEVEL_MEDIUM, 
"WakeAlarmNotTriggeredTest3",
> @@ -98,6 +109,10 @@ static int wakealarm_test4(fwts_framework *fw)
>  	uint32_t i;
>  	int failed = 0;
> 
> +	if (skip_suite) {
> +		return FWTS_SKIP;
> +	}
> +
>  	for (i = 1; i < 5; i++) {
>  		fwts_log_info(fw, "Trigger wakealarm for %" PRIu32 " 
seconds in the
> future.", i); int ret = fwts_wakealarm_test_firing(fw, i);
> @@ -125,6 +140,10 @@ static int wakealarm_test5(fwts_framework *fw)
>  {
>  	struct rtc_time rtc_now;
> 
> +	if (skip_suite) {
> +		return FWTS_SKIP;
> +	}
> +
>  	if (fwts_wakealarm_set(fw, &rtc_tm) == FWTS_OK) {
>  		fwts_passed(fw, "RTC wakealarm set.");
>  	} else {
> diff --git a/src/lib/src/fwts_wakealarm.c b/src/lib/src/fwts_wakealarm.c
> index 779fd48e..090888ba 100644
> --- a/src/lib/src/fwts_wakealarm.c
> +++ b/src/lib/src/fwts_wakealarm.c
> @@ -47,9 +47,16 @@ int fwts_wakealarm_get(fwts_framework *fw, struct
> rtc_time *rtc_tm) return FWTS_ERROR;
>  	}
> 
> -	if (ioctl(fd, RTC_ALM_READ, rtc_tm) < 0) {
> +	struct rtc_wkalrm wkalarm;
> +
> +	if (ioctl(fd, RTC_WKALM_RD, &wkalarm) < 0) {
>  		fwts_log_error(fw, "Cannot read Real Time Clock Alarm 
with ioctl
> RTC_ALM_READ %s.", fwts_rtc); ret = FWTS_ERROR;
> +	} else if (!wkalarm.enabled) {

I've realized that this field does not indicate that the wake alarm
is implemented thus this portion of the patch is incorrect.

I'm submitting a new version.

> +		fwts_log_error(fw, "The wake alarm is not supported.");
> +		ret = FWTS_ERROR;
> +	} else {
> +		*rtc_tm = wkalarm.time;
>  	}
>  	(void)close(fd);

--
Sincerely yours,
Al Korv





More information about the fwts-devel mailing list