All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH 3/5] syscalls: semctl: Add new test to verify the _time_high fields
Date: Thu, 21 May 2020 15:20:46 +0200	[thread overview]
Message-ID: <CAK8P3a0pxv5wauMcf223n=_7zNJ4mn1Y0WvcssFC13pcvz9wmQ@mail.gmail.com> (raw)
In-Reply-To: <5d502fbc7070644ed83c423713941b457c3a7aff.1590057824.git.viresh.kumar@linaro.org>

On Thu, May 21, 2020 at 12:48 PM Viresh Kumar <viresh.kumar@linaro.org> wrote:
>
> The _time_high fields must be reset by the kernel, add a test to verify
> that.
>
> Suggested-by: Arnd Bergmann <arnd@arndb.de>
> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>

Right, here you do need to copy the struct definitions since I forgot
to add a way to detect the presence in the kernel header files,
sorry about that.

Possibly you could just have a check in the Makefile that lets
skips the test if it fails to build because of old kernel headers?
Or maybe check LINUX_VERSION_CODE to see if the headers
are at least from linux-4.19?

>  configure.ac                                  |   1 +
>  include/sembuf.h                              | 234 ++++++++++++++++++
>  runtest/syscalls                              |   1 +
>  runtest/syscalls-ipc                          |   1 +
>  testcases/kernel/syscalls/ipc/msgctl/msgctl05 | Bin 0 -> 498784 bytes

stale file

> +       /* get an IPC resource key */
> +       key = GETIPCKEY();
> +
> +       semid = semget(key, 1, SEM_RA | IPC_CREAT);
> +       if (semid == -1)
> +               tst_brk(TBROK | TERRNO, "couldn't create semaphore");
> +
> +       arg.buf = (struct semid_ds *)&buf_ds;
> +       TEST(semctl(semid, 0, IPC_STAT, arg));
> +       if (TST_RET == -1)
> +               tst_brk(TFAIL | TTERRNO, "semctl() failed");
> +
> +       if (buf_ds.sem_otime_high || buf_ds.sem_ctime_high)
> +               tst_res(TFAIL, "time_high fields aren't cleared by the kernel");
> +       else
> +               tst_res(TPASS, "time_high fields cleared by the kernel");
> +
> +       if (semctl(semid, 0, IPC_RMID, arg) == -1)
> +               tst_res(TINFO, "WARNING: semaphore deletion failed.");
> +}

The test looks good to me.

If we wanted to get fancy, you could check that the time is actually
correct when setting the system clock past y2038 with clock_settime64()
at the start and then setting it back at the end.
That might risk crashing the system though, depending what else
is running at the same time that relies on the time fitting into
a 32-bit time_t.

     Arnd

  reply	other threads:[~2020-05-21 13:20 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-21 10:47 [LTP] [PATCH 0/5] syscalls: Add tests to verify the _time_high fields Viresh Kumar
2020-05-21 10:47 ` [LTP] [PATCH 1/5] syscalls:ipc: Move libraries to libs/ director Viresh Kumar
2020-05-22 12:39   ` Cyril Hrubis
2020-05-26  3:08     ` Viresh Kumar
2020-05-29  5:39       ` Yang Xu
2020-06-15 12:20       ` Cyril Hrubis
2020-05-21 10:47 ` [LTP] [PATCH 2/5] include: Add declaration of struct ipc64_perm Viresh Kumar
2020-05-21 13:11   ` Arnd Bergmann
2020-05-22  7:10     ` Viresh Kumar
2020-05-22  7:16   ` [LTP] [PATCH V2 " Viresh Kumar
2020-06-15 12:43     ` Cyril Hrubis
2020-06-16  6:41       ` Viresh Kumar
2020-06-16  9:53         ` Cyril Hrubis
2020-06-16 18:56   ` [LTP] [PATCH " Petr Vorel
2020-05-21 10:47 ` [LTP] [PATCH 3/5] syscalls: semctl: Add new test to verify the _time_high fields Viresh Kumar
2020-05-21 13:20   ` Arnd Bergmann [this message]
2020-05-21 14:26     ` Cyril Hrubis
2020-05-22  7:12       ` Viresh Kumar
2020-05-22  7:16   ` [LTP] [PATCH V2 " Viresh Kumar
2020-06-15 13:31     ` Cyril Hrubis
2020-06-16  6:40       ` Viresh Kumar
2020-06-16  9:52         ` Cyril Hrubis
2020-06-16 10:09           ` Viresh Kumar
2020-06-16 12:41             ` Cyril Hrubis
2020-05-21 10:47 ` [LTP] [PATCH 4/5] syscalls: shmctl: " Viresh Kumar
2020-06-15 13:33   ` Cyril Hrubis
2020-05-21 10:47 ` [LTP] [PATCH 5/5] syscalls: msgctl: " Viresh Kumar
2020-06-15 13:38   ` Cyril Hrubis
2020-05-21 13:08 ` [LTP] [PATCH 0/5] syscalls: Add tests " Arnd Bergmann
2020-05-21 14:25   ` Cyril Hrubis
2020-05-21 14:29     ` Cyril Hrubis
2020-05-22  9:08     ` Viresh Kumar

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='CAK8P3a0pxv5wauMcf223n=_7zNJ4mn1Y0WvcssFC13pcvz9wmQ@mail.gmail.com' \
    --to=arnd@arndb.de \
    --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.