<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 Mon, Jul 12, 2021 at 4:42 PM Li Wang <<a href="mailto:liwang@redhat.com">liwang@redhat.com</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"><div dir="ltr"><div dir="ltr"><div style="font-size:small"><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Jul 12, 2021 at 4:37 PM Alexey Kodanev <<a href="mailto:aleksei.kodanev@bell-sw.com" target="_blank">aleksei.kodanev@bell-sw.com</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">On 12.07.2021 11:28, Li Wang wrote:<br>
> <br>
> <br>
> On Mon, Jul 12, 2021 at 3:54 PM Alexey Kodanev <<a href="mailto:aleksei.kodanev@bell-sw.com" target="_blank">aleksei.kodanev@bell-sw.com</a> <mailto:<a href="mailto:aleksei.kodanev@bell-sw.com" target="_blank">aleksei.kodanev@bell-sw.com</a>>> wrote:<br>
> <br>
>     It's unlikely, but still possible that some of them could be<br>
>     created/released during the test as well, so the patch only<br>
>     checks errno.<br>
> <br>
>     Signed-off-by: Alexey Kodanev <<a href="mailto:aleksei.kodanev@bell-sw.com" target="_blank">aleksei.kodanev@bell-sw.com</a> <mailto:<a href="mailto:aleksei.kodanev@bell-sw.com" target="_blank">aleksei.kodanev@bell-sw.com</a>>><br>
>     ---<br>
>     v2: * Move the loop to the test run function and try to get<br>
>           ENOSPC errno there.<br>
> <br>
> <br>
> I'm fine to go with this but move the loop to test run without any<br>
> limit will bring new fail if running with parameter '-i 2'.<br>
> <br>
> We have to handle that situation (maybe add a judgment to skip<br>
> test for run more times) in case someone uses it like:<br>
<br>
Or just release them asap after tpass?</blockquote><div><br></div><div style="font-size:small">Sure, but looks a bit redundant.</div><div style="font-size:small"><br></div><div style="font-size:small">Or we can just adding a global varible for saving num:</div><div style="font-size:small"><br></div>--- a/testcases/kernel/syscalls/ipc/shmget/shmget03.c<br>+++ b/testcases/kernel/syscalls/ipc/shmget/shmget03.c<br>@@ -22,7 +22,7 @@<br> #include "libnewipc.h"<br> <br> static int *segments;<br>-static int maxshms, segments_cnt;<br>+static int number = 0, maxshms, segments_cnt;<br> static key_t shmkey;<br> <br> static void verify_shmget(void)<br>@@ -30,7 +30,7 @@ static void verify_shmget(void)<br>        int res = 0, num;<br> <br>        errno = 0;<br>-       for (num = 0; num <= maxshms; ++num) {<br>+       for (num = number; num <= maxshms; ++num) {<br></div></div></blockquote><div><br></div><div><div class="gmail_default" style="font-size:small">Oh, this method is thoughtless, because if the test gets ENOSPC at</div><div class="gmail_default" style="font-size:small">the last looping time, which means num == maxshms, then the global</div><div class="gmail_default" style="font-size:small">number will be larger than maxshms, so the test won't fall into</div><div class="gmail_default" style="font-size:small">for() loop next time and report FAIL again.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">So, let's go with your way: release them after TPASS. This is safer.</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"><div dir="ltr"><div class="gmail_quote">                res = shmget(shmkey + num, SHM_SIZE, IPC_CREAT | IPC_EXCL | SHM_RW);<br>                if (res == -1)<br>                        break;<br>@@ -42,6 +42,8 @@ static void verify_shmget(void)<br> <br>        tst_res(TPASS, "Maximum number of segments reached (%d), used by test %d",<br>                maxshms, segments_cnt);<br>+<br>+       number = num;<br> }<br> <br> static void setup(void)<br><div style="font-size:small"></div></div><br clear="all"><div><br></div>-- <br><div dir="ltr"><div dir="ltr"><div>Regards,<br></div><div>Li Wang<br></div></div></div></div>
</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>