| Message ID | 20250802182617.110784-1-alkorv@posteo.uk |
|---|---|
| State | Superseded |
| Headers | show |
| Series | [v5] fwts: skip the wake alarm suite if the feature is not implemented | expand |
Thanks for the patch. I am not sure why you create a init function and do what test1 need to do, and make test1 all pass. I assume you would like to do the skip in init function, you should keep the tests in test1. Cheers, Ivan On Sun, Aug 3, 2025 at 2:26 AM Al Korv <alkorv@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 merging the routine wakealarm_test1() > into the suite initialization callback, the stub of the routine > is left for compatibility; if fwts_framework_run_test() fails on > an x86 machine, then the suite will be aborted, if it fails on > an non-x86 machine, then the suite will be skipped. 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@posteo.uk> > --- > src/acpi/wakealarm/wakealarm.c | 13 +++++++++---- > 1 file changed, 9 insertions(+), 4 deletions(-) > > diff --git a/src/acpi/wakealarm/wakealarm.c > b/src/acpi/wakealarm/wakealarm.c > index 89512540..2022f48e 100644 > --- a/src/acpi/wakealarm/wakealarm.c > +++ b/src/acpi/wakealarm/wakealarm.c > @@ -32,11 +32,9 @@ > > static struct rtc_time rtc_tm; > > -static int wakealarm_test1(fwts_framework *fw) > +static int wakealarm_test_init(fwts_framework *fw) > { > - if (fwts_wakealarm_get(fw, &rtc_tm) == FWTS_OK) { > - fwts_passed(fw, "RTC with a RTC alarm ioctl() interface > found."); > - } else { > + if (fwts_wakealarm_get(fw, &rtc_tm) != FWTS_OK) { > #ifdef FWTS_ARCH_INTEL > /* For x86 devices, this is considered a failure */ > fwts_failed(fw, LOG_LEVEL_MEDIUM, "NoWakeAlarmTest1", > @@ -57,6 +55,12 @@ static int wakealarm_test1(fwts_framework *fw) > return FWTS_OK; > } > > +static int wakealarm_test1(fwts_framework *fw) > +{ > + fwts_passed(fw, "RTC with a RTC alarm ioctl() interface found."); > + return FWTS_OK; > +} > + > static int wakealarm_test2(fwts_framework *fw) > { > fwts_log_info(fw, "Trigger wakealarm for 1 seconds in the > future."); > @@ -172,6 +176,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 > >
On Monday, 4 August 2025 03:37:36 BST Ivan Hu wrote: > Thanks for the patch. > > I am not sure why you create a init function and do what test1 need to do, > and make test1 all pass. > I assume you would like to do the skip in init function Yes, exactly, otherwise it will be necessary to do the skip in test2..test5 as well. > you should keep > the tests in test1. Why? If the init function succeeds, then the original version of test1 succeeds. I do not see why it might be necessary to perform the same action in init and test1. I presume test1 may be removed, however, I'm not sure whether it's OK to remove a test from a suite. -- Sincerely yours, Al Korv
The init function is intended for initializing the test and verifying the test environment. Actual test logic should be placed in the test function instead. I think it's sufficient to skip the test in the init function, you don't need to change all test1 results to "pass." On Tue, Aug 5, 2025 at 6:53 AM Al Korv <alkorv@posteo.uk> wrote: > On Monday, 4 August 2025 03:37:36 BST Ivan Hu wrote: > > Thanks for the patch. > > > > I am not sure why you create a init function and do what test1 need to > do, > > and make test1 all pass. > > I assume you would like to do the skip in init function > > Yes, exactly, otherwise it will be necessary to do the skip > in test2..test5 as well. > > > you should keep > > the tests in test1. > > Why? If the init function succeeds, then the original > version of test1 succeeds. I do not see why it might > be necessary to perform the same action in init and > test1. I presume test1 may be removed, however, > I'm not sure whether it's OK to remove a test from > a suite. > > -- > Sincerely yours, > Al Korv > > >
On Tuesday, 5 August 2025 07:37:01 BST Ivan Hu wrote: > The init function is intended for initializing the test and verifying the > test environment. OK, I've found out how to use sysfs to check whether the wake alarm is implemented. > Actual test logic should be placed in the test function > instead. > > I think it's sufficient to skip the test in the init function, you don't > need to change all test1 results to "pass." > > On Tue, Aug 5, 2025 at 6:53 AM Al Korv <alkorv@posteo.uk> wrote: > > On Monday, 4 August 2025 03:37:36 BST Ivan Hu wrote: > > > Thanks for the patch. > > > > > > I am not sure why you create a init function and do what test1 need to > > > > do, > > > > > and make test1 all pass. > > > I assume you would like to do the skip in init function > > > > Yes, exactly, otherwise it will be necessary to do the skip > > in test2..test5 as well. > > > > > you should keep > > > the tests in test1. > > > > Why? If the init function succeeds, then the original > > version of test1 succeeds. I do not see why it might > > be necessary to perform the same action in init and > > test1. I presume test1 may be removed, however, > > I'm not sure whether it's OK to remove a test from > > a suite. > > > > -- > > Sincerely yours, > > Al Korv -- Sincerely yours, Al Korv
diff --git a/src/acpi/wakealarm/wakealarm.c b/src/acpi/wakealarm/wakealarm.c index 89512540..2022f48e 100644 --- a/src/acpi/wakealarm/wakealarm.c +++ b/src/acpi/wakealarm/wakealarm.c @@ -32,11 +32,9 @@ static struct rtc_time rtc_tm; -static int wakealarm_test1(fwts_framework *fw) +static int wakealarm_test_init(fwts_framework *fw) { - if (fwts_wakealarm_get(fw, &rtc_tm) == FWTS_OK) { - fwts_passed(fw, "RTC with a RTC alarm ioctl() interface found."); - } else { + if (fwts_wakealarm_get(fw, &rtc_tm) != FWTS_OK) { #ifdef FWTS_ARCH_INTEL /* For x86 devices, this is considered a failure */ fwts_failed(fw, LOG_LEVEL_MEDIUM, "NoWakeAlarmTest1", @@ -57,6 +55,12 @@ static int wakealarm_test1(fwts_framework *fw) return FWTS_OK; } +static int wakealarm_test1(fwts_framework *fw) +{ + fwts_passed(fw, "RTC with a RTC alarm ioctl() interface found."); + return FWTS_OK; +} + static int wakealarm_test2(fwts_framework *fw) { fwts_log_info(fw, "Trigger wakealarm for 1 seconds in the future."); @@ -172,6 +176,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 };
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 merging the routine wakealarm_test1() into the suite initialization callback, the stub of the routine is left for compatibility; if fwts_framework_run_test() fails on an x86 machine, then the suite will be aborted, if it fails on an non-x86 machine, then the suite will be skipped. 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@posteo.uk> --- src/acpi/wakealarm/wakealarm.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)