Skip to contentSkip to conversation

syscall/kcmp: Add tests for kcmp

PATCH Superseded Cedric Hnyda 2 participants 2 messages Oct 8, 2015

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 syscall/kcmp: Add tests for kcmp

Add tests for the syscall kcmp

---
 configure.ac                            |   2 +
 m4/ltp-kcmp.m4                          |  23 +++++
 m4/ltp-kcmp_type.m4                     |  23 +++++
 runtest/syscalls                        |   3 +
 testcases/kernel/include/aarch64.in     |   1 +
 testcases/kernel/include/arm.in         |   1 +
 testcases/kernel/include/i386.in        |   1 +
 testcases/kernel/include/powerpc.in     |   1 +
 testcases/kernel/include/powerpc64.in   |   1 +
 testcases/kernel/include/s390.in        |   1 +
 testcases/kernel/include/s390x.in       |   1 +
 testcases/kernel/include/sh.in          |   1 +
 testcases/kernel/include/sparc.in       |   1 +
 testcases/kernel/include/sparc64.in     |   1 +
 testcases/kernel/include/x86_64.in      |   1 +
 testcases/kernel/syscalls/.gitignore    |   2 +
 testcases/kernel/syscalls/kcmp/Makefile |  24 ++++++
 testcases/kernel/syscalls/kcmp/kcmp.h   |  51 ++++++++++++
 testcases/kernel/syscalls/kcmp/kcmp01.c | 143 ++++++++++++++++++++++++++++++++
 testcases/kernel/syscalls/kcmp/kcmp02.c | 137 ++++++++++++++++++++++++++++++
 20 files changed, 419 insertions(+)
 create mode 100644 m4/ltp-kcmp.m4
 create mode 100644 m4/ltp-kcmp_type.m4
 create mode 100644 testcases/kernel/syscalls/kcmp/Makefile
 create mode 100644 testcases/kernel/syscalls/kcmp/kcmp.h
 create mode 100644 testcases/kernel/syscalls/kcmp/kcmp01.c
 create mode 100644 testcases/kernel/syscalls/kcmp/kcmp02.c
configure.ac +2 -0
index ce09fbd..b63daa4 100644
@@ -178,5 +178,7 @@ LTP_CHECK_IOVEC
 LTP_CHECK_KEYCTL
 LTP_CHECK_LINUXRANDOM
 LTP_CHECK_IF_LINK
+LTP_CHECK_KCMP
+LTP_CHECK_KCMP_TYPE
 
 AC_OUTPUT
m4/ltp-kcmp.m4 new file +23 -0
new file mode 100644
index 0000000..70bf375
@@ -0,0 +1,23 @@
+dnl
+dnl Copyright (c) Linux Test Project, 2015
+dnl
+dnl This program is free software;  you can redistribute it and/or modify
+dnl it under the terms of the GNU General Public License as published by
+dnl the Free Software Foundation; either version 2 of the License, or
+dnl (at your option) any later version.
+dnl
+dnl This program is distributed in the hope that it will be useful,
+dnl but WITHOUT ANY WARRANTY;  without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
+dnl the GNU General Public License for more details.
+dnl
+dnl You should have received a copy of the GNU General Public License
+dnl along with this program;  if not, write to the Free Software Foundation,
+dnl Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+dnl
+dnl Author: Cedric Hnyda <[email protected]>
+dnl
+
+AC_DEFUN([LTP_CHECK_KCMP],[
+AC_CHECK_FUNCS(kcmp,,)
+])
m4/ltp-kcmp_type.m4 new file +23 -0
new file mode 100644
index 0000000..f4d7e2d
@@ -0,0 +1,23 @@
+dnl
+dnl Copyright (c) Linux Test Project, 2015
+dnl
+dnl This program is free software;  you can redistribute it and/or modify
+dnl it under the terms of the GNU General Public License as published by
+dnl the Free Software Foundation; either version 2 of the License, or
+dnl (at your option) any later version.
+dnl
+dnl This program is distributed in the hope that it will be useful,
+dnl but WITHOUT ANY WARRANTY;  without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
+dnl the GNU General Public License for more details.
+dnl
+dnl You should have received a copy of the GNU General Public License
+dnl along with this program;  if not, write to the Free Software Foundation,
+dnl Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+dnl
+dnl Author: Cedric Hnyda <[email protected]>
+dnl
+
+AC_DEFUN([LTP_CHECK_KCMP_TYPE],[
+AC_CHECK_TYPES([enum kcmp_type],,)
+])
runtest/syscalls +3 -0
index 25d10ac..3427aaa 100644
@@ -472,6 +472,9 @@ io_submit01 io_submit01
 
 keyctl01 keyctl01
 
