[GSOC][PATCH] tests/fcntl.c: add test for struct f_owner_ex

Zhibin Li 08826794brmt at gmail.com
Sun Mar 25 14:28:26 UTC 2018


Signed-off-by: Zhibin Li <08826794brmt at gmail.com>
---
 tests/fcntl.c | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 74 insertions(+)

diff --git a/tests/fcntl.c b/tests/fcntl.c
index 4f62ca2a..17a30336 100644
--- a/tests/fcntl.c
+++ b/tests/fcntl.c
@@ -36,6 +36,10 @@
 # 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;
+typedef struct struct_kernel_f_owner_ex struct_f_owner_ex;
 
 static void
 test_flock64_einval(const int cmd, const char *name)
@@ -69,12 +73,82 @@ test_flock64(void)
 #endif
 }
 
+static void
+test_f_owner_ex_esrch(const int cmd, const char *name)
+{
+	struct_kernel_f_owner_ex fo[] = {
+		{ .type = F_OWNER_TID, .pid = 1234567890 },
+		{ .type = F_OWNER_PID, .pid = 1234567890 },
+		{ .type = F_OWNER_PGRP, .pid = -1234567890 }
+	};
+
+	long rc;
+
+	rc = invoke_test_syscall(cmd, &fo[0]);
+	printf("%s(0, %s, {type=F_OWNER_TID, pid=%d}) = %s\n",
+		TEST_SYSCALL_STR, name, (__kernel_pid_t) fo[0].pid, sprintrc(rc));
+
+	rc = invoke_test_syscall(cmd, &fo[1]);
+	printf("%s(0, %s, {type=F_OWNER_PID, pid=%d}) = %s\n",
+		TEST_SYSCALL_STR, name, (__kernel_pid_t) fo[1].pid, sprintrc(rc));
+
+	rc = invoke_test_syscall(cmd, &fo[2]);
+	printf("%s(0, %s, {type=F_OWNER_PGRP, pid=%d}) = %s\n",
+		TEST_SYSCALL_STR, name, (__kernel_pid_t) fo[2].pid, sprintrc(rc));
+
+}
+
+static void
+test_f_owner_ex(void)
+{
+	TEST_F_OWNER_EX_ESRCH(F_SETOWN_EX);
+
+	struct_kernel_f_owner_ex fo[] = {
+		{ .type = F_OWNER_TID, .pid = 20 }, //magic, need reconsidering
+		{ .type = F_OWNER_PID, .pid = 30 },
+		{ .type = F_OWNER_PGRP, .pid = 40 }
+	};
+
+	long rc;
+	rc = invoke_test_syscall(F_SETOWN_EX, &fo[0]);
+	printf("%s(0, F_SETOWN, {type=F_OWNER_TID, pid=%d}) = 0\n",
+		TEST_SYSCALL_STR, (__kernel_pid_t) fo[0].pid);
+	if (rc)
+		return;
+
+	invoke_test_syscall(F_GETOWN, &fo[0]);
+	printf("%s(0, F_GETOWN, {type=F_OWNER_TID, pid=%d}) = 0\n",
+		TEST_SYSCALL_STR, (__kernel_pid_t) fo[0].pid);
+
+	rc = invoke_test_syscall(F_SETOWN_EX, &fo[1]);
+	printf("%s(0, F_SETOWN, {type=F_OWNER_PID, pid=%d}) = 0\n",
+		TEST_SYSCALL_STR, (__kernel_pid_t) fo[1].pid);
+	if (rc)
+		return;
+
+	invoke_test_syscall(F_GETOWN, &fo[1]);
+	printf("%s(0, F_GETOWN, {type=F_OWNER_PID, pid=%d}) = 0\n",
+		TEST_SYSCALL_STR, (__kernel_pid_t) fo[1].pid);
+
+	rc = invoke_test_syscall(F_SETOWN_EX, &fo[2]);
+	printf("%s(0, F_SETOWN, {type=F_OWNER_PGRP, pid=%d}) = 0\n",
+		TEST_SYSCALL_STR, (__kernel_pid_t) fo[2].pid);
+	if (rc)
+		return;
+
+	invoke_test_syscall(F_GETOWN, &fo[2]);
+	printf("%s(0, F_GETOWN, {type=F_OWNER_PGRP, pid=%d}) = 0\n",
+		TEST_SYSCALL_STR, (__kernel_pid_t) fo[2].pid);
+
+}
+
 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