From: Cyril Hrubis <chrubis@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v1 3/4] syscalls/shmget05: Add test for /proc/sys/kernel/shm_next_id
Date: Thu, 22 Jul 2021 13:52:26 +0200 [thread overview]
Message-ID: <YPlb+ogqehyG210l@yuki> (raw)
In-Reply-To: <1620809541-6891-3-git-send-email-xuyang2018.jy@fujitsu.com>
Hi!
First of all, sorry for the late response.
> diff --git a/testcases/kernel/syscalls/ipc/shmget/shmget05.c b/testcases/kernel/syscalls/ipc/shmget/shmget05.c
> new file mode 100644
> index 000000000..601609648
> --- /dev/null
> +++ b/testcases/kernel/syscalls/ipc/shmget/shmget05.c
> @@ -0,0 +1,69 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +/*
> + * Copyright (c) 2021 FUJITSU LIMITED. All rights reserved.
> + * Author: Yang Xu <xuyang2018.jy@fujitsu.com>
> + */
> +
> +/*\
> + * [Description]
> + *
> + * It is a basic test about shm_next_id.
^
for
> + *
> + * shm_next_id specifies desired id for next allocated IPC shared memory. By
> + * default they are equal to -1, which means generic allocation logic.
^
it's instead of 'they are'
> + * Possible values to set are in range {0..INT_MAX}.
> + * Toggle with non-default value will be set back to -1 by kernel after
This would probably be better with just: "The value will be set back ..."
> + * successful IPC object allocation.
> + */
> +
> +#include <errno.h>
> +#include <string.h>
> +#include <sys/types.h>
> +#include <sys/ipc.h>
> +#include <sys/shm.h>
> +#include "tst_test.h"
> +#include "tst_safe_sysv_ipc.h"
> +#include "libnewipc.h"
> +
> +#define NEXT_ID_PATH "/proc/sys/kernel/shm_next_id"
> +static int shm_id, pid;
> +static key_t shmkey;
> +
> +static void verify_shmget(void)
> +{
> + SAFE_FILE_PRINTF(NEXT_ID_PATH, "%d", pid);
> +
> + shm_id = SAFE_SHMGET(shmkey, SHM_SIZE, SHM_RW | IPC_CREAT);
> + if (shm_id == pid)
> + tst_res(TPASS, "shm_next_id succeeded, shm id %d", pid);
> + else
> + tst_res(TFAIL, "shm_next_id failed, expected id %d, but got %d", pid, shm_id);
> +
> + TST_ASSERT_INT(NEXT_ID_PATH, -1);
> + SAFE_SHMCTL(shm_id, IPC_RMID, NULL);
> + pid++;
> +}
> +
> +static void setup(void)
> +{
> + shmkey = GETIPCKEY();
> + pid = getpid();
> +}
> +
> +static void cleanup(void)
> +{
> + if (shm_id != -1)
> + SAFE_SHMCTL(shm_id, IPC_RMID, NULL);
> +}
> +
> +static struct tst_test test = {
> + .needs_tmpdir = 1,
I guess that we want this for the GETIPCKEY() right?
> + .setup = setup,
> + .cleanup = cleanup,
> + .test_all = verify_shmget,
> + .needs_kconfigs = (const char *[]) {
> + "CONFIG_CHECKPOINT_RESTORE=y",
> + NULL
> + },
> + .needs_root = 1,
> +};
Looks good.
With the minor adjustements in the test description:
Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
--
Cyril Hrubis
chrubis@suse.cz
next prev parent reply other threads:[~2021-07-22 11:52 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-12 8:52 [LTP] [PATCH v1 1/4] syscalls/shmget01: Remove it Yang Xu
2021-05-12 8:52 ` [LTP] [PATCH v1 2/4] syscalls/shmget*: Convert into new api Yang Xu
2021-05-12 10:44 ` xuyang2018.jy
2021-06-03 9:49 ` xuyang2018.jy
2021-06-18 14:28 ` Cyril Hrubis
2021-06-21 9:48 ` xuyang2018.jy
2021-06-22 8:31 ` [LTP] [PATCH v2] " Yang Xu
2021-06-23 13:35 ` Cyril Hrubis
2021-06-24 3:46 ` xuyang2018.jy
2021-05-12 8:52 ` [LTP] [PATCH v1 3/4] syscalls/shmget05: Add test for /proc/sys/kernel/shm_next_id Yang Xu
2021-06-29 3:25 ` xuyang2018.jy
2021-07-12 2:37 ` xuyang2018.jy
2021-07-22 11:52 ` Cyril Hrubis [this message]
2021-07-23 9:10 ` xuyang2018.jy
2021-05-12 8:52 ` [LTP] [PATCH v1 4/4] syscalls/shmget06: Add test when the id of shm_next_id has existed Yang Xu
2021-07-22 12:08 ` Cyril Hrubis
2021-07-23 9:15 ` xuyang2018.jy
2021-07-23 9:41 ` [LTP] [PATCH v2 1/2] syscalls/shmget05: Add test for /proc/sys/kernel/shm_next_id Yang Xu
2021-07-23 9:42 ` [LTP] [PATCH v2 2/2] syscalls/shmget06: Add test when shm_next_id is already in use Yang Xu
2021-07-27 2:13 ` xuyang2018.jy
2021-06-18 12:54 ` [LTP] [PATCH v1 1/4] syscalls/shmget01: Remove it Cyril Hrubis
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=YPlb+ogqehyG210l@yuki \
--to=chrubis@suse.cz \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox