All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 3/3] y2038: testsuite/smokey/y2038: testcase for nanosleep64
@ 2021-04-21  8:38 Song Chen
  2021-04-23 12:48 ` Bezdeka, Florian
  0 siblings, 1 reply; 7+ messages in thread
From: Song Chen @ 2021-04-21  8:38 UTC (permalink / raw)
  To: xenomai, florian.bezdeka; +Cc: chensong

From: chensong <chensong@tj.kylinos.cn>

add test case for clock_nanosleep64 in testsuite

Signed-off-by: chensong <chensong@tj.kylinos.cn>

---
v2:
1, REALTIME --> MONOTONIC
2, more combinations
3, smokey warning in clock_gettime
4, remove magic number
---
 testsuite/smokey/y2038/syscall-tests.c | 50 ++++++++++++++++++++++++++++++++++
 1 file changed, 50 insertions(+)

diff --git a/testsuite/smokey/y2038/syscall-tests.c b/testsuite/smokey/y2038/syscall-tests.c
index 990e05c..0ea6ddd 100644
--- a/testsuite/smokey/y2038/syscall-tests.c
+++ b/testsuite/smokey/y2038/syscall-tests.c
@@ -228,6 +228,52 @@ static int test_sc_cobalt_clock_settime64(void)
 	return 0;
 }
 
+static int test_sc_cobalt_clock_nanosleep64(void)
+{
+	long ret;
+	int code = __xn_syscode(sc_cobalt_clock_nanosleep64);
+	struct xn_timespec64 next, rmt;
+	struct timespec now;
+
+	/* Make sure we don't crash because of NULL pointers */
+	ret = syscall(code, NULL, NULL, NULL, NULL);
+	if (ret == -1 && errno == ENOSYS) {
+		smokey_note("clock_nanosleep64: skipped. (no kernel support)");
+		return 0; // Not implemented, nothing to test, success
+	}
+	if (!smokey_assert(ret == -1) || !smokey_assert(errno == EFAULT))
+		return errno;
+
+	/* Provide a valid 64bit timespec*/
+	ret = clock_gettime(CLOCK_MONOTONIC, &now);
+	if (ret) {
+		smokey_warning("clock_gettime failed in clock_nanosleep64.");
+		return errno;
+	}
+
+	/* Providing an invalid address has to deliver EFAULT */
+	ret = syscall(code, CLOCK_MONOTONIC, TIMER_ABSTIME,
+				(void *)0xdeadbeefUL, &rmt);
+	if (!smokey_assert(ret == -1) || !smokey_assert(errno == EFAULT))
+		return errno;
+
+	next.tv_sec  = now.tv_sec + 1;
+	next.tv_nsec = now.tv_nsec;
+
+	ret = syscall(code, CLOCK_MONOTONIC, TIMER_ABSTIME,
+				&next, (void *)0xdeadbeefUL);
+	if (!smokey_assert(ret == -1) || !smokey_assert(errno == EFAULT))
+		return errno;
+
+	next.tv_sec  = next.tv_sec + 1;
+
+	ret = syscall(code, CLOCK_MONOTONIC, TIMER_ABSTIME, &next, &rmt);
+	if (!smokey_assert(!ret))
+		return errno;
+
+	return 0;
+}
+
 static int run_y2038(struct smokey_test *t, int argc, char *const argv[])
 {
 	int ret;
@@ -244,5 +290,9 @@ static int run_y2038(struct smokey_test *t, int argc, char *const argv[])
 	if (ret)
 		return ret;
 
+	ret = test_sc_cobalt_clock_nanosleep64();
+	if (ret)
+		return ret;
+
 	return 0;
 }
-- 
2.7.4



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 3/3] y2038: testsuite/smokey/y2038: testcase for nanosleep64
  2021-04-21  8:38 [PATCH v2 3/3] y2038: testsuite/smokey/y2038: testcase for nanosleep64 Song Chen
@ 2021-04-23 12:48 ` Bezdeka, Florian
  2021-04-26 17:05   ` chensong_2000
  0 siblings, 1 reply; 7+ messages in thread
From: Bezdeka, Florian @ 2021-04-23 12:48 UTC (permalink / raw)
  To: xenomai, chensong_2000; +Cc: chensong

On Wed, 2021-04-21 at 16:38 +0800, Song Chen wrote:
>  
> 
> +static int test_sc_cobalt_clock_nanosleep64(void)+{
> +	long ret;
> +	int code = __xn_syscode(sc_cobalt_clock_nanosleep64);
> +	struct xn_timespec64 next, rmt;
> +	struct timespec now;
> +
> +	/* Make sure we don't crash because of NULL pointers */
> +	ret = syscall(code, NULL, NULL, NULL, NULL);
> +	if (ret == -1 && errno == ENOSYS) {
> +		smokey_note("clock_nanosleep64: skipped. (no kernel support)");
> +		return 0; // Not implemented, nothing to test, success
> +	}
> +	if (!smokey_assert(ret == -1) || !smokey_assert(errno == EFAULT))
> +		return errno;
> +
> +	/* Provide a valid 64bit timespec*/
> +	ret = clock_gettime(CLOCK_MONOTONIC, &now);
> +	if (ret) {
> +		smokey_warning("clock_gettime failed in clock_nanosleep64.");
> +		return errno;
> +	}
> +
> +	/* Providing an invalid address has to deliver EFAULT */
> +	ret = syscall(code, CLOCK_MONOTONIC, TIMER_ABSTIME,
> +				(void *)0xdeadbeefUL, &rmt);
> +	if (!smokey_assert(ret == -1) || !smokey_assert(errno == EFAULT))
> +		return errno;
> +
> +	next.tv_sec  = now.tv_sec + 1;
> +	next.tv_nsec = now.tv_nsec;
> +
> +	ret = syscall(code, CLOCK_MONOTONIC, TIMER_ABSTIME,
> +				&next, (void *)0xdeadbeefUL);
> +	if (!smokey_assert(ret == -1) || !smokey_assert(errno == EFAULT))
> +		return errno;
> +
> +	next.tv_sec  = next.tv_sec + 1;

That looks like duplicate code. The last call to nanosleep was an error
handling check, so we would end up here adding 2 secs to "now".

> +
> +	ret = syscall(code, CLOCK_MONOTONIC, TIMER_ABSTIME, &next, &rmt);
> +	if (!smokey_assert(!ret))
> +		return errno;
> +

As long as nobody has a better idea we should make sure that we don't
come back to early. Checking for the upper boundary requires some magic
numbers as already discussed, so let's check at least the lower
boundary.

> +	return 0;
> +}
> +
>  static int run_y2038(struct smokey_test *t, int argc, char *const argv[])
>  {
>  	int ret;
> @@ -244,5 +290,9 @@ static int run_y2038(struct smokey_test *t, int argc, char *const argv[])
>  	if (ret)
>  		return ret;
>  
> +	ret = test_sc_cobalt_clock_nanosleep64();
> +	if (ret)
> +		return ret;
> +
>  	return 0;
>  }


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 3/3] y2038: testsuite/smokey/y2038: testcase for nanosleep64
  2021-04-26 17:05   ` chensong_2000
