* [LTP] [PATCH] shmctl01: don't use hardcoded index == 0 for SHM_STAT test
@ 2019-05-20 19:08 Jan Stancek
2019-05-20 19:58 ` Petr Vorel
2019-05-21 9:58 ` Cyril Hrubis
0 siblings, 2 replies; 6+ messages in thread
From: Jan Stancek @ 2019-05-20 19:08 UTC (permalink / raw)
To: ltp
Test fails on SHM_STAT testcase:
shmctl01 5 TFAIL : shmctl01.c:173: shmctl01 call failed
errno = 22 : Invalid argument
shmctl(0, SHM_STAT, 0x601060) = -EINVAL
since following commit:
commit 99db46ea292780cd978d56932d9445b1e8bdafe8
Author: Manfred Spraul <manfred@colorfullife.com>
Date: Tue May 14 15:46:36 2019 -0700
ipc: do cyclic id allocation for the ipc object.
Don't rely on index 0 being always available, but instead
use (maximum) index returned by SHM_INFO.
Signed-off-by: Jan Stancek <jstancek@redhat.com>
---
testcases/kernel/syscalls/ipc/shmctl/shmctl01.c | 21 ++++++++++++++++++---
1 file changed, 18 insertions(+), 3 deletions(-)
diff --git a/testcases/kernel/syscalls/ipc/shmctl/shmctl01.c b/testcases/kernel/syscalls/ipc/shmctl/shmctl01.c
index 1b46977554d5..52bf23a40fc1 100644
--- a/testcases/kernel/syscalls/ipc/shmctl/shmctl01.c
+++ b/testcases/kernel/syscalls/ipc/shmctl/shmctl01.c
@@ -79,6 +79,7 @@ static void func_info(int ret);
/* Check routine for SHM_STAT */
static void func_sstat(int ret);
+static void func_sstat_setup(void);
/* Check routine for SHM_LOCK */
static void func_lock(int ret);
@@ -110,7 +111,7 @@ static struct test_case_t {
#endif
{&shm_id_1, IPC_SET, &buf, func_set, set_setup},
{&shm_id_1, IPC_INFO, (struct shmid_ds *) &info, func_info, NULL},
- {&shm_index, SHM_STAT, &buf, func_sstat, NULL},
+ {&shm_index, SHM_STAT, &buf, func_sstat, func_sstat_setup},
{&shm_id_1, SHM_LOCK, NULL, func_lock, NULL},
{&shm_id_1, SHM_UNLOCK, NULL, func_unlock, NULL},
{&shm_id_1, IPC_RMID, NULL, func_rmid, NULL},
@@ -407,9 +408,23 @@ static void func_info(int ret)
static void func_sstat(int ret)
{
if (ret >= 0)
- tst_resm(TPASS, "get correct shared memory id");
+ tst_resm(TPASS, "get correct shared memory id for index: %d",
+ shm_index);
else
- tst_resm(TFAIL, "shared memory id is incorrect");
+ tst_resm(TFAIL, "shared memory id is incorrect, index: %d",
+ shm_index);
+}
+
+static void func_sstat_setup(void)
+{
+ struct shm_info tmp;
+ int ret;
+
+ ret = shmctl(shm_id_1, SHM_INFO, (void *)&tmp);
+ if (ret < 0)
+ tst_resm(TFAIL|TERRNO, "shmctl(SHM_INFO)");
+ else
+ shm_index = ret;
}
static void func_lock(int ret)
--
1.8.3.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [LTP] [PATCH] shmctl01: don't use hardcoded index == 0 for SHM_STAT test
2019-05-20 19:08 [LTP] [PATCH] shmctl01: don't use hardcoded index == 0 for SHM_STAT test Jan Stancek
@ 2019-05-20 19:58 ` Petr Vorel
2019-05-21 9:58 ` Cyril Hrubis
1 sibling, 0 replies; 6+ messages in thread
From: Petr Vorel @ 2019-05-20 19:58 UTC (permalink / raw)
To: ltp
Hi Jan,
> Test fails on SHM_STAT testcase:
> shmctl01 5 TFAIL : shmctl01.c:173: shmctl01 call failed
> errno = 22 : Invalid argument
> shmctl(0, SHM_STAT, 0x601060) = -EINVAL
> since following commit:
> commit 99db46ea292780cd978d56932d9445b1e8bdafe8
> Author: Manfred Spraul <manfred@colorfullife.com>
> Date: Tue May 14 15:46:36 2019 -0700
> ipc: do cyclic id allocation for the ipc object.
> Don't rely on index 0 being always available, but instead
> use (maximum) index returned by SHM_INFO.
> Signed-off-by: Jan Stancek <jstancek@redhat.com>
Reviewed-by: Petr Vorel <petr.vorel@gmail.com>
Good catch + further improvements.
Kind regards,
Petr
^ permalink raw reply [flat|nested] 6+ messages in thread
* [LTP] [PATCH] shmctl01: don't use hardcoded index == 0 for SHM_STAT test
2019-05-20 19:08 [LTP] [PATCH] shmctl01: don't use hardcoded index == 0 for SHM_STAT test Jan Stancek
2019-05-20 19:58 ` Petr Vorel
@ 2019-05-21 9:58 ` Cyril Hrubis
2019-05-21 13:49 ` Jan Stancek
1 sibling, 1 reply; 6+ messages in thread
From: Cyril Hrubis @ 2019-05-21 9:58 UTC (permalink / raw)
To: ltp
Hi!
> +static void func_sstat_setup(void)
> +{
> + struct shm_info tmp;
> + int ret;
> +
> + ret = shmctl(shm_id_1, SHM_INFO, (void *)&tmp);
> + if (ret < 0)
> + tst_resm(TFAIL|TERRNO, "shmctl(SHM_INFO)");
I wonder if it makes sense to continue here if shmctl() has failed,
maybe we should do tst_brkm(TBROK ...) instead.
Otherwise it looks good, acked.
--
Cyril Hrubis
chrubis@suse.cz
^ permalink raw reply [flat|nested] 6+ messages in thread
* [LTP] [PATCH] shmctl01: don't use hardcoded index == 0 for SHM_STAT test
2019-05-21 9:58 ` Cyril Hrubis
@ 2019-05-21 13:49 ` Jan Stancek
2019-05-21 14:10 ` Petr Vorel
0 siblings, 1 reply; 6+ messages in thread
From: Jan Stancek @ 2019-05-21 13:49 UTC (permalink / raw)
To: ltp
----- Original Message -----
> Hi!
> > +static void func_sstat_setup(void)
> > +{
> > + struct shm_info tmp;
> > + int ret;
> > +
> > + ret = shmctl(shm_id_1, SHM_INFO, (void *)&tmp);
> > + if (ret < 0)
> > + tst_resm(TFAIL|TERRNO, "shmctl(SHM_INFO)");
>
> I wonder if it makes sense to continue here if shmctl() has failed,
> maybe we should do tst_brkm(TBROK ...) instead.
It is 'setup phase', but it also is kind-of test for shmctl() as well.
We don't risk much if we continue, worst case is we get one more fail.
@Petr: Do you have any preference?
>
> Otherwise it looks good, acked.
>
> --
> Cyril Hrubis
> chrubis@suse.cz
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [LTP] [PATCH] shmctl01: don't use hardcoded index == 0 for SHM_STAT test
2019-05-21 13:49 ` Jan Stancek
@ 2019-05-21 14:10 ` Petr Vorel
2019-05-21 16:02 ` Jan Stancek
0 siblings, 1 reply; 6+ messages in thread
From: Petr Vorel @ 2019-05-21 14:10 UTC (permalink / raw)
To: ltp
Hi Jan, Cyril,
> ----- Original Message -----
> > Hi!
> > > +static void func_sstat_setup(void)
> > > +{
> > > + struct shm_info tmp;
> > > + int ret;
> > > +
> > > + ret = shmctl(shm_id_1, SHM_INFO, (void *)&tmp);
> > > + if (ret < 0)
> > > + tst_resm(TFAIL|TERRNO, "shmctl(SHM_INFO)");
> > I wonder if it makes sense to continue here if shmctl() has failed,
> > maybe we should do tst_brkm(TBROK ...) instead.
> It is 'setup phase', but it also is kind-of test for shmctl() as well.
> We don't risk much if we continue, worst case is we get one more fail.
> @Petr: Do you have any preference?
Cyril's point makes sense, but I prefer Jan's way.
Kind regards,
Petr
^ permalink raw reply [flat|nested] 6+ messages in thread
* [LTP] [PATCH] shmctl01: don't use hardcoded index == 0 for SHM_STAT test
2019-05-21 14:10 ` Petr Vorel
@ 2019-05-21 16:02 ` Jan Stancek
0 siblings, 0 replies; 6+ messages in thread
From: Jan Stancek @ 2019-05-21 16:02 UTC (permalink / raw)
To: ltp
----- Original Message -----
> Hi Jan, Cyril,
>
> > ----- Original Message -----
> > > Hi!
> > > > +static void func_sstat_setup(void)
> > > > +{
> > > > + struct shm_info tmp;
> > > > + int ret;
> > > > +
> > > > + ret = shmctl(shm_id_1, SHM_INFO, (void *)&tmp);
> > > > + if (ret < 0)
> > > > + tst_resm(TFAIL|TERRNO, "shmctl(SHM_INFO)");
>
> > > I wonder if it makes sense to continue here if shmctl() has failed,
> > > maybe we should do tst_brkm(TBROK ...) instead.
>
> > It is 'setup phase', but it also is kind-of test for shmctl() as well.
> > We don't risk much if we continue, worst case is we get one more fail.
>
> > @Petr: Do you have any preference?
> Cyril's point makes sense, but I prefer Jan's way.
I pushed TFAIL version.
Thanks for review,
Jan
>
>
> Kind regards,
> Petr
>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2019-05-21 16:02 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-20 19:08 [LTP] [PATCH] shmctl01: don't use hardcoded index == 0 for SHM_STAT test Jan Stancek
2019-05-20 19:58 ` Petr Vorel
2019-05-21 9:58 ` Cyril Hrubis
2019-05-21 13:49 ` Jan Stancek
2019-05-21 14:10 ` Petr Vorel
2019-05-21 16:02 ` Jan Stancek
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.