[LTP] [PATCH] syscalls/cma: add runtime check to setup()

Jan Stancek
2013-04-23T08:17:27Z

__NR_process_vm_readv / __NR_process_vm_writev defined doesn't
guarantee, that kernel supports these syscalls. Add check to setup(),
which uses ltp_syscall(). If syscall isn't supported it will
end the testcase with TCONF.

This also fixes small copy-paste error in process_vm_writev02.

Signed-off-by: Jan Stancek <jstancek@redhat.com>
---
testcases/kernel/syscalls/cma/process_vm.h | 1 +
testcases/kernel/syscalls/cma/process_vm01.c | 2 ++
testcases/kernel/syscalls/cma/process_vm_readv02.c | 2 ++
testcases/kernel/syscalls/cma/process_vm_readv03.c | 2 ++
.../kernel/syscalls/cma/process_vm_writev02.c | 6 ++++--
5 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/testcases/kernel/syscalls/cma/process_vm.h b/testcases/kernel/syscalls/cma/process_vm.h
index 5241fa1..35086c6 100644
--- a/testcases/kernel/syscalls/cma/process_vm.h
+++ b/testcases/kernel/syscalls/cma/process_vm.h
@@ -31,6 +31,7 @@
#include <sys/syscall.h>
#include <sys/uio.h>
#include <unistd.h>
+#include "linux_syscall_numbers.h"

union semun {
int val;
diff --git a/testcases/kernel/syscalls/cma/process_vm01.c b/testcases/kernel/syscalls/cma/process_vm01.c
index 1a91570..bb09855 100644
--- a/testcases/kernel/syscalls/cma/process_vm01.c
+++ b/testcases/kernel/syscalls/cma/process_vm01.c
@@ -108,6 +108,7 @@ static void setup(char *argv[])
else if (rflag) {
TCID = TCID_readv;
#if defined(__NR_process_vm_readv)
+ ltp_syscall(__NR_process_vm_readv, 0, NULL, 0, NULL, 0, 0);
cma_test_params = cma_test_params_read;
#else
tst_brkm(TCONF, NULL, "process_vm_readv does not"
@@ -116,6 +117,7 @@ static void setup(char *argv[])
} else if (wflag) {
TCID = TCID_writev;
#if defined(__NR_process_vm_writev)
+ ltp_syscall(__NR_process_vm_writev, 0, NULL, 0, NULL, 0, 0);
cma_test_params = cma_test_params_write;
#else
tst_brkm(TCONF, NULL, "process_vm_writev does not"
diff --git a/testcases/kernel/syscalls/cma/process_vm_readv02.c b/testcases/kernel/syscalls/cma/process_vm_readv02.c
index dea1bbe..752a513 100644
--- a/testcases/kernel/syscalls/cma/process_vm_readv02.c
+++ b/testcases/kernel/syscalls/cma/process_vm_readv02.c
@@ -159,6 +159,8 @@ static void setup(void)
#if !defined(__NR_process_vm_readv)
tst_brkm(TCONF, NULL, "process_vm_readv does not exist "
"on your system");
+#else
+ ltp_syscall(__NR_process_vm_readv, 0, NULL, 0, NULL, 0, 0);
#endif
semid = init_sem(1);

diff --git a/testcases/kernel/syscalls/cma/process_vm_readv03.c b/testcases/kernel/syscalls/cma/process_vm_readv03.c
index 7475a64..2a8f631 100644
--- a/testcases/kernel/syscalls/cma/process_vm_readv03.c
+++ b/testcases/kernel/syscalls/cma/process_vm_readv03.c
@@ -261,6 +261,8 @@ static void setup(void)
#if !defined(__NR_process_vm_readv)
tst_brkm(TCONF, NULL, "process_vm_readv does not exist "
"on your system");
+#else
+ ltp_syscall(__NR_process_vm_readv, 0, NULL, 0, NULL, 0, 0);
#endif
semid = init_sem(1);
srand(time(NULL));
diff --git a/testcases/kernel/syscalls/cma/process_vm_writev02.c b/testcases/kernel/syscalls/cma/process_vm_writev02.c
index 0ea956d..6fd7aea 100644
--- a/testcases/kernel/syscalls/cma/process_vm_writev02.c
+++ b/testcases/kernel/syscalls/cma/process_vm_writev02.c
@@ -180,7 +180,7 @@ static void child_write(void)
tst_resm(TINFO, "child 2: write to the same memory location.");
TEST(test_process_vm_writev(pids[0], &local, 1, &remote, 1, 0));
if (TEST_RETURN != bufsz)
- tst_brkm(TFAIL | TERRNO, tst_exit, "process_vm_readv");
+ tst_brkm(TFAIL | TERRNO, tst_exit, "process_vm_writev");
}

static void setup(void)
@@ -191,9 +191,11 @@ static void setup(void)
sflag ? SAFE_STRTOL(NULL, sz_opt, 1, LONG_MAX - PADDING_SIZE * 2)
: 100000;

-#if !defined(__NR_process_vm_readv)
+#if !defined(__NR_process_vm_writev)
tst_brkm(TCONF, NULL, "process_vm_writev does not exist "
"on your system");
+#else
+ ltp_syscall(__NR_process_vm_writev, 0, NULL, 0, NULL, 0, 0);
#endif
semid = init_sem(1);

--
1.7.1