From: Petr Vorel <pvorel@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH 1/1] shmget03: Consider already mapped segments
Date: Thu, 22 Jul 2021 09:44:31 +0200 [thread overview]
Message-ID: <YPkh31qJKJflPdGv@pevik> (raw)
In-Reply-To: <20210722073523.5099-1-pvorel@suse.cz>
Hi,
ok, Alexey already send [1] few weeks ago a different approach to fix this, which is
better, please ignore this.
[1] https://patchwork.ozlabs.org/project/ltp/patch/20210712075223.10682-1-aleksei.kodanev@bell-sw.com/
> This fixes running test on systems with already mapped segments.
> Test expected that no segment was already mapped, thus reached the
> maximum earlier:
> $ ipcs -m
> ------ Shared Memory Segments --------
> key shmid owner perms bytes nattch status
> 0x62001fae 0 root 660 4124096 1
> ./shmget03
> tst_test.c:1344: TINFO: Timeout per run is 0h 05m 00s
> shmget03.c:46: TBROK: shmget failed unexpectedly: ENOSPC (28)
> Signed-off-by: Petr Vorel <pvorel@suse.cz>
> ---
> Hi,
> I suppose we don't want to factor out the code counting lines and put it
> into safe_file_ops.c.
> Kind regards,
> Petr
> testcases/kernel/syscalls/ipc/shmget/shmget03.c | 16 ++++++++++++++++
> 1 file changed, 16 insertions(+)
> diff --git a/testcases/kernel/syscalls/ipc/shmget/shmget03.c b/testcases/kernel/syscalls/ipc/shmget/shmget03.c
> index efbc465e1..57130e993 100644
> --- a/testcases/kernel/syscalls/ipc/shmget/shmget03.c
> +++ b/testcases/kernel/syscalls/ipc/shmget/shmget03.c
> @@ -14,15 +14,19 @@
> #include <errno.h>
> #include <sys/types.h>
> #include <sys/ipc.h>
> +#include <stdio.h>
> #include <stdlib.h>
> #include <pwd.h>
> #include <sys/shm.h>
> #include "tst_test.h"
> #include "tst_safe_sysv_ipc.h"
> +#include "tst_safe_stdio.h"
> #include "libnewipc.h"
> static int *queues;
> static int maxshms, queue_cnt;
> +static int mapped_shms = -1;
> +static FILE *f = NULL;
> static key_t shmkey;
> static void verify_shmget(void)
> @@ -34,10 +38,19 @@ static void verify_shmget(void)
> static void setup(void)
> {
> int res, num;
> + char c;
> shmkey = GETIPCKEY();
> + f = SAFE_FOPEN("/proc/sysvipc/shm", "r");
> + while ((c = fgetc(f)) != EOF) {
> + if (c == '\n')
> + mapped_shms++;
> + }
> + tst_res(TINFO, "Already mapped shared memory segments: %d", mapped_shms);
> +
> SAFE_FILE_SCANF("/proc/sys/kernel/shmmni", "%i", &maxshms);
> + maxshms -= mapped_shms;
> queues = SAFE_MALLOC(maxshms * sizeof(int));
> for (num = 0; num < maxshms; num++) {
> @@ -62,6 +75,9 @@ static void cleanup(void)
> SAFE_SHMCTL(queues[num], IPC_RMID, NULL);
> free(queues);
> +
> + if (f)
> + SAFE_FCLOSE(f);
> }
> static struct tst_test test = {
prev parent reply other threads:[~2021-07-22 7:44 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-22 7:35 [LTP] [PATCH 1/1] shmget03: Consider already mapped segments Petr Vorel
2021-07-22 7:44 ` Petr Vorel [this message]
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=YPkh31qJKJflPdGv@pevik \
--to=pvorel@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