<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, May 2, 2018 at 6:39 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_or_<wbr>printaddr, test_f_owner_ex): New functions.<br>
(main): Use test_f_owner_ex.<br>
---<br>
 tests/fcntl.c | 52 ++++++++++++++++++++++++++++++<wbr>++++++++++++++++++++++<br>
 1 file changed, 52 insertions(+)<br>
<br>
diff --git a/tests/fcntl.c b/tests/fcntl.c<br>
index 4f62ca2a..fdf9dacf 100644<br>
--- a/tests/fcntl.c<br>
+++ b/tests/fcntl.c<br>
@@ -69,12 +69,64 @@ test_flock64(void)<br>
 #endif<br>
 }<br>
<br>
+static long<br>
+test_f_owner_ex_type_pid(<wbr>const int cmd, const char *const cmd_name,<br>
+                        const int type, const char *const type_name,<br>
+                        pid_t pid)<br>
+{<br>
+       TAIL_ALLOC_OBJECT_CONST_PTR(<wbr>struct f_owner_ex, fo);<br>
+<br>
+       fo->type = type;<br>
+       fo->pid = pid;<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, fo->pid, sprintrc(rc));<br>
+<br>
+       void *bad_addr = (void *)(uintptr_t)fo + 1;<br></blockquote><div>Here should I use (void *)((uintptr_t)fo + 1) instead? It causes no difference in this case</div><div>but should I emphasize fo+1 by using seemingly useless brackets? </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+       long rc_efault = invoke_test_syscall(cmd, bad_addr);<br>
+       printf("%s(0, %s, %p) = %s\n",<br>
+              TEST_SYSCALL_STR, cmd_name, bad_addr, sprintrc(rc_efault));<br>
+<br>
+       return rc;<br>
+}<br>
+<br>
+static void<br>
+test_f_owner_ex_umove_or_<wbr>printaddr(const int type, const char *const type_name, pid_t pid)<br>
+{<br>
+       long rc = test_f_owner_ex_type_pid(ARG_<wbr>STR(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(void)<br>
+{<br>
+       static const struct {<br>
+               int type;<br>
+               const char *type_name;<br>
+               pid_t pid[2];<br>
+       } a[] = {<br>
+               { ARG_STR(F_OWNER_TID), { 1234567890, 20 } },<br>
+               { ARG_STR(F_OWNER_PID), { 1298126790, 30 } },<br>
+               { ARG_STR(F_OWNER_PGRP), { 1294567890, 40 } }<br>
+       };<br>
+<br>
+       for (unsigned int i = 0; i < ARRAY_SIZE(a); i++) {<br>
+               for (unsigned int j = 0; j < ARRAY_SIZE(a[0].pid); j++) {<br>
+                       test_f_owner_ex_umove_or_<wbr>printaddr(a[i].type, a[i].type_name, a[i].pid[j]);<br>
+               }<br>
+       }<br>
+}<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="HOEnZb"><font color="#888888">-- <br>
2.14.3<br>
<br>
</font></span></blockquote></div><br></div></div>