@ 2021-04-26 11:57     ` Bezdeka, Florian
  2021-04-27  1:14       ` chensong_2000
  0 siblings, 1 reply; 7+ messages in thread
From: Bezdeka, Florian @ 2021-04-26 11:57 UTC (permalink / raw)
  To: xenomai, chensong_2000; +Cc: chensong

On Tue, 2021-04-27 at 01:05 +0800, chensong_2000@189.cn wrote:
> 
> 在 2021/4/23 下午8:48, Bezdeka, Florian 写道:
> > On Wed, 2021-04-21 at 16:38 +0800, Song Chen wrote:
> > >   
> > > 
> > > 
> > > 
> > > 
> > > +static int test_sc_cobalt_clock_nanosleep64(void)+{
> > > +	long ret;
> > > +	int code = __xn_syscode(sc_cobalt_clock_nanosleep64);
> > > +	struct xn_timespec64 next, rmt;
> > > +	struct timespec now;
> > > +
> > > +	/* Make sure we don't crash because of NULL pointers */
> > > +	ret = syscall(code, NULL, NULL, NULL, NULL);
> > > +	if (ret == -1 && errno == ENOSYS) {
> > > +		smokey_note("clock_nanosleep64: skipped. (no kernel support)");
> > > +		return 0; // Not implemented, nothing to test, success
> > > +	}
> > > +	if (!smokey_assert(ret == -1) || !smokey_assert(errno == EFAULT))
> > > +		return errno;
> > > +
> > > +	/* Provide a valid 64bit timespec*/
> > > +	ret = clock_gettime(CLOCK_MONOTONIC, &now);
> > > +	if (ret) {
> > > +		smokey_warning("clock_gettime failed in clock_nanosleep64.");
> > > +		return errno;
> > > +	}
> > > +
> > > +	/* Providing an invalid address has to deliver EFAULT */
> > > +	ret = syscall(code, CLOCK_MONOTONIC, TIMER_ABSTIME,
> > > +				(void *)0xdeadbeefUL, &rmt);
> > > +	if (!smokey_assert(ret == -1) || !smokey_assert(errno == EFAULT))
> > > +		return errno;
> > > +
> > > +	next.tv_sec  = now.tv_sec + 1;
> > > +	next.tv_nsec = now.tv_nsec;
> > > +
> > > +	ret = syscall(code, CLOCK_MONOTONIC, TIMER_ABSTIME,
> > > +				&next, (void *)0xdeadbeefUL);
> > > +	if (!smokey_assert(ret == -1) || !smokey_assert(errno == EFAULT))
> > > +		return errno;
> > > +
> > > +	next.tv_sec  = next.tv_sec + 1;
> > 
> > That looks like duplicate code. The last call to nanosleep was an error
> > handling check, so we would end up here adding 2 secs to "now".
> 
> point taken
> > 
> > > +
> > > +	ret = syscall(code, CLOCK_MONOTONIC, TIMER_ABSTIME, &next, &rmt);
> > > +	if (!smokey_assert(!ret))
> > > +		return errno;
> > > +
> > 
> > As long as nobody has a better idea we should make sure that we don't
> > come back to early. Checking for the upper boundary requires some magic
> > numbers as already discussed, so let's check at least the lower
> > boundary.
> 
> point is not taken, could you please explain upper/lower boundary more 
> specifically, thanks.

Lower boundary: We should not come back too early
Upper boundary: We should not come back too late

While the lower boundary is defined, the upper boundary depends on the
used architecture and/or platform.

I had something similar to [1] in mind. That's the test case for
nanosleep() in glibc. Checking the lower boundary by making sure we
don't come back too early.

Do you agree? Was that helpful?


[1] https://elixir.bootlin.com/glibc/latest/source/posix/tst-nanosleep.c

> 
> Song
> 
> > 
> > > +	return 0;
> > > +}
> > > +
> > >   static int run_y2038(struct smokey_test *t, int argc, char *const argv[])
> > >   {
> > >   	int ret;
> > > @@ -244,5 +290,9 @@ static int run_y2038(struct smokey_test *t, int argc, char *const argv[])
> > >   	if (ret)
> > >   		return ret;
> > >   
> > > 
> > > 
> > > 
> > > +	ret = test_sc_cobalt_clock_nanosleep64();
> > > +	if (ret)
> > > +		return ret;
> > > +
> > >   	return 0;
> > >   }
> > 


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 3/3] y2038: testsuite/smokey/y2038: testcase for nanosleep64
  2021-04-23 12:48 ` Bezdeka, Florian
@ 2021-04-26 17:05   ` chensong_2000
  2021-04-26 11:57     ` Bezdeka, Florian
  0 siblings, 1 reply; 7+ messages in thread
From: chensong_2000 @ 2021-04-26 17:05 UTC (permalink / raw)
  To: Bezdeka, Florian, xenomai; +Cc: chensong



在 2021/4/23 下午8:48, Bezdeka, Florian 写道:
> On Wed, 2021-04-21 at 16:38 +0800, Song Chen wrote:
>>   
>>
>> +static int test_sc_cobalt_clock_nanosleep64(void)+{
>> +	long ret;
>> +	int code = __xn_syscode(sc_cobalt_clock_nanosleep64);
>> +	struct xn_timespec64 next, rmt;
>> +	struct timespec now;
>> +
>> +	/* Make sure we don't crash because of NULL pointers */
>> +	ret = syscall(code, NULL, NULL, NULL, NULL);
>> +	if (ret == -1 && errno == ENOSYS) {
>> +		smokey_note("clock_nanosleep64: skipped. (no kernel support)");
>> +		return 0; // Not implemented, nothing to test, success
>> +	}
>> +	if (!smokey_assert(ret == -1) || !smokey_assert(errno == EFAULT))
>> +		return errno;
>> +
>> +	/* Provide a valid 64bit timespec*/
>> +	ret = clock_gettime(CLOCK_MONOTONIC, &now);
>> +	if (ret) {
>> +		smokey_warning("clock_gettime failed in clock_nanosleep64.");
>> +		return errno;
>> +	}
>> +
>> +	/* Providing an invalid address has to deliver EFAULT */
>> +	ret = syscall(code, CLOCK_MONOTONIC, TIMER_ABSTIME,
>> +				(void *)0xdeadbeefUL, &rmt);
>> +	if (!smokey_assert(ret == -1) || !smokey_assert(errno == EFAULT))
>> +		return errno;
>> +
>> +	next.tv_sec  = now.tv_sec + 1;
>> +	next.tv_nsec = now.tv_nsec;
>> +
>> +	ret = syscall(code, CLOCK_MONOTONIC, TIMER_ABSTIME,
>> +				&next, (void *)0xdeadbeefUL);
>> +	if (!smokey_assert(ret == -1) || !smokey_assert(errno == EFAULT))
>> +		return errno;
>> +
>> +	next.tv_sec  = next.tv_sec + 1;
> 
> That looks like duplicate code. The last call to nanosleep was an error
> handling check, so we would end up here adding 2 secs to "now".

point taken
> 
>> +
>> +	ret = syscall(code, CLOCK_MONOTONIC, TIMER_ABSTIME, &next, &rmt);
>> +	if (!smokey_assert(!ret))
>> +		return errno;
>> +
> 
> As long as nobody has a better idea we should make sure that we don't
> come back to early. Checking for the upper boundary requires some magic
> numbers as already discussed, so let's check at least the lower
> boundary.

point is not taken, could you please explain upper/lower boundary more 
specifically, thanks.

Song

> 
>> +	return 0;
>> +}
>> +
>>   static int run_y2038(struct smokey_test *t, int argc, char *const argv[])
>>   {
>>   	int ret;
>> @@ -244,5 +290,9 @@ static int run_y2038(struct smokey_test *t, int argc, char *const argv[])
>>   	if (ret)
>>   		return ret;
>>   
>> +	ret = test_sc_cobalt_clock_nanosleep64();
>> +	if (ret)
>> +		return ret;
>> +
>>   	return 0;
>>   }
> 


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 3/3] y2038: testsuite/smokey/y2038: testcase for nanosleep64
  2021-04-26 11:57     ` Bezdeka, Florian
