Simplify semctl03 testcases by dropping the variadicness from test
wrappers which might spin out of control if not handled correctly.
Also, it seems that the level of indirection for the valid union semun
argument went slightly too far, resulting in passing over an address of
the above mentioned union instead it's value, so fix that one as well.
Signed-off-by: Beata Michalska <beata.michalska(a)arm.com>
---
v2:
- restore test wrappers but drop variadicness from those
.../kernel/syscalls/ipc/semctl/semctl03.c | 23 +++++--------------
1 file changed, 6 insertions(+), 17 deletions(-)
diff --git a/testcases/kernel/syscalls/ipc/semctl/semctl03.c b/testcases/kernel/syscalls/ipc/semctl/semctl03.c
index f9f335e4a..dacd929b6 100644
--- a/testcases/kernel/syscalls/ipc/semctl/semctl03.c
+++ b/testcases/kernel/syscalls/ipc/semctl/semctl03.c
@@ -21,28 +21,16 @@ static int sem_id = -1;
static int bad_id = -1;
static struct semid_ds sem_ds;
-static union semun sem_un = {.buf = &sem_ds};
-static void *semds_ptr = &sem_un;
+static void *semds_ptr = &sem_ds;
static void *bad_ptr;
-static union semun arg = {0};
-static int libc_semctl(int semid, int semnum, int cmd, ...)
+static int libc_semctl(int semid, int semnum, int cmd, union semun arg)
{
- va_list ap;
-
- va_start(ap, cmd);
- arg = va_arg(ap, union semun);
- va_end(ap);
return semctl(semid, semnum, cmd, arg);
}
-static int sys_semctl(int semid, int semnum, int cmd, ...)
+static int sys_semctl(int semid, int semnum, int cmd, union semun arg)
{
- va_list ap;
-
- va_start(ap, cmd);
- arg = va_arg(ap, union semun);
- va_end(ap);
return tst_syscall(__NR_semctl, semid, semnum, cmd, arg);
}
@@ -61,7 +49,7 @@ static struct tcases {
static struct test_variants
{
- int (*semctl)(int semid, int semnum, int cmd, ...);
+ int (*semctl)(int semid, int semnum, int cmd, union semun arg);
char *desc;
} variants[] = {
{ .semctl = libc_semctl, .desc = "libc semctl()"},
@@ -74,13 +62,14 @@ static void verify_semctl(unsigned int n)
{
struct tcases *tc = &tests[n];
struct test_variants *tv = &variants[tst_variant];
+ union semun arg = {.buf = *(tc->buf)};
if (tc->error == EFAULT && tv->semctl == libc_semctl) {
tst_res(TCONF, "EFAULT is skipped for libc variant");
return;
}
- TST_EXP_FAIL(tv->semctl(*(tc->sem_id), 0, tc->ipc_cmd, *(tc->buf)),
+ TST_EXP_FAIL(tv->semctl(*(tc->sem_id), 0, tc->ipc_cmd, arg),
tc->error, "semctl() with %s", tc->message);
}
--
2.25.1
In msync03, sbrk(0) was used and offset to get a pointer to an unmapped
area.
This caused issues in purecap because sbrk is now disabled, and
in compat with the 1.5 verrsion of musl because of a bug in the
sbrk implementation.
Instead, don't rely on sbrk at all and mmap a page, unmap it and use
this pointer in order to get an unmapped area of memory, generating an
ENOMEM in compat and purecap.
Signed-off-by: Teo Couprie Diaz <teo.coupriediaz(a)arm.com>
---
testcases/kernel/syscalls/msync/msync03.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/testcases/kernel/syscalls/msync/msync03.c b/testcases/kernel/syscalls/msync/msync03.c
index 8fa62e57a..6d59c9d26 100644
--- a/testcases/kernel/syscalls/msync/msync03.c
+++ b/testcases/kernel/syscalls/msync/msync03.c
@@ -130,8 +130,17 @@ static void setup(void)
SAFE_GETRLIMIT(NULL, RLIMIT_DATA, &rl);
addr3 = (char *)(uintptr_t)rl.rlim_max;
- /* memory pointed to by addr4 was not mapped */
- addr4 = sbrk(0) + (4 * page_sz);
+ /* memory pointed to by addr4 is not mapped */
+ addr4 = mmap(NULL, page_sz, PROT_NONE, MAP_PRIVATE, 0, 0);
+ if (addr4 == MAP_FAILED) {
+ addr4 = NULL;
+ } else {
+ if (!munmap(addr4, page_sz))
+ tst_resm(TFAIL, "Could not setup test, munmap failed :\n%s",
+ strerror(errno));
+ }
+
+ tst_resm(TINFO, "addr4 : %p", addr4);
}
static void msync_verify(struct test_case_t *tc)
--
2.25.1
Disable brk* tests as those depend on yet to be released Morello Linux
kernel version.
Signed-off-by: Beata Michalska <beata.michalska(a)arm.com>
---
Targetting LTP morello/master only
v2:
- Dropped the comment on dependency as one was added in a separate patch
runtest/morello_transitional_extended | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/runtest/morello_transitional_extended b/runtest/morello_transitional_extended
index 286e3e568..6bfa14058 100644
--- a/runtest/morello_transitional_extended
+++ b/runtest/morello_transitional_extended
@@ -1,8 +1,8 @@
#DESCRIPTION: Morello transitional extended ABI system calls
#KERN - depends on Morello Linux kernel release > morello-release-1.5.0
-brk01 brk01
-brk02 brk02
+#brk01 brk01
+#brk02 brk02
#KERN - epoll_*: depends on Morello Linux kernel release >= morello-release-1.5.0
epoll_create01 epoll_create01
--
2.25.1