All of lore.kernel.org
 help / color / mirror / Atom feed
From: Florian Bezdeka <florian.bezdeka@siemens.com>
To: Song Chen <chensong_2000@189.cn>, xenomai@xenomai.org
Subject: Re: [PATCH 3/3] y2038: testsuite/smokey/y2038: testcase for adjtime64
Date: Tue, 1 Jun 2021 14:16:16 +0200	[thread overview]
Message-ID: <ada790d9-2a5d-d722-ee36-a1ef06986975@siemens.com> (raw)
In-Reply-To: <1619682320-16309-1-git-send-email-chensong_2000@189.cn>

On 29.04.21 09:45, Song Chen wrote:
> add test case for clock_adjtime64 in testsuite
> 
> Signed-off-by: Song Chen <chensong_2000@189.cn>
> ---
>  testsuite/smokey/y2038/syscall-tests.c | 71 ++++++++++++++++++++++++++++++++++
>  1 file changed, 71 insertions(+)
> 
> diff --git a/testsuite/smokey/y2038/syscall-tests.c b/testsuite/smokey/y2038/syscall-tests.c
> index c59a9d6..22fd9b6 100644
> --- a/testsuite/smokey/y2038/syscall-tests.c
> +++ b/testsuite/smokey/y2038/syscall-tests.c
> @@ -25,6 +25,43 @@ struct xn_timespec64 {
>  	int64_t tv_nsec;
>  };
>  
> +struct xn_timex_timeval {
> +	int64_t tv_sec;
> +	int64_t	tv_usec;
> +};
> +
> +struct xn_timex64 {
> +	unsigned int modes;	/* mode selector */
> +	int:32;            /* pad */
> +	long long offset;	/* time offset (usec) */
> +	long long freq;	/* frequency offset (scaled ppm) */
> +	long long maxerror;/* maximum error (usec) */
> +	long long esterror;/* estimated error (usec) */
> +	int status;		/* clock command/status */
> +	int:32;            /* pad */
> +	long long constant;/* pll time constant */
> +	long long precision;/* clock precision (usec) (read only) */
> +	long long tolerance;/* clock frequency tolerance (ppm) (read only) */
> +	struct xn_timex_timeval time;	/* (read only, except for ADJ_SETOFFSET) */
> +	long long tick;	/* (modified) usecs between clock ticks */
> +
> +	long long ppsfreq;/* pps frequency (scaled ppm) (ro) */
> +	long long jitter; /* pps jitter (us) (ro) */
> +	int shift;              /* interval duration (s) (shift) (ro) */
> +	int:32;            /* pad */
> +	long long stabil;            /* pps stability (scaled ppm) (ro) */
> +	long long jitcnt; /* jitter limit exceeded (ro) */
> +	long long calcnt; /* calibration intervals (ro) */
> +	long long errcnt; /* calibration errors (ro) */
> +	long long stbcnt; /* stability limit exceeded (ro) */
> +
> +	int tai;		/* TAI offset (ro) */
> +
> +	int:32; int:32; int:32; int:32;
> +	int:32; int:32; int:32; int:32;
> +	int:32; int:32; int:32;
> +};
> +
>  #define NSEC_PER_SEC 1000000000
>  
>  static void ts_normalise(struct xn_timespec64 *ts)
> @@ -326,6 +363,36 @@ static int test_sc_cobalt_clock_getres64(void)
>  	return 0;
>  }
>  
> +static int test_sc_cobalt_clock_adjtime64(void)
> +{
> +	long ret;
> +	int code = __xn_syscode(sc_cobalt_clock_adjtime64);
> +	struct xn_timex64 tx64 = {};
> +
> +	/* Make sure we don't crash because of NULL pointers */
> +	ret = syscall(code, NULL, NULL);
> +	if (ret == -1 && errno == ENOSYS) {
> +		smokey_note("clock_adjtime64: skipped. (no kernel support)");
> +		return 0; // Not implemented, nothing to test, success
> +	}
> +	if (!smokey_assert(ret == -1) || !smokey_assert(errno == EFAULT))
> +		return errno;
> +
> +	/* Providing an invalid address has to deliver EFAULT */
> +	ret = syscall(code, CLOCK_REALTIME, (void *)0xdeadbeefUL);
> +	if (!smokey_assert(ret == -1) || !smokey_assert(errno == EFAULT))
> +		return errno;
> +
> +	/* Provide a valid 64bit timex*/
> +	tx64.modes = ADJ_SETOFFSET;
> +	tx64.time.tv_usec = 123;
> +	ret = syscall(code, CLOCK_REALTIME, &tx64);

In int __cobalt_clock_adjtime() we have

	switch (clock_id) {
	case CLOCK_REALTIME:
	case CLOCK_MONOTONIC:
	case CLOCK_MONOTONIC_RAW:
	case CLOCK_HOST_REALTIME:
		return -EOPNOTSUPP;

So the test-failure I see on x86 is fully expected. How did you get this
test running successfully?


> +	if (!smokey_assert(!ret))
> +		return errno;
> +
> +	return 0;
> +}
> +
>  static int run_y2038(struct smokey_test *t, int argc, char *const argv[])
>  {
>  
> @@ -351,5 +418,9 @@ static int run_y2038(struct smokey_test *t, int argc, char *const argv[])
>  	if (ret)
>  		return ret;
>  
> +	ret = test_sc_cobalt_clock_adjtime64();
> +	if (ret)
> +		return ret;
> +
>  	return 0;
>  }
> 


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


  reply	other threads:[~2021-06-01 12:16 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-29  7:45 [PATCH 3/3] y2038: testsuite/smokey/y2038: testcase for adjtime64 Song Chen
2021-06-01 12:16 ` Florian Bezdeka [this message]
2021-06-02  5:55   ` chensong_2000
2021-06-02  6:46     ` Florian Bezdeka
2021-06-02  6:59       ` chensong_2000
2021-06-02  8:01         ` Bezdeka, Florian
2021-06-02  8:32           ` chensong_2000

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=ada790d9-2a5d-d722-ee36-a1ef06986975@siemens.com \
    --to=florian.bezdeka@siemens.com \
    --cc=chensong_2000@189.cn \
    --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.