Skip to content

Commit

Permalink
syscalls: ppoll: Reuse struct time64_variants
Browse files Browse the repository at this point in the history
Lets reuse the common structure here.

Signed-off-by: Viresh Kumar <[email protected]>
Reviewed-by: Cyril Hrubis <[email protected]>
  • Loading branch information
vireshk authored and metan-ucw committed Sep 17, 2020
1 parent 9827141 commit c5cf170
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions testcases/kernel/syscalls/ppoll/ppoll01.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <sys/wait.h>
#include "lapi/syscalls.h"
#include "ltp_signal.h"
#include "time64_variants.h"
#include "tst_sig_proc.h"
#include "tst_test.h"
#include "tst_timer.h"
Expand Down Expand Up @@ -174,21 +175,15 @@ static inline int sys_ppoll_time64(struct pollfd *fds, nfds_t nfds, void *tmo_p,
sigsetsize);
}

static struct test_variants {
int (*ppoll)(struct pollfd *fds, nfds_t nfds, void *tmo_p,
const sigset_t *sigmask, size_t sigsetsize);

enum tst_ts_type type;
char *desc;
} variants[] = {
{ .ppoll = libc_ppoll, .type = TST_LIBC_TIMESPEC, .desc = "vDSO or syscall with libc spec"},
static struct time64_variants variants[] = {
{ .ppoll = libc_ppoll, .ts_type = TST_LIBC_TIMESPEC, .desc = "vDSO or syscall with libc spec"},

#if (__NR_ppoll != __LTP__NR_INVALID_SYSCALL)
{ .ppoll = sys_ppoll, .type = TST_KERN_OLD_TIMESPEC, .desc = "syscall with old kernel spec"},
{ .ppoll = sys_ppoll, .ts_type = TST_KERN_OLD_TIMESPEC, .desc = "syscall with old kernel spec"},
#endif

#if (__NR_ppoll_time64 != __LTP__NR_INVALID_SYSCALL)
{ .ppoll = sys_ppoll_time64, .type = TST_KERN_TIMESPEC, .desc = "syscall time64 with kernel spec"},
{ .ppoll = sys_ppoll_time64, .ts_type = TST_KERN_TIMESPEC, .desc = "syscall time64 with kernel spec"},
#endif
};

Expand All @@ -198,7 +193,7 @@ static void sighandler(int sig LTP_ATTRIBUTE_UNUSED)

static void setup(void)
{
struct test_variants *tv = &variants[tst_variant];
struct time64_variants *tv = &variants[tst_variant];
int fd2;

tst_res(TINFO, "Testing variant: %s", tv->desc);
Expand All @@ -222,7 +217,7 @@ static void setup(void)
fds_already_closed[0].revents = 0;
SAFE_CLOSE(fd2);

ts_short.type = ts_long.type = tv->type;
ts_short.type = ts_long.type = tv->ts_type;
tst_ts_set_sec(&ts_short, 0);
tst_ts_set_nsec(&ts_short, 20000000);
tst_ts_set_sec(&ts_long, 2);
Expand All @@ -237,7 +232,7 @@ static void cleanup(void)

static void do_test(unsigned int i)
{
struct test_variants *tv = &variants[tst_variant];
struct time64_variants *tv = &variants[tst_variant];
pid_t pid = 0;
int sys_ret, sys_errno = 0, dummy;
struct test_case *tc = &tcase[i];
Expand Down

0 comments on commit c5cf170

Please sign in to comment.