@ 2021-04-27  1:14       ` chensong_2000
  0 siblings, 0 replies; 7+ messages in thread
From: chensong_2000 @ 2021-04-27  1:14 UTC (permalink / raw)
  To: Bezdeka, Florian, xenomai; +Cc: chensong



在 2021/4/26 下午7:57, Bezdeka, Florian 写道:
> On Tue, 2021-04-27 at 01:05 +0800, chensong_2000@189.cn wrote:
>>
>> 在 2021/4/23 下午8:48, Bezdeka, Florian 写道:
>>> On Wed, 2021-04-21 at 16:38 +0800, Song Chen wrote:
>>>>    
>>>>
>>>>
>>>>
>>>>
>>>> +static int test_sc_cobalt_clock_nanosleep64(void)+{
>>>> +	long ret;
>>>> +	int code = __xn_syscode(sc_cobalt_clock_nanosleep64);
>>>> +	struct xn_timespec64 next, rmt;
>>>> +	struct timespec now;
>>>> +
>>>> +	/* Make sure we don't crash because of NULL pointers */
>>>> +	ret = syscall(code, NULL, NULL, NULL, NULL);
>>>> +	if (ret == -1 && errno == ENOSYS) {
>>>> +		smokey_note("clock_nanosleep64: skipped. (no kernel support)");
>>>> +		return 0; // Not implemented, nothing to test, success
>>>> +	}
>>>> +	if (!smokey_assert(ret == -1) || !smokey_assert(errno == EFAULT))
>>>> +		return errno;
>>>> +
>>>> +	/* Provide a valid 64bit timespec*/
>>>> +	ret = clock_gettime(CLOCK_MONOTONIC, &now);
>>>> +	if (ret) {
>>>> +		smokey_warning("clock_gettime failed in clock_nanosleep64.");
>>>> +		return errno;
>>>> +	}
>>>> +
>>>> +	/* Providing an invalid address has to deliver EFAULT */
>>>> +	ret = syscall(code, CLOCK_MONOTONIC, TIMER_ABSTIME,
>>>> +				(void *)0xdeadbeefUL, &rmt);
>>>> +	if (!smokey_assert(ret == -1) || !smokey_assert(errno == EFAULT))
>>>> +		return errno;
>>>> +
>>>> +	next.tv_sec  = now.tv_sec + 1;
>>>> +	next.tv_nsec = now.tv_nsec;
>>>> +
>>>> +	ret = syscall(code, CLOCK_MONOTONIC, TIMER_ABSTIME,
>>>> +				&next, (void *)0xdeadbeefUL);
>>>> +	if (!smokey_assert(ret == -1) || !smokey_assert(errno == EFAULT))
>>>> +		return errno;
>>>> +
>>>> +	next.tv_sec  = next.tv_sec + 1;
>>>
>>> That looks like duplicate code. The last call to nanosleep was an error
>>> handling check, so we would end up here adding 2 secs to "now".
>>
>> point taken
>>>
>>>> +
>>>> +	ret = syscall(code, CLOCK_MONOTONIC, TIMER_ABSTIME, &next, &rmt);
>>>> +	if (!smokey_assert(!ret))
>>>> +		return errno;
>>>> +
>>>
>>> As long as nobody has a better idea we should make sure that we don't
>>> come back to early. Checking for the upper boundary requires some magic
>>> numbers as already discussed, so let's check at least the lower
>>> boundary.
>>
>> point is not taken, could you please explain upper/lower boundary more
>> specifically, thanks.
> 
> Lower boundary: We should not come back too early
> Upper boundary: We should not come back too late
> 
> While the lower boundary is defined, the upper boundary depends on the
> used architecture and/or platform.
> 
> I had something similar to [1] in mind. That's the test case for
> nanosleep() in glibc. Checking the lower boundary by making sure we
> don't come back too early.
> 
> Do you agree? Was that helpful?

make sense, understood, thanks.

Song

> 
> 
> [1] https://elixir.bootlin.com/glibc/latest/source/posix/tst-nanosleep.c
> 
>>
>> Song
>>
>>>
>>>> +	return 0;
>>>> +}
>>>> +
>>>>    static int run_y2038(struct smokey_test *t, int argc, char *const argv[])
>>>>    {
>>>>    	int ret;
>>>> @@ -244,5 +290,9 @@ static int run_y2038(struct smokey_test *t, int argc, char *const argv[])
>>>>    	if (ret)
>>>>    		return ret;
>>>>    
>>>>
>>>>
>>>>
>>>> +	ret = test_sc_cobalt_clock_nanosleep64();
>>>> +	if (ret)
>>>> +		return ret;
>>>> +
>>>>    	return 0;
>>>>    }
>>>
> 


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 3/3] y2038: testsuite/smokey/y2038: testcase for nanosleep64
  2021-04-20  6:25 Song Chen
@ 2021-04-21  6:56 ` Jan Kiszka
  0 siblings, 0 replies; 7+ messages in thread
