[GSOC][PATCH v2] tests/fcntl.c: add test for struct f_owner_ex
Zhibin Li
08826794brmt at gmail.com
Mon Mar 26 17:20:14 UTC 2018
Signed-off-by: Zhibin Li <08826794brmt at gmail.com>
---
tests/fcntl.c | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 63 insertions(+)
diff --git a/tests/fcntl.c b/tests/fcntl.c
index 4f62ca2a..8c74ed22 100644
--- a/tests/fcntl.c
+++ b/tests/fcntl.c
@@ -36,6 +36,9 @@
# include "struct_flock.c"
# define TEST_FLOCK64_EINVAL(cmd) test_flock64_einval(cmd, #cmd)
+# define TEST_F_OWNER_EX_ESRCH(cmd) test_f_owner_ex_esrch(cmd, #cmd)
+
+typedef struct f_owner_ex struct_kernel_f_owner_ex;
static void
test_flock64_einval(const int cmd, const char *name)
@@ -69,12 +72,72 @@ test_flock64(void)
#endif
}
+static int
+test_f_owner_ex_type_pid(const int cmd, const char *const cmd_name,
+ const int type, const char *const type_name,
+ const pid_t pid)
+{
+ struct_kernel_f_owner_ex fo = { .type = type, .pid = pid };
+
+ long rc = invoke_test_syscall(cmd, &fo);
+ printf("%s(0, %s, {type=%s, pid=%d}) = %s\n",
+ TEST_SYSCALL_STR, cmd_name, type_name, pid, sprintrc(rc));
+ if (rc)
+ return 1;
+ return 0;
+}
+
+static void
+test_f_owner_ex_esrch(const int cmd, const char *const cmd_name)
+{
+ test_f_owner_ex_type_pid(cmd, cmd_name,
+ ARG_STR(F_OWNER_TID), 1234567890);
+ test_f_owner_ex_type_pid(cmd, cmd_name,
+ ARG_STR(F_OWNER_PID), 1234567890);
+ test_f_owner_ex_type_pid(cmd, cmd_name,
+ ARG_STR(F_OWNER_PGRP), -1234567890);
+}
+
+static void
+test_f_owner_ex(void)
+{
+ TEST_F_OWNER_EX_ESRCH(F_SETOWN_EX);
+
+ long rc;
+
+ rc = test_f_owner_ex_type_pid(ARG_STR(F_SETOWN_EX),
+ ARG_STR(F_OWNER_TID), 20);
+ if (rc)
+ return;
+
+ test_f_owner_ex_type_pid(ARG_STR(F_GETOWN_EX),
+ ARG_STR(F_OWNER_TID), 20);
+
+ rc = test_f_owner_ex_type_pid(ARG_STR(F_SETOWN_EX),
+ ARG_STR(F_OWNER_PID), 30);
+ if (rc)
+ return;
+
+ test_f_owner_ex_type_pid(ARG_STR(F_GETOWN_EX),
+ ARG_STR(F_OWNER_PID), 30);
+
+ rc = test_f_owner_ex_type_pid(ARG_STR(F_SETOWN_EX),
+ ARG_STR(F_OWNER_PGRP), 40);
+ if (rc)
+ return;
+
+ test_f_owner_ex_type_pid(ARG_STR(F_GETOWN_EX),
+ ARG_STR(F_OWNER_PGRP), 40);
+
+}
+
int
main(void)
{
create_sample();
test_flock();
test_flock64();
+ test_f_owner_ex();
puts("+++ exited with 0 +++");
return 0;
--
2.14.3
More information about the Strace-devel
mailing list