All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH 2/2] syscalls: shift to time() if __NR_time not support
Date: Tue, 24 Nov 2020 10:56:26 +0800	[thread overview]
Message-ID: <5FBC765A.3020102@cn.fujitsu.com> (raw)
In-Reply-To: <20201123083137.11575-2-liwang@redhat.com>

Hi Li

I have seen this patchset, Can we use a function to check whether kernel 
supports time syscall (like time_supported_by_kernel()) in setup
and then we use time() - !return value in verify funtion?
> On some platforms(aarch64) __NR_time is not supported, if that happens,
> go back to invoke time() and relax 1-second in low bound for comparing.
>
> This also to fix:
>    TFAIL: msg_stime = 1605730573 out of [1605730574, 1605730574]
>
> Signed-off-by: Li Wang<liwang@redhat.com>
> Cc: Chunyu Hu<chuhu@redhat.com>
> Cc: Cyril Hrubis<chrubis@suse.cz>
> ---
>   testcases/kernel/syscalls/ipc/msgrcv/msgrcv01.c | 14 ++++++++++++--
>   testcases/kernel/syscalls/ipc/msgsnd/msgsnd01.c | 14 ++++++++++++--
>   testcases/kernel/syscalls/ipc/shmctl/shmctl01.c | 14 ++++++++++++--
>   3 files changed, 36 insertions(+), 6 deletions(-)
>
> diff --git a/testcases/kernel/syscalls/ipc/msgrcv/msgrcv01.c b/testcases/kernel/syscalls/ipc/msgrcv/msgrcv01.c
> index 6fdc47dc3..9dc778ca7 100644
> --- a/testcases/kernel/syscalls/ipc/msgrcv/msgrcv01.c
> +++ b/testcases/kernel/syscalls/ipc/msgrcv/msgrcv01.c
> @@ -26,13 +26,23 @@ static void verify_msgrcv(void)
>
>   	SAFE_MSGSND(queue_id,&snd_buf, MSGSIZE, 0);
>
> -	tst_syscall(__NR_time,&before_rcv);
> +	before_rcv = syscall(__NR_time, NULL);
> +	if (before_rcv == -1&&  errno == ENOSYS) {
> +		tst_res(TINFO, "__NR_time not supported");
> +		before_rcv = time(NULL) - 1;
> +	}
> +
>   	TEST(msgrcv(queue_id,&rcv_buf, MSGSIZE, 1, 0));
>   	if (TST_RET == -1) {
>   		tst_res(TFAIL | TTERRNO, "msgrcv failed");
>   		return;
>   	}
> -	tst_syscall(__NR_time,&after_rcv);
> +
> +	after_rcv = syscall(__NR_time, NULL);
> +	if (after_rcv == -1&&  errno == ENOSYS) {
> +		tst_res(TINFO, "__NR_time not supported");
> +		after_rcv = time(NULL);
> +	}
>
>   	if (strcmp(rcv_buf.mtext, snd_buf.mtext) == 0)
>   		tst_res(TPASS, "message received(%s) = message sent(%s)",
> diff --git a/testcases/kernel/syscalls/ipc/msgsnd/msgsnd01.c b/testcases/kernel/syscalls/ipc/msgsnd/msgsnd01.c
> index 9101f2668..27464e79f 100644
> --- a/testcases/kernel/syscalls/ipc/msgsnd/msgsnd01.c
> +++ b/testcases/kernel/syscalls/ipc/msgsnd/msgsnd01.c
> @@ -30,13 +30,23 @@ static void verify_msgsnd(void)
>   	struct msqid_ds qs_buf;
>   	time_t before_snd, after_snd;
>
> -	tst_syscall(__NR_time,&before_snd);
> +	before_snd = syscall(__NR_time, NULL);
> +	if (before_snd == -1&&  errno == ENOSYS) {
> +		tst_res(TINFO, "__NR_time not supported");
> +		before_snd = time(NULL) - 1;
> +	}
> +
>   	TEST(msgsnd(queue_id,&snd_buf, MSGSIZE, 0));
>   	if (TST_RET == -1) {
>   		tst_res(TFAIL | TTERRNO, "msgsnd() failed");
>   		return;
>   	}
> -	tst_syscall(__NR_time,&after_snd);
> +
> +	after_snd = syscall(__NR_time, NULL);
> +	if (after_snd == -1&&  errno == ENOSYS) {
> +		tst_res(TINFO, "__NR_time not supported");
> +		after_snd = time(NULL);
> +	}
>
>   	SAFE_MSGCTL(queue_id, IPC_STAT,&qs_buf);
>
> diff --git a/testcases/kernel/syscalls/ipc/shmctl/shmctl01.c b/testcases/kernel/syscalls/ipc/shmctl/shmctl01.c
> index f5b8eaef9..356513726 100644
> --- a/testcases/kernel/syscalls/ipc/shmctl/shmctl01.c
> +++ b/testcases/kernel/syscalls/ipc/shmctl/shmctl01.c
> @@ -241,9 +241,19 @@ static int get_shm_idx_from_id(int shm_id)
>
>   static void setup(void)
>   {
> -	ctime_min = tst_syscall(__NR_time, NULL);
> +	ctime_min = syscall(__NR_time, NULL);
> +	if (ctime_min == -1&&  errno == ENOSYS) {
> +		tst_res(TINFO, "__NR_time not supported");
> +		ctime_min = time(NULL) - 1;
> +	}
> +
>   	shm_id = SAFE_SHMGET(IPC_PRIVATE, SHM_SIZE, IPC_CREAT | SHM_RW);
> -	ctime_max = tst_syscall(__NR_time, NULL);
> +
> +	ctime_max = syscall(__NR_time, NULL);
> +	if (ctime_max == -1&&  errno == ENOSYS) {
> +		tst_res(TINFO, "__NR_time not supported");
> +		ctime_max = time(NULL);
> +	}
>
>   	shm_idx = get_shm_idx_from_id(shm_id);
>




  reply	other threads:[~2020-11-24  2:56 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-23  8:31 [LTP] [PATCH 1/2] syscalls: avoid time() using __cvdso_gettimeofday in use-level's VDSO Li Wang
2020-11-23  8:31 ` [LTP] [PATCH 2/2] syscalls: shift to time() if __NR_time not support Li Wang
2020-11-24  2:56   ` Yang Xu [this message]
2020-11-24  7:57     ` Li Wang
2020-11-24 10:24       ` Yang Xu
2020-11-24 15:38 ` [LTP] [PATCH 1/2] syscalls: avoid time() using __cvdso_gettimeofday in use-level's VDSO Cyril Hrubis
2020-11-25 11:32   ` Thomas Gleixner
2020-11-25 11:32     ` [LTP] " Thomas Gleixner
2020-11-25 12:35     ` Cyril Hrubis
2020-11-25 12:35       ` [LTP] " Cyril Hrubis
2020-11-26 11:36     ` Vincenzo Frascino
2020-11-26 11:36       ` [LTP] " Vincenzo Frascino

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=5FBC765A.3020102@cn.fujitsu.com \
    --to=xuyang2018.jy@cn.fujitsu.com \
    --cc=ltp@lists.linux.it \
    /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.