+kcmp01 kcmp01
+kcmp02 kcmp02
+
 kill01 kill01
 kill02 kill02
 kill03 kill03
testcases/kernel/include/aarch64.in +1 -0
index ceb67c6..4dda026 100644
@@ -253,3 +253,4 @@ clock_adjtime 266
 syncfs 267
 setns 268
 sendmmsg 269
+kcmp 378
testcases/kernel/include/arm.in +1 -0
index 841b064..ba6e07e 100644
@@ -333,4 +333,5 @@ accept4 (__NR_SYSCALL_BASE+366)
 fanotify_init (__NR_SYSCALL_BASE+367)
 fanotify_mark (__NR_SYSCALL_BASE+368)
 prlimit64 (__NR_SYSCALL_BASE+369)
+kcmp (__NR_SYSCALL_BASE+378)
 getrandom (__NR_SYSCALL_BASE+384)
testcases/kernel/include/i386.in +1 -0
index a4585c2..e4631a3 100644
@@ -333,4 +333,5 @@ recvmmsg 337
 fanotify_init 338
 fanotify_mark 339
 prlimit64 340
+kcmp 349
 getrandom 355
testcases/kernel/include/powerpc.in +1 -0
index 4025436..450ed39 100644
@@ -340,4 +340,5 @@ recvmsg 342
 recvmmsg 343
 accept4 344
 syscalls 345
+kcmp 354
 getrandom 359
testcases/kernel/include/powerpc64.in +1 -0
index 4025436..450ed39 100644
@@ -340,4 +340,5 @@ recvmsg 342
 recvmmsg 343
 accept4 344
 syscalls 345
+kcmp 354
 getrandom 359
testcases/kernel/include/s390.in +1 -0
index 9c7cfa1..92b0b94 100644
@@ -324,4 +324,5 @@ setgid 214
 setfsuid 215
 setfsgid 216
 newfstatat 293
+kcmp 343
 getrandom 349
testcases/kernel/include/s390x.in +1 -0
index 9c7cfa1..92b0b94 100644
@@ -324,4 +324,5 @@ setgid 214
 setfsuid 215
 setfsgid 216
 newfstatat 293
+kcmp 343
 getrandom 349
testcases/kernel/include/sh.in +1 -0
index c6e8aa5..3cb7e21 100644
@@ -361,3 +361,4 @@ accept4 366
 fanotify_init 367
 fanotify_mark 368
 prlimit64 369
+kcmp 378
testcases/kernel/include/sparc.in +1 -0
index 697378f..182db25 100644
@@ -331,3 +331,4 @@ recvmmsg 328
 fanotify_init 329
 fanotify_mark 330
 prlimit64 331
+kcmp 341
testcases/kernel/include/sparc64.in +1 -0
index 83c1792..b5b817b 100644
@@ -307,3 +307,4 @@ recvmmsg 328
 fanotify_init 329
 fanotify_mark 330
 prlimit64 331
+kcmp 341
testcases/kernel/include/x86_64.in +1 -0
index 860e726..d4b5756 100644
@@ -300,4 +300,5 @@ recvmmsg 299
 fanotify_init 300
 fanotify_mark 301
 prlimit64 302
+kcmp 312
 getrandom 318
testcases/kernel/syscalls/.gitignore +2 -0
index f3a18ab..3fb91a3 100644
@@ -440,6 +440,8 @@
 /ipc/shmget/shmget04
 /ipc/shmget/shmget05
 /keyctl/keyctl01
+/kcmp/kcmp01
+/kcmp/kcmp02
 /kill/kill01
 /kill/kill02
 /kill/kill03
testcases/kernel/syscalls/kcmp/Makefile new file +24 -0
new file mode 100644
index 0000000..083a071
@@ -0,0 +1,24 @@
+#
+#  Copyright (C) 2015 Cedric Hnyda [email protected]
+#
+#  This program is free software;  you can redistribute it and/or modify
+#  it under the terms of the GNU General Public License as published by
+#  the Free Software Foundation; either version 2 of the License, or
+#  (at your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY;  without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
+#  the GNU General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this program;  if not, write to the Free Software
+#  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#
+
+
+top_srcdir		?= ../../../..
+
+include $(top_srcdir)/include/mk/testcases.mk
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/syscalls/kcmp/kcmp.h new file +51 -0

51 lines not on this page · raw message

testcases/kernel/syscalls/kcmp/kcmp01.c new file +143 -0

143 lines not on this page · raw message

testcases/kernel/syscalls/kcmp/kcmp02.c new file +137 -0

137 lines not on this page · raw message

Signature · 1 line
2.1.4
#1 lore raw

PATCH 1/1 syscall/kcmp: Add tests for kcmp

Hi!

Quoted 19 lines
m4/ltp-kcmp_type.m4 new file +13 -0
new file mode 100644
index 0000000..f4d7e2d
@@ -0,0 +1,23 @@
+dnl
+dnl Copyright (c) Linux Test Project, 2015
+dnl
+dnl This program is free software;  you can redistribute it and/or modify
+dnl it under the terms of the GNU General Public License as published by
+dnl the Free Software Foundation; either version 2 of the License, or
+dnl (at your option) any later version.
+dnl
+dnl This program is distributed in the hope that it will be useful,
+dnl but WITHOUT ANY WARRANTY;  without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
+dnl the GNU General Public License for more details.
+dnl

m4/ltp-kcmp_type.m4 line 23

Quoted 10 lines
m4/ltp-kcmp_type.m4 new file +10 -0
+dnl You should have received a copy of the GNU General Public License
+dnl along with this program;  if not, write to the Free Software Foundation,
+dnl Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+dnl
+dnl Author: Cedric Hnyda <[email protected]>
+dnl
+
+AC_DEFUN([LTP_CHECK_KCMP_TYPE],[
+AC_CHECK_TYPES([enum kcmp_type],,)
+])

