[LTP] [PATCH v4 07/10] Rewrite shmem_2nstest.c using new LTP API
Cyril Hrubis
chrubis@suse.cz
Fri Jun 3 11:26:08 CEST 2022
Hi!
Pushed with a few changes, thanks.
I did rearrange the code to make it a bit simpler and removed some
useless code.
Full diff:
diff --git a/testcases/kernel/containers/sysvipc/shmem_2nstest.c b/testcases/kernel/containers/sysvipc/shmem_2nstest.c
index e6c1a16fa..ea3de94bd 100644
--- a/testcases/kernel/containers/sysvipc/shmem_2nstest.c
+++ b/testcases/kernel/containers/sysvipc/shmem_2nstest.c
@@ -40,36 +40,28 @@
static char *str_op;
static int use_clone;
-/*
- * check_shmem1() does not read -- it writes to check_shmem2() when it's done.
- */
static int check_shmem1(LTP_ATTRIBUTE_UNUSED void *vtest)
{
- SAFE_SHMGET(TESTKEY, 100, IPC_CREAT);
+ int id;
+
+ id = SAFE_SHMGET(TESTKEY, 100, IPC_CREAT);
tst_res(TINFO, "container1: able to create shared mem segment");
- TST_CHECKPOINT_WAKE(0);
+ TST_CHECKPOINT_WAKE_AND_WAIT(0);
+
+ SAFE_SHMCTL(id, IPC_RMID, NULL);
return 0;
}
-/*
- * check_shmem2() reads from check_shmem1() and writes to main() when it's done.
- */
static int check_shmem2(LTP_ATTRIBUTE_UNUSED void *vtest)
{
- int id;
-
TST_CHECKPOINT_WAIT(0);
TEST(shmget(TESTKEY, 100, 0));
if (TST_RET < 0) {
- SAFE_SHMGET(TESTKEY, 100, IPC_CREAT);
-
- tst_res(TINFO, "container2: able to allocate shmem seg with the same key");
-
if (use_clone == T_NONE)
tst_res(TFAIL, "Plain cloned process didn't find shmem segment");
else
@@ -81,8 +73,7 @@ static int check_shmem2(LTP_ATTRIBUTE_UNUSED void *vtest)
tst_res(TFAIL, "%s: in namespace2 found the shmem segment created in namespace1", str_op);
}
- id = SAFE_SHMGET(TESTKEY, 100, 0);
- SAFE_SHMCTL(id, IPC_RMID, NULL);
+ TST_CHECKPOINT_WAKE(0);
return 0;
}
--
Cyril Hrubis
chrubis@suse.cz
More information about the ltp
mailing list