From: Jan Kiszka @ 2021-04-21  6:56 UTC (permalink / raw)
  To: Song Chen, xenomai, florian.bezdeka

On 20.04.21 08:25, Song Chen via Xenomai wrote:
> From: chensong <chensong@tj.kylinos.cn>
> 
> add test case for clock_nanosleep64 in testsuite
> 
> Signed-off-by: chensong <chensong@tj.kylinos.cn>
> 
> ---
> v2:
> 1, REALTIME --> MONOTONIC
> 2, more combinations
> 3, smokey warning in clock_gettime
> 4, remove magic number
> ---
>  testsuite/smokey/y2038/syscall-tests.c | 50 ++++++++++++++++++++++++++++++++++
>  1 file changed, 50 insertions(+)
> 
> diff --git a/testsuite/smokey/y2038/syscall-tests.c b/testsuite/smokey/y2038/syscall-tests.c
> index 990e05c..0ea6ddd 100644
> --- a/testsuite/smokey/y2038/syscall-tests.c
> +++ b/testsuite/smokey/y2038/syscall-tests.c
> @@ -228,6 +228,52 @@ static int test_sc_cobalt_clock_settime64(void)
>  	return 0;
>  }
>  
> +static int test_sc_cobalt_clock_nanosleep64(void)
> +{
> +	long ret;
> +	int code = __xn_syscode(sc_cobalt_clock_nanosleep64);
> +	struct xn_timespec64 next, rmt;
> +	struct timespec now;
> +
> +	/* Make sure we don't crash because of NULL pointers */
> +	ret = syscall(code, NULL, NULL, NULL, NULL);
> +	if (ret == -1 && errno == ENOSYS) {
> +		smokey_note("clock_nanosleep64: skipped. (no kernel support)");
> +		return 0; // Not implemented, nothing to test, success
> +	}
> +	if (!smokey_assert(ret == -1) || !smokey_assert(errno == EFAULT))
> +		return errno;
> +
> +	/* Provide a valid 64bit timespec*/
> +	ret = clock_gettime(CLOCK_MONOTONIC, &now);
> +	if (ret) {
> +		smokey_warning("clock_gettime failed in clock_nanosleep64.");
> +		return errno;
> +	}
> +
> +	/* Providing an invalid address has to deliver EFAULT */
> +	ret = syscall(code, CLOCK_MONOTONIC, TIMER_ABSTIME,
> +				(void *)0xdeadbeefUL, &rmt);
> +	if (!smokey_assert(ret == -1) || !smokey_assert(errno == EFAULT))
> +		return errno;
> +
> +	next.tv_sec  = now.tv_sec + 1;
> +	next.tv_nsec = now.tv_nsec;
> +
> +	ret = syscall(code, CLOCK_MONOTONIC, TIMER_ABSTIME,
> +				&next, (void *)0xdeadbeefUL);
> +	if (!smokey_assert(ret == -1) || !smokey_assert(errno == EFAULT))
> +		return errno;
> +
> +	next.tv_sec  = next.tv_sec + 1;
> +
> +	ret = syscall(code, CLOCK_MONOTONIC, TIMER_ABSTIME, &next, &rmt);
> +	if (!smokey_assert(!ret))
> +		return errno;
> +
> +	return 0;
> +}
> +
>  static int run_y2038(struct smokey_test *t, int argc, char *const argv[])
>  {
>  	int ret;
> @@ -244,5 +290,9 @@ static int run_y2038(struct smokey_test *t, int argc, char *const argv[])
>  	if (ret)
>  		return ret;
>  
> +	ret = test_sc_cobalt_clock_nanosleep64();
> +	if (ret)
> +		return ret;
> +
>  	return 0;
>  }
> 