We should pass the third parameter as [#include <linux/kcmp.h>] (which is the place the enum will be defined in new enough kernel headers package). Otherwise this will always report that the enum is missing as by default it only uses a few system includes (see:
https://www.gnu.org/software/autoconf/manual/autoconf-2.64/html_node/Default-Includes.html#Default-Includes)

Quoted 9 lines

+ * Copyright (c) 2015 Cedric Hnyda <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it would be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Quoted 8 lines

+ *
+ * Further, this software is distributed without any warranty that it is
+ * free of the rightful claim of any third person regarding infringement
+ * or the like. Any license provided herein, whether implied or
+ * otherwise, applies only to this software file. Patent licenses, if
+ * any, provided herein do not apply to combinations of this program with
+ * other software, or any other product whatsoever.
+ */

This is GPLv2 header, can we please use GPLv2+ instead?

Have a look at: include/lapi/fcntl.h for instance.

And it looks like I've missed that in the renameat2 case as well, sorry. Can you please fix these as well?

Quoted 11 lines
m4/ltp-kcmp_type.m4 new file +11 -0
+#ifndef KCMP_H
+#define KCMP_H
+
+#include <sys/types.h>
+#include "config.h"
+#include "linux_syscall_numbers.h"
+
+#if !defined(HAVE_ENUM_KCMP_TYPE)
+
+enum kcmp_type {
+	KCMP_FILE,

m4/ltp-kcmp_type.m4

Quoted 10 lines
m4/ltp-kcmp_type.m4 new file +10 -0
+	KCMP_VM,
+	KCMP_FILES,
+	KCMP_FS,
+	KCMP_SIGHAND,
+	KCMP_IO,
+	KCMP_SYSVSEM,
+	KCMP_TYPES,
+};
+
+#endif

Here should be an #else branch that includes the <linux/kcmp.h> in case that the enum is defined there. Otherwise the definitions would be missing when the header actuall exists and the code will fail to compile.

m4/ltp-kcmp_type.m4

Quoted 10 lines
m4/ltp-kcmp_type.m4 new file +10 -0
+#if !defined(HAVE_KCMP)
+
+int kcmp(int pid1, int pid2, int type, int fd1, int fd2)
+{
+	return ltp_syscall(__NR_kcmp, pid1, pid2, type, fd1, fd2);
+}
+
+#endif
+
+#endif /* KCMP_H */

And this file may be moved to include/lapi/ so that we have all fallback definitions in one place. However in this case I doubt that we will want to reuse it, so it can also stay in the kcmp directory as well.

Quoted 19 lines
testcases/kernel/syscalls/kcmp/kcmp01.c new file +13 -0
new file mode 100644
index 0000000..585e89e
@@ -0,0 +1,143 @@
+/*
+ * Copyright (c) 2015 Cedric Hnyda <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it would be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * Further, this software is distributed without any warranty that it is
+ * free of the rightful claim of any third person regarding infringement

testcases/kernel/syscalls/kcmp/kcmp01.c line 23

Quoted 10 lines
testcases/kernel/syscalls/kcmp/kcmp01.c new file +10 -0
+ * or the like.  Any license provided herein, whether implied or
+ * otherwise, applies only to this software file.  Patent licenses, if
+ * any, provided herein do not apply to combinations of this program with
+ * other software, or any other product whatsoever.
+ */
+
+ /* Description:
+ *   Verify that:
+ *		1) kcmp returns 0 with two process and two fd refering to the
+ *			same fd

^
open file would be less confusing in this context

Quoted 45 lines
testcases/kernel/syscalls/kcmp/kcmp01.c new file +45 -0
+ *		2) kcmp doesn't return 0 with two process and two fd refering
+ *		    to the same fd
+ */
+
+#define _GNU_SOURCE
+
+#include "test.h"
+#include "safe_macros.h"
+#include "lapi/fcntl.h"
+#include "kcmp.h"
+
+#define TEST_FILE "test_file"
+#define TEST_FILE2 "test_file2"
+
+
+static int fd1;
+static int fd2;
+static int fd3;
+static int pid1;
+static int pid2;
+
+char *TCID = "kcmp01";
+
+static struct test_case {
+	int *pid1;
+	int *pid2;
+	int type;
+	int *fd1;
+	int *fd2;
+	int exp_fail;
+} test_cases[] = {
+	{&pid1, &pid2, KCMP_FILE, &fd1, &fd2, 0},
+	{&pid1, &pid2, KCMP_FILE, &fd1, &fd3, 1},
+};
+
+int TST_TOTAL = ARRAY_SIZE(test_cases);
+
+static void cleanup(void);
+static void setup(void);
+static void do_child(const struct test_case *test);
+static void cleanup_child(void);
+
+int main(int ac, char **av)
+{
+	int lc;

testcases/kernel/syscalls/kcmp/kcmp01.c line 78

Quoted 10 lines
testcases/kernel/syscalls/kcmp/kcmp01.c new file +10 -0
+	int i;
+
+	tst_parse_opts(ac, av, NULL, NULL);
+	setup();
+
+	for (lc = 0; TEST_LOOPING(lc); lc++) {
+		tst_count = 0;
+
+		for (i = 0; i < TST_TOTAL; ++i) {
+			pid2 = tst_fork();

Unline SAFE_MACROS() the tst_fork() may still fail, it's unlikely but possible (for isntance it may fail if there is not enough system memory left).

So we need to check the return value from the function and call tst_brkm() if it failed.

Or we can add SAFE_FORK() that would call tst_fork() and make use of it here.

Quoted 11 lines
testcases/kernel/syscalls/kcmp/kcmp01.c new file +11 -0
+			if (!pid2)
+				do_child(&test_cases[i]);
+			else
+				tst_record_childstatus(cleanup, pid2);
+			tst_count++;
+		}
+	}
+
+	cleanup();
+	tst_exit();
+}

testcases/kernel/syscalls/kcmp/kcmp01.c line 99

Quoted 10 lines
testcases/kernel/syscalls/kcmp/kcmp01.c new file +10 -0
+
+static void do_child(const struct test_case *test)
+{
+	pid2 = getpid();
+	fd2 = dup(fd1);
+	fd3 = SAFE_OPEN(cleanup_child, TEST_FILE2, O_CREAT | O_RDWR, 0666);
+
+	TEST(kcmp(*(test->pid1), *(test->pid2), test->type,
+			  *(test->fd1), *(test->fd2)));
+	cleanup_child();

Well, these file descriptors will be closed when the child exits (when tst_exit() calls exit() file descriptors are closed, etc.). So this is not strictly needed...

The reason why we strictly close all remaining file descriptors before we call tst_rmdir() in cleanup() is "nfs silly rename" which breaks the cleanup in case that file was unlinked but there is open file descriptor pointing to the file (in this case NFS keeps the file as .nfsXXXXX which couldn't be deleted). Which caused test failures if TMPDIR points to NFS mounts.

testcases/kernel/syscalls/kcmp/kcmp01.c line 105

Quoted 5 lines
testcases/kernel/syscalls/kcmp/kcmp01.c new file +5 -0
+	if (TEST_RETURN == -1)
+		tst_resm(TFAIL | TTERRNO, "kcmp() failed unexpectedly");
+
+	if ((test->exp_fail && TEST_RETURN == 0)
+		|| (test->exp_fail == 0 && TEST_RETURN))

^
This should rather be exp_different or something similar. As it is it's quite confusing since the call actually haven't failed but reported that resources are different.

testcases/kernel/syscalls/kcmp/kcmp01.c line 106

Quoted 1 line
testcases/kernel/syscalls/kcmp/kcmp01.c new file +1 -0
+		tst_resm(TFAIL, "kcmp() didn't return the expected value");

^
Can we be a litte more specific here? Can we print hat have we expected and what was the result?

Quoted 89 lines
testcases/kernel/syscalls/kcmp/kcmp01.c new file +36 -0
+	if ((test->exp_fail == 0 && TEST_RETURN == 0)
+		|| (test->exp_fail && TEST_RETURN))
+		tst_resm(TPASS, "kcmp() returned the expected value");
+
+	tst_exit();
+}
+
+static void cleanup_child(void)
+{
+	if (fd2 > 0 && close(fd2) < 0)
+		tst_resm(TWARN | TERRNO, "close fd2 failed");
+	fd2 = 0;
+	if (fd3 > 0 && close(fd3) < 0)
+		tst_resm(TWARN | TERRNO, "close fd3 failed");
+	fd3 = 0;
+}
+
+static void setup(void)
+{
+	if ((tst_kvercmp(3, 5, 0)) < 0) {
+		tst_brkm(TCONF, NULL,
+			"This test can only run on kernels that are 3.5. and higher");
+	}
+
+	tst_tmpdir();
+
+	pid1 = getpid();
+	fd1 = SAFE_OPEN(cleanup, TEST_FILE, O_CREAT | O_RDWR | O_TRUNC);
+}
+
+static void cleanup(void)
+{
+	if (fd1 > 0 && close(fd1) < 0)
+		tst_resm(TWARN | TERRNO, "close fd1 failed");
+	tst_rmdir();
+}
testcases/kernel/syscalls/kcmp/kcmp02.c new file +47 -0
new file mode 100644
index 0000000..0d734ad
@@ -0,0 +1,137 @@
+/*
+ * Copyright (c) 2015 Cedric Hnyda <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it would be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * Further, this software is distributed without any warranty that it is
+ * free of the rightful claim of any third person regarding infringement
+ * or the like.  Any license provided herein, whether implied or
+ * otherwise, applies only to this software file.  Patent licenses, if
+ * any, provided herein do not apply to combinations of this program with
+ * other software, or any other product whatsoever.
+ */
+
+ /* Description:
+ *   Verify that:
+ *		1) kcmp fails with bad pid
+ *		2) kcmp fails with invalid flag
+ *		3) kcmp fails with invalid fd
+ */
+
+#define _GNU_SOURCE
+
+#include "test.h"
+#include "safe_macros.h"
+#include "lapi/fcntl.h"
+#include "kcmp.h"
+
+#define TEST_FILE "test_file"
+#define TEST_FILE2 "test_file2"
+
+static int fd1;
+static int fd2;
+static int fd_fake;
+static int pid1;
+static int pid_fake = -1;
+static int fd_fake = -1;
+
+char *TCID = "kcmp02";
+
+#include <sys/types.h>
+#include <sys/wait.h>

testcases/kernel/syscalls/kcmp/kcmp02.c line 57

Quoted 10 lines
testcases/kernel/syscalls/kcmp/kcmp02.c new file +10 -0
+
+static struct test_case {
+	int *pid1;
+	int *pid2;
+	int type;
+	int *fd1;
+	int *fd2;
+	int exp_errno;
+} test_cases[] = {
+	{&pid1, &pid_fake, KCMP_FILE, &fd1, &fd2, ESRCH},

We have tst_get_unused_pid() please make use of it.

testcases/kernel/syscalls/kcmp/kcmp02.c line 58

Quoted 1 line
testcases/kernel/syscalls/kcmp/kcmp02.c new file +1 -0
+	{&pid1, &pid1, EINVAL, &fd1, &fd2, EINVAL},

^
Why? It fails only by chance since EINVAL is 22 and KCMP_TYPES is less than 22. Good values for this are >= KCMP_TYPES and < 0 since enum starts on 0 by definition.

So I would test with KCMP_TYPES, KCMP_TYPES + 1, INT_MAX, -1, and INT_MIN, which should be enough to cover most of the possibilities.

Quoted 33 lines
testcases/kernel/syscalls/kcmp/kcmp02.c new file +33 -0
+	{&pid1, &pid1, KCMP_FILE, &fd1, &fd_fake, EBADF}
+};
+
+int TST_TOTAL = ARRAY_SIZE(test_cases);
+
+static void cleanup(void);
+static void setup(void);
+static void kcmp_verify(const struct test_case *test);
+
+int main(int ac, char **av)
+{
+	int lc;
+	int i;
+
+	tst_parse_opts(ac, av, NULL, NULL);
+	setup();
+
+	for (lc = 0; TEST_LOOPING(lc); lc++) {
+		tst_count = 0;
+
+		for (i = 0; i < TST_TOTAL; i++)
+			kcmp_verify(&test_cases[i]);
+
+	}
+
+	cleanup();
+	tst_exit();
+}
+
+static void kcmp_verify(const struct test_case *test)
+{
+	TEST(kcmp(*(test->pid1), *(test->pid2), test->type,
+			  *(test->fd1), *(test->fd2)));

testcases/kernel/syscalls/kcmp/kcmp02.c line 101

Quoted 10 lines
testcases/kernel/syscalls/kcmp/kcmp02.c new file +10 -0
+
+	if (test->exp_errno && TEST_RETURN != -1) {
+		tst_resm(TFAIL, "kcmp() succeeded unexpectedly");
+		return;
+	}
+
+	if (!test->exp_errno && !TEST_RETURN) {
+		tst_resm(TFAIL | TTERRNO, "kcmp() failed unexpectedly");
+		return;
+	}

We do not have possitive testcases in this tests -> this branch is never called.

Quoted 41 lines
testcases/kernel/syscalls/kcmp/kcmp02.c new file +35 -0
+	if (test->exp_errno == TEST_ERRNO) {
+		tst_resm(TPASS | TTERRNO, "kcmp() returned the expected value");
+		return;
+	}
+
+	tst_resm(TFAIL | TTERRNO,
+		"kcmp() got unexpected return value: expected: %d - %s",
+			test->exp_errno, tst_strerrno(test->exp_errno));
+}
+
+static void setup(void)
+{
+	if ((tst_kvercmp(3, 5, 0)) < 0) {
+		tst_brkm(TCONF, NULL,
+			"This test can only run on kernels that are 3.5. and higher");
+	}
+
+	tst_tmpdir();
+
+	pid1 = getpid();
+	fd1 = SAFE_OPEN(cleanup, TEST_FILE, O_CREAT | O_RDWR | O_TRUNC);
+	fd2 = SAFE_OPEN(cleanup, TEST_FILE2, O_CREAT | O_RDWR | O_TRUNC);
+
+}
+
+static void cleanup(void)
+{
+	if (fd1 > 0 && close(fd1) < 0)
+		tst_resm(TWARN | TERRNO, "close fd1 failed");
+
+	if (fd2 > 0 && close(fd2) < 0)
+		tst_resm(TWARN | TERRNO, "close fd2 failed");
+	tst_rmdir();
+
+}
Signature · 5 lines
2.1.4


-- 
Mailing list info: http://lists.linux.it/listinfo/ltp
Signature · 2 lines
Cyril Hrubis
[email protected]