diff mbox series

[2/2] selftest: rtc: Check if could access /dev/rtc0 before testing

Message ID 20240524013807.154338-3-jjang@nvidia.com (mailing list archive)
State Accepted
Commit 1ad999870a86d58246b6a614a435d055a9edf269
Headers show
Series selftest: rtc: Add rtc feature detection and rtc file check | expand

Commit Message

Joseph Jang May 24, 2024, 1:38 a.m. UTC
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>
---
 tools/testing/selftests/rtc/rtctest.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

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
>
Joseph Jang Sept. 24, 2024, 5:37 a.m. UTC | #2
Hi Alexandre,

Thank you for looking at the rtc patch.
I saw you Acked the [PATCH 2/2], not sure when could we see the patch
in kernel master or next branch ?

Thank you,
Joseph.

On 2024/6/21 3:37 AM, Alexandre Belloni wrote:
> 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
>>
>
Shuah Khan Sept. 24, 2024, 4:05 p.m. UTC | #3
On 9/23/24 23:37, Joseph Jang wrote:
> Hi Alexandre,
> 
> Thank you for looking at the rtc patch.
> I saw you Acked the [PATCH 2/2], not sure when could we see the patch
> in kernel master or next branch ?
> 
> Thank you,
> Joseph.
> 

Please don't top post. It is hard to follow the thread.

> On 2024/6/21 3:37 AM, Alexandre Belloni wrote:
>> 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>
>>

Alexandre, I can take this patch through kselftest. Might have
slipped through my Inbox or the assumption that this will go
through rtc tree.

thanks,
-- Shuah
Alexandre Belloni Sept. 24, 2024, 7:31 p.m. UTC | #4
Hello,

On 24/09/2024 10:05:43-0600, Shuah Khan wrote:
> On 9/23/24 23:37, Joseph Jang wrote:
> > Hi Alexandre,
> > 
> > Thank you for looking at the rtc patch.
> > I saw you Acked the [PATCH 2/2], not sure when could we see the patch
> > in kernel master or next branch ?
> > 
> > Thank you,
> > Joseph.
> > 
> 
> Please don't top post. It is hard to follow the thread.
> 
> > On 2024/6/21 3:37 AM, Alexandre Belloni wrote:
> > > 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>
> > > 
> 
> Alexandre, I can take this patch through kselftest. Might have
> slipped through my Inbox or the assumption that this will go
> through rtc tree.

I assumed this would go through your tree, this is why I didn't carry
it.
Shuah Khan Sept. 24, 2024, 7:57 p.m. UTC | #5
On 9/24/24 13:31, Alexandre Belloni wrote:
> Hello,
> 
> On 24/09/2024 10:05:43-0600, Shuah Khan wrote:
>> On 9/23/24 23:37, Joseph Jang wrote:
>>> Hi Alexandre,
>>>
>>> Thank you for looking at the rtc patch.
>>> I saw you Acked the [PATCH 2/2], not sure when could we see the patch
>>> in kernel master or next branch ?
>>>
>>> Thank you,
>>> Joseph.
>>>
>>
>> Please don't top post. It is hard to follow the thread.
>>
>>> On 2024/6/21 3:37 AM, Alexandre Belloni wrote:
>>>> 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>
>>>>
>>
>> Alexandre, I can take this patch through kselftest. Might have
>> slipped through my Inbox or the assumption that this will go
>> through rtc tree.
> 
> I assumed this would go through your tree, this is why I didn't carry
> it.
> 

I will take it through my tree then. Sorry for the delay.

thanks,
-- Shuah
Joseph Jang Oct. 18, 2024, 4:18 a.m. UTC | #6
On 2024/9/25 3:57 AM, Shuah Khan wrote:
> On 9/24/24 13:31, Alexandre Belloni wrote:
>> Hello,
>>
>> On 24/09/2024 10:05:43-0600, Shuah Khan wrote:
>>> On 9/23/24 23:37, Joseph Jang wrote:
>>>> Hi Alexandre,
>>>>
>>>> Thank you for looking at the rtc patch.
>>>> I saw you Acked the [PATCH 2/2], not sure when could we see the patch
>>>> in kernel master or next branch ?
>>>>
>>>> Thank you,
>>>> Joseph.
>>>>
>>>
>>> Please don't top post. It is hard to follow the thread.
>>>
>>>> On 2024/6/21 3:37 AM, Alexandre Belloni wrote:
>>>>> 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>
>>>>>
>>>
>>> Alexandre, I can take this patch through kselftest. Might have
>>> slipped through my Inbox or the assumption that this will go
>>> through rtc tree.
>>
>> I assumed this would go through your tree, this is why I didn't carry
>> it.
>>
> 
> I will take it through my tree then. Sorry for the delay.

Hi Shuah,

Thanks your help.
May I know when can we see the patch on master branch ?

Thank you,
Joseph.

> 
> thanks,
> -- Shuah
Shuah Khan Oct. 18, 2024, 3:39 p.m. UTC | #7
On 10/17/24 22:18, Joseph Jang wrote:
> 
> 
> On 2024/9/25 3:57 AM, Shuah Khan wrote:
>> On 9/24/24 13:31, Alexandre Belloni wrote:
>>> Hello,
>>>
>>> On 24/09/2024 10:05:43-0600, Shuah Khan wrote:
>>>> On 9/23/24 23:37, Joseph Jang wrote:
>>>>> Hi Alexandre,
>>>>>
>>>>> Thank you for looking at the rtc patch.
>>>>> I saw you Acked the [PATCH 2/2], not sure when could we see the patch
>>>>> in kernel master or next branch ?
>>>>>
>>>>> Thank you,
>>>>> Joseph.
>>>>>
>>>>
>>>> Please don't top post. It is hard to follow the thread.
>>>>
>>>>> On 2024/6/21 3:37 AM, Alexandre Belloni wrote:
>>>>>> 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>
>>>>>>
>>>>
>>>> Alexandre, I can take this patch through kselftest. Might have
>>>> slipped through my Inbox or the assumption that this will go
>>>> through rtc tree.
>>>
>>> I assumed this would go through your tree, this is why I didn't carry
>>> it.
>>>
>>
>> I will take it through my tree then. Sorry for the delay.
> 
> Hi Shuah,
> 
> Thanks your help.
> May I know when can we see the patch on master branch ?
> 

Did you check the mainline:
This is already in  Linux 6.12 since rc2

commit 1ad999870a86d58246b6a614a435d055a9edf269
Author: Joseph Jang <jjang@nvidia.com>
Date:   Thu May 23 18:38:07 2024 -0700

     selftest: rtc: Check if could access /dev/rtc0 before testing

thanks,
-- Shuah
diff mbox series

Patch

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;
 }