<div dir="auto"><div><br><br><div class="gmail_quote"><div dir="ltr">On Tue, Apr 17, 2018, 21:09 Zhibin Li <<a href="mailto:08826794brmt@gmail.com">08826794brmt@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">*tests/fcntl.c include <stdarg.h><br>
(test_f_owner_ex_type_pid, test_f_owner_ex_umove)<br>
(test_f_owner_ex): New functions.<br>
(main): Use test_f_owner_ex.<br>
---<br>
tests/fcntl.c | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++<br>
1 file changed, 65 insertions(+)<br>
<br>
diff --git a/tests/fcntl.c b/tests/fcntl.c<br>
index 4f62ca2a..2270ee57 100644<br>
--- a/tests/fcntl.c<br>
+++ b/tests/fcntl.c<br>
@@ -28,6 +28,7 @@<br>
<br>
#include "tests.h"<br>
#include <asm/unistd.h><br>
+#include <stdarg.h><br>
<br>
#ifdef __NR_fcntl<br>
<br>
@@ -69,12 +70,76 @@ test_flock64(void)<br>
#endif<br>
}<br>
<br>
+static long<br>
+test_f_owner_ex_type_pid(const int cmd, const char *const cmd_name, ...)<br>
+{<br>
+ va_list ap;<br>
+ va_start(ap, cmd_name);<br>
+<br>
+ long rc;<br>
+ const char *type_name;<br>
+<br>
+ TAIL_ALLOC_OBJECT_CONST_PTR(struct f_owner_ex, fo);<br>
+<br>
+ if ((type_name = va_arg(ap, char *)) != NULL) {<br></blockquote></div></div><div dir="auto">here I forgot to use !!(expression) again, I will correct it in my next patch.</div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ fo->type = va_arg(ap, int);<br>
+ fo->pid = va_arg(ap, int);<br>
+<br>
+ 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>
+ va_end(ap);<br>
+ return rc;<br>
+ }<br>
+<br>
+ rc = invoke_test_syscall(cmd, (void *) (uintptr_t) fo + 1);<br>
+ printf("%s(0, %s, %p) = %s\n",<br>
+ TEST_SYSCALL_STR, cmd_name, (void *) (uintptr_t) fo + 1, sprintrc(rc));<br>
+ va_end(ap);<br>
+ return rc;<br>
+}<br>
+<br>
+static void<br>
+test_f_owner_ex_umove(const char *const type_name, const int type, pid_t pid)<br>
+{<br>
+ long rc = test_f_owner_ex_type_pid(ARG_STR(F_SETOWN_EX),<br>
+ type_name, type, pid);<br>
+ if (!rc)<br>
+ test_f_owner_ex_type_pid(ARG_STR(F_GETOWN_EX),<br>
+ type_name, type, pid);<br>
+}<br>
+<br>
+static void<br>
+test_f_owner_ex(void)<br>
+{<br>
+ unsigned int i;<br>
+ unsigned int j;<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 (i = 0; i < ARRAY_SIZE(a); i++) {<br>
+ for (j = 0; j < ARRAY_SIZE(a[0].pid); j++) {<br>
+ test_f_owner_ex_umove(a[i].type_name, a[i].type, a[i].pid[j]);<br>
+ }<br>
+ }<br>
+ test_f_owner_ex_type_pid(ARG_STR(F_SETOWN_EX));<br>
+ test_f_owner_ex_type_pid(ARG_STR(F_GETOWN_EX));<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>
-- <br>
2.14.3<br>
<br>
</blockquote></div></div></div>