Looks like patch 2/3 didn't make it to the list. Also your other series
arrived incompletely. Please check. And also consider adding a cover
letter in order to associate patches of a series.

Thanks,
Jan

PS: Dropping chensong@tj.kylinos.cn as your server does not know you
anymore.

-- 
Siemens AG, T RDA IOT
Corporate Competence Center Embedded Linux


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v2 3/3] y2038: testsuite/smokey/y2038: testcase for nanosleep64
@ 2021-04-20  6:25 Song Chen
  2021-04-21  6:56 ` Jan Kiszka
  0 siblings, 1 reply; 7+ messages in thread
From: Song Chen @ 2021-04-20  6:25 UTC (permalink / raw)
  To: xenomai, florian.bezdeka; +Cc: chensong

From: chensong <chensong@tj.kylinos.cn>

add test case for clock_nanosleep64 in testsuite

Signed-off-by: chensong <chensong@tj.kylinos.cn>

---
v2:
1, REALTIME --> MONOTONIC
2, more combinations
3, smokey warning in clock_gettime
4, remove magic number
---
 testsuite/smokey/y2038/syscall-tests.c | 50 ++++++++++++++++++++++++++++++++++
 1 file changed, 50 insertions(+)

diff --git a/testsuite/smokey/y2038/syscall-tests.c b/testsuite/smokey/y2038/syscall-tests.c
index 990e05c..0ea6ddd 100644
--- a/testsuite/smokey/y2038/syscall-tests.c
+++ b/testsuite/smokey/y2038/syscall-tests.c
@@ -228,6 +228,52 @@ static int test_sc_cobalt_clock_settime64(void)
 	return 0;
 }
 
+static int test_sc_cobalt_clock_nanosleep64(void)
+{
+	long ret;
+	int code = __xn_syscode(sc_cobalt_clock_nanosleep64);
+	struct xn_timespec64 next, rmt;
+	struct timespec now;
+
+	/* Make sure we don't crash because of NULL pointers */
+	ret = syscall(code, NULL, NULL, NULL, NULL);
+	if (ret == -1 && errno == ENOSYS) {
+		smokey_note("clock_nanosleep64: skipped. (no kernel support)");
+		return 0; // Not implemented, nothing to test, success
+	}
+	if (!smokey_assert(ret == -1) || !smokey_assert(errno == EFAULT))
+		return errno;
+
+	/* Provide a valid 64bit timespec*/
+	ret = clock_gettime(CLOCK_MONOTONIC, &now);
+	if (ret) {
+		smokey_warning("clock_gettime failed in clock_nanosleep64.");
+		return errno;
+	}
+
+	/* Providing an invalid address has to deliver EFAULT */
+	ret = syscall(code, CLOCK_MONOTONIC, TIMER_ABSTIME,
+				(void *)0xdeadbeefUL, &rmt);
+	if (!smokey_assert(ret == -1) || !smokey_assert(errno == EFAULT))
+		return errno;
+
+	next.tv_sec  = now.tv_sec + 1;
+	next.tv_nsec = now.tv_nsec;
+
+	ret = syscall(code, CLOCK_MONOTONIC, TIMER_ABSTIME,
+				&next, (void *)0xdeadbeefUL);
+	if (!smokey_assert(ret == -1) || !smokey_assert(errno == EFAULT))
+		return errno;
+
+	next.tv_sec  = next.tv_sec + 1;
+
+	ret = syscall(code, CLOCK_MONOTONIC, TIMER_ABSTIME, &next, &rmt);
+	if (!smokey_assert(!ret))
+		return errno;
+
+	return 0;
+}
+
 static int run_y2038(struct smokey_test *t, int argc, char *const argv[])
 {
 	int ret;
@@ -244,5 +290,9 @@ static int run_y2038(struct smokey_test *t, int argc, char *const argv[])
 	if (ret)
 		return ret;
 
+	ret = test_sc_cobalt_clock_nanosleep64();
+	if (ret)
+		return ret;
+
 	return 0;
 }
-- 
2.7.4



^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-04-27  1:14 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-21  8:38 [PATCH v2 3/3] y2038: testsuite/smokey/y2038: testcase for nanosleep64 Song Chen
2021-04-23 12:48 ` Bezdeka, Florian
2021-04-26 17:05   ` chensong_2000
2021-04-26 11:57     ` Bezdeka, Florian
2021-04-27  1:14       ` chensong_2000
  -- strict thread matches above, loose matches on Subject: below --
2021-04-20  6:25 Song Chen
2021-04-21  6:56 ` Jan Kiszka

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.