* [LTP] [PATCH 1/3] syscall/kcmp*: Convert to new API
@ 2016-07-06 11:10 Xiao Yang
2016-07-06 11:10 ` [LTP] [PATCH 2/3] lib/cloner.c: Add tst_clone.h for " Xiao Yang
` (2 more replies)
0 siblings, 3 replies; 12+ messages in thread
From: Xiao Yang @ 2016-07-06 11:10 UTC (permalink / raw)
To: ltp
Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
---
testcases/kernel/syscalls/kcmp/kcmp.h | 2 +-
testcases/kernel/syscalls/kcmp/kcmp01.c | 119 ++++++++++++++------------------
testcases/kernel/syscalls/kcmp/kcmp02.c | 85 ++++++++---------------
3 files changed, 82 insertions(+), 124 deletions(-)
diff --git a/testcases/kernel/syscalls/kcmp/kcmp.h b/testcases/kernel/syscalls/kcmp/kcmp.h
index 513af39..ab50d4b 100644
--- a/testcases/kernel/syscalls/kcmp/kcmp.h
+++ b/testcases/kernel/syscalls/kcmp/kcmp.h
@@ -46,7 +46,7 @@ enum kcmp_type {
int kcmp(int pid1, int pid2, int type, int fd1, int fd2)
{
- return ltp_syscall(__NR_kcmp, pid1, pid2, type, fd1, fd2);
+ return tst_syscall(__NR_kcmp, pid1, pid2, type, fd1, fd2);
}
#endif
diff --git a/testcases/kernel/syscalls/kcmp/kcmp01.c b/testcases/kernel/syscalls/kcmp/kcmp01.c
index 96d6b07..3be3948 100644
--- a/testcases/kernel/syscalls/kcmp/kcmp01.c
+++ b/testcases/kernel/syscalls/kcmp/kcmp01.c
@@ -26,23 +26,19 @@
#define _GNU_SOURCE
-#include "test.h"
-#include "safe_macros.h"
+#include "tst_test.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;
@@ -58,92 +54,79 @@ static struct test_case {
{&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)
+static void cleanup(void)
{
- 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) {
- pid2 = tst_fork();
-
- if (pid2 == -1)
- tst_brkm(TBROK, cleanup, "fork failed");
+ if (fd1 > 0 && close(fd1) < 0)
+ tst_res(TWARN | TERRNO, "close fd1 failed");
+}
- if (!pid2)
- do_child(&test_cases[i]);
- else
- tst_record_childstatus(cleanup, pid2);
- tst_count++;
- }
- }
+static void cleanup_child(void)
+{
+ if (fd2 > 0 && close(fd2) < 0)
+ tst_res(TWARN | TERRNO, "close fd2 failed");
+ fd2 = 0;
- cleanup();
- tst_exit();
+ if (fd3 > 0 && close(fd3) < 0)
+ tst_res(TWARN | TERRNO, "close fd3 failed");
+ fd3 = 0;
}
static void do_child(const struct test_case *test)
{
pid2 = getpid();
+
+ fd3 = SAFE_OPEN(TEST_FILE2, O_CREAT | O_RDWR, 0666);
+
fd2 = dup(fd1);
- fd3 = SAFE_OPEN(cleanup_child, TEST_FILE2, O_CREAT | O_RDWR, 0666);
+ if (fd2 == -1) {
+ tst_res(TFAIL | TERRNO, "dup() failed unexpectedly");
+ goto end;
+ }
TEST(kcmp(*(test->pid1), *(test->pid2), test->type,
- *(test->fd1), *(test->fd2)));
+ *(test->fd1), *(test->fd2)));
- if (TEST_RETURN == -1)
- tst_resm(TFAIL | TTERRNO, "kcmp() failed unexpectedly");
+ if (TEST_RETURN == -1) {
+ tst_res(TFAIL | TTERRNO, "kcmp() failed unexpectedly");
+ goto end;
+ }
if ((test->exp_different && TEST_RETURN == 0)
- || (test->exp_different == 0 && TEST_RETURN))
- tst_resm(TFAIL, "kcmp() returned %lu instead of %d",
- TEST_RETURN, test->exp_different);
+ || (test->exp_different == 0 && TEST_RETURN)) {
+ tst_res(TFAIL, "kcmp() returned %lu instead of %d",
+ TEST_RETURN, test->exp_different);
+ goto end;
+ }
if ((test->exp_different == 0 && TEST_RETURN == 0)
|| (test->exp_different && TEST_RETURN))
- tst_resm(TPASS, "kcmp() returned the expected value");
+ tst_res(TPASS, "kcmp() returned the expected value");
- tst_exit();
+end:
+ cleanup_child();
}
-static void cleanup_child(void)
+static void verify_kcmp(unsigned int n)
{
- 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;
-}
+ struct test_case *tc = &test_cases[n];
-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");
- }
+ pid1 = getpid();
- tst_tmpdir();
+ fd1 = SAFE_OPEN(TEST_FILE, O_CREAT | O_RDWR | O_TRUNC);
- pid1 = getpid();
- fd1 = SAFE_OPEN(cleanup, TEST_FILE, O_CREAT | O_RDWR | O_TRUNC);
+ pid2 = SAFE_FORK();
+ if (!pid2)
+ do_child(tc);
+ else
+ SAFE_WAITPID(pid2, NULL, 0);
}
-static void cleanup(void)
-{
- if (fd1 > 0 && close(fd1) < 0)
- tst_resm(TWARN | TERRNO, "close fd1 failed");
- tst_rmdir();
-}
+static struct tst_test test = {
+ .tid = "kcmp01",
+ .tcnt = ARRAY_SIZE(test_cases),
+ .cleanup = cleanup,
+ .forks_child = 1,
+ .test = verify_kcmp,
+ .min_kver = "3.5.0",
+ .needs_tmpdir = 1,
+};
diff --git a/testcases/kernel/syscalls/kcmp/kcmp02.c b/testcases/kernel/syscalls/kcmp/kcmp02.c
index fb651d0..943c084 100644
--- a/testcases/kernel/syscalls/kcmp/kcmp02.c
+++ b/testcases/kernel/syscalls/kcmp/kcmp02.c
@@ -28,8 +28,7 @@
#define _GNU_SOURCE
-#include "test.h"
-#include "safe_macros.h"
+#include "tst_test.h"
#include "lapi/fcntl.h"
#include "kcmp.h"
@@ -43,10 +42,9 @@ static int pid1;
static int pid_unused;
static int fd_fake = -1;
-char *TCID = "kcmp02";
-
#include <sys/types.h>
#include <sys/wait.h>
+#include <limits.h>
static struct test_case {
int *pid1;
@@ -64,75 +62,52 @@ static struct test_case {
{&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)
+static void setup(void)
{
- int lc;
- int i;
-
- tst_parse_opts(ac, av, NULL, NULL);
- setup();
-
- for (lc = 0; TEST_LOOPING(lc); lc++) {
- tst_count = 0;
+ pid1 = getpid();
+ pid_unused = tst_get_unused_pid();
- for (i = 0; i < TST_TOTAL; i++)
- kcmp_verify(&test_cases[i]);
+ fd1 = SAFE_OPEN(TEST_FILE, O_CREAT | O_RDWR | O_TRUNC);
+ fd2 = SAFE_OPEN(TEST_FILE2, O_CREAT | O_RDWR | O_TRUNC);
+}
- }
+static void cleanup(void)
+{
+ if (fd1 > 0 && close(fd1) < 0)
+ tst_res(TWARN | TERRNO, "close fd1 failed");
- cleanup();
- tst_exit();
+ if (fd2 > 0 && close(fd2) < 0)
+ tst_res(TWARN | TERRNO, "close fd2 failed");
}
-static void kcmp_verify(const struct test_case *test)
+static void verify_kcmp(unsigned int n)
{
+ struct test_case *test = &test_cases[n];
+
TEST(kcmp(*(test->pid1), *(test->pid2), test->type,
- *(test->fd1), *(test->fd2)));
+ *(test->fd1), *(test->fd2)));
if (TEST_RETURN != -1) {
- tst_resm(TFAIL, "kcmp() succeeded unexpectedly");
+ tst_res(TFAIL, "kcmp() succeeded unexpectedly");
return;
}
if (test->exp_errno == TEST_ERRNO) {
- tst_resm(TPASS | TTERRNO, "kcmp() returned the expected value");
+ tst_res(TPASS | TTERRNO, "kcmp() returned the expected value");
return;
}
- tst_resm(TFAIL | TTERRNO,
+ tst_res(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();
- pid_unused = tst_get_unused_pid(cleanup);
- 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();
-
-}
+static struct tst_test test = {
+ .tid = "kcmp02",
+ .tcnt = ARRAY_SIZE(test_cases),
+ .setup = setup,
+ .cleanup = cleanup,
+ .test = verify_kcmp,
+ .min_kver = "3.5.0",
+ .needs_tmpdir = 1
+};
--
1.8.3.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [LTP] [PATCH 2/3] lib/cloner.c: Add tst_clone.h for new API
2016-07-06 11:10 [LTP] [PATCH 1/3] syscall/kcmp*: Convert to new API Xiao Yang
@ 2016-07-06 11:10 ` Xiao Yang
2016-07-19 14:09 ` Cyril Hrubis
2016-07-06 11:10 ` [LTP] [PATCH 3/3] syscalls/kcmp03.c: Add new testcase Xiao Yang
2016-07-19 13:53 ` [LTP] [PATCH 1/3] syscall/kcmp*: Convert to new API Cyril Hrubis
2 siblings, 1 reply; 12+ messages in thread
From: Xiao Yang @ 2016-07-06 11:10 UTC (permalink / raw)
To: ltp
Make sure the functions from lib/cloner.c can be used by new API.
Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
---
include/tst_clone.h | 39 +++++++++++++++++++++++++++++++++++++++
include/tst_test.h | 1 +
lib/cloner.c | 1 +
3 files changed, 41 insertions(+)
create mode 100644 include/tst_clone.h
diff --git a/include/tst_clone.h b/include/tst_clone.h
new file mode 100644
index 0000000..a6c5a5b
--- /dev/null
+++ b/include/tst_clone.h
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2016 Xiao Yang <yangx.jy@cn.fujitsu.com>
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program.
+ *
+ */
+
+#ifndef TST_CLONE_H__
+#define TST_CLONE_H__
+
+/* Functions from lib/cloner.c */
+int ltp_clone(unsigned long flags, int (*fn)(void *arg), void *arg,
+ size_t stack_size, void *stack);
+int ltp_clone7(unsigned long flags, int (*fn)(void *arg), void *arg,
+ size_t stack_size, void *stack, ...);
+int ltp_clone_malloc(unsigned long clone_flags, int (*fn)(void *arg),
+ void *arg, size_t stacksize);
+int ltp_clone_quick(unsigned long clone_flags, int (*fn)(void *arg),
+ void *arg);
+
+#define clone(...) (use_the_ltp_clone_functions, do_not_use_clone)
+
+#endif /* TST_CLONE_H__ */
diff --git a/include/tst_test.h b/include/tst_test.h
index 7d0cff8..c89e51f 100644
--- a/include/tst_test.h
+++ b/include/tst_test.h
@@ -32,6 +32,7 @@
#include "tst_process_state.h"
#include "tst_atomic.h"
#include "tst_kvercmp.h"
+#include "tst_clone.h"
/*
* Reports testcase result.
diff --git a/lib/cloner.c b/lib/cloner.c
index 63f223d..2947817 100644
--- a/lib/cloner.c
+++ b/lib/cloner.c
@@ -30,6 +30,7 @@
#include <stdarg.h>
#include "test.h"
#include "config.h"
+#include "tst_clone.h"
#undef clone /* we want to use clone() */
--
1.8.3.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [LTP] [PATCH 3/3] syscalls/kcmp03.c: Add new testcase
2016-07-06 11:10 [LTP] [PATCH 1/3] syscall/kcmp*: Convert to new API Xiao Yang
2016-07-06 11:10 ` [LTP] [PATCH 2/3] lib/cloner.c: Add tst_clone.h for " Xiao Yang
@ 2016-07-06 11:10 ` Xiao Yang
2016-07-19 14:21 ` Cyril Hrubis
2016-07-19 13:53 ` [LTP] [PATCH 1/3] syscall/kcmp*: Convert to new API Cyril Hrubis
2 siblings, 1 reply; 12+ messages in thread
From: Xiao Yang @ 2016-07-06 11:10 UTC (permalink / raw)
To: ltp
1) kcmp() returns 0 if the processes share the same file system
information.
2) kcmp() returns 0 if the processes share I/O context.
3) kcmp() returns 0 if the processes share the same list of
System V semaphore undo operations.
4) kcmp() returns 0 if the processes share the same address space.
Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
---
runtest/syscalls | 1 +
testcases/kernel/syscalls/.gitignore | 1 +
testcases/kernel/syscalls/kcmp/kcmp03.c | 107 ++++++++++++++++++++++++++++++++
3 files changed, 109 insertions(+)
create mode 100644 testcases/kernel/syscalls/kcmp/kcmp03.c
diff --git a/runtest/syscalls b/runtest/syscalls
index ed63358..a76df9a 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -484,6 +484,7 @@ keyctl01 keyctl01
kcmp01 kcmp01
kcmp02 kcmp02
+kcmp03 kcmp03
kill01 kill01
kill02 kill02
diff --git a/testcases/kernel/syscalls/.gitignore b/testcases/kernel/syscalls/.gitignore
index 0512f8a..0c16830 100644
--- a/testcases/kernel/syscalls/.gitignore
+++ b/testcases/kernel/syscalls/.gitignore
@@ -452,6 +452,7 @@
/keyctl/keyctl01
/kcmp/kcmp01
/kcmp/kcmp02
+/kcmp/kcmp03
/kill/kill01
/kill/kill02
/kill/kill03
diff --git a/testcases/kernel/syscalls/kcmp/kcmp03.c b/testcases/kernel/syscalls/kcmp/kcmp03.c
new file mode 100644
index 0000000..e144609
--- /dev/null
+++ b/testcases/kernel/syscalls/kcmp/kcmp03.c
@@ -0,0 +1,107 @@
+/*
+ * Copyright (c) 2016 Xiao Yang <yangx.jy@cn.fujitsu.com>
+ *
+ * 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 would 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.
+ */
+
+ /*
+ * Testname: kcmp03.c
+ *
+ * Description:
+ * 1) kcmp() returns 0 if the processes share the same file system information.
+ * 2) kcmp() returns 0 if the processes share I/O context.
+ * 3) kcmp() returns 0 if the processes share the same list of System V
+ * semaphore undo operations.
+ * 4) kcmp() returns 0 if the processes share the same address space.
+ */
+
+#define _GNU_SOURCE
+
+#include <errno.h>
+#include <stdlib.h>
+#include <sched.h>
+#include <sys/wait.h>
+#include "tst_test.h"
+#include "kcmp.h"
+
+#ifndef CLONE_SYSVSEM
+#define CLONE_SYSVSEM 0x00040000
+#endif
+
+#ifndef CLONE_IO
+#define CLONE_IO 0x80000000
+#endif
+
+#define STACK_SIZE (1024*1024)
+
+static int pid1;
+static int pid2;
+
+static struct tcase {
+ int clone_type;
+ int kcmp_type;
+} tcases[] = {
+ {CLONE_VM, KCMP_VM},
+ {CLONE_FS, KCMP_FS},
+ {CLONE_IO, KCMP_IO},
+ {CLONE_SYSVSEM, KCMP_SYSVSEM}
+};
+
+static int do_child(void *arg)
+{
+ pid2 = getpid();
+
+ TEST(kcmp(pid1, pid2, *(int *)arg, 0, 0));
+ if (TEST_RETURN == -1) {
+ tst_res(TFAIL | TTERRNO, "kcmp() failed unexpectedly");
+ return 1;
+ }
+
+ if (TEST_RETURN == 0) {
+ tst_res(TPASS, "kcmp() returned the expected value");
+ } else {
+ tst_res(TFAIL, "kcmp() returned the unexpected value");
+ return 1;
+ }
+
+ return 0;
+}
+
+static void verify_kcmp(unsigned int n)
+{
+ int res;
+ void *stack;
+
+ struct tcase *tc = &tcases[n];
+
+ pid1 = getpid();
+
+ stack = SAFE_MALLOC(STACK_SIZE);
+
+ res = ltp_clone(tc->clone_type | SIGCHLD, do_child, &tc->kcmp_type,
+ STACK_SIZE, stack);
+ if (res == -1)
+ tst_res(TFAIL | TERRNO, "clone() Failed");
+
+ SAFE_WAIT(NULL);
+
+ free(stack);
+}
+
+static struct tst_test test = {
+ .tid = "kcmp03",
+ .tcnt = ARRAY_SIZE(tcases),
+ .test = verify_kcmp,
+ .min_kver = "3.5.0"
+};
--
1.8.3.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [LTP] [PATCH 1/3] syscall/kcmp*: Convert to new API
2016-07-06 11:10 [LTP] [PATCH 1/3] syscall/kcmp*: Convert to new API Xiao Yang
2016-07-06 11:10 ` [LTP] [PATCH 2/3] lib/cloner.c: Add tst_clone.h for " Xiao Yang
2016-07-06 11:10 ` [LTP] [PATCH 3/3] syscalls/kcmp03.c: Add new testcase Xiao Yang
@ 2016-07-19 13:53 ` Cyril Hrubis
2016-07-20 8:21 ` [LTP] [PATCH v2 1/3] syscalls/kcmp*: " Xiao Yang
2 siblings, 1 reply; 12+ messages in thread
From: Cyril Hrubis @ 2016-07-19 13:53 UTC (permalink / raw)
To: ltp
Hi!
> +static void verify_kcmp(unsigned int n)
> {
> - 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;
> -}
> + struct test_case *tc = &test_cases[n];
>
> -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");
> - }
> + pid1 = getpid();
>
> - tst_tmpdir();
> + fd1 = SAFE_OPEN(TEST_FILE, O_CREAT | O_RDWR | O_TRUNC);
This SAFE_OPEN() has to be done in the test setup, otherwise it will
start to fail with large enough iteration (-i) parameter once the
maximal number of open files is reached.
The rest looks good.
--
Cyril Hrubis
chrubis@suse.cz
^ permalink raw reply [flat|nested] 12+ messages in thread
* [LTP] [PATCH 2/3] lib/cloner.c: Add tst_clone.h for new API
2016-07-06 11:10 ` [LTP] [PATCH 2/3] lib/cloner.c: Add tst_clone.h for " Xiao Yang
@ 2016-07-19 14:09 ` Cyril Hrubis
0 siblings, 0 replies; 12+ messages in thread
From: Cyril Hrubis @ 2016-07-19 14:09 UTC (permalink / raw)
To: ltp
Hi!
> +/*
> + * Copyright (c) 2016 Xiao Yang <yangx.jy@cn.fujitsu.com>
> + *
> + * 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.
> + *
> + * You should have received a copy of the GNU General Public License along
> + * with this program.
> + *
> + */
> +
> +#ifndef TST_CLONE_H__
> +#define TST_CLONE_H__
> +
> +/* Functions from lib/cloner.c */
> +int ltp_clone(unsigned long flags, int (*fn)(void *arg), void *arg,
> + size_t stack_size, void *stack);
> +int ltp_clone7(unsigned long flags, int (*fn)(void *arg), void *arg,
> + size_t stack_size, void *stack, ...);
> +int ltp_clone_malloc(unsigned long clone_flags, int (*fn)(void *arg),
> + void *arg, size_t stacksize);
> +int ltp_clone_quick(unsigned long clone_flags, int (*fn)(void *arg),
> + void *arg);
I'm undecided if we should rename these to start with tst_ in the new
library. Apart from that it's fine.
--
Cyril Hrubis
chrubis@suse.cz
^ permalink raw reply [flat|nested] 12+ messages in thread
* [LTP] [PATCH 3/3] syscalls/kcmp03.c: Add new testcase
2016-07-06 11:10 ` [LTP] [PATCH 3/3] syscalls/kcmp03.c: Add new testcase Xiao Yang
@ 2016-07-19 14:21 ` Cyril Hrubis
0 siblings, 0 replies; 12+ messages in thread
From: Cyril Hrubis @ 2016-07-19 14:21 UTC (permalink / raw)
To: ltp
Hi!
> +#ifndef CLONE_SYSVSEM
> +#define CLONE_SYSVSEM 0x00040000
> +#endif
> +
> +#ifndef CLONE_IO
> +#define CLONE_IO 0x80000000
> +#endif
These should rather go to the lapi/namespaces_constants.h
> +#define STACK_SIZE (1024*1024)
> +
> +static int pid1;
> +static int pid2;
> +
> +static struct tcase {
> + int clone_type;
> + int kcmp_type;
> +} tcases[] = {
> + {CLONE_VM, KCMP_VM},
> + {CLONE_FS, KCMP_FS},
> + {CLONE_IO, KCMP_IO},
> + {CLONE_SYSVSEM, KCMP_SYSVSEM}
> +};
> +
> +static int do_child(void *arg)
> +{
> + pid2 = getpid();
> +
> + TEST(kcmp(pid1, pid2, *(int *)arg, 0, 0));
> +
> + if (TEST_RETURN == -1) {
> + tst_res(TFAIL | TTERRNO, "kcmp() failed unexpectedly");
> + return 1;
> + }
> +
> + if (TEST_RETURN == 0) {
> + tst_res(TPASS, "kcmp() returned the expected value");
> + } else {
> + tst_res(TFAIL, "kcmp() returned the unexpected value");
> + return 1;
Why do we do the return 1 here if the value is not used at all? Why
don't we just fall down to the return 0; below?
> + }
> +
> + return 0;
> +}
> +
> +static void verify_kcmp(unsigned int n)
> +{
> + int res;
> + void *stack;
> +
> + struct tcase *tc = &tcases[n];
> +
> + pid1 = getpid();
> +
> + stack = SAFE_MALLOC(STACK_SIZE);
Well, the stack could be allocated once in the test setup and freed in
the test cleanup.
> + res = ltp_clone(tc->clone_type | SIGCHLD, do_child, &tc->kcmp_type,
> + STACK_SIZE, stack);
> + if (res == -1)
> + tst_res(TFAIL | TERRNO, "clone() Failed");
> +
> + SAFE_WAIT(NULL);
> +
> + free(stack);
> +}
> +
> +static struct tst_test test = {
> + .tid = "kcmp03",
> + .tcnt = ARRAY_SIZE(tcases),
> + .test = verify_kcmp,
> + .min_kver = "3.5.0"
> +};
The rest is fine.
--
Cyril Hrubis
chrubis@suse.cz
^ permalink raw reply [flat|nested] 12+ messages in thread
* [LTP] [PATCH v2 1/3] syscalls/kcmp*: Convert to new API
2016-07-19 13:53 ` [LTP] [PATCH 1/3] syscall/kcmp*: Convert to new API Cyril Hrubis
@ 2016-07-20 8:21 ` Xiao Yang
2016-07-20 8:21 ` [LTP] [PATCH v2 2/3] lib/cloner.c: Add tst_clone.h for " Xiao Yang
` (2 more replies)
0 siblings, 3 replies; 12+ messages in thread
From: Xiao Yang @ 2016-07-20 8:21 UTC (permalink / raw)
To: ltp
Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
---
testcases/kernel/syscalls/kcmp/kcmp.h | 2 +-
testcases/kernel/syscalls/kcmp/kcmp01.c | 121 ++++++++++++++------------------
testcases/kernel/syscalls/kcmp/kcmp02.c | 85 ++++++++--------------
3 files changed, 84 insertions(+), 124 deletions(-)
diff --git a/testcases/kernel/syscalls/kcmp/kcmp.h b/testcases/kernel/syscalls/kcmp/kcmp.h
index 513af39..ab50d4b 100644
--- a/testcases/kernel/syscalls/kcmp/kcmp.h
+++ b/testcases/kernel/syscalls/kcmp/kcmp.h
@@ -46,7 +46,7 @@ enum kcmp_type {
int kcmp(int pid1, int pid2, int type, int fd1, int fd2)
{
- return ltp_syscall(__NR_kcmp, pid1, pid2, type, fd1, fd2);
+ return tst_syscall(__NR_kcmp, pid1, pid2, type, fd1, fd2);
}
#endif
diff --git a/testcases/kernel/syscalls/kcmp/kcmp01.c b/testcases/kernel/syscalls/kcmp/kcmp01.c
index 96d6b07..a8b43d4 100644
--- a/testcases/kernel/syscalls/kcmp/kcmp01.c
+++ b/testcases/kernel/syscalls/kcmp/kcmp01.c
@@ -26,23 +26,19 @@
#define _GNU_SOURCE
-#include "test.h"
-#include "safe_macros.h"
+#include "tst_test.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;
@@ -58,92 +54,81 @@ static struct test_case {
{&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)
+static void setup(void)
{
- 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) {
- pid2 = tst_fork();
+ fd1 = SAFE_OPEN(TEST_FILE, O_CREAT | O_RDWR | O_TRUNC);
+}
- if (pid2 == -1)
- tst_brkm(TBROK, cleanup, "fork failed");
+static void cleanup(void)
+{
+ if (fd1 > 0 && close(fd1) < 0)
+ tst_res(TWARN | TERRNO, "close fd1 failed");
+}
- if (!pid2)
- do_child(&test_cases[i]);
- else
- tst_record_childstatus(cleanup, pid2);
- tst_count++;
- }
- }
+static void cleanup_child(void)
+{
+ if (fd2 > 0 && close(fd2) < 0)
+ tst_res(TWARN | TERRNO, "close fd2 failed");
+ fd2 = 0;
- cleanup();
- tst_exit();
+ if (fd3 > 0 && close(fd3) < 0)
+ tst_res(TWARN | TERRNO, "close fd3 failed");
+ fd3 = 0;
}
static void do_child(const struct test_case *test)
{
pid2 = getpid();
+
+ fd3 = SAFE_OPEN(TEST_FILE2, O_CREAT | O_RDWR, 0666);
+
fd2 = dup(fd1);
- fd3 = SAFE_OPEN(cleanup_child, TEST_FILE2, O_CREAT | O_RDWR, 0666);
+ if (fd2 == -1) {
+ tst_res(TFAIL | TERRNO, "dup() failed unexpectedly");
+ goto end;
+ }
TEST(kcmp(*(test->pid1), *(test->pid2), test->type,
- *(test->fd1), *(test->fd2)));
+ *(test->fd1), *(test->fd2)));
- if (TEST_RETURN == -1)
- tst_resm(TFAIL | TTERRNO, "kcmp() failed unexpectedly");
+ if (TEST_RETURN == -1) {
+ tst_res(TFAIL | TTERRNO, "kcmp() failed unexpectedly");
+ goto end;
+ }
if ((test->exp_different && TEST_RETURN == 0)
- || (test->exp_different == 0 && TEST_RETURN))
- tst_resm(TFAIL, "kcmp() returned %lu instead of %d",
- TEST_RETURN, test->exp_different);
+ || (test->exp_different == 0 && TEST_RETURN)) {
+ tst_res(TFAIL, "kcmp() returned %lu instead of %d",
+ TEST_RETURN, test->exp_different);
+ goto end;
+ }
if ((test->exp_different == 0 && TEST_RETURN == 0)
|| (test->exp_different && TEST_RETURN))
- tst_resm(TPASS, "kcmp() returned the expected value");
+ tst_res(TPASS, "kcmp() returned the expected value");
- tst_exit();
+end:
+ cleanup_child();
}
-static void cleanup_child(void)
+static void verify_kcmp(unsigned int n)
{
- 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();
+ struct test_case *tc = &test_cases[n];
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();
+ pid2 = SAFE_FORK();
+ if (!pid2)
+ do_child(tc);
}
+
+static struct tst_test test = {
+ .tid = "kcmp01",
+ .tcnt = ARRAY_SIZE(test_cases),
+ .setup = setup,
+ .cleanup = cleanup,
+ .forks_child = 1,
+ .test = verify_kcmp,
+ .min_kver = "3.5.0",
+ .needs_tmpdir = 1,
+};
diff --git a/testcases/kernel/syscalls/kcmp/kcmp02.c b/testcases/kernel/syscalls/kcmp/kcmp02.c
index fb651d0..943c084 100644
--- a/testcases/kernel/syscalls/kcmp/kcmp02.c
+++ b/testcases/kernel/syscalls/kcmp/kcmp02.c
@@ -28,8 +28,7 @@
#define _GNU_SOURCE
-#include "test.h"
-#include "safe_macros.h"
+#include "tst_test.h"
#include "lapi/fcntl.h"
#include "kcmp.h"
@@ -43,10 +42,9 @@ static int pid1;
static int pid_unused;
static int fd_fake = -1;
-char *TCID = "kcmp02";
-
#include <sys/types.h>
#include <sys/wait.h>
+#include <limits.h>
static struct test_case {
int *pid1;
@@ -64,75 +62,52 @@ static struct test_case {
{&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)
+static void setup(void)
{
- int lc;
- int i;
-
- tst_parse_opts(ac, av, NULL, NULL);
- setup();
-
- for (lc = 0; TEST_LOOPING(lc); lc++) {
- tst_count = 0;
+ pid1 = getpid();
+ pid_unused = tst_get_unused_pid();
- for (i = 0; i < TST_TOTAL; i++)
- kcmp_verify(&test_cases[i]);
+ fd1 = SAFE_OPEN(TEST_FILE, O_CREAT | O_RDWR | O_TRUNC);
+ fd2 = SAFE_OPEN(TEST_FILE2, O_CREAT | O_RDWR | O_TRUNC);
+}
- }
+static void cleanup(void)
+{
+ if (fd1 > 0 && close(fd1) < 0)
+ tst_res(TWARN | TERRNO, "close fd1 failed");
- cleanup();
- tst_exit();
+ if (fd2 > 0 && close(fd2) < 0)
+ tst_res(TWARN | TERRNO, "close fd2 failed");
}
-static void kcmp_verify(const struct test_case *test)
+static void verify_kcmp(unsigned int n)
{
+ struct test_case *test = &test_cases[n];
+
TEST(kcmp(*(test->pid1), *(test->pid2), test->type,
- *(test->fd1), *(test->fd2)));
+ *(test->fd1), *(test->fd2)));
if (TEST_RETURN != -1) {
- tst_resm(TFAIL, "kcmp() succeeded unexpectedly");
+ tst_res(TFAIL, "kcmp() succeeded unexpectedly");
return;
}
if (test->exp_errno == TEST_ERRNO) {
- tst_resm(TPASS | TTERRNO, "kcmp() returned the expected value");
+ tst_res(TPASS | TTERRNO, "kcmp() returned the expected value");
return;
}
- tst_resm(TFAIL | TTERRNO,
+ tst_res(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();
- pid_unused = tst_get_unused_pid(cleanup);
- 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();
-
-}
+static struct tst_test test = {
+ .tid = "kcmp02",
+ .tcnt = ARRAY_SIZE(test_cases),
+ .setup = setup,
+ .cleanup = cleanup,
+ .test = verify_kcmp,
+ .min_kver = "3.5.0",
+ .needs_tmpdir = 1
+};
--
1.8.3.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [LTP] [PATCH v2 2/3] lib/cloner.c: Add tst_clone.h for new API
2016-07-20 8:21 ` [LTP] [PATCH v2 1/3] syscalls/kcmp*: " Xiao Yang
@ 2016-07-20 8:21 ` Xiao Yang
2016-07-25 15:13 ` Cyril Hrubis
2016-07-20 8:21 ` [LTP] [PATCH v2 3/3] syscalls/kcmp03.c: Add new testcase Xiao Yang
2016-07-25 13:55 ` [LTP] [PATCH v2 1/3] syscalls/kcmp*: Convert to new API Cyril Hrubis
2 siblings, 1 reply; 12+ messages in thread
From: Xiao Yang @ 2016-07-20 8:21 UTC (permalink / raw)
To: ltp
Make sure the functions from lib/cloner.c can be used by new API.
Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
---
include/tst_clone.h | 39 +++++++++++++++++++++++++++++++++++++++
include/tst_test.h | 1 +
lib/cloner.c | 1 +
3 files changed, 41 insertions(+)
create mode 100644 include/tst_clone.h
diff --git a/include/tst_clone.h b/include/tst_clone.h
new file mode 100644
index 0000000..a6c5a5b
--- /dev/null
+++ b/include/tst_clone.h
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2016 Xiao Yang <yangx.jy@cn.fujitsu.com>
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program.
+ *
+ */
+
+#ifndef TST_CLONE_H__
+#define TST_CLONE_H__
+
+/* Functions from lib/cloner.c */
+int ltp_clone(unsigned long flags, int (*fn)(void *arg), void *arg,
+ size_t stack_size, void *stack);
+int ltp_clone7(unsigned long flags, int (*fn)(void *arg), void *arg,
+ size_t stack_size, void *stack, ...);
+int ltp_clone_malloc(unsigned long clone_flags, int (*fn)(void *arg),
+ void *arg, size_t stacksize);
+int ltp_clone_quick(unsigned long clone_flags, int (*fn)(void *arg),
+ void *arg);
+
+#define clone(...) (use_the_ltp_clone_functions, do_not_use_clone)
+
+#endif /* TST_CLONE_H__ */
diff --git a/include/tst_test.h b/include/tst_test.h
index 7d0cff8..c89e51f 100644
--- a/include/tst_test.h
+++ b/include/tst_test.h
@@ -32,6 +32,7 @@
#include "tst_process_state.h"
#include "tst_atomic.h"
#include "tst_kvercmp.h"
+#include "tst_clone.h"
/*
* Reports testcase result.
diff --git a/lib/cloner.c b/lib/cloner.c
index 63f223d..2947817 100644
--- a/lib/cloner.c
+++ b/lib/cloner.c
@@ -30,6 +30,7 @@
#include <stdarg.h>
#include "test.h"
#include "config.h"
+#include "tst_clone.h"
#undef clone /* we want to use clone() */
--
1.8.3.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [LTP] [PATCH v2 3/3] syscalls/kcmp03.c: Add new testcase
2016-07-20 8:21 ` [LTP] [PATCH v2 1/3] syscalls/kcmp*: " Xiao Yang
2016-07-20 8:21 ` [LTP] [PATCH v2 2/3] lib/cloner.c: Add tst_clone.h for " Xiao Yang
@ 2016-07-20 8:21 ` Xiao Yang
2016-07-25 15:27 ` Cyril Hrubis
2016-07-25 13:55 ` [LTP] [PATCH v2 1/3] syscalls/kcmp*: Convert to new API Cyril Hrubis
2 siblings, 1 reply; 12+ messages in thread
From: Xiao Yang @ 2016-07-20 8:21 UTC (permalink / raw)
To: ltp
1) kcmp() returns 0 if the processes share the same file system
information.
2) kcmp() returns 0 if the processes share I/O context.
3) kcmp() returns 0 if the processes share the same list of
System V semaphore undo operations.
4) kcmp() returns 0 if the processes share the same address space.
Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
---
include/lapi/sched.h | 16 +++++
runtest/syscalls | 1 +
testcases/kernel/syscalls/.gitignore | 1 +
testcases/kernel/syscalls/kcmp/kcmp03.c | 105 ++++++++++++++++++++++++++++++++
4 files changed, 123 insertions(+)
create mode 100644 testcases/kernel/syscalls/kcmp/kcmp03.c
diff --git a/include/lapi/sched.h b/include/lapi/sched.h
index 189c2de..a0efbb0 100644
--- a/include/lapi/sched.h
+++ b/include/lapi/sched.h
@@ -56,4 +56,20 @@ int sched_getattr(pid_t pid,
return syscall(__NR_sched_getattr, pid, attr, size, flags);
}
+#ifndef CLONE_VM
+#define CLONE_VM 0x00000100
+#endif
+
+#ifndef CLONE_FS
+#define CLONE_FS 0x00000200
+#endif
+
+#ifndef CLONE_SYSVSEM
+#define CLONE_SYSVSEM 0x00040000
+#endif
+
+#ifndef CLONE_IO
+#define CLONE_IO 0x80000000
+#endif
+
#endif /* __SCHED_H__ */
diff --git a/runtest/syscalls b/runtest/syscalls
index 40b3257..75fdd4a 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -484,6 +484,7 @@ keyctl01 keyctl01
kcmp01 kcmp01
kcmp02 kcmp02
+kcmp03 kcmp03
kill01 kill01
kill02 kill02
diff --git a/testcases/kernel/syscalls/.gitignore b/testcases/kernel/syscalls/.gitignore
index fb980ba..217b38e 100644
--- a/testcases/kernel/syscalls/.gitignore
+++ b/testcases/kernel/syscalls/.gitignore
@@ -452,6 +452,7 @@
/keyctl/keyctl01
/kcmp/kcmp01
/kcmp/kcmp02
+/kcmp/kcmp03
/kill/kill01
/kill/kill02
/kill/kill03
diff --git a/testcases/kernel/syscalls/kcmp/kcmp03.c b/testcases/kernel/syscalls/kcmp/kcmp03.c
new file mode 100644
index 0000000..d64ea2c
--- /dev/null
+++ b/testcases/kernel/syscalls/kcmp/kcmp03.c
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 2016 Xiao Yang <yangx.jy@cn.fujitsu.com>
+ *
+ * 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 would 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.
+ */
+
+ /*
+ * Testname: kcmp03.c
+ *
+ * Description:
+ * 1) kcmp() returns 0 if the processes share the same file system information.
+ * 2) kcmp() returns 0 if the processes share I/O context.
+ * 3) kcmp() returns 0 if the processes share the same list of System V
+ * semaphore undo operations.
+ * 4) kcmp() returns 0 if the processes share the same address space.
+ */
+
+#define _GNU_SOURCE
+
+#include <errno.h>
+#include <stdlib.h>
+#include <sched.h>
+#include <sys/wait.h>
+#include "tst_test.h"
+#include "kcmp.h"
+#include "lapi/sched.h"
+
+#define STACK_SIZE (1024*1024)
+
+static int pid1;
+static int pid2;
+static void *stack;
+
+static struct tcase {
+ int clone_type;
+ int kcmp_type;
+} tcases[] = {
+ {CLONE_VM, KCMP_VM},
+ {CLONE_FS, KCMP_FS},
+ {CLONE_IO, KCMP_IO},
+ {CLONE_SYSVSEM, KCMP_SYSVSEM}
+};
+
+static void setup(void)
+{
+ stack = SAFE_MALLOC(STACK_SIZE);
+}
+
+static void cleanup(void)
+{
+ free(stack);
+}
+
+static int do_child(void *arg)
+{
+ pid2 = getpid();
+
+ TEST(kcmp(pid1, pid2, *(int *)arg, 0, 0));
+ if (TEST_RETURN == -1) {
+ tst_res(TFAIL | TTERRNO, "kcmp() failed unexpectedly");
+ return 0;
+ }
+
+ if (TEST_RETURN == 0)
+ tst_res(TPASS, "kcmp() returned the expected value");
+ else
+ tst_res(TFAIL, "kcmp() returned the unexpected value");
+
+ return 0;
+}
+
+static void verify_kcmp(unsigned int n)
+{
+ int res;
+
+ struct tcase *tc = &tcases[n];
+
+ pid1 = getpid();
+
+ res = ltp_clone(tc->clone_type | SIGCHLD, do_child, &tc->kcmp_type,
+ STACK_SIZE, stack);
+ if (res == -1)
+ tst_res(TFAIL | TERRNO, "clone() Failed");
+}
+
+static struct tst_test test = {
+ .tid = "kcmp03",
+ .tcnt = ARRAY_SIZE(tcases),
+ .setup = setup,
+ .cleanup = cleanup,
+ .forks_child = 1,
+ .test = verify_kcmp,
+ .min_kver = "3.5.0"
+};
--
1.8.3.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [LTP] [PATCH v2 1/3] syscalls/kcmp*: Convert to new API
2016-07-20 8:21 ` [LTP] [PATCH v2 1/3] syscalls/kcmp*: " Xiao Yang
2016-07-20 8:21 ` [LTP] [PATCH v2 2/3] lib/cloner.c: Add tst_clone.h for " Xiao Yang
2016-07-20 8:21 ` [LTP] [PATCH v2 3/3] syscalls/kcmp03.c: Add new testcase Xiao Yang
@ 2016-07-25 13:55 ` Cyril Hrubis
2 siblings, 0 replies; 12+ messages in thread
From: Cyril Hrubis @ 2016-07-25 13:55 UTC (permalink / raw)
To: ltp
Hi!
I've simplified the kcmp01.c a bit and pushed, thanks.
(We can safely use SAFE_CLOSE() in child since it's cleanup is not
executed from test cleanup())
--
Cyril Hrubis
chrubis@suse.cz
^ permalink raw reply [flat|nested] 12+ messages in thread
* [LTP] [PATCH v2 2/3] lib/cloner.c: Add tst_clone.h for new API
2016-07-20 8:21 ` [LTP] [PATCH v2 2/3] lib/cloner.c: Add tst_clone.h for " Xiao Yang
@ 2016-07-25 15:13 ` Cyril Hrubis
0 siblings, 0 replies; 12+ messages in thread
From: Cyril Hrubis @ 2016-07-25 15:13 UTC (permalink / raw)
To: ltp
Hi!
> Make sure the functions from lib/cloner.c can be used by new API.
I've made use of the tst_clone.h in the test.h as well, since it does
not makes sense to keep two copies of the function prototypes and
pushed, thanks.
--
Cyril Hrubis
chrubis@suse.cz
^ permalink raw reply [flat|nested] 12+ messages in thread
* [LTP] [PATCH v2 3/3] syscalls/kcmp03.c: Add new testcase
2016-07-20 8:21 ` [LTP] [PATCH v2 3/3] syscalls/kcmp03.c: Add new testcase Xiao Yang
@ 2016-07-25 15:27 ` Cyril Hrubis
0 siblings, 0 replies; 12+ messages in thread
From: Cyril Hrubis @ 2016-07-25 15:27 UTC (permalink / raw)
To: ltp
Hi!
Pushed, thanks.
--
Cyril Hrubis
chrubis@suse.cz
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2016-07-25 15:27 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-07-06 11:10 [LTP] [PATCH 1/3] syscall/kcmp*: Convert to new API Xiao Yang
2016-07-06 11:10 ` [LTP] [PATCH 2/3] lib/cloner.c: Add tst_clone.h for " Xiao Yang
2016-07-19 14:09 ` Cyril Hrubis
2016-07-06 11:10 ` [LTP] [PATCH 3/3] syscalls/kcmp03.c: Add new testcase Xiao Yang
2016-07-19 14:21 ` Cyril Hrubis
2016-07-19 13:53 ` [LTP] [PATCH 1/3] syscall/kcmp*: Convert to new API Cyril Hrubis
2016-07-20 8:21 ` [LTP] [PATCH v2 1/3] syscalls/kcmp*: " Xiao Yang
2016-07-20 8:21 ` [LTP] [PATCH v2 2/3] lib/cloner.c: Add tst_clone.h for " Xiao Yang
2016-07-25 15:13 ` Cyril Hrubis
2016-07-20 8:21 ` [LTP] [PATCH v2 3/3] syscalls/kcmp03.c: Add new testcase Xiao Yang
2016-07-25 15:27 ` Cyril Hrubis
2016-07-25 13:55 ` [LTP] [PATCH v2 1/3] syscalls/kcmp*: Convert to new API Cyril Hrubis
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox