mbox series

[0/2] selftest: rtc: Add rtc feature detection and rtc file check

Message ID 20240524013807.154338-1-jjang@nvidia.com
Headers show
Series selftest: rtc: Add rtc feature detection and rtc file check | expand

Message

Joseph Jang May 24, 2024, 1:38 a.m. UTC
1. In order to make rtctest more explicit and robust, we propose to use
RTC_PARAM_GET ioctl interface to check rtc alarm feature state before
running alarm related tests.

2. The rtctest requires the read permission on /dev/rtc0. The rtctest will
be skipped if the /dev/rtc0 is not readable.

Joseph Jang (2):
  selftest: rtc: Add to check rtc alarm status for alarm related test
  selftest: rtc: Check if could access /dev/rtc0 before testing

 tools/testing/selftests/rtc/Makefile  |  2 +-
 tools/testing/selftests/rtc/rtctest.c | 71 ++++++++++++++++++++++++++-
 2 files changed, 71 insertions(+), 2 deletions(-)

Comments

Alexandre Belloni June 20, 2024, 7:37 p.m. UTC | #1
On 23/05/2024 18:38:07-0700, Joseph Jang wrote:
> The rtctest requires the read permission on /dev/rtc0. The rtctest will
> be skipped if the /dev/rtc0 is not readable.
> 
> Reviewed-by: Koba Ko <kobak@nvidia.com>
> Reviewed-by: Matthew R. Ochs <mochs@nvidia.com>
> Signed-off-by: Joseph Jang <jjang@nvidia.com>

Acked-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

> ---
>  tools/testing/selftests/rtc/rtctest.c | 11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/testing/selftests/rtc/rtctest.c b/tools/testing/selftests/rtc/rtctest.c
> index 2b12497eb30d..d104f5326cf4 100644
> --- a/tools/testing/selftests/rtc/rtctest.c
> +++ b/tools/testing/selftests/rtc/rtctest.c
> @@ -483,6 +483,8 @@ __constructor_order_last(void)
>  
>  int main(int argc, char **argv)
>  {
> +	int ret = -1;
> +
>  	switch (argc) {
>  	case 2:
>  		rtc_file = argv[1];
> @@ -494,5 +496,12 @@ int main(int argc, char **argv)
>  		return 1;
>  	}
>  
> -	return test_harness_run(argc, argv);
> +	/* Run the test if rtc_file is accessible */
> +	if (access(rtc_file, R_OK) == 0)
> +		ret = test_harness_run(argc, argv);
> +	else
> +		ksft_exit_skip("[SKIP]: Cannot access rtc file %s - Exiting\n",
> +						rtc_file);
> +
> +	return ret;
>  }
> -- 
> 2.34.1
>