<div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-size:small"><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Jul 18, 2020 at 12:35 AM Cyril Hrubis <<a href="mailto:chrubis@suse.cz">chrubis@suse.cz</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="gmail_default" style="font-size:small">...</span><br>
+<br>
+static void verify_shmlock(void)<br>
+{<br>
+       struct <span class="gmail_default" style="font-size:small"></span>shmid_ds ds;<br>
+<br>
+       TEST(shmctl(shm_id, SHM_LOCK, NULL));<br>
+<br>
+       if (TST_RET != 0)<br>
+               tst_res(TFAIL | TTERRNO, "shmctl(%i, SHM_LOCK, NULL)", shm_id);<br>
+       else<br>
+               tst_res(TPASS, "shmctl(%i, SHM_LOCK, NULL)", shm_id);<br>
+<br>
+<br>
+       SAFE_SHMCTL(shm_id, IPC_STAT, &ds);<br>
+<br>
+       if (ds.shm_perm.mode & SHM_LOCKED)<br>
+               tst_res(TPASS, "SMH_LOCKED bit is on in shm_perm.mode");<br>
+       else<br>
+               tst_res(TFAIL, "SHM_LOCKED bit is off in shm_perm.mode");<br>
+<br>
+       TEST(shmctl(shm_id, SHM_UNLOCK, NULL));<br>
+<br>
+       if (TST_RET != 0)<br>
+               tst_res(TFAIL | TTERRNO, "shmctl(%i, SHM_UNLOCK, NULL)", shm_id);<br>
+       else<br>
+               tst_res(TPASS, "shmctl(%i, SHM_UNLOCK, NULL)", shm_id);<br>
+<br></blockquote><div><br></div><div><div class="gmail_default" style="font-size:small">Shouldn't we do update '<span class="gmail_default"></span>ds' before checking the <span class="gmail_default"></span>ds.shm_perm.mode?</div><div class="gmail_default" style="font-size:small"><br></div>--- a/testcases/kernel/syscalls/ipc/shmctl/shmctl07.c<br>+++ b/testcases/kernel/syscalls/ipc/shmctl/shmctl07.c<br>@@ -42,10 +42,11 @@ static void verify_shmlock(void)<br>        else<br>                tst_res(TPASS, "shmctl(%i, SHM_UNLOCK, NULL)", shm_id);<br> <br>+       SAFE_SHMCTL(shm_id, IPC_STAT, &ds);<br>        if (ds.shm_perm.mode & SHM_LOCKED)<br>-               tst_res(TPASS, "SHM_LOCKED bit is off in shm_perm.mode");<br>-       else<br>                tst_res(TFAIL, "SMH_LOCKED bit is on in shm_perm.mode");<br>+       else<br>+               tst_res(TPASS, "SHM_LOCKED bit is off in shm_perm.mode");<br> }<br><div class="gmail_default" style="font-size:small"></div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
+       if (<span class="gmail_default" style="font-size:small"></span>ds.shm_perm.mode & SHM_LOCKED)<br>
+               tst_res(TPASS, "SHM_LOCKED bit is off in shm_perm.mode");<br></blockquote><div><br></div><div><div class="gmail_default" style="font-size:small">And in this branch, the status should be "on" but not "off".</div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
+       else<br>
+               tst_res(TFAIL, "SMH_LOCKED bit is on in shm_perm.mode");<br>
+}<br>
+<br>
+static void setup(void)<br>
+{<br>
+       shm_id = SAFE_SHMGET(IPC_PRIVATE, SHM_SIZE, IPC_CREAT | SHM_RW);<br>
+}<br>
+<br>
+static void cleanup(void)<br>
+{<br>
+       if (shm_id >= 0)<br>
+               SAFE_SHMCTL(shm_id, IPC_RMID, NULL);<br>
+}<br>
+<br>
+static struct tst_test test = {<br>
+       .setup = setup,<br>
+       .cleanup = cleanup,<br>
+       .test_all = verify_shmlock,<br>
+};<br>
-- <br>
2.26.2<br>
<br>
<br>
-- <br>
Mailing list info: <a href="https://lists.linux.it/listinfo/ltp" rel="noreferrer" target="_blank">https://lists.linux.it/listinfo/ltp</a><br>
<br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div>Regards,<br></div><div>Li Wang<br></div></div></div></div>