diff mbox series

syscalls/shmget03: Stat and skip existing shared segments

Message ID 20210804004216.2754304-1-ian.may@canonical.com
State Rejected
Headers show
Series syscalls/shmget03: Stat and skip existing shared segments | expand

Commit Message

Ian M Aug. 4, 2021, 12:42 a.m. UTC
From: Ian May <ian.s.may@gmail.com>

Run a SHM_STAT prior to the creation of the shared memory segment.
This allows for not failing unexpectedly and still exhausting the
proper max shared segments.

Signed-off-by: Ian May <ian.s.may@gmail.com>
---
 testcases/kernel/syscalls/ipc/shmget/shmget03.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Cyril Hrubis Aug. 5, 2021, 12:08 p.m. UTC | #1
Hi!
Yang Xu is already working on it, see:

http://patchwork.ozlabs.org/project/ltp/list/?series=256752

Thanks for the effort anyway.
Ian M Aug. 5, 2021, 1:53 p.m. UTC | #2
That looks like a good solution!

Thanks,
Ian

On Thu, Aug 5, 2021 at 7:07 AM Cyril Hrubis <chrubis@suse.cz> wrote:

> Hi!
> Yang Xu is already working on it, see:
>
> http://patchwork.ozlabs.org/project/ltp/list/?series=256752
>
> Thanks for the effort anyway.
>
> --
> Cyril Hrubis
> chrubis@suse.cz
>
diff mbox series

Patch

diff --git a/testcases/kernel/syscalls/ipc/shmget/shmget03.c b/testcases/kernel/syscalls/ipc/shmget/shmget03.c
index efbc465e1..fe91b6191 100644
--- a/testcases/kernel/syscalls/ipc/shmget/shmget03.c
+++ b/testcases/kernel/syscalls/ipc/shmget/shmget03.c
@@ -34,6 +34,7 @@  static void verify_shmget(void)
 static void setup(void)
 {
 	int res, num;
+	struct shmid_ds buf;
 
 	shmkey = GETIPCKEY();
 
@@ -41,6 +42,8 @@  static void setup(void)
 
 	queues = SAFE_MALLOC(maxshms * sizeof(int));
 	for (num = 0; num < maxshms; num++) {
+		if(shmctl(num, SHM_STAT, &buf) != -1)
+			continue;
 		res = shmget(shmkey + num, SHM_SIZE, IPC_CREAT | IPC_EXCL | SHM_RW);
 		if (res == -1)
 			tst_brk(TBROK | TERRNO, "shmget failed unexpectedly");