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
Cc: chensong@tj.kylinos.cn
Subject: Re: [PATCH 9/9] y2038: testsuite/smokey/y2038: Adding testcase for nanosleep64
Date: Fri, 4 Jun 2021 13:41:21 +0200	[thread overview]
Message-ID: <e7724a84-cf55-20df-d8ed-fcc79a2772f1@siemens.com> (raw)
In-Reply-To: <20210601094334.774394-10-florian.bezdeka@siemens.com>

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.

Jan

> +
> +	ret = clock_gettime(CLOCK_MONOTONIC, &ts1);
> +	if (ret)
> +		return -errno;
> +
> +	timespec_sub(&delta, &ts1, &ts2);
> +	if (delta.tv_sec < interval)
> +		smokey_warning("nanosleep didn't sleep long enough.");
> +
> +	return 0;
> +}
> +
>  static int run_y2038(struct smokey_test *t, int argc, char *const argv[])
>  {
>  	int ret;
> @@ -258,5 +321,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;
>  }
> 


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


  reply	other threads:[~2021-06-04 11:41 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 [this message]
2021-06-04 11:43     ` Jan Kiszka
2021-06-04 12:05       ` Jan Kiszka
2021-06-04 12:21         ` Jan Kiszka
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=e7724a84-cf55-20df-d8ed-fcc79a2772f1@siemens.com \
    --to=jan.kiszka@siemens.com \
    --cc=chensong@tj.kylinos.cn \
    --cc=florian.bezdeka@siemens.com \
    --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.