<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Apr 16, 2018 at 4:23 PM, Zhibin Li <span dir="ltr"><<a href="mailto:08826794brmt@gmail.com" target="_blank">08826794brmt@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">*tests/fcntl.c (test_f_owner_ex_type_pid)<br>
(test_f_owner_ex_umove, test_f_owner_ex_printaddr)<br>
(test_f_owner_ex): New functions.<br>
(main): Use test_f_owner_ex.<br>
---<br>
 tests/fcntl.c | 55 ++++++++++++++++++++++++++++++<wbr>+++++++++++++++++++++++++<br>
 1 file changed, 55 insertions(+)<br>
<br>
diff --git a/tests/fcntl.c b/tests/fcntl.c<br>
index 4f62ca2a..3a7d243d 100644<br>
--- a/tests/fcntl.c<br>
+++ b/tests/fcntl.c<br>
@@ -69,12 +69,67 @@ test_flock64(void)<br>
 #endif<br>
 }<br>
<br>
+static long<br>
+test_f_owner_ex_type_pid(cons<wbr>t int cmd, const char *const cmd_name,<br>
+                        const int type, const char *const type_name,<br>
+                        const pid_t pid)<br>
+{<br>
+       TAIL_ALLOC_OBJECT_CONST_PTR(s<wbr>truct f_owner_ex, fo);<br>
+       fo->type = type;<br>
+       fo->pid = pid;<br>
+<br>
+       long rc = invoke_test_syscall(cmd, fo);<br>
+       printf("%s(0, %s, {type=%s, pid=%d}) = %s\n",<br>
+              TEST_SYSCALL_STR, cmd_name, type_name, pid, sprintrc(rc));<br>
+       return rc;<br>
+}<br>
+<br></blockquote><div>Since this part is similar with function test_f_owner_ex_printaddr below, I don't know</div><div>whether it's necessary to put them into just one function. But <span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">test_f_owner_ex_printaddr</span></div><div><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">doesn't need parameters such as type or pid.</span></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+static void<br>
+test_f_owner_ex_umove(const int type, const char *const type_name, pid_t pid)<br>
+{<br>
+       long rc = test_f_owner_ex_type_pid(ARG_S<wbr>TR(F_SETOWN_EX),<br>
+                                          type, type_name, pid);<br>
+       if (!rc)<br>
+               test_f_owner_ex_type_pid(ARG_<wbr>STR(F_GETOWN_EX),<br>
+                                        type, type_name, pid);<br>
+}<br>
+<br>
+static void<br>
+test_f_owner_ex_printaddr(con<wbr>st int cmd, const char *const cmd_name)<br>
+{<br>
+       TAIL_ALLOC_OBJECT_CONST_PTR(s<wbr>truct f_owner_ex, fo);<br>
+<br>
+       long rc = invoke_test_syscall(cmd, fo+1ULL);<br>
+       printf("%s(0, %s, %p) = %s\n",<br>
+              TEST_SYSCALL_STR, cmd_name, fo+1ULL, sprintrc(rc));<br>
+}<br>
+<br>
+static void<br>
+test_f_owner_ex(void)<br>
+{<br>
+       unsigned int i;<br>
+       unsigned int j;<br>
+       unsigned int k = 0;<br>
+       const int type[] = { F_OWNER_TID, F_OWNER_PID, F_OWNER_PGRP };<br>
+       const char *type_name[] = { "F_OWNER_TID", "F_OWNER_PID", "F_OWNER_PGRP" };<br>
+       const int pid[] = { 1234567890, 1298126790, 1294567890, 20, 30, 40 };<br>
+<br>
+       for (i = 0; i < 2; i++) {<br>
+               for (j = 0; j < ARRAY_SIZE(type); j++) {<br>
+                       test_f_owner_ex_umove(type[j]<wbr>, type_name[j], pid[k++]);<br>
+               }<br>
+       }<br>
+       test_f_owner_ex_printaddr(<wbr>ARG_STR(F_SETOWN_EX));<br>
+       test_f_owner_ex_printaddr(<wbr>ARG_STR(F_GETOWN_EX));<br></blockquote><div>As Eugene said, here we should use for loops when there are multiple invocations. I wonder </div><div>is this test_f_owner_ex_printaddr supposed to use a loop? Because there are just two</div><div>invocations, unlike test_f_owner_ex_umove, which is called for six times. Are there any</div><div>basic rules or criteria we can refer to?</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+}<br>
+<br>
 int<br>
 main(void)<br>
 {<br>
        create_sample();<br>
        test_flock();<br>
        test_flock64();<br>
+       test_f_owner_ex();<br>
<br>
        puts("+++ exited with 0 +++");<br>
        return 0;<br>
<span class="m_9081394881180590679HOEnZb"><font color="#888888">-- <br>
2.14.3<br>
<br>
</font></span></blockquote></div><br></div></div>