All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@siemens.com>
To: Florian Bezdeka <florian.bezdeka@siemens.com>,
	xenomai@xenomai.org, Philippe Gerum <rpm@xenomai.org>
Cc: chensong@tj.kylinos.cn
Subject: Re: [PATCH 9/9] y2038: testsuite/smokey/y2038: Adding testcase for nanosleep64
Date: Fri, 4 Jun 2021 14:21:15 +0200	[thread overview]
Message-ID: <2917f21e-6cc2-099f-076d-0c584d5349c8@siemens.com> (raw)
In-Reply-To: <b45b901f-27f2-9770-de39-2a54396989c1@siemens.com>

On 04.06.21 14:05, Jan Kiszka wrote:
> On 04.06.21 13:43, Jan Kiszka via Xenomai wrote:
>> On 04.06.21 13:41, Jan Kiszka via Xenomai wrote:
>>> On 01.06.21 11:43, Florian Bezdeka wrote:
>>>> From: chensong <chensong@tj.kylinos.cn>
>>>>
>>>> Add test case for clock_nanosleep64 in smokey testsuite
>>>>
>>>> Signed-off-by: chensong <chensong@tj.kylinos.cn>
>>>> [Florian: Reword commit msg, syscall()->XENOMAI_SYSCALLx()]
>>>> Signed-off-by: Florian Bezdeka <florian.bezdeka@siemens.com>
>>>> ---
>>>>  testsuite/smokey/y2038/syscall-tests.c | 67 ++++++++++++++++++++++++++
>>>>  1 file changed, 67 insertions(+)
>>>>
>>>> diff --git a/testsuite/smokey/y2038/syscall-tests.c b/testsuite/smokey/y2038/syscall-tests.c
>>>> index 840be89a5..54d529b6b 100644
>>>> --- a/testsuite/smokey/y2038/syscall-tests.c
>>>> +++ b/testsuite/smokey/y2038/syscall-tests.c
>>>> @@ -242,6 +242,69 @@ static int test_sc_cobalt_clock_settime64(void)
>>>>  	return 0;
>>>>  }
>>>>  
>>>> +static int test_sc_cobalt_clock_nanosleep64(void)
>>>> +{
>>>> +	int ret;
>>>> +	int sc_nr = sc_cobalt_clock_nanosleep64;
>>>> +	struct xn_timespec64 next, rmt;
>>>> +	struct timespec ts1, ts2, delta;
>>>> +	long interval = 1;
>>>> +
>>>> +	/* Make sure we don't crash because of NULL pointers */
>>>> +	ret = XENOMAI_SYSCALL4(sc_nr, NULL, NULL, NULL, NULL);
>>>> +	if (ret == -ENOSYS) {
>>>> +		smokey_note("clock_nanosleep64: skipped. (no kernel support)");
>>>> +		return 0; // Not implemented, nothing to test, success
>>>> +	}
>>>> +	if (!smokey_assert(ret == -EFAULT))
>>>> +		return ret ? ret : -EINVAL;
>>>> +
>>>> +	/* Providing an invalid address has to deliver EFAULT */
>>>> +	ret = XENOMAI_SYSCALL4(sc_nr, CLOCK_MONOTONIC, TIMER_ABSTIME,
>>>> +			       (void *)0xdeadbeefUL, &rmt);
>>>> +	if (!smokey_assert(ret == -EFAULT))
>>>> +		return ret ? ret : -EINVAL;
>>>> +
>>>> +	/* Provide a valid 64bit timespec, round 1 */
>>>> +	ret = clock_gettime(CLOCK_MONOTONIC, &ts1);
>>>> +	if (ret)
>>>> +		return -errno;
>>>> +
>>>> +	next.tv_sec  = ts1.tv_sec + interval;
>>>> +	next.tv_nsec = ts1.tv_nsec;
>>>> +
>>>> +	ret = XENOMAI_SYSCALL4(sc_nr, CLOCK_MONOTONIC, TIMER_ABSTIME,
>>>> +			       &next, (void *)0xdeadbeefUL);
>>>> +	if (!smokey_assert(!ret))
>>>> +		return ret ? ret : -EINVAL;
>>>
>>> Unneeded test here - ret is != 0.
>>>
>>>> +
>>>> +	ret = clock_gettime(CLOCK_MONOTONIC, &ts2);
>>>> +	if (ret)
>>>> +		return -errno;
>>>> +
>>>> +	timespec_sub(&delta, &ts2, &ts1);
>>>> +	if (delta.tv_sec < interval)
>>>> +		smokey_warning("nanosleep didn't sleep long enough.");
>>>> +
>>>> +	/* Provide a valid 64bit timespec, round 2*/
>>>> +	next.tv_sec  = ts2.tv_sec + interval;
>>>> +	next.tv_nsec = ts2.tv_nsec;
>>>> +
>>>> +	ret = XENOMAI_SYSCALL4(sc_nr, CLOCK_MONOTONIC, TIMER_ABSTIME, &next, &rmt);
>>>> +	if (!smokey_assert(!ret))
>>>> +		return ret ? ret : -EINVAL;
>>>
>>> Same here.
>>>
>>> I can fix those up - once I understood why they trigger here ATM.
>>>
>>
>> In fact, if we want to return the real error, errno needs to be
>> consulted. What is the intention then?
> 
> Err, no, it's direct syscall invocation, no errno at this point yet.
> 
> Found the reason for the failing test meanwhile: I was on wip/dovetail
> already, and there we have
> 
> static inline int pipeline_set_wallclock(xnticks_t epoch_ns)
> {
> 	return -EOPNOTSUPP;
> }
> 
> Philippe, any particular reason for this?
> 

...because of

COBALT_IMPL(int, clock_settime, (clockid_t clock_id, const struct timespec *tp))
{
	int ret;

	if (clock_id == CLOCK_REALTIME && !cobalt_use_legacy_tsc())
		return __STD(clock_settime(CLOCK_REALTIME, tp));


IOW, that set settime64 syscall is I-pipe only.

Florian, we need to adjust the test case accordingly for dovetail.

Jan

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


  reply	other threads:[~2021-06-04 12:21 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-01  9:43 [PATCH 0/9] y2038: clock_{g,s}ettime64, clock_nanosleep64 Florian Bezdeka
2021-06-01  9:43 ` [PATCH 1/9] y2038: libcobalt: Centralize sc_cobalt_clock_gettime syscall Florian Bezdeka
2021-06-01  9:43 ` [PATCH 2/9] y2038: cobalt/posix/clock: Adding clock_gettime64 Florian Bezdeka
2021-06-01  9:43 ` [PATCH 3/9] y2038: cobalt/posix/clock: Adding clock_settime64 Florian Bezdeka
2021-06-01  9:43 ` [PATCH 4/9] y2038: lib/cobalt/clock: dispatch clock_gettime Florian Bezdeka
2021-06-01  9:43 ` [PATCH 5/9] y2038: lib/cobalt/clock: dispatch clock_settime Florian Bezdeka
2021-06-01  9:43 ` [PATCH 6/9] y2038: testsuite/smokey/y2038: testcase for settime64 and gettime64 Florian Bezdeka
2021-06-01  9:43 ` [PATCH 7/9] y2038: cobalt/posix/clock: Adding clock_nanosleep64 Florian Bezdeka
2021-06-01  9:43 ` [PATCH 8/9] y2038: lib/cobalt/clock: dispatch clock_nanosleep Florian Bezdeka
2021-06-01  9:43 ` [PATCH 9/9] y2038: testsuite/smokey/y2038: Adding testcase for nanosleep64 Florian Bezdeka
2021-06-04 11:41   ` Jan Kiszka
2021-06-04 11:43     ` Jan Kiszka
2021-06-04 12:05       ` Jan Kiszka
2021-06-04 12:21         ` Jan Kiszka [this message]
2021-06-04 12:45         ` Philippe Gerum
2021-06-04 12:07 ` [PATCH 0/9] y2038: clock_{g,s}ettime64, clock_nanosleep64 Jan Kiszka

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2917f21e-6cc2-099f-076d-0c584d5349c8@siemens.com \
    --to=jan.kiszka@siemens.com \
    --cc=chensong@tj.kylinos.cn \
    --cc=florian.bezdeka@siemens.com \
    --cc=rpm@xenomai.org \
    --cc=xenomai@xenomai.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.