From patchwork Tue Sep 8 06:19:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 1359479 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=2001:1418:10:5::2; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=B+z8XV5U; dkim-atps=neutral Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Blw4D3TYPz9sT6 for ; Tue, 8 Sep 2020 16:20:12 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 411E23C2C32 for ; Tue, 8 Sep 2020 08:20:03 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-2.smtp.seeweb.it (in-2.smtp.seeweb.it [IPv6:2001:4b78:1:20::2]) by picard.linux.it (Postfix) with ESMTP id 067D23C53EA for ; Tue, 8 Sep 2020 08:19:45 +0200 (CEST) Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by in-2.smtp.seeweb.it (Postfix) with ESMTPS id 4152560007C for ; Tue, 8 Sep 2020 08:19:45 +0200 (CEST) Received: by mail-pg1-x541.google.com with SMTP id m5so9311161pgj.9 for ; Mon, 07 Sep 2020 23:19:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=uLc6Bp0/iO7+krBorjiBUE3a6bFRRYRWxSFsgiR/tAQ=; b=B+z8XV5UEVX46MpYGEKS5oLDudGT2+dBsbkiQseuuZDNXJ/NdVETtoXUSUfT7QFuUe PN2bnZY+xt851ftV1Wmbnn4WHkfkCDW+Adfxa/lWO5N+9dMuC186/7eh/2Bd/QTjrf08 H11M7OPUMpgqH8dmigtvb1b8m2mCQHqD9qdeAFEkpV/60BnUVKkpP7X5SbyOsAzDydHG edOGZrIwSCO0WYxzh3KGANW4L/S4A+0VGsyqW8hIomKtyqLd6qQGtEt8xVpp2ZNR/8oD 7KNO2Im5hdM155LrOCEJwWlJnvRiwwl4bouWUfuN0TKh5nGsHvOffRcE8yT3htEQfjh/ m0VA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=uLc6Bp0/iO7+krBorjiBUE3a6bFRRYRWxSFsgiR/tAQ=; b=qT01YgFSyyV8Msphw2JSNsO7VV4oJHIKzXIfx4OAsv8PqXfS+T5osvWzANF1CLMiQu 3LjmmUxvclX56oiWcipHo6NHdd5vR7hmcCCYmBeygR18PqK/WXFX7lSI31eI/LFAr5j2 hTqMHSBUFhPzRptoga83knO7/RII0cLJj9VnLXeY6p2J6fBrxz01nUviVm1Hxxxe3BEq vBln93t914xI80C8s8NWruFuT5gC8lH7GGRjQ3PXEhvP0315W/utwoJk8+31eogK0Fgo JfuglLia7Fxe/gK1Hu8bfGOze0R1FKGxRYXNVSYUPOrTImFdHL5NoDT+KLd07blsenQc pf9Q== X-Gm-Message-State: AOAM533Pq6t8ikW2LL0IeTfQT4FN1n16TpbX4dqNt2EVzdfIQeRW3AjO 0ZF0We2VZAsLdDSoZp24N9z86y7hERCsIQ== X-Google-Smtp-Source: ABdhPJxL1VJ7OleMItHZOW2sYCBQT4RVGsd5ceJn6Al9imGhPySdgh9HOMUUcjmtLpGqy0At2LvYmg== X-Received: by 2002:a62:4e96:: with SMTP id c144mr22462571pfb.27.1599545983487; Mon, 07 Sep 2020 23:19:43 -0700 (PDT) Received: from localhost ([122.181.54.133]) by smtp.gmail.com with ESMTPSA id z11sm7631745pfc.181.2020.09.07.23.19.42 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Sep 2020 23:19:42 -0700 (PDT) From: Viresh Kumar To: ltp@lists.linux.it Date: Tue, 8 Sep 2020 11:49:14 +0530 Message-Id: <7bfadc417d4a40348a0aa742f3c44582a955913a.1599545766.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.25.0.rc1.19.g042ed3e048af In-Reply-To: References: MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.102.4 at in-2.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-2.smtp.seeweb.it Subject: [LTP] [PATCH 01/16] syscalls: Add common time64 variants structure X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Viresh Kumar , Vincent Guittot Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" This adds a common variants structure which all other syscall tests can use. Suggested-by: Cyril Hrubis Signed-off-by: Viresh Kumar --- include/time64_variants.h | 56 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 include/time64_variants.h diff --git a/include/time64_variants.h b/include/time64_variants.h new file mode 100644 index 000000000000..934268b0328b --- /dev/null +++ b/include/time64_variants.h @@ -0,0 +1,56 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) 2020 Linaro Limited. All rights reserved. + * Author: Viresh Kumar + */ + +#ifndef TIME64_VARIANTS_H +#define TIME64_VARIANTS_H + +#include +#include +#include +#include +#include +#include "tst_timer.h" + +struct tst_ts; +struct pollfd; +struct io_event; +struct sembuf; +struct mmsghdr; + +struct time64_variants { + char *desc; + + enum tst_ts_type ts_type; + int (*clock_gettime)(clockid_t clk_id, void *ts); + int (*clock_settime)(clockid_t clk_id, void *ts); + int (*clock_nanosleep)(clockid_t clock_id, int flags, void *request, void *remain); + + int (*timer_gettime)(kernel_timer_t timer, void *its); + int (*timer_settime)(kernel_timer_t timerid, int flags, void *its, void *old_its); + int (*tfd_gettime)(int fd, void *its); + int (*tfd_settime)(int fd, int flags, void *new_value, void *old_value); + int (*io_pgetevents)(io_context_t ctx, long min_nr, long max_nr, + struct io_event *events, void *timeout, sigset_t *sigmask); + int (*mqt_send)(mqd_t mqdes, const char *msg_ptr, size_t msg_len, + unsigned int msg_prio, void *abs_timeout); + ssize_t (*mqt_receive)(mqd_t mqdes, char *msg_ptr, size_t msg_len, + unsigned int *msg_prio, void *abs_timeout); + int (*ppoll)(struct pollfd *fds, nfds_t nfds, void *tmo_p, + const sigset_t *sigmask, size_t sigsetsize); + int (*sched_rr_get_interval)(pid_t pid, void *ts); + int (*semop)(int semid, struct sembuf *sops, size_t nsops); + int (*semtimedop)(int semid, struct sembuf *sops, size_t nsops, void *timeout); + int (*sigwait) (const sigset_t * set, siginfo_t * info, + void * timeout); + int (*recvmmsg)(int sockfd, struct mmsghdr *msgvec, unsigned int vlen, + unsigned int flags, void *timeout); + int (*sendmmsg)(int sockfd, struct mmsghdr *msgvec, unsigned int vlen, + unsigned int flags); + int (*utimensat)(int dirfd, const char *pathname, void *times, + int flags); +}; + +#endif /* TIME64_VARIANTS_H */ From patchwork Tue Sep 8 06:19:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 1359478 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=213.254.12.146; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=S/x9+/CR; dkim-atps=neutral Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Blw3w6TZNz9sTK for ; Tue, 8 Sep 2020 16:19:56 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 644603C53C2 for ; Tue, 8 Sep 2020 08:19:54 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-6.smtp.seeweb.it (in-6.smtp.seeweb.it [217.194.8.6]) by picard.linux.it (Postfix) with ESMTP id F04353C53D9 for ; Tue, 8 Sep 2020 08:19:48 +0200 (CEST) Received: from mail-pj1-x1043.google.com (mail-pj1-x1043.google.com [IPv6:2607:f8b0:4864:20::1043]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by in-6.smtp.seeweb.it (Postfix) with ESMTPS id 5DC021400756 for ; Tue, 8 Sep 2020 08:19:48 +0200 (CEST) Received: by mail-pj1-x1043.google.com with SMTP id n3so8279650pjq.1 for ; Mon, 07 Sep 2020 23:19:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Y1SuY/dTrpAVEG8rOy9sZJ5s1Qooi4ZIqja9o5YNXIw=; b=S/x9+/CRM57RV+pMFhoydYepoj3zxxE7vDtEPTtc9IQ2fyoE4DRSaPymUV3usL2yUe lVC/GrKBY0GhsUSx0dNSL9SiRrr3b5RiJDwNwERoEtVeJpjgTfz1K1iazQ2OXXCYdm8I rzPrTaSA+IxM0dorWpxv/VNbOsPQhnYggiwNQOWM+lcHjZbwbw+z0nSxGoIpUhP4CW8P EyK26QY9+fBvogaQj8Z+ynldYDizR/zcG43VD3K891tp4wYsT8UIMIR0aie4jfSVAH0e LZoh4R2PyGQDiOdSc5o4GGrOVIOvUs+i2vj7Eu9Wt4p/5lq4Fj/DAl52TnDBSCBz3N69 +Bjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Y1SuY/dTrpAVEG8rOy9sZJ5s1Qooi4ZIqja9o5YNXIw=; b=W9+Bu/lyE/SiL4VchVvhFR2+9W7Un8HBetJbH6WaS/eQ/mY0RyDBljFZAq6AorBFYK 53wj4fsRxkX+CbvxNPVdTXmKggnLZL0ZtP8PlSs8xLXURLS5XYD3rSpmMz1aALnJUw06 yx1kiB20o7bzk5/dWYTHjRPW7mRDnIIjX4fDtfH7aKr7EepyyZuryZA99Viman7xz5KV om5BGEkS0BCeeTHtr+U8pKuMCuO5Oor7KtM4ZNMQr0oETm7VlPy5BoyqDfDgLp64lf2e VRNvSUrStSNVLkET5CEXyu8K68I1gLnHw84HGE2aY4OKwf2/dOtwn9ROkaUAFa0xS874 HN6Q== X-Gm-Message-State: AOAM532N3xjWcjx3QnweNzolt0k+sBi+TyZNP+cfLnH/btcwY173tW4Y YNIJWRZGFfjE755VNnvoSOpCFZw4pWtEtw== X-Google-Smtp-Source: ABdhPJxK6ZNd7EaF/SWaydW7wLKsHzbPd8O1XG/kEWVd9yk0pGwJFfd0H2faPbePKFoEIbyXZ/K2KA== X-Received: by 2002:a17:90b:1916:: with SMTP id mp22mr2410509pjb.132.1599545986118; Mon, 07 Sep 2020 23:19:46 -0700 (PDT) Received: from localhost ([122.181.54.133]) by smtp.gmail.com with ESMTPSA id 68sm16612583pfd.64.2020.09.07.23.19.45 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Sep 2020 23:19:45 -0700 (PDT) From: Viresh Kumar To: ltp@lists.linux.it Date: Tue, 8 Sep 2020 11:49:15 +0530 Message-Id: <37d24581883b736971fc88a4fc47c08456c464b8.1599545766.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.25.0.rc1.19.g042ed3e048af In-Reply-To: References: MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.102.4 at in-6.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-6.smtp.seeweb.it Subject: [LTP] [PATCH 02/16] syscalls: clock_gettime: Reuse struct time64_variants X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Viresh Kumar , Vincent Guittot Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Lets reuse the common structure here. Signed-off-by: Viresh Kumar --- .../syscalls/clock_gettime/clock_gettime01.c | 19 +++++------- .../syscalls/clock_gettime/clock_gettime02.c | 17 +++++------ .../syscalls/clock_gettime/clock_gettime03.c | 27 ++++++++--------- .../syscalls/clock_gettime/clock_gettime04.c | 29 +++++++++---------- 4 files changed, 40 insertions(+), 52 deletions(-) diff --git a/testcases/kernel/syscalls/clock_gettime/clock_gettime01.c b/testcases/kernel/syscalls/clock_gettime/clock_gettime01.c index 769ac32cd038..be9573afcc8e 100644 --- a/testcases/kernel/syscalls/clock_gettime/clock_gettime01.c +++ b/testcases/kernel/syscalls/clock_gettime/clock_gettime01.c @@ -17,6 +17,7 @@ */ #include "config.h" +#include "time64_variants.h" #include "tst_timer.h" #include "tst_safe_clocks.h" @@ -58,19 +59,15 @@ static struct test_case tc[] = { static struct tst_ts spec; -static struct test_variants { - int (*func)(clockid_t clk_id, void *ts); - enum tst_ts_type type; - char *desc; -} variants[] = { - { .func = libc_clock_gettime, .type = TST_LIBC_TIMESPEC, .desc = "vDSO or syscall with libc spec"}, +static struct time64_variants variants[] = { + { .clock_gettime = libc_clock_gettime, .ts_type = TST_LIBC_TIMESPEC, .desc = "vDSO or syscall with libc spec"}, #if (__NR_clock_gettime != __LTP__NR_INVALID_SYSCALL) - { .func = sys_clock_gettime, .type = TST_KERN_OLD_TIMESPEC, .desc = "syscall with old kernel spec"}, + { .clock_gettime = sys_clock_gettime, .ts_type = TST_KERN_OLD_TIMESPEC, .desc = "syscall with old kernel spec"}, #endif #if (__NR_clock_gettime64 != __LTP__NR_INVALID_SYSCALL) - { .func = sys_clock_gettime64, .type = TST_KERN_TIMESPEC, .desc = "syscall time64 with kernel spec"}, + { .clock_gettime = sys_clock_gettime64, .ts_type = TST_KERN_TIMESPEC, .desc = "syscall time64 with kernel spec"}, #endif }; @@ -81,13 +78,13 @@ static void setup(void) static void verify_clock_gettime(unsigned int i) { - struct test_variants *tv = &variants[tst_variant]; + struct time64_variants *tv = &variants[tst_variant]; int ret; memset(&spec, 0, sizeof(spec)); - spec.type = tv->type; + spec.type = tv->ts_type; - TEST(tv->func(tc[i].clktype, tst_ts_get(&spec))); + TEST(tv->clock_gettime(tc[i].clktype, tst_ts_get(&spec))); if (TST_RET == -1) { /* errors: allow unsupported clock types */ diff --git a/testcases/kernel/syscalls/clock_gettime/clock_gettime02.c b/testcases/kernel/syscalls/clock_gettime/clock_gettime02.c index f26db7c577e3..b0a9e9067142 100644 --- a/testcases/kernel/syscalls/clock_gettime/clock_gettime02.c +++ b/testcases/kernel/syscalls/clock_gettime/clock_gettime02.c @@ -19,6 +19,7 @@ */ #include "config.h" +#include "time64_variants.h" #include "tst_timer.h" #include "tst_safe_clocks.h" @@ -86,17 +87,13 @@ static struct tst_ts spec; /* * bad pointer w/ libc causes SIGSEGV signal, call syscall directly */ -static struct test_variants { - int (*func)(clockid_t clk_id, void *ts); - enum tst_ts_type type; - char *desc; -} variants[] = { +static struct time64_variants variants[] = { #if (__NR_clock_gettime != __LTP__NR_INVALID_SYSCALL) - { .func = sys_clock_gettime, .type = TST_KERN_OLD_TIMESPEC, .desc = "syscall with old kernel spec"}, + { .clock_gettime = sys_clock_gettime, .ts_type = TST_KERN_OLD_TIMESPEC, .desc = "syscall with old kernel spec"}, #endif #if (__NR_clock_gettime64 != __LTP__NR_INVALID_SYSCALL) - { .func = sys_clock_gettime64, .type = TST_KERN_TIMESPEC, .desc = "syscall time64 with kernel spec"}, + { .clock_gettime = sys_clock_gettime64, .ts_type = TST_KERN_TIMESPEC, .desc = "syscall time64 with kernel spec"}, #endif }; @@ -109,18 +106,18 @@ static void setup(void) static void verify_clock_gettime(unsigned int i) { - struct test_variants *tv = &variants[tst_variant]; + struct time64_variants *tv = &variants[tst_variant]; void *ts; /* bad pointer cases */ if (tc[i].exp_err == EFAULT) { ts = bad_addr; } else { - spec.type = tv->type; + spec.type = tv->ts_type; ts = tst_ts_get(&spec); } - TEST(tv->func(tc[i].clktype, ts)); + TEST(tv->clock_gettime(tc[i].clktype, ts)); if (TST_RET != -1) { tst_res(TFAIL, "clock_gettime(2): clock %s passed unexcpectedly", diff --git a/testcases/kernel/syscalls/clock_gettime/clock_gettime03.c b/testcases/kernel/syscalls/clock_gettime/clock_gettime03.c index 8341051088d7..dc570a06c55c 100644 --- a/testcases/kernel/syscalls/clock_gettime/clock_gettime03.c +++ b/testcases/kernel/syscalls/clock_gettime/clock_gettime03.c @@ -18,6 +18,7 @@ */ #define _GNU_SOURCE +#include "time64_variants.h" #include "tst_safe_clocks.h" #include "tst_timer.h" #include "lapi/namespaces_constants.h" @@ -40,27 +41,23 @@ static struct tcase { static struct tst_ts now, then, parent_then; static int parent_ns; -static struct test_variants { - int (*func)(clockid_t clk_id, void *ts); - enum tst_ts_type type; - char *desc; -} variants[] = { - { .func = libc_clock_gettime, .type = TST_LIBC_TIMESPEC, .desc = "vDSO or syscall with libc spec"}, +static struct time64_variants variants[] = { + { .clock_gettime = libc_clock_gettime, .ts_type = TST_LIBC_TIMESPEC, .desc = "vDSO or syscall with libc spec"}, #if (__NR_clock_gettime != __LTP__NR_INVALID_SYSCALL) - { .func = sys_clock_gettime, .type = TST_KERN_OLD_TIMESPEC, .desc = "syscall with old kernel spec"}, + { .clock_gettime = sys_clock_gettime, .ts_type = TST_KERN_OLD_TIMESPEC, .desc = "syscall with old kernel spec"}, #endif #if (__NR_clock_gettime64 != __LTP__NR_INVALID_SYSCALL) - { .func = sys_clock_gettime64, .type = TST_KERN_TIMESPEC, .desc = "syscall time64 with kernel spec"}, + { .clock_gettime = sys_clock_gettime64, .ts_type = TST_KERN_TIMESPEC, .desc = "syscall time64 with kernel spec"}, #endif }; -static void child(struct test_variants *tv, struct tcase *tc) +static void child(struct time64_variants *tv, struct tcase *tc) { long long diff; - if (tv->func(tc->clk_id, tst_ts_get(&then))) { + if (tv->clock_gettime(tc->clk_id, tst_ts_get(&then))) { tst_res(TFAIL | TERRNO, "clock_gettime(%s) failed", tst_clock_name(tc->clk_id)); return; @@ -68,7 +65,7 @@ static void child(struct test_variants *tv, struct tcase *tc) SAFE_SETNS(parent_ns, CLONE_NEWTIME); - if (tv->func(tc->clk_id, tst_ts_get(&parent_then))) { + if (tv->clock_gettime(tc->clk_id, tst_ts_get(&parent_then))) { tst_res(TFAIL | TERRNO, "clock_gettime(%s) failed", tst_clock_name(tc->clk_id)); return; @@ -97,7 +94,7 @@ static void child(struct test_variants *tv, struct tcase *tc) static void verify_ns_clock(unsigned int n) { - struct test_variants *tv = &variants[tst_variant]; + struct time64_variants *tv = &variants[tst_variant]; struct tcase *tc = &tcases[n]; SAFE_UNSHARE(CLONE_NEWTIME); @@ -105,7 +102,7 @@ static void verify_ns_clock(unsigned int n) SAFE_FILE_PRINTF("/proc/self/timens_offsets", "%d %d 0", tc->clk_off, tc->off); - if (tv->func(tc->clk_id, tst_ts_get(&now))) { + if (tv->clock_gettime(tc->clk_id, tst_ts_get(&now))) { tst_res(TFAIL | TERRNO, "%d clock_gettime(%s) failed", __LINE__, tst_clock_name(tc->clk_id)); return; @@ -117,9 +114,9 @@ static void verify_ns_clock(unsigned int n) static void setup(void) { - struct test_variants *tv = &variants[tst_variant]; + struct time64_variants *tv = &variants[tst_variant]; - now.type = then.type = parent_then.type = tv->type; + now.type = then.type = parent_then.type = tv->ts_type; tst_res(TINFO, "Testing variant: %s", variants[tst_variant].desc); parent_ns = SAFE_OPEN("/proc/self/ns/time_for_children", O_RDONLY); } diff --git a/testcases/kernel/syscalls/clock_gettime/clock_gettime04.c b/testcases/kernel/syscalls/clock_gettime/clock_gettime04.c index 2f484c43fc06..fd62e3b9de70 100644 --- a/testcases/kernel/syscalls/clock_gettime/clock_gettime04.c +++ b/testcases/kernel/syscalls/clock_gettime/clock_gettime04.c @@ -9,6 +9,7 @@ #include "config.h" #include "parse_vdso.h" +#include "time64_variants.h" #include "tst_timer.h" #include "tst_safe_clocks.h" @@ -61,23 +62,19 @@ static inline int my_gettimeofday(clockid_t clk_id, void *ts) return 0; } -static struct test_variants { - int (*gettime)(clockid_t clk_id, void *ts); - enum tst_ts_type type; - char *desc; -} variants[] = { - { .gettime = libc_clock_gettime, .type = TST_LIBC_TIMESPEC, .desc = "vDSO or syscall with libc spec"}, +static struct time64_variants variants[] = { + { .clock_gettime = libc_clock_gettime, .ts_type = TST_LIBC_TIMESPEC, .desc = "vDSO or syscall with libc spec"}, #if (__NR_clock_gettime != __LTP__NR_INVALID_SYSCALL) - { .gettime = sys_clock_gettime, .type = TST_KERN_OLD_TIMESPEC, .desc = "syscall with old kernel spec"}, - { .gettime = vdso_gettime, .type = TST_KERN_OLD_TIMESPEC, .desc = "vDSO with old kernel spec"}, + { .clock_gettime = sys_clock_gettime, .ts_type = TST_KERN_OLD_TIMESPEC, .desc = "syscall with old kernel spec"}, + { .clock_gettime = vdso_gettime, .ts_type = TST_KERN_OLD_TIMESPEC, .desc = "vDSO with old kernel spec"}, #endif #if (__NR_clock_gettime64 != __LTP__NR_INVALID_SYSCALL) - { .gettime = sys_clock_gettime64, .type = TST_KERN_TIMESPEC, .desc = "syscall time64 with kernel spec"}, - { .gettime = vdso_gettime64, .type = TST_KERN_TIMESPEC, .desc = "vDSO time64 with kernel spec"}, + { .clock_gettime = sys_clock_gettime64, .ts_type = TST_KERN_TIMESPEC, .desc = "syscall time64 with kernel spec"}, + { .clock_gettime = vdso_gettime64, .ts_type = TST_KERN_TIMESPEC, .desc = "vDSO time64 with kernel spec"}, #endif - { .gettime = my_gettimeofday, .type = TST_LIBC_TIMESPEC, .desc = "gettimeofday"}, + { .clock_gettime = my_gettimeofday, .ts_type = TST_LIBC_TIMESPEC, .desc = "gettimeofday"}, }; static void setup(void) @@ -89,7 +86,7 @@ static void run(unsigned int i) { struct tst_ts ts; long long start, end = 0, diff, slack; - struct test_variants *tv; + struct time64_variants *tv; int count = 10000, ret; unsigned int j; @@ -99,13 +96,13 @@ static void run(unsigned int i) start = end; tv = &variants[j]; - ts.type = tv->type; + ts.type = tv->ts_type; /* Do gettimeofday() test only for CLOCK_REALTIME */ - if (tv->gettime == my_gettimeofday && clks[i] != CLOCK_REALTIME) + if (tv->clock_gettime == my_gettimeofday && clks[i] != CLOCK_REALTIME) continue; - ret = tv->gettime(clks[i], tst_ts_get(&ts)); + ret = tv->clock_gettime(clks[i], tst_ts_get(&ts)); if (ret) { /* * _vdso_gettime() sets error to ENOSYS if vdso @@ -129,7 +126,7 @@ static void run(unsigned int i) * gettimeofday() doesn't capture time less than 1 us, * add 999 to it. */ - if (tv->gettime == my_gettimeofday) + if (tv->clock_gettime == my_gettimeofday) slack = 999; else slack = 0; From patchwork Tue Sep 8 06:19:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 1359480 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=213.254.12.146; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=cbTAXEHb; dkim-atps=neutral Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Blw4L1nHfz9sT6 for ; Tue, 8 Sep 2020 16:20:18 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 3DAC53C1CB6 for ; Tue, 8 Sep 2020 08:20:15 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-4.smtp.seeweb.it (in-4.smtp.seeweb.it [217.194.8.4]) by picard.linux.it (Postfix) with ESMTP id 2A19B3C53ED for ; Tue, 8 Sep 2020 08:19:51 +0200 (CEST) Received: from mail-pj1-x1044.google.com (mail-pj1-x1044.google.com [IPv6:2607:f8b0:4864:20::1044]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by in-4.smtp.seeweb.it (Postfix) with ESMTPS id A3ED11000C1A for ; Tue, 8 Sep 2020 08:19:50 +0200 (CEST) Received: by mail-pj1-x1044.google.com with SMTP id b17so5341874pji.1 for ; Mon, 07 Sep 2020 23:19:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=AQa9lISQli39PJ7zBdC0Sb8DVbbVwtNV6y95pE/JOKQ=; b=cbTAXEHbVB080YSt5dCby3qTYZBLoh0nOsORhuaakvzIfGaVlOEgi6hI4KQcOWrkfV PmKqQzISBwzou7f9apz/HzRoJOco3yVNOnu8yAK50rhmxW1cXdBhc9tO5d1X7kRNfNgb JDW/s4pY5p/PlFrNhnzudgfTY+Wlp28/IqEEWnMMSoVoJy9sZjdtcLL7qyuW2oKydK8e 7AIH8Hb1jdXJKWXyDxDOd0oU8oj16zswa/jXCBsMc9KQqDp22r6b2a/wq6zZXO3hKFlH +FS7XA5I6kPNYvtz6hmQlPcubhryG/z6RxTf3nh7Xt6+qHwA2f/IkOh3s5aq/VzPb1e6 M5xw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=AQa9lISQli39PJ7zBdC0Sb8DVbbVwtNV6y95pE/JOKQ=; b=gvg+2pk2H5DpF1pfDbTX3pi9ePGPBWdMwW0RpzXZHZ0Kd4bwr3bACRMfx7dK9t56Jj XblHNqIIq1vKJRSPtyZ4PHCOsSg1Q+yv3DfduTjwQnfI6HXobXOKz6yv5QFfc2SywvmG 9cElglB2X8zKLNr4yFUmN2bALgLyA7GzadCvM0orUt4Z0imQ7HW1HhFCF1isfZKfeffV YI6BUbbPjD4S9klKj37B58oWp7X15tfTH4l2XVy1trhPBBSq6pdaNLp1TWPKdghnoVqS I9hlpr3bb6bdML+1CxYs3bqwMgifQp4H4uSaRwpx0eQ6vZRalT/h3SU9J/ciaAieQ1Ji Ga1Q== X-Gm-Message-State: AOAM530h6kkgmfIjJsWHv0unIsWi/6EqvDafCuT62kACZaCpwHnNGb8z 58kZ65fipcm6h9PCEBcLt/vcptcdbGmTtQ== X-Google-Smtp-Source: ABdhPJzMZy5dwPWBo6gPgngTpt3G+f8DIjq4/8ORtqUVLnnCC3UUz0HFo3irgTjQQ2dQS1rItdhtWQ== X-Received: by 2002:a17:90a:744f:: with SMTP id o15mr2703371pjk.216.1599545988746; Mon, 07 Sep 2020 23:19:48 -0700 (PDT) Received: from localhost ([122.181.54.133]) by smtp.gmail.com with ESMTPSA id b29sm14002255pgb.71.2020.09.07.23.19.47 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Sep 2020 23:19:48 -0700 (PDT) From: Viresh Kumar To: ltp@lists.linux.it Date: Tue, 8 Sep 2020 11:49:16 +0530 Message-Id: X-Mailer: git-send-email 2.25.0.rc1.19.g042ed3e048af In-Reply-To: References: MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.102.4 at in-4.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-4.smtp.seeweb.it Subject: [LTP] [PATCH 03/16] syscalls: clock_nanosleep: Reuse struct time64_variants X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Viresh Kumar , Vincent Guittot Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Lets reuse the common structure here. Signed-off-by: Viresh Kumar --- .../clock_nanosleep/clock_nanosleep01.c | 21 +++++++-------- .../clock_nanosleep/clock_nanosleep03.c | 26 ++++++++----------- .../clock_nanosleep/clock_nanosleep04.c | 22 +++++++--------- 3 files changed, 29 insertions(+), 40 deletions(-) diff --git a/testcases/kernel/syscalls/clock_nanosleep/clock_nanosleep01.c b/testcases/kernel/syscalls/clock_nanosleep/clock_nanosleep01.c index 716f383bbeca..516ab50f16d6 100644 --- a/testcases/kernel/syscalls/clock_nanosleep/clock_nanosleep01.c +++ b/testcases/kernel/syscalls/clock_nanosleep/clock_nanosleep01.c @@ -17,6 +17,7 @@ #include +#include "time64_variants.h" #include "tst_safe_clocks.h" #include "tst_sig_proc.h" #include "tst_timer.h" @@ -105,25 +106,21 @@ static struct test_case tcase[] = { static struct tst_ts *rq; static struct tst_ts *rm; -static struct test_variants { - int (*func)(clockid_t clock_id, int flags, void *request, void *remain); - enum tst_ts_type type; - char *desc; -} variants[] = { - { .func = libc_clock_nanosleep, .type = TST_LIBC_TIMESPEC, .desc = "vDSO or syscall with libc spec"}, +static struct time64_variants variants[] = { + { .clock_nanosleep = libc_clock_nanosleep, .ts_type = TST_LIBC_TIMESPEC, .desc = "vDSO or syscall with libc spec"}, #if (__NR_clock_nanosleep != __LTP__NR_INVALID_SYSCALL) - { .func = sys_clock_nanosleep, .type = TST_KERN_OLD_TIMESPEC, .desc = "syscall with old kernel spec"}, + { .clock_nanosleep = sys_clock_nanosleep, .ts_type = TST_KERN_OLD_TIMESPEC, .desc = "syscall with old kernel spec"}, #endif #if (__NR_clock_nanosleep_time64 != __LTP__NR_INVALID_SYSCALL) - { .func = sys_clock_nanosleep64, .type = TST_KERN_TIMESPEC, .desc = "syscall time64 with kernel spec"}, + { .clock_nanosleep = sys_clock_nanosleep64, .ts_type = TST_KERN_TIMESPEC, .desc = "syscall time64 with kernel spec"}, #endif }; void setup(void) { - rq->type = variants[tst_variant].type; + rq->type = variants[tst_variant].ts_type; tst_res(TINFO, "Testing variant: %s", variants[tst_variant].desc); SAFE_SIGNAL(SIGINT, sighandler); bad_addr = tst_get_bad_addr(NULL); @@ -131,7 +128,7 @@ void setup(void) static void do_test(unsigned int i) { - struct test_variants *tv = &variants[tst_variant]; + struct time64_variants *tv = &variants[tst_variant]; struct test_case *tc = &tcase[i]; pid_t pid = 0; void *request, *remain; @@ -157,9 +154,9 @@ static void do_test(unsigned int i) else remain = tst_ts_get(rm); - TEST(tv->func(tc->clk_id, tc->flags, request, remain)); + TEST(tv->clock_nanosleep(tc->clk_id, tc->flags, request, remain)); - if (tv->func == libc_clock_nanosleep) { + if (tv->clock_nanosleep == libc_clock_nanosleep) { /* * The return value and error number are differently set for * libc syscall as compared to kernel syscall. diff --git a/testcases/kernel/syscalls/clock_nanosleep/clock_nanosleep03.c b/testcases/kernel/syscalls/clock_nanosleep/clock_nanosleep03.c index 0a7ea5586327..bd2c38ee3401 100644 --- a/testcases/kernel/syscalls/clock_nanosleep/clock_nanosleep03.c +++ b/testcases/kernel/syscalls/clock_nanosleep/clock_nanosleep03.c @@ -16,6 +16,7 @@ */ #include +#include "time64_variants.h" #include "tst_safe_clocks.h" #include "tst_timer.h" #include "lapi/namespaces_constants.h" @@ -23,40 +24,35 @@ #define OFFSET_S 10 #define SLEEP_US 100000 -static struct test_variants { - int (*gettime)(clockid_t clk_id, void *ts); - int (*func)(clockid_t clock_id, int flags, void *request, void *remain); - enum tst_ts_type type; - char *desc; -} variants[] = { - { .gettime = libc_clock_gettime, .func = libc_clock_nanosleep, .type = TST_LIBC_TIMESPEC, .desc = "vDSO or syscall with libc spec"}, +static struct time64_variants variants[] = { + { .clock_gettime = libc_clock_gettime, .clock_nanosleep = libc_clock_nanosleep, .ts_type = TST_LIBC_TIMESPEC, .desc = "vDSO or syscall with libc spec"}, #if (__NR_clock_nanosleep != __LTP__NR_INVALID_SYSCALL) - { .gettime = sys_clock_gettime, .func = sys_clock_nanosleep, .type = TST_KERN_OLD_TIMESPEC, .desc = "syscall with old kernel spec"}, + { .clock_gettime = sys_clock_gettime, .clock_nanosleep = sys_clock_nanosleep, .ts_type = TST_KERN_OLD_TIMESPEC, .desc = "syscall with old kernel spec"}, #endif #if (__NR_clock_nanosleep_time64 != __LTP__NR_INVALID_SYSCALL) - { .gettime = sys_clock_gettime64, .func = sys_clock_nanosleep64, .type = TST_KERN_TIMESPEC, .desc = "syscall time64 with kernel spec"}, + { .clock_gettime = sys_clock_gettime64, .clock_nanosleep = sys_clock_nanosleep64, .ts_type = TST_KERN_TIMESPEC, .desc = "syscall time64 with kernel spec"}, #endif }; -static void do_clock_gettime(struct test_variants *tv, struct tst_ts *ts) +static void do_clock_gettime(struct time64_variants *tv, struct tst_ts *ts) { int ret; - ret = tv->gettime(CLOCK_MONOTONIC, tst_ts_get(ts)); + ret = tv->clock_gettime(CLOCK_MONOTONIC, tst_ts_get(ts)); if (ret == -1) tst_brk(TBROK | TERRNO, "clock_settime(CLOCK_MONOTONIC) failed"); } static void verify_clock_nanosleep(void) { - struct test_variants *tv = &variants[tst_variant]; + struct time64_variants *tv = &variants[tst_variant]; struct tst_ts start, end, sleep_abs; tst_res(TINFO, "Testing variant: %s", tv->desc); - start.type = end.type = sleep_abs.type = tv->type; + start.type = end.type = sleep_abs.type = tv->ts_type; SAFE_UNSHARE(CLONE_NEWTIME); @@ -67,12 +63,12 @@ static void verify_clock_nanosleep(void) sleep_abs = tst_ts_add_us(start, 1000000 * OFFSET_S + SLEEP_US); if (!SAFE_FORK()) { - TEST(tv->func(CLOCK_MONOTONIC, TIMER_ABSTIME, tst_ts_get(&sleep_abs), NULL)); + TEST(tv->clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, tst_ts_get(&sleep_abs), NULL)); /* * The return value and error number are differently set for * libc syscall as compared to kernel syscall. */ - if ((tv->func == libc_clock_nanosleep) && TST_RET) { + if ((tv->clock_nanosleep == libc_clock_nanosleep) && TST_RET) { TST_ERR = TST_RET; TST_RET = -1; } diff --git a/testcases/kernel/syscalls/clock_nanosleep/clock_nanosleep04.c b/testcases/kernel/syscalls/clock_nanosleep/clock_nanosleep04.c index 1f2d3c4f83ec..c5aeed505685 100644 --- a/testcases/kernel/syscalls/clock_nanosleep/clock_nanosleep04.c +++ b/testcases/kernel/syscalls/clock_nanosleep/clock_nanosleep04.c @@ -7,6 +7,7 @@ #include #include #include +#include "time64_variants.h" #include "tst_safe_clocks.h" #include "tst_timer.h" @@ -15,20 +16,15 @@ static clockid_t tcase[] = { CLOCK_REALTIME, }; -static struct test_variants { - int (*gettime)(clockid_t clk_id, void *ts); - int (*func)(clockid_t clock_id, int flags, void *request, void *remain); - enum tst_ts_type type; - char *desc; -} variants[] = { - { .gettime = libc_clock_gettime, .func = libc_clock_nanosleep, .type = TST_LIBC_TIMESPEC, .desc = "vDSO or syscall with libc spec"}, +static struct time64_variants variants[] = { + { .clock_gettime = libc_clock_gettime, .clock_nanosleep = libc_clock_nanosleep, .ts_type = TST_LIBC_TIMESPEC, .desc = "vDSO or syscall with libc spec"}, #if (__NR_clock_nanosleep != __LTP__NR_INVALID_SYSCALL) - { .gettime = sys_clock_gettime, .func = sys_clock_nanosleep, .type = TST_KERN_OLD_TIMESPEC, .desc = "syscall with old kernel spec"}, + { .clock_gettime = sys_clock_gettime, .clock_nanosleep = sys_clock_nanosleep, .ts_type = TST_KERN_OLD_TIMESPEC, .desc = "syscall with old kernel spec"}, #endif #if (__NR_clock_nanosleep_time64 != __LTP__NR_INVALID_SYSCALL) - { .gettime = sys_clock_gettime64, .func = sys_clock_nanosleep64, .type = TST_KERN_TIMESPEC, .desc = "syscall time64 with kernel spec"}, + { .clock_gettime = sys_clock_gettime64, .clock_nanosleep = sys_clock_nanosleep64, .ts_type = TST_KERN_TIMESPEC, .desc = "syscall time64 with kernel spec"}, #endif }; @@ -39,10 +35,10 @@ void setup(void) static void do_test(unsigned int i) { - struct test_variants *tv = &variants[tst_variant]; - struct tst_ts ts = {.type = tv->type}; + struct time64_variants *tv = &variants[tst_variant]; + struct tst_ts ts = {.type = tv->ts_type}; - TEST(tv->gettime(tcase[i], tst_ts_get(&ts))); + TEST(tv->clock_gettime(tcase[i], tst_ts_get(&ts))); if (TST_RET == -1) { tst_res(TFAIL | TTERRNO, "clock_gettime(2) failed for clock %s", tst_clock_name(tcase[i])); @@ -51,7 +47,7 @@ static void do_test(unsigned int i) ts = tst_ts_add_us(ts, 10000); - TEST(tv->func(tcase[i], TIMER_ABSTIME, tst_ts_get(&ts), NULL)); + TEST(tv->clock_nanosleep(tcase[i], TIMER_ABSTIME, tst_ts_get(&ts), NULL)); if (TST_RET) { tst_res(TFAIL | TTERRNO, "clock_nanosleep(2) failed for clock %s", From patchwork Tue Sep 8 06:19:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 1359481 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=2001:1418:10:5::2; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=V/NrVuEQ; dkim-atps=neutral Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Blw4W2RDQz9sTK for ; Tue, 8 Sep 2020 16:20:27 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id BAEBC3C53C2 for ; Tue, 8 Sep 2020 08:20:24 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-2.smtp.seeweb.it (in-2.smtp.seeweb.it [217.194.8.2]) by picard.linux.it (Postfix) with ESMTP id CB5003C53D7 for ; Tue, 8 Sep 2020 08:19:58 +0200 (CEST) Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by in-2.smtp.seeweb.it (Postfix) with ESMTPS id 5F84C6009C6 for ; Tue, 8 Sep 2020 08:19:58 +0200 (CEST) Received: by mail-pg1-x542.google.com with SMTP id 5so9319680pgl.4 for ; Mon, 07 Sep 2020 23:19:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gqeJmD7nGYOdVFdRxLdoOlYzfj4FCL7bisTu6DMhm4A=; b=V/NrVuEQTtxGMfHlrdx5MtTSNX7G1VFs+A7D9NHSNUXVScd06+4F1XMZZzu9qhiTZU qfXjOzBAMABqANs9PMozXgYC25LSdUssS8szogtTxIMfTLFNlBkt6sBuROSQgfsJymNd q5bZMU5PQalShjP+qpLjzG4hGF7H8DGkq+CiClbNnURtqxTBVbu+sHhSKKY2f5qmsdxa qc/azuAFLJFL0Q2jfYIeA9Juwp/QG1QEWYlDRv2GDmRdowU0f6ixS+wqnT816a9Sb1B6 xCojKD9fvkJDxL6FVAk/Oh2hgxBNZH7SEI/CT5WnxQVEmSrWRVFMRTMaQyhvl2m6L4gF FuvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gqeJmD7nGYOdVFdRxLdoOlYzfj4FCL7bisTu6DMhm4A=; b=Nhc9mkgsR6TtRE9vJUocn6wgVMdZBzPH6eTM3SrrX3B6OT/8IKvYcrxCDsE10T0Agq BTIxam1yTqqAchfIMuR0A9Gn30PP9K6qylxW9eq5YdN3PPuJDL1k6w9cVNqkj2aRzAs9 QxO8orO0J23YMQKcC6UnFDaCS47ZS1bCUbl6TNOpn3m1l1Yvpdd9rKIyEEDIqKamktSs VLGDLSWRIIIyJ8pMkDuA8larnzlofVqiCAj98YCUHnhCDTFediDOzHIlWZJCspIy42KG O4i0t4Dzak+briRkX6Pl05SK5yjNJL34oMyxgXunEblRxSpL7uE4BscvDk7VIWObcYd1 bsPQ== X-Gm-Message-State: AOAM533CvrtKL0c9NRRW6fz6RNPEM/psWxnSlSduIosdYedRq5XkHKdh NG6nZf2O+t7c5IYy3HbJu21J+VXMOSr5Jw== X-Google-Smtp-Source: ABdhPJzETJI3rCkRExWv7zLcEaw147Q3Wq3TLI9/ZnyC5cFYoq+De19fQPCm3jrrupkH9KTipY0Z7Q== X-Received: by 2002:a63:e1e:: with SMTP id d30mr6081808pgl.278.1599545996408; Mon, 07 Sep 2020 23:19:56 -0700 (PDT) Received: from localhost ([122.181.54.133]) by smtp.gmail.com with ESMTPSA id r6sm17244039pfq.11.2020.09.07.23.19.55 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Sep 2020 23:19:55 -0700 (PDT) From: Viresh Kumar To: ltp@lists.linux.it Date: Tue, 8 Sep 2020 11:49:17 +0530 Message-Id: X-Mailer: git-send-email 2.25.0.rc1.19.g042ed3e048af In-Reply-To: References: MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.102.4 at in-2.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-2.smtp.seeweb.it Subject: [LTP] [PATCH 04/16] syscalls: clock_settime: Reuse struct time64_variants X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Viresh Kumar , Vincent Guittot Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Lets reuse the common structure here. Signed-off-by: Viresh Kumar --- .../syscalls/clock_settime/clock_settime01.c | 26 ++++++++----------- .../syscalls/clock_settime/clock_settime02.c | 20 ++++++-------- .../syscalls/clock_settime/clock_settime03.c | 22 ++++++---------- 3 files changed, 27 insertions(+), 41 deletions(-) diff --git a/testcases/kernel/syscalls/clock_settime/clock_settime01.c b/testcases/kernel/syscalls/clock_settime/clock_settime01.c index ba6045fc5c8f..19bddbcd30ef 100644 --- a/testcases/kernel/syscalls/clock_settime/clock_settime01.c +++ b/testcases/kernel/syscalls/clock_settime/clock_settime01.c @@ -14,6 +14,7 @@ */ #include "config.h" +#include "time64_variants.h" #include "tst_timer.h" #include "tst_safe_clocks.h" @@ -23,41 +24,36 @@ static struct tst_ts *begin, *change, *end; -static struct test_variants { - int (*gettime)(clockid_t clk_id, void *ts); - int (*settime)(clockid_t clk_id, void *ts); - enum tst_ts_type type; - char *desc; -} variants[] = { - { .gettime = libc_clock_gettime, .settime = libc_clock_settime, .type = TST_LIBC_TIMESPEC, .desc = "vDSO or syscall with libc spec"}, +static struct time64_variants variants[] = { + { .clock_gettime = libc_clock_gettime, .clock_settime = libc_clock_settime, .ts_type = TST_LIBC_TIMESPEC, .desc = "vDSO or syscall with libc spec"}, #if (__NR_clock_settime != __LTP__NR_INVALID_SYSCALL) - { .gettime = sys_clock_gettime, .settime = sys_clock_settime, .type = TST_KERN_OLD_TIMESPEC, .desc = "syscall with old kernel spec"}, + { .clock_gettime = sys_clock_gettime, .clock_settime = sys_clock_settime, .ts_type = TST_KERN_OLD_TIMESPEC, .desc = "syscall with old kernel spec"}, #endif #if (__NR_clock_settime64 != __LTP__NR_INVALID_SYSCALL) - { .gettime = sys_clock_gettime64, .settime = sys_clock_settime64, .type = TST_KERN_TIMESPEC, .desc = "syscall time64 with kernel spec"}, + { .clock_gettime = sys_clock_gettime64, .clock_settime = sys_clock_settime64, .ts_type = TST_KERN_TIMESPEC, .desc = "syscall time64 with kernel spec"}, #endif }; static void setup(void) { - begin->type = change->type = end->type = variants[tst_variant].type; + begin->type = change->type = end->type = variants[tst_variant].ts_type; tst_res(TINFO, "Testing variant: %s", variants[tst_variant].desc); } -static void do_clock_gettime(struct test_variants *tv, struct tst_ts *ts) +static void do_clock_gettime(struct time64_variants *tv, struct tst_ts *ts) { int ret; - ret = tv->gettime(CLOCK_REALTIME, tst_ts_get(ts)); + ret = tv->clock_gettime(CLOCK_REALTIME, tst_ts_get(ts)); if (ret == -1) tst_brk(TBROK | TERRNO, "clock_settime(CLOCK_REALTIME) failed"); } static void verify_clock_settime(void) { - struct test_variants *tv = &variants[tst_variant]; + struct time64_variants *tv = &variants[tst_variant]; long long elapsed; /* test 01: move forward */ @@ -65,7 +61,7 @@ static void verify_clock_settime(void) *change = tst_ts_add_us(*begin, DELTA_US); - TEST(tv->settime(CLOCK_REALTIME, tst_ts_get(change))); + TEST(tv->clock_settime(CLOCK_REALTIME, tst_ts_get(change))); if (TST_RET == -1) { tst_res(TFAIL | TTERRNO, "clock_settime(2) failed for clock %s", tst_clock_name(CLOCK_REALTIME)); @@ -86,7 +82,7 @@ static void verify_clock_settime(void) *change = tst_ts_sub_us(*begin, DELTA_US); - TEST(tv->settime(CLOCK_REALTIME, tst_ts_get(change))); + TEST(tv->clock_settime(CLOCK_REALTIME, tst_ts_get(change))); if (TST_RET == -1) { tst_res(TFAIL | TTERRNO, "clock_settime(2) failed for clock %s", tst_clock_name(CLOCK_REALTIME)); diff --git a/testcases/kernel/syscalls/clock_settime/clock_settime02.c b/testcases/kernel/syscalls/clock_settime/clock_settime02.c index 0a8245dd4889..88d4492456f8 100644 --- a/testcases/kernel/syscalls/clock_settime/clock_settime02.c +++ b/testcases/kernel/syscalls/clock_settime/clock_settime02.c @@ -9,6 +9,7 @@ */ #include "config.h" +#include "time64_variants.h" #include "tst_timer.h" #include "tst_safe_clocks.h" @@ -91,18 +92,13 @@ struct test_case tc[] = { static struct tst_ts spec; -static struct test_variants { - int (*gettime)(clockid_t clk_id, void *ts); - int (*settime)(clockid_t clk_id, void *ts); - enum tst_ts_type type; - char *desc; -} variants[] = { +static struct time64_variants variants[] = { #if (__NR_clock_settime != __LTP__NR_INVALID_SYSCALL) - { .gettime = sys_clock_gettime, .settime = sys_clock_settime, .type = TST_KERN_OLD_TIMESPEC, .desc = "syscall with old kernel spec"}, + { .clock_gettime = sys_clock_gettime, .clock_settime = sys_clock_settime, .ts_type = TST_KERN_OLD_TIMESPEC, .desc = "syscall with old kernel spec"}, #endif #if (__NR_clock_settime64 != __LTP__NR_INVALID_SYSCALL) - { .gettime = sys_clock_gettime64, .settime = sys_clock_settime64, .type = TST_KERN_TIMESPEC, .desc = "syscall time64 with kernel spec"}, + { .clock_gettime = sys_clock_gettime64, .clock_settime = sys_clock_settime64, .ts_type = TST_KERN_TIMESPEC, .desc = "syscall time64 with kernel spec"}, #endif }; @@ -115,13 +111,13 @@ static void setup(void) static void verify_clock_settime(unsigned int i) { - struct test_variants *tv = &variants[tst_variant]; + struct time64_variants *tv = &variants[tst_variant]; void *ts; - spec.type = tv->type; + spec.type = tv->ts_type; if (tc[i].replace == 0) { - TEST(tv->gettime(CLOCK_REALTIME, tst_ts_get(&spec))); + TEST(tv->clock_gettime(CLOCK_REALTIME, tst_ts_get(&spec))); if (TST_RET == -1) { tst_res(TFAIL | TTERRNO, "clock_gettime(2) failed for clock %s", tst_clock_name(CLOCK_REALTIME)); @@ -142,7 +138,7 @@ static void verify_clock_settime(unsigned int i) else ts = tst_ts_get(&spec); - TEST(tv->settime(tc[i].type, ts)); + TEST(tv->clock_settime(tc[i].type, ts)); if (TST_RET != -1) { tst_res(TFAIL | TTERRNO, "clock_settime(2): clock %s passed unexpectedly, expected %s", diff --git a/testcases/kernel/syscalls/clock_settime/clock_settime03.c b/testcases/kernel/syscalls/clock_settime/clock_settime03.c index ad6183e4ce3e..fef3c10e98b1 100644 --- a/testcases/kernel/syscalls/clock_settime/clock_settime03.c +++ b/testcases/kernel/syscalls/clock_settime/clock_settime03.c @@ -8,6 +8,7 @@ #include #include "config.h" +#include "time64_variants.h" #include "tst_timer.h" #include "tst_safe_clocks.h" @@ -17,32 +18,25 @@ static struct tst_ts start, end; static struct tst_its its; -static struct test_variants { - int (*clock_gettime)(clockid_t clk_id, void *ts); - int (*clock_settime)(clockid_t clk_id, void *ts); - int (*timer_settime)(kernel_timer_t timerid, int flags, void *its, - void *old_its); - enum tst_ts_type type; - char *desc; -} variants[] = { +static struct time64_variants variants[] = { #if (__NR_clock_settime != __LTP__NR_INVALID_SYSCALL) - { .clock_gettime = sys_clock_gettime, .clock_settime = sys_clock_settime, .timer_settime = sys_timer_settime, .type = TST_KERN_OLD_TIMESPEC, .desc = "syscall with old kernel spec"}, + { .clock_gettime = sys_clock_gettime, .clock_settime = sys_clock_settime, .timer_settime = sys_timer_settime, .ts_type = TST_KERN_OLD_TIMESPEC, .desc = "syscall with old kernel spec"}, #endif #if (__NR_clock_settime64 != __LTP__NR_INVALID_SYSCALL) - { .clock_gettime = sys_clock_gettime64, .clock_settime = sys_clock_settime64, .timer_settime = sys_timer_settime64, .type = TST_KERN_TIMESPEC, .desc = "syscall time64 with kernel spec"}, + { .clock_gettime = sys_clock_gettime64, .clock_settime = sys_clock_settime64, .timer_settime = sys_timer_settime64, .ts_type = TST_KERN_TIMESPEC, .desc = "syscall time64 with kernel spec"}, #endif }; static void setup(void) { - struct test_variants *tv = &variants[tst_variant]; + struct time64_variants *tv = &variants[tst_variant]; tst_res(TINFO, "Testing variant: %s", tv->desc); - start.type = end.type = its.type = tv->type; + start.type = end.type = its.type = tv->ts_type; /* Check if the kernel is y2038 safe */ - if (tv->type == TST_KERN_OLD_TIMESPEC && + if (tv->ts_type == TST_KERN_OLD_TIMESPEC && sizeof(start.ts.kern_old_ts.tv_sec) == 4) { tst_brk(TCONF, "Not Y2038 safe to run test"); } @@ -50,7 +44,7 @@ static void setup(void) static void run(void) { - struct test_variants *tv = &variants[tst_variant]; + struct time64_variants *tv = &variants[tst_variant]; unsigned long long time = 0x7FFFFFFE; /* Time just before y2038 */ struct sigevent ev = { .sigev_notify = SIGEV_SIGNAL, From patchwork Tue Sep 8 06:19:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 1359482 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=2001:1418:10:5::2; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=nFcZlsdI; dkim-atps=neutral Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Blw4j6bhlz9sT6 for ; Tue, 8 Sep 2020 16:20:37 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 479193C2C43 for ; Tue, 8 Sep 2020 08:20:35 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-6.smtp.seeweb.it (in-6.smtp.seeweb.it [IPv6:2001:4b78:1:20::6]) by picard.linux.it (Postfix) with ESMTP id AFC513C53D9 for ; Tue, 8 Sep 2020 08:20:01 +0200 (CEST) Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by in-6.smtp.seeweb.it (Postfix) with ESMTPS id B72FE1400E16 for ; Tue, 8 Sep 2020 08:20:00 +0200 (CEST) Received: by mail-pg1-x544.google.com with SMTP id w186so9304626pgb.8 for ; Mon, 07 Sep 2020 23:20:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=kTZuO3BsOhQB1O/qcM7fo1qwC99mW9NdwyAfB2oTfKk=; b=nFcZlsdIy1fiNnY1f7Ytn7+03wgSsDd3q5Rv1Z6IKHMZShHIFg8Sm9vqKyQwHGBmm6 YHZ6Q3bPvEvu3RhWP+0jfdypD9gfDdZVBW0vaF5uCDV9lQt7uZPsK/qJIIMVMs+zKKWT mjEhF8tWsIEqBPFW4b0H7DzB1MF0WH+88xX6Eb98iBwhQCSr3lZcgJYxIHTO2Ol+mTTC TJb72zACkkqgbD6yU2VkQwOHFpNpyH2fgVVpu55maIstougeGDai0W4myToU51kiB4yt 1HGZOlSSgnjsoy7qefnsMX3OYvlNsl6FLR3qIHKl87rX/8FIha/WdYH6CzbEeR875cg0 xnhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=kTZuO3BsOhQB1O/qcM7fo1qwC99mW9NdwyAfB2oTfKk=; b=R2sodphNT4ZqzcbK4y0CWymK8ZXLAYkr7tCU9LzcAijCwx4bfhmR8rLwzX2LjWKrda d0sfvsrXaW3G9J5CxexAzMZ7TpXdVo3K9Pn2cNmnIpiujV6HdycuvGGkO3HolUomjo18 2IMu1ooowfAb3hIt6n6bT1UXVCarRomncFnL0f+GaOCX1pWEigFCEkJwWXk7FF/n0jfG UOJTDa/ona2QjaxDtFtZDMdqmzw8SXf5YjPt6BmDYRqXLGMrAq8zIt3IFjULipSVUSbr SZqpQkVPHV9PyppIweBvGnCmApeUI+89FAgCJ/MAMbpQXSBYcL8ts+IfbsAUEA42a8Fa 5ulA== X-Gm-Message-State: AOAM533RfIEyrRTAgWuxAzM/jB1r1vTtrhOvGAbQ6T52AEJN+H9tPjVL J+Uhyiu1FWq8Xz14RcicjW7GmCPgLuKzbQ== X-Google-Smtp-Source: ABdhPJyS1aN0ta7wLlaBLsvb53vMhDH8r2QDbjkJ6zdxDJRm7eRgUqI5J0R0HXpMmE+eg1f8T7CYXA== X-Received: by 2002:a63:4a19:: with SMTP id x25mr18605209pga.56.1599545998971; Mon, 07 Sep 2020 23:19:58 -0700 (PDT) Received: from localhost ([122.181.54.133]) by smtp.gmail.com with ESMTPSA id z11sm7632927pfc.181.2020.09.07.23.19.58 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Sep 2020 23:19:58 -0700 (PDT) From: Viresh Kumar To: ltp@lists.linux.it Date: Tue, 8 Sep 2020 11:49:18 +0530 Message-Id: <938c530af0353358609b847350cd2e184452ecbd.1599545766.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.25.0.rc1.19.g042ed3e048af In-Reply-To: References: MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.102.4 at in-6.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-6.smtp.seeweb.it Subject: [LTP] [PATCH 05/16] syscalls: io_pgetevents: Reuse struct time64_variants X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Viresh Kumar , Vincent Guittot Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Lets reuse the common structure here. Signed-off-by: Viresh Kumar --- .../syscalls/io_pgetevents/io_pgetevents01.c | 16 ++++++---------- .../syscalls/io_pgetevents/io_pgetevents02.c | 18 +++++++----------- 2 files changed, 13 insertions(+), 21 deletions(-) diff --git a/testcases/kernel/syscalls/io_pgetevents/io_pgetevents01.c b/testcases/kernel/syscalls/io_pgetevents/io_pgetevents01.c index adeca3f3cf79..2a1aad8d9f96 100644 --- a/testcases/kernel/syscalls/io_pgetevents/io_pgetevents01.c +++ b/testcases/kernel/syscalls/io_pgetevents/io_pgetevents01.c @@ -5,6 +5,7 @@ * Description: * Basic io_pgetevents() test to receive 1 event successfully. */ +#include "time64_variants.h" #include "tst_test.h" #include "tst_timer.h" #include "lapi/io_pgetevents.h" @@ -12,18 +13,13 @@ #ifdef HAVE_LIBAIO static int fd; -static struct test_variants { - int (*io_pgetevents)(io_context_t ctx, long min_nr, long max_nr, - struct io_event *events, void *timeout, sigset_t *sigmask); - enum tst_ts_type type; - char *desc; -} variants[] = { +static struct time64_variants variants[] = { #if (__NR_io_pgetevents != __LTP__NR_INVALID_SYSCALL) - { .io_pgetevents = sys_io_pgetevents, .type = TST_KERN_OLD_TIMESPEC, .desc = "syscall with old kernel spec"}, + { .io_pgetevents = sys_io_pgetevents, .ts_type = TST_KERN_OLD_TIMESPEC, .desc = "syscall with old kernel spec"}, #endif #if (__NR_io_pgetevents_time64 != __LTP__NR_INVALID_SYSCALL) - { .io_pgetevents = sys_io_pgetevents_time64, .type = TST_KERN_TIMESPEC, .desc = "syscall time64 with kernel spec"}, + { .io_pgetevents = sys_io_pgetevents_time64, .ts_type = TST_KERN_TIMESPEC, .desc = "syscall time64 with kernel spec"}, #endif }; @@ -40,11 +36,11 @@ static void cleanup(void) static void run(void) { - struct test_variants *tv = &variants[tst_variant]; + struct time64_variants *tv = &variants[tst_variant]; struct io_event events[1]; struct iocb cb, *cbs[1]; io_context_t ctx = 0; - struct tst_ts to = tst_ts_from_ns(tv->type, 10000); + struct tst_ts to = tst_ts_from_ns(tv->ts_type, 10000); sigset_t sigmask; char data[4096]; int ret; diff --git a/testcases/kernel/syscalls/io_pgetevents/io_pgetevents02.c b/testcases/kernel/syscalls/io_pgetevents/io_pgetevents02.c index 885722fcad09..28afdb4a02d7 100644 --- a/testcases/kernel/syscalls/io_pgetevents/io_pgetevents02.c +++ b/testcases/kernel/syscalls/io_pgetevents/io_pgetevents02.c @@ -5,6 +5,7 @@ * Description: * Basic io_pgetevents() test to check various failures. */ +#include "time64_variants.h" #include "tst_test.h" #include "tst_timer.h" #include "lapi/io_pgetevents.h" @@ -36,31 +37,26 @@ static struct tcase { {"invalid sigmask", &ctx, 1, 1, events, &to, NULL, EFAULT}, }; -static struct test_variants { - int (*io_pgetevents)(io_context_t ctx, long min_nr, long max_nr, - struct io_event *events, void *timeout, sigset_t *sigmask); - enum tst_ts_type type; - char *desc; -} variants[] = { +static struct time64_variants variants[] = { #if (__NR_io_pgetevents != __LTP__NR_INVALID_SYSCALL) - { .io_pgetevents = sys_io_pgetevents, .type = TST_KERN_OLD_TIMESPEC, .desc = "syscall with old kernel spec"}, + { .io_pgetevents = sys_io_pgetevents, .ts_type = TST_KERN_OLD_TIMESPEC, .desc = "syscall with old kernel spec"}, #endif #if (__NR_io_pgetevents_time64 != __LTP__NR_INVALID_SYSCALL) - { .io_pgetevents = sys_io_pgetevents_time64, .type = TST_KERN_TIMESPEC, .desc = "syscall time64 with kernel spec"}, + { .io_pgetevents = sys_io_pgetevents_time64, .ts_type = TST_KERN_TIMESPEC, .desc = "syscall time64 with kernel spec"}, #endif }; static void setup(void) { - struct test_variants *tv = &variants[tst_variant]; + struct time64_variants *tv = &variants[tst_variant]; struct iocb cb, *cbs[1]; char data[4096]; int ret; tst_res(TINFO, "Testing variant: %s", tv->desc); bad_addr = tst_get_bad_addr(NULL); - to = tst_ts_from_ns(tv->type, 10000); + to = tst_ts_from_ns(tv->ts_type, 10000); cbs[0] = &cb; @@ -93,7 +89,7 @@ static void cleanup(void) static void run(unsigned int n) { - struct test_variants *tv = &variants[tst_variant]; + struct time64_variants *tv = &variants[tst_variant]; struct tcase *tc = &tcases[n]; struct timespec *to; sigset_t *sigmask; From patchwork Tue Sep 8 06:19:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 1359483 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=2001:1418:10:5::2; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=iuDZu5zN; dkim-atps=neutral Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Blw4w1NqVz9sT6 for ; Tue, 8 Sep 2020 16:20:47 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 36D4A3C53C2 for ; Tue, 8 Sep 2020 08:20:45 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-6.smtp.seeweb.it (in-6.smtp.seeweb.it [IPv6:2001:4b78:1:20::6]) by picard.linux.it (Postfix) with ESMTP id 021953C53E9 for ; Tue, 8 Sep 2020 08:20:03 +0200 (CEST) Received: from mail-pj1-x1043.google.com (mail-pj1-x1043.google.com [IPv6:2607:f8b0:4864:20::1043]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by in-6.smtp.seeweb.it (Postfix) with ESMTPS id 6F4E71400E16 for ; Tue, 8 Sep 2020 08:20:03 +0200 (CEST) Received: by mail-pj1-x1043.google.com with SMTP id o16so7739445pjr.2 for ; Mon, 07 Sep 2020 23:20:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=71AENkj/E/iV/t7TV6AvE+8wXh46GuhOdWXHvUtHSSw=; b=iuDZu5zN8OKeRBDYjk90aAxWbS5uW4TgAvLtYZr73fyhlwy+P156IpEK1h/BrrjzUm 1AmFyB8O0y7qza6hSuyV5YKpc9WRNZofEx4wCTmc+/MUDWs/JMRmfn64yiTl9IdDAYrT UDX6aSUC3tCUvL9FY5rx4ZR0kCrbH8JPoQrVBrCAdmK5zjUK/lss2HLmk7Q/jUyeZvDy HuT1GDOHdesRes4kLg02BZ+nDcIno+OaQBIXNUvon3UKbYHhyUf1Dfg2kqYey10m7tPD PMY2r8UhrHzYV+LoRDVllSE4Yz9ect2sVZ7ILCA8S1agA/d5EnEqQI0whgpwPXN9bPIb OJeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=71AENkj/E/iV/t7TV6AvE+8wXh46GuhOdWXHvUtHSSw=; b=moEFyOKpbqI3NQc7qhso36i/D6c5N4HgxjiWtMfrsIBLBmF2XMRrqVMpP9wwDRdhsK G8VkP3yASDkwusSe3tFZhoLCCbKI0453mRZl9y4+hhzVX++A8yumNpJvpPyYOGsxOOB1 PbUllWZj4C4jMhpqs7ZCtbAT/2xD2AKPNI5PiCRT5WnwJubNN89lKZN45LIO6x+lD5BI KvCATlP+sy8R+R3cidC7Wy69QFoGE5NeGBDhyItLfSkLX2KTYPfmTLep8cVTCBJdpH+2 rnQ6RQuyiHs+B1DW46GCQkzsHRH5OVv9v+QisLUSkkF1qkisIxp5ctCArdnzSJBHDDB0 IdUg== X-Gm-Message-State: AOAM533xaoQpPXb0426RZQu42yDFj1eRm6+TCeNAHVplEyV8NfVdteo5 N1hcpUfy9IY8NLnNhJ0K1FPSticOLwvCUw== X-Google-Smtp-Source: ABdhPJxNW73InNMfCIcbGVBPY3Aq7TxKJSxncr6SzVDzakLE25o0TsVXEepVF1jCD7S9r9pilBDL2w== X-Received: by 2002:a17:90a:77c7:: with SMTP id e7mr2546616pjs.175.1599546001506; Mon, 07 Sep 2020 23:20:01 -0700 (PDT) Received: from localhost ([122.181.54.133]) by smtp.gmail.com with ESMTPSA id i1sm13699922pgq.41.2020.09.07.23.20.00 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Sep 2020 23:20:01 -0700 (PDT) From: Viresh Kumar To: ltp@lists.linux.it Date: Tue, 8 Sep 2020 11:49:19 +0530 Message-Id: <429ca6f4c2496df28f236ad1366505a9519e68c9.1599545766.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.25.0.rc1.19.g042ed3e048af In-Reply-To: References: MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.102.4 at in-6.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-6.smtp.seeweb.it Subject: [LTP] [PATCH 06/16] syscalls: semop: Reuse struct time64_variants X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Viresh Kumar , Vincent Guittot Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Lets reuse the common structure here. Signed-off-by: Viresh Kumar --- testcases/kernel/syscalls/ipc/semop/semop.h | 18 +++++++----------- testcases/kernel/syscalls/ipc/semop/semop01.c | 6 +++--- testcases/kernel/syscalls/ipc/semop/semop02.c | 6 +++--- testcases/kernel/syscalls/ipc/semop/semop03.c | 6 +++--- 4 files changed, 16 insertions(+), 20 deletions(-) diff --git a/testcases/kernel/syscalls/ipc/semop/semop.h b/testcases/kernel/syscalls/ipc/semop/semop.h index 1fac31818108..73ab9fbbc15c 100644 --- a/testcases/kernel/syscalls/ipc/semop/semop.h +++ b/testcases/kernel/syscalls/ipc/semop/semop.h @@ -4,6 +4,7 @@ #define SEMOP_VAR__ #include +#include "time64_variants.h" #include "tst_timer.h" static inline int sys_semtimedop(int semid, struct sembuf *sops, size_t nsops, @@ -18,24 +19,19 @@ static inline int sys_semtimedop_time64(int semid, struct sembuf *sops, return tst_syscall(__NR_semtimedop_time64, semid, sops, nsops, timeout); } -struct test_variants { - int (*semop)(int semid, struct sembuf *sops, size_t nsops); - int (*semtimedop)(int semid, struct sembuf *sops, size_t nsops, void *timeout); - enum tst_ts_type type; - char *desc; -} variants[] = { - { .semop = semop, .type = TST_LIBC_TIMESPEC, .desc = "semop: syscall"}, +static struct time64_variants variants[] = { + { .semop = semop, .ts_type = TST_LIBC_TIMESPEC, .desc = "semop: syscall"}, #if (__NR_semtimedop != __LTP__NR_INVALID_SYSCALL) - { .semtimedop = sys_semtimedop, .type = TST_KERN_OLD_TIMESPEC, .desc = "semtimedop: syscall with old kernel spec"}, + { .semtimedop = sys_semtimedop, .ts_type = TST_KERN_OLD_TIMESPEC, .desc = "semtimedop: syscall with old kernel spec"}, #endif #if (__NR_semtimedop_time64 != __LTP__NR_INVALID_SYSCALL) - { .semtimedop = sys_semtimedop_time64, .type = TST_KERN_TIMESPEC, .desc = "semtimedop: syscall time64 with kernel spec"}, + { .semtimedop = sys_semtimedop_time64, .ts_type = TST_KERN_TIMESPEC, .desc = "semtimedop: syscall time64 with kernel spec"}, #endif }; -static inline int call_semop(struct test_variants *tv, int semid, +static inline int call_semop(struct time64_variants *tv, int semid, struct sembuf *sops, size_t nsops, void *timeout) { if (tv->semop) @@ -44,7 +40,7 @@ static inline int call_semop(struct test_variants *tv, int semid, return tv->semtimedop(semid, sops, nsops, timeout); } -static inline void semop_supported_by_kernel(struct test_variants *tv) +static inline void semop_supported_by_kernel(struct time64_variants *tv) { /* Check if the syscall is implemented on the platform */ TEST(call_semop(tv, 0, NULL, 0, NULL)); diff --git a/testcases/kernel/syscalls/ipc/semop/semop01.c b/testcases/kernel/syscalls/ipc/semop/semop01.c index add9d07f3ad4..b20eef45cf59 100644 --- a/testcases/kernel/syscalls/ipc/semop/semop01.c +++ b/testcases/kernel/syscalls/ipc/semop/semop01.c @@ -33,7 +33,7 @@ static struct test_case_t { static void run(unsigned int n) { - struct test_variants *tv = &variants[tst_variant]; + struct time64_variants *tv = &variants[tst_variant]; union semun arr = { .val = 0 }; int fail = 0; int i; @@ -66,13 +66,13 @@ static void run(unsigned int n) static void setup(void) { - struct test_variants *tv = &variants[tst_variant]; + struct time64_variants *tv = &variants[tst_variant]; int i; tst_res(TINFO, "Testing variant: %s", tv->desc); semop_supported_by_kernel(tv); - timeout.type = tv->type; + timeout.type = tv->ts_type; tst_ts_set_sec(&timeout, 0); tst_ts_set_nsec(&timeout, 10000); diff --git a/testcases/kernel/syscalls/ipc/semop/semop02.c b/testcases/kernel/syscalls/ipc/semop/semop02.c index 9d799e6437cd..2c3ec2c66686 100644 --- a/testcases/kernel/syscalls/ipc/semop/semop02.c +++ b/testcases/kernel/syscalls/ipc/semop/semop02.c @@ -69,7 +69,7 @@ static struct test_case_t { static void setup(void) { - struct test_variants *tv = &variants[tst_variant]; + struct time64_variants *tv = &variants[tst_variant]; struct passwd *ltpuser; key_t semkey; union semun arr; @@ -79,7 +79,7 @@ static void setup(void) tst_res(TINFO, "Testing variant: %s", tv->desc); semop_supported_by_kernel(tv); - timeout.type = tv->type; + timeout.type = tv->ts_type; tst_ts_set_sec(&timeout, 0); tst_ts_set_nsec(&timeout, 10000); @@ -110,7 +110,7 @@ static void setup(void) static void run(unsigned int i) { - struct test_variants *tv = &variants[tst_variant]; + struct time64_variants *tv = &variants[tst_variant]; union semun arr = {.val = tc[i].arr_val}; struct sembuf buf = { .sem_op = *tc[i].sem_op, diff --git a/testcases/kernel/syscalls/ipc/semop/semop03.c b/testcases/kernel/syscalls/ipc/semop/semop03.c index 43d22a8ee1a7..89603f19d651 100644 --- a/testcases/kernel/syscalls/ipc/semop/semop03.c +++ b/testcases/kernel/syscalls/ipc/semop/semop03.c @@ -36,7 +36,7 @@ struct test_case_t { static void do_child(int i) { - struct test_variants *tv = &variants[tst_variant]; + struct time64_variants *tv = &variants[tst_variant]; struct sembuf s_buf = { .sem_op = tc[i].op, .sem_flg = tc[i].flg, @@ -65,12 +65,12 @@ static void sighandler(int sig) static void setup(void) { - struct test_variants *tv = &variants[tst_variant]; + struct time64_variants *tv = &variants[tst_variant]; tst_res(TINFO, "Testing variant: %s", tv->desc); semop_supported_by_kernel(tv); - timeout.type = tv->type; + timeout.type = tv->ts_type; tst_ts_set_sec(&timeout, 0); tst_ts_set_nsec(&timeout, 10000000); From patchwork Tue Sep 8 06:19:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 1359484 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=2001:1418:10:5::2; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=ZiL6IbrV; dkim-atps=neutral Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Blw546vZkz9sT6 for ; Tue, 8 Sep 2020 16:20:56 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 3E5FA3C53D3 for ; Tue, 8 Sep 2020 08:20:54 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-6.smtp.seeweb.it (in-6.smtp.seeweb.it [IPv6:2001:4b78:1:20::6]) by picard.linux.it (Postfix) with ESMTP id 857FE3C53D4 for ; Tue, 8 Sep 2020 08:20:06 +0200 (CEST) Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by in-6.smtp.seeweb.it (Postfix) with ESMTPS id 107161400E1C for ; Tue, 8 Sep 2020 08:20:06 +0200 (CEST) Received: by mail-pf1-x444.google.com with SMTP id d9so3808346pfd.3 for ; Mon, 07 Sep 2020 23:20:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=FSyaGbT/bFdVeCg55/LWsrUz1w5VbWOEmdcog2kZIz0=; b=ZiL6IbrVqAkki1nBrJfs++yh9opeUYZH5ix6YgKTT6XgsrUVB5J/sGr1BPJePoTjWO JDWudixvE+DKixljzNQEeY6pInsIFIzQo0zWVO2ZMqfotAjNWSRxW9QMk0h0vNsyrmq8 QKr5728P6WVi05wwKs2HEgP9VsJNawPKoRrKr7poWFaYZAUmWzxyvhHdx3sJKko+BU5n o8aq2dIASYnZGwcUXT7bijfxel9dj1UEXaqTAA/PBc0rAI8dlrQHY1RrwSV1j17Z7dyl yCvxw0ztqQyHVrmN0qvFnq+c6V/Z8OytFr9z7mPq3YVmY9M0MRVet5cyZELFfSXHBiHM SfAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=FSyaGbT/bFdVeCg55/LWsrUz1w5VbWOEmdcog2kZIz0=; b=bqckbNwHObS8H8YSQdGZYaq5HVPRabbcDNnsZnysPhMR6lF5p+b75mdkHHew/pjPe6 BctKeMeA/e5zNvfq6/vZrWGLn2hFWYZX/6nXNGrUJ75JinMTrTM/d+vHg/RYulN2qyJC nj4hiFQBWwO5566AVJ3NthtL3t4eToZvtPDcSrOaA84n+Mw/TtLhM5Xm2kHw0Gr9sHvQ Lt6LFqB5iHf/zk4Zw3OisLn4HeEWnBVsNCCpEfKiWuUkst+H86vRzu7yD+VUdpzTNjkj MQZH93gMZK2aBFLbS+Bf/gtL5Eg1lxRBr0Qc6O5d7VFc5QQExOMAukrdSaWw5855cN+Z QpKA== X-Gm-Message-State: AOAM5307lSvra6QJOAJQEstSDVfqryj6O4ejx62cJOzHhapeFgQToSrb gaahLK4XfE97Qas60qvUAx3v8lftzgNkZA== X-Google-Smtp-Source: ABdhPJzUr0XVK3PxVlFg2faZg84KY1QD9aqL7FJr601OHOeLJ+j7vg45n9N5Dd+h9bBaXTdDx0leqw== X-Received: by 2002:a17:902:8d8a:: with SMTP id v10mr22267977plo.249.1599546004163; Mon, 07 Sep 2020 23:20:04 -0700 (PDT) Received: from localhost ([122.181.54.133]) by smtp.gmail.com with ESMTPSA id 25sm8988275pfj.35.2020.09.07.23.20.03 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Sep 2020 23:20:03 -0700 (PDT) From: Viresh Kumar To: ltp@lists.linux.it Date: Tue, 8 Sep 2020 11:49:20 +0530 Message-Id: X-Mailer: git-send-email 2.25.0.rc1.19.g042ed3e048af In-Reply-To: References: MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.102.4 at in-6.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-6.smtp.seeweb.it Subject: [LTP] [PATCH 07/16] syscalls: mq_timed: Reuse struct time64_variants X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Viresh Kumar , Vincent Guittot Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Lets reuse the common structure here. Signed-off-by: Viresh Kumar --- .../mq_timedreceive/mq_timedreceive01.c | 14 +++++++------- .../syscalls/mq_timedsend/mq_timedsend01.c | 16 ++++++++-------- testcases/kernel/syscalls/utils/mq_timed.h | 18 +++++------------- 3 files changed, 20 insertions(+), 28 deletions(-) diff --git a/testcases/kernel/syscalls/mq_timedreceive/mq_timedreceive01.c b/testcases/kernel/syscalls/mq_timedreceive/mq_timedreceive01.c index de0505106d04..be437e19a47f 100644 --- a/testcases/kernel/syscalls/mq_timedreceive/mq_timedreceive01.c +++ b/testcases/kernel/syscalls/mq_timedreceive/mq_timedreceive01.c @@ -135,10 +135,10 @@ static struct test_case tcase[] = { static void setup(void) { - struct test_variants *tv = &variants[tst_variant]; + struct time64_variants *tv = &variants[tst_variant]; tst_res(TINFO, "Testing variant: %s", tv->desc); - ts.type = tv->type; + ts.type = tv->ts_type; bad_addr = tst_get_bad_addr(NULL); @@ -147,7 +147,7 @@ static void setup(void) static void do_test(unsigned int i) { - struct test_variants *tv = &variants[tst_variant]; + struct time64_variants *tv = &variants[tst_variant]; const struct test_case *tc = &tcase[i]; unsigned int j; unsigned int prio; @@ -160,13 +160,13 @@ static void do_test(unsigned int i) tst_ts_set_nsec(&ts, tc->tv_nsec); if (tc->signal) - pid = set_sig(tc->rq, tv->gettime); + pid = set_sig(tc->rq, tv->clock_gettime); if (tc->timeout) - set_timeout(tc->rq, tv->gettime); + set_timeout(tc->rq, tv->clock_gettime); if (tc->send) { - if (tv->send(*tc->fd, smsg, tc->len, tc->prio, NULL) < 0) { + if (tv->mqt_send(*tc->fd, smsg, tc->len, tc->prio, NULL) < 0) { tst_res(TFAIL | TTERRNO, "mq_timedsend() failed"); return; } @@ -180,7 +180,7 @@ static void do_test(unsigned int i) else abs_timeout = tst_ts_get(tc->rq); - TEST(tv->receive(*tc->fd, rmsg, len, &prio, abs_timeout)); + TEST(tv->mqt_receive(*tc->fd, rmsg, len, &prio, abs_timeout)); if (pid > 0) kill_pid(pid); diff --git a/testcases/kernel/syscalls/mq_timedsend/mq_timedsend01.c b/testcases/kernel/syscalls/mq_timedsend/mq_timedsend01.c index d72f5d41ad61..334131402c9d 100644 --- a/testcases/kernel/syscalls/mq_timedsend/mq_timedsend01.c +++ b/testcases/kernel/syscalls/mq_timedsend/mq_timedsend01.c @@ -148,10 +148,10 @@ static struct test_case tcase[] = { static void setup(void) { - struct test_variants *tv = &variants[tst_variant]; + struct time64_variants *tv = &variants[tst_variant]; tst_res(TINFO, "Testing variant: %s", tv->desc); - ts.type = tv->type; + ts.type = tv->ts_type; bad_addr = tst_get_bad_addr(cleanup_common); @@ -160,7 +160,7 @@ static void setup(void) static void do_test(unsigned int i) { - struct test_variants *tv = &variants[tst_variant]; + struct time64_variants *tv = &variants[tst_variant]; const struct test_case *tc = &tcase[i]; unsigned int j; unsigned int prio; @@ -173,14 +173,14 @@ static void do_test(unsigned int i) tst_ts_set_nsec(&ts, tc->tv_nsec); if (tc->signal) - pid = set_sig(tc->rq, tv->gettime); + pid = set_sig(tc->rq, tv->clock_gettime); if (tc->timeout) - set_timeout(tc->rq, tv->gettime); + set_timeout(tc->rq, tv->clock_gettime); if (tc->send) { for (j = 0; j < MSG_LENGTH; j++) - if (tv->send(*tc->fd, smsg, tc->len, tc->prio, NULL) < 0) { + if (tv->mqt_send(*tc->fd, smsg, tc->len, tc->prio, NULL) < 0) { tst_res(TFAIL | TTERRNO, "mq_timedsend() failed"); return; } @@ -196,7 +196,7 @@ static void do_test(unsigned int i) else abs_timeout = tst_ts_get(tc->rq); - TEST(tv->send(*tc->fd, msg_ptr, tc->len, tc->prio, abs_timeout)); + TEST(tv->mqt_send(*tc->fd, msg_ptr, tc->len, tc->prio, abs_timeout)); if (pid > 0) kill_pid(pid); @@ -215,7 +215,7 @@ static void do_test(unsigned int i) return; } - TEST(tv->receive(*tc->fd, rmsg, len, &prio, tst_ts_get(tc->rq))); + TEST(tv->mqt_receive(*tc->fd, rmsg, len, &prio, tst_ts_get(tc->rq))); if (*tc->fd == fd) cleanup_queue(fd); diff --git a/testcases/kernel/syscalls/utils/mq_timed.h b/testcases/kernel/syscalls/utils/mq_timed.h index a217e864e1e4..adf46034bdc6 100644 --- a/testcases/kernel/syscalls/utils/mq_timed.h +++ b/testcases/kernel/syscalls/utils/mq_timed.h @@ -7,26 +7,18 @@ #define MQ_TIMED_H #include "mq.h" +#include "time64_variants.h" #include "tst_timer.h" -static struct test_variants { - int (*send)(mqd_t mqdes, const char *msg_ptr, size_t msg_len, - unsigned int msg_prio, void *abs_timeout); - ssize_t (*receive)(mqd_t mqdes, char *msg_ptr, size_t msg_len, - unsigned int *msg_prio, void *abs_timeout); - - int (*gettime)(clockid_t clk_id, void *ts); - enum tst_ts_type type; - char *desc; -} variants[] = { - { .gettime = libc_clock_gettime, .send = libc_mq_timedsend, .receive = libc_mq_timedreceive, .type = TST_LIBC_TIMESPEC, .desc = "vDSO or syscall with libc spec"}, +static struct time64_variants variants[] = { + { .clock_gettime = libc_clock_gettime, .mqt_send = libc_mq_timedsend, .mqt_receive = libc_mq_timedreceive, .ts_type = TST_LIBC_TIMESPEC, .desc = "vDSO or syscall with libc spec"}, #if (__NR_mq_timedsend != __LTP__NR_INVALID_SYSCALL) - { .gettime = sys_clock_gettime, .send = sys_mq_timedsend, .receive = sys_mq_timedreceive, .type = TST_KERN_OLD_TIMESPEC, .desc = "syscall with old kernel spec"}, + { .clock_gettime = sys_clock_gettime, .mqt_send = sys_mq_timedsend, .mqt_receive = sys_mq_timedreceive, .ts_type = TST_KERN_OLD_TIMESPEC, .desc = "syscall with old kernel spec"}, #endif #if (__NR_mq_timedsend_time64 != __LTP__NR_INVALID_SYSCALL) - { .gettime = sys_clock_gettime64, .send = sys_mq_timedsend64, .receive = sys_mq_timedreceive64, .type = TST_KERN_TIMESPEC, .desc = "syscall time64 with kernel spec"}, + { .clock_gettime = sys_clock_gettime64, .mqt_send = sys_mq_timedsend64, .mqt_receive = sys_mq_timedreceive64, .ts_type = TST_KERN_TIMESPEC, .desc = "syscall time64 with kernel spec"}, #endif }; From patchwork Tue Sep 8 06:19:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 1359485 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=213.254.12.146; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=Nt++L+PJ; dkim-atps=neutral Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Blw5F39Wvz9sT6 for ; Tue, 8 Sep 2020 16:21:05 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 918CF3C53C4 for ; Tue, 8 Sep 2020 08:21:02 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-4.smtp.seeweb.it (in-4.smtp.seeweb.it [IPv6:2001:4b78:1:20::4]) by picard.linux.it (Postfix) with ESMTP id DF43A3C53C0 for ; Tue, 8 Sep 2020 08:20:08 +0200 (CEST) Received: from mail-pj1-x1042.google.com (mail-pj1-x1042.google.com [IPv6:2607:f8b0:4864:20::1042]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by in-4.smtp.seeweb.it (Postfix) with ESMTPS id 902571000C1E for ; Tue, 8 Sep 2020 08:20:08 +0200 (CEST) Received: by mail-pj1-x1042.google.com with SMTP id q4so1545621pjh.5 for ; Mon, 07 Sep 2020 23:20:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Zim4xMahnIj33rOUinGvnyI6K/1vf/vbsHNzFhnsJAc=; b=Nt++L+PJocXbM5sHOdhky8KvonuiIQHZ9Gh/om4/wOryoBfNAsSeiiNb9jd+ujtUnp 81MRQHMphG9ppzXpT6boxM6z9LLl97ncf0qUP4rORL8w3JU4iwNn7B5yS4C68isX3h9X j0AHyjQJ5ex28bShXY6BOJ0f1IBbaDRSKU8Fpm8M8lG0nSW66RIKEG5xfGZavsa0qeof Au0paE8dBoeDGsj2nVVNr3hen2F0hAWwcXCAWyRDymJNNhJeSTHqXMrI2faVfKK0QtKa FOhf9ZpNqs9QmWKbNnvVw54A5vaWI/lAM/yKHdSX8QtXwFRvm6jxxYxNDSOvaHwfBg18 /ZqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Zim4xMahnIj33rOUinGvnyI6K/1vf/vbsHNzFhnsJAc=; b=PphbdTtqpzenQpmC4qphUcGb+eatloGk+9kUvWHgaxQyqvBJp7TFVSiHc0tG4jGvWp ODYeBU/w0ftUGAPKbCYoWYj29OCr9hAKm7ib+ZFqHrNfTKqz8EVMpie/lpxM/nlPJOpi YKzgBrpOu3pMXTzujY6x5o+kjk1F1l53EjVnjsmoNndeOntr6MJCR1M4OosoyBm0sf7S PN30tlu8mGsxp8qFiI5hjQlofMboyjVWlthw6g5FcHh8U2Ur2xsjoSPoYt7FYi0ZHEBH 7QaAQtFDi30wp+qpUmwMF3nwQdTdRd02ZpahRXWlK46l6B491Jg49BZDNL8sl27zj+pr WblQ== X-Gm-Message-State: AOAM530mOUgqImEjshuMU6L+uvfO48qBBXprxmk8md/UAzI6yfcHMYOr 2FryLxqOgJx6ufIuEiugWaGE0c9l2ga8kg== X-Google-Smtp-Source: ABdhPJwDIo+BZyUPwBp4DZBUeIaL17wnOR3Fk0R2NwhF8pM7UxwUc5Tpi0rys9t6Gd48i4axaqpabA== X-Received: by 2002:a17:90b:889:: with SMTP id bj9mr2600284pjb.101.1599546006747; Mon, 07 Sep 2020 23:20:06 -0700 (PDT) Received: from localhost ([122.181.54.133]) by smtp.gmail.com with ESMTPSA id x25sm13204888pgk.26.2020.09.07.23.20.05 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Sep 2020 23:20:06 -0700 (PDT) From: Viresh Kumar To: ltp@lists.linux.it Date: Tue, 8 Sep 2020 11:49:21 +0530 Message-Id: <3d6e0cd2eca89015ccf0e9f582537f7c8b8fcb97.1599545766.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.25.0.rc1.19.g042ed3e048af In-Reply-To: References: MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.102.4 at in-4.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-4.smtp.seeweb.it Subject: [LTP] [PATCH 08/16] syscalls: ppoll: Reuse struct time64_variants X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Viresh Kumar , Vincent Guittot Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Lets reuse the common structure here. Signed-off-by: Viresh Kumar --- testcases/kernel/syscalls/ppoll/ppoll01.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/testcases/kernel/syscalls/ppoll/ppoll01.c b/testcases/kernel/syscalls/ppoll/ppoll01.c index e9e57e5858e6..3d2f92f2ac1d 100644 --- a/testcases/kernel/syscalls/ppoll/ppoll01.c +++ b/testcases/kernel/syscalls/ppoll/ppoll01.c @@ -19,6 +19,7 @@ #include #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" @@ -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 }; @@ -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); @@ -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); @@ -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]; From patchwork Tue Sep 8 06:19:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 1359486 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=213.254.12.146; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=ZMjYy2bv; dkim-atps=neutral Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Blw5R0cMpz9sT6 for ; Tue, 8 Sep 2020 16:21:15 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 8E1253C53ED for ; Tue, 8 Sep 2020 08:21:12 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-2.smtp.seeweb.it (in-2.smtp.seeweb.it [217.194.8.2]) by picard.linux.it (Postfix) with ESMTP id 7A0083C180A for ; Tue, 8 Sep 2020 08:20:11 +0200 (CEST) Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by in-2.smtp.seeweb.it (Postfix) with ESMTPS id 19ACB60083F for ; Tue, 8 Sep 2020 08:20:11 +0200 (CEST) Received: by mail-pf1-x444.google.com with SMTP id c196so4618900pfc.0 for ; Mon, 07 Sep 2020 23:20:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=OOC4QtR8jsxOWP4rKAJVigVWFKrsqW7lijt+qmhNhCk=; b=ZMjYy2bvEI3P1TzmdjAH4YqtvA4Z4xI05H+PMiv+blDqH3Cs5LzGKrwC/L5cnNq/vR thkEsWMtLno2wrZ3wr3OsV+/5xCwqlytTmHcgSH6u7X9MjYRYptliM4EhLfM/fUoTbb1 oY2YIRMAMQbd99tBQdsSX77WwT9QkwQT9NzyxSKjhpccrM+iMTWH+VdR3KYRrhORbbLF 02EO507LTKGmXSj1WGPLanW031uiQCNQNNtT4t2lDFFR4ASrJA6pG/CAVPMufqrr5/W2 a+g2QQXG5mKG6ba0CEMuhOvqs/1KEZugwvxX0aoXepDpsu5uDTqScIHC1PJ07YqbF1s9 a4HA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=OOC4QtR8jsxOWP4rKAJVigVWFKrsqW7lijt+qmhNhCk=; b=gVcZy/ZphkqRl3PIVKJznY23hO3r1fKibaIpfTWsPValvAWMi67YQ8TuPT5m1HLFK9 OSIZO/X+a8JUZ8C2uWSuxmWDbcLTWdxios7eIcAU5fdHe4OeAJcXN2/CgwSCxLDvZRnL RVb/P1JWssB18yve0vgISpTglyXuCZcwNrGpLjIiPduoE4oWQasiBEmDekuTSnOXwCd3 yXvLCWnNsHdvhTQi3uQmrveFlBYT842goob2r2C5kAAx2mW3v98xaW1EACR2IescfjsF ToUZNy3QIbZwi1tSpFX02eDVUY9oFypb2WWSplDXVre/rjlm5QQMSuaPtBbhgc+NXD+9 2w1w== X-Gm-Message-State: AOAM532lgLVv3GRg7IIFiH+zpmohrVUNB1Ivhy96AoyB5jWd+4pRUhEI fLBbWU9RlVTlsA0w6aRS83jfF8k+H7FgMw== X-Google-Smtp-Source: ABdhPJwzuM0hcSryWoeN2pUO35i0aDTrUEeJWD0Exu0AdqUysiY9mTXjqno/noh+M6tk8Gwhen95LQ== X-Received: by 2002:a17:902:266:: with SMTP id 93mr22598372plc.108.1599546009363; Mon, 07 Sep 2020 23:20:09 -0700 (PDT) Received: from localhost ([122.181.54.133]) by smtp.gmail.com with ESMTPSA id r15sm6757387pgg.17.2020.09.07.23.20.08 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Sep 2020 23:20:08 -0700 (PDT) From: Viresh Kumar To: ltp@lists.linux.it Date: Tue, 8 Sep 2020 11:49:22 +0530 Message-Id: <6a0c125f148dba426c1c0483c287da0ca5b5ae93.1599545766.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.25.0.rc1.19.g042ed3e048af In-Reply-To: References: MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.102.4 at in-2.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-2.smtp.seeweb.it Subject: [LTP] [PATCH 09/16] syscalls: rt_sigtimedwait: Reuse struct time64_variants X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Viresh Kumar , Vincent Guittot Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Lets reuse the common structure here. Signed-off-by: Viresh Kumar --- .../syscalls/rt_sigtimedwait/rt_sigtimedwait01.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/testcases/kernel/syscalls/rt_sigtimedwait/rt_sigtimedwait01.c b/testcases/kernel/syscalls/rt_sigtimedwait/rt_sigtimedwait01.c index db4901a40ea1..813f75b9ed82 100644 --- a/testcases/kernel/syscalls/rt_sigtimedwait/rt_sigtimedwait01.c +++ b/testcases/kernel/syscalls/rt_sigtimedwait/rt_sigtimedwait01.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-or-later /* Copyright (c) Jiri Palecek, 2009 */ +#include "time64_variants.h" #include "libsigwait.h" static int my_rt_sigtimedwait(const sigset_t * set, siginfo_t * info, @@ -40,26 +41,22 @@ struct sigwait_test_desc tests[] = { { test_masked_matching_rt, -1}, }; -static struct test_variants { - swi_func swi; - enum tst_ts_type type; - char *desc; -} variants[] = { +static struct time64_variants variants[] = { #if (__NR_rt_sigtimedwait != __LTP__NR_INVALID_SYSCALL) - { .swi = my_rt_sigtimedwait, .type = TST_KERN_OLD_TIMESPEC, .desc = "syscall with old kernel spec"}, + { .sigwait = my_rt_sigtimedwait, .ts_type = TST_KERN_OLD_TIMESPEC, .desc = "syscall with old kernel spec"}, #endif #if (__NR_rt_sigtimedwait_time64 != __LTP__NR_INVALID_SYSCALL) - { .swi = my_rt_sigtimedwait_time64, .type = TST_KERN_TIMESPEC, .desc = "syscall time64 with kernel spec"}, + { .sigwait = my_rt_sigtimedwait_time64, .ts_type = TST_KERN_TIMESPEC, .desc = "syscall time64 with kernel spec"}, #endif }; static void run(unsigned int i) { - struct test_variants *tv = &variants[tst_variant]; + struct time64_variants *tv = &variants[tst_variant]; struct sigwait_test_desc *tc = &tests[i]; - tc->tf(tv->swi, tc->signo, tv->type); + tc->tf(tv->sigwait, tc->signo, tv->ts_type); } static void setup(void) From patchwork Tue Sep 8 06:19:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 1359487 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=2001:1418:10:5::2; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=Krsvz6Z8; dkim-atps=neutral Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Blw5d4jjWz9sT6 for ; Tue, 8 Sep 2020 16:21:25 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 09BAB3C53BA for ; Tue, 8 Sep 2020 08:21:23 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-5.smtp.seeweb.it (in-5.smtp.seeweb.it [IPv6:2001:4b78:1:20::5]) by picard.linux.it (Postfix) with ESMTP id 2887D3C2C2F for ; Tue, 8 Sep 2020 08:20:14 +0200 (CEST) Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by in-5.smtp.seeweb.it (Postfix) with ESMTPS id C53AC600BDC for ; Tue, 8 Sep 2020 08:20:13 +0200 (CEST) Received: by mail-pg1-x542.google.com with SMTP id 31so9289901pgy.13 for ; Mon, 07 Sep 2020 23:20:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=TZiGIclA2EVKeBvx43CgcG/E+bOuNe8Wx2vdmYcHmxA=; b=Krsvz6Z8axgWZkbQ8tG88tCXxlslfFa4Dcu98M2t2NIZ8ArAsBZ2Pq5MDu9/Ldsv3g lOSj4KdA+7jLz4RtQed238SI1la3J6yO0uar4nVceqz8WdHKZt7LY2wzMmDj4FBvy8Ui OBofe6JN8EFaw1Us8/MJ9JJktYqMIfQmXeGhzKN3bOWxk1SIahFWpn1iHX7bWxWBgdDG snl3n9lxiGWjUENn1BLaAbBzmL85eVuNz0PV3DMnCzibZQLg0ynvxyXh85IhEhFZuZhX +0eqpXdXKAteX4pVZE0fk5QhN8DIg/Z0Qu2lwevKlFj3QTWcBoKfW7wyfg0sKV2d3ojJ J7GQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=TZiGIclA2EVKeBvx43CgcG/E+bOuNe8Wx2vdmYcHmxA=; b=S5+xm5MVJIbtSDMTUr4TSaUNWoZwyj9YEBHoNC8IXy/JpYHapzquRpXneulB1DZR4p PIlA2dQBatwUrunGmMwGBznCug/uefm1463SDUY5oQtkGbqkT7wTdIiYlatPRqipMILg PmqSnZw/oC9Q9aDi1jurnZa2A91RRxrtcSx8a5MacA4JDFzAkcBgKC44gJDMgvHhi7ic DvX45Q1J6GmIAVKYRhxUhMh8fwDRWatrE+Cn0gIpe9zL0vm7eOb8WuxyJjKcCeT0VfEq oFhCHo07LrTzzaOzC6QiNdt4lJpbwZvenkic7A5B/xub5n8iaVCCMFZ0LUONUaaf7rCN wKDQ== X-Gm-Message-State: AOAM531mdF26mCMN48DoxzhTJneEzpSdtDLOqFH3CMcF8kdwlTXqboTi qS4GtGWL3BAbY4s66UUyoUnej9HjZLlw5A== X-Google-Smtp-Source: ABdhPJzCDGQ2Kqbecvj1QOcxy1+Q0cdK1/WM7nN7AJkVWWPAeGdm6D6xS8s4nl8eXBWJS4qg98mVPg== X-Received: by 2002:a17:902:b18e:: with SMTP id s14mr15548482plr.72.1599546011939; Mon, 07 Sep 2020 23:20:11 -0700 (PDT) Received: from localhost ([122.181.54.133]) by smtp.gmail.com with ESMTPSA id r6sm17245475pfq.11.2020.09.07.23.20.11 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Sep 2020 23:20:11 -0700 (PDT) From: Viresh Kumar To: ltp@lists.linux.it Date: Tue, 8 Sep 2020 11:49:23 +0530 Message-Id: <26a1aa0c61d71ae5a2ce738ee08d1e3ba4c663c8.1599545766.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.25.0.rc1.19.g042ed3e048af In-Reply-To: References: MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.102.4 at in-5.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-5.smtp.seeweb.it Subject: [LTP] [PATCH 10/16] syscalls: sched_rr_get_interval: Reuse struct time64_variants X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Viresh Kumar , Vincent Guittot Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Lets reuse the common structure here. Signed-off-by: Viresh Kumar --- .../sched_rr_get_interval01.c | 21 ++++++++----------- .../sched_rr_get_interval02.c | 21 ++++++++----------- .../sched_rr_get_interval03.c | 21 ++++++++----------- 3 files changed, 27 insertions(+), 36 deletions(-) diff --git a/testcases/kernel/syscalls/sched_rr_get_interval/sched_rr_get_interval01.c b/testcases/kernel/syscalls/sched_rr_get_interval/sched_rr_get_interval01.c index 0466be36bec0..9d9ddf32eec1 100644 --- a/testcases/kernel/syscalls/sched_rr_get_interval/sched_rr_get_interval01.c +++ b/testcases/kernel/syscalls/sched_rr_get_interval/sched_rr_get_interval01.c @@ -12,6 +12,7 @@ */ #include +#include "time64_variants.h" #include "tst_timer.h" #define PROC_SCHED_RR_TIMESLICE_MS "/proc/sys/kernel/sched_rr_timeslice_ms" @@ -19,30 +20,26 @@ static int proc_flag; struct tst_ts tp; -static struct test_variants { - int (*func)(pid_t pid, void *ts); - enum tst_ts_type type; - char *desc; -} variants[] = { - { .func = libc_sched_rr_get_interval, .type = TST_LIBC_TIMESPEC, .desc = "vDSO or syscall with libc spec"}, +static struct time64_variants variants[] = { + { .sched_rr_get_interval = libc_sched_rr_get_interval, .ts_type = TST_LIBC_TIMESPEC, .desc = "vDSO or syscall with libc spec"}, #if (__NR_sched_rr_get_interval != __LTP__NR_INVALID_SYSCALL) - { .func = sys_sched_rr_get_interval, .type = TST_KERN_OLD_TIMESPEC, .desc = "syscall with old kernel spec"}, + { .sched_rr_get_interval = sys_sched_rr_get_interval, .ts_type = TST_KERN_OLD_TIMESPEC, .desc = "syscall with old kernel spec"}, #endif #if (__NR_sched_rr_get_interval_time64 != __LTP__NR_INVALID_SYSCALL) - { .func = sys_sched_rr_get_interval64, .type = TST_KERN_TIMESPEC, .desc = "syscall time64 with kernel spec"}, + { .sched_rr_get_interval = sys_sched_rr_get_interval64, .ts_type = TST_KERN_TIMESPEC, .desc = "syscall time64 with kernel spec"}, #endif }; static void setup(void) { - struct test_variants *tv = &variants[tst_variant]; + struct time64_variants *tv = &variants[tst_variant]; struct sched_param p = { 1 }; tst_res(TINFO, "Testing variant: %s", tv->desc); - tp.type = tv->type; + tp.type = tv->ts_type; if ((sched_setscheduler(0, SCHED_RR, &p)) == -1) tst_res(TFAIL | TTERRNO, "sched_setscheduler() failed"); @@ -52,9 +49,9 @@ static void setup(void) static void run(void) { - struct test_variants *tv = &variants[tst_variant]; + struct time64_variants *tv = &variants[tst_variant]; - TEST(tv->func(0, tst_ts_get(&tp))); + TEST(tv->sched_rr_get_interval(0, tst_ts_get(&tp))); if (!TST_RET) { tst_res(TPASS, "sched_rr_get_interval() passed"); diff --git a/testcases/kernel/syscalls/sched_rr_get_interval/sched_rr_get_interval02.c b/testcases/kernel/syscalls/sched_rr_get_interval/sched_rr_get_interval02.c index 5b38e5bff0d3..0e98fec5608f 100644 --- a/testcases/kernel/syscalls/sched_rr_get_interval/sched_rr_get_interval02.c +++ b/testcases/kernel/syscalls/sched_rr_get_interval/sched_rr_get_interval02.c @@ -9,34 +9,31 @@ */ #include +#include "time64_variants.h" #include "tst_timer.h" static struct tst_ts tp; -static struct test_variants { - int (*func)(pid_t pid, void *ts); - enum tst_ts_type type; - char *desc; -} variants[] = { - { .func = libc_sched_rr_get_interval, .type = TST_LIBC_TIMESPEC, .desc = "vDSO or syscall with libc spec"}, +static struct time64_variants variants[] = { + { .sched_rr_get_interval = libc_sched_rr_get_interval, .ts_type = TST_LIBC_TIMESPEC, .desc = "vDSO or syscall with libc spec"}, #if (__NR_sched_rr_get_interval != __LTP__NR_INVALID_SYSCALL) - { .func = sys_sched_rr_get_interval, .type = TST_KERN_OLD_TIMESPEC, .desc = "syscall with old kernel spec"}, + { .sched_rr_get_interval = sys_sched_rr_get_interval, .ts_type = TST_KERN_OLD_TIMESPEC, .desc = "syscall with old kernel spec"}, #endif #if (__NR_sched_rr_get_interval_time64 != __LTP__NR_INVALID_SYSCALL) - { .func = sys_sched_rr_get_interval64, .type = TST_KERN_TIMESPEC, .desc = "syscall time64 with kernel spec"}, + { .sched_rr_get_interval = sys_sched_rr_get_interval64, .ts_type = TST_KERN_TIMESPEC, .desc = "syscall time64 with kernel spec"}, #endif }; static void setup(void) { - struct test_variants *tv = &variants[tst_variant]; + struct time64_variants *tv = &variants[tst_variant]; struct sched_param p = { 1 }; tst_res(TINFO, "Testing variant: %s", tv->desc); - tp.type = tv->type; + tp.type = tv->ts_type; if ((sched_setscheduler(0, SCHED_FIFO, &p)) == -1) tst_res(TFAIL | TTERRNO, "sched_setscheduler() failed"); @@ -44,12 +41,12 @@ static void setup(void) static void run(void) { - struct test_variants *tv = &variants[tst_variant]; + struct time64_variants *tv = &variants[tst_variant]; tst_ts_set_sec(&tp, 99); tst_ts_set_nsec(&tp, 99); - TEST(tv->func(0, tst_ts_get(&tp))); + TEST(tv->sched_rr_get_interval(0, tst_ts_get(&tp))); if (!TST_RET && tst_ts_valid(&tp) == -1) { tst_res(TPASS, "sched_rr_get_interval() passed"); diff --git a/testcases/kernel/syscalls/sched_rr_get_interval/sched_rr_get_interval03.c b/testcases/kernel/syscalls/sched_rr_get_interval/sched_rr_get_interval03.c index d7bbe268689c..6a64ca2c6b94 100644 --- a/testcases/kernel/syscalls/sched_rr_get_interval/sched_rr_get_interval03.c +++ b/testcases/kernel/syscalls/sched_rr_get_interval/sched_rr_get_interval03.c @@ -13,6 +13,7 @@ */ #include +#include "time64_variants.h" #include "tst_timer.h" static pid_t unused_pid; @@ -32,31 +33,27 @@ struct test_cases_t { { &zero_pid, NULL, EFAULT} }; -static struct test_variants { - int (*func)(pid_t pid, void *ts); - enum tst_ts_type type; - char *desc; -} variants[] = { - { .func = libc_sched_rr_get_interval, .type = TST_LIBC_TIMESPEC, .desc = "vDSO or syscall with libc spec"}, +static struct time64_variants variants[] = { + { .sched_rr_get_interval = libc_sched_rr_get_interval, .ts_type = TST_LIBC_TIMESPEC, .desc = "vDSO or syscall with libc spec"}, #if (__NR_sched_rr_get_interval != __LTP__NR_INVALID_SYSCALL) - { .func = sys_sched_rr_get_interval, .type = TST_KERN_OLD_TIMESPEC, .desc = "syscall with old kernel spec"}, + { .sched_rr_get_interval = sys_sched_rr_get_interval, .ts_type = TST_KERN_OLD_TIMESPEC, .desc = "syscall with old kernel spec"}, #endif #if (__NR_sched_rr_get_interval_time64 != __LTP__NR_INVALID_SYSCALL) - { .func = sys_sched_rr_get_interval64, .type = TST_KERN_TIMESPEC, .desc = "syscall time64 with kernel spec"}, + { .sched_rr_get_interval = sys_sched_rr_get_interval64, .ts_type = TST_KERN_TIMESPEC, .desc = "syscall time64 with kernel spec"}, #endif }; static void setup(void) { - struct test_variants *tv = &variants[tst_variant]; + struct time64_variants *tv = &variants[tst_variant]; struct sched_param p = { 1 }; tst_res(TINFO, "Testing variant: %s", tv->desc); bad_addr = tst_get_bad_addr(NULL); - tp.type = tv->type; + tp.type = tv->ts_type; if ((sched_setscheduler(0, SCHED_RR, &p)) == -1) tst_res(TFAIL | TTERRNO, "sched_setscheduler() failed"); @@ -66,7 +63,7 @@ static void setup(void) static void run(unsigned int i) { - struct test_variants *tv = &variants[tst_variant]; + struct time64_variants *tv = &variants[tst_variant]; struct test_cases_t *tc = &test_cases[i]; struct timerspec *ts; @@ -75,7 +72,7 @@ static void run(unsigned int i) else ts = tst_ts_get(tc->tp); - TEST(tv->func(*tc->pid, ts)); + TEST(tv->sched_rr_get_interval(*tc->pid, ts)); if (TST_RET != -1) { tst_res(TFAIL, "sched_rr_get_interval() passed unexcpectedly"); From patchwork Tue Sep 8 06:19:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 1359488 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=2001:1418:10:5::2; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=necQ0BQr; dkim-atps=neutral Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Blw5p1lFKz9sT6 for ; Tue, 8 Sep 2020 16:21:34 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 84E913C53C6 for ; Tue, 8 Sep 2020 08:21:31 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-7.smtp.seeweb.it (in-7.smtp.seeweb.it [217.194.8.7]) by picard.linux.it (Postfix) with ESMTP id 000383C53CF for ; Tue, 8 Sep 2020 08:20:17 +0200 (CEST) Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by in-7.smtp.seeweb.it (Postfix) with ESMTPS id 75E7B201008 for ; Tue, 8 Sep 2020 08:20:17 +0200 (CEST) Received: by mail-pg1-x541.google.com with SMTP id l191so9316492pgd.5 for ; Mon, 07 Sep 2020 23:20:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=SlPjsip7eXR8lr94MdYcmy29T+5MgL8zaEQ1Y8tggMI=; b=necQ0BQrF2mGfZ/xEE8oeBDFqa+vxC+M2IWryxhDbwa3ynCsBh8pLu5DZeGbTjsayB M6Tqy2Fv8R/c3DNjZh9SdDwYkIPIh2M0K6mv5OLuGEHeWvb4Zv4vIM8qwYlPmlKlZmcX uSvrVJFJlGWdiElb42n0ByBi7OkcCJvCrspiGohsveMltkGqZOv5bCtMC32F//7/SISK WCMiiGU5s2ZYJ7aGrt1M5vOJqxgiKR0J0hAJaq2U6jAVRvk3FE9z8d7VGHMdXXA7oruA zhTwJfS0nACnQViBTMtVb8IDSq9BmSEcx0gYTye9HLqWMRexBWqFWJB1uftLIFbaQxgL gsKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=SlPjsip7eXR8lr94MdYcmy29T+5MgL8zaEQ1Y8tggMI=; b=Ou2v+dxxvA3gdPFebbZKhB1tRjGpiaweWgjqkx7JCoqcL1q4WoB4AzrseEaDjf78jH xwTIthZpTBxI5Z9UUZe9EOWqpiXDcddTtc8gfJiFh4EtKmRsCdQZ5ceuFBHiiAmaYmx8 XhMd6mWwZ4vdueJTJqjlNTHWgT9FPYTx/OeupvuI87u3zBRenVZK6vCWFIjVWMtxkQqD c8OKdzSj1PFFa+2XSoXT3PsIflp6r/S6a1dTttBsdqoPxHcNjp94dRNMtSL+0LiV2Zvr VGAVKYXnQHaAIpv10p+IB8g/MYt3dQSHyfJLo4a6Nd2DhgODNGBbfSphW/eWNx/+JdnA 246A== X-Gm-Message-State: AOAM532NvHYoYSx3ZpQJNzDw7GxSIhXcM/drF4xd9bgONY1XTC10D0Gp LpZVltvVMtvSySIh13rYhr+nFxwECuPfJQ== X-Google-Smtp-Source: ABdhPJw4dNskRKEFHTyb8KB7URBzyLK6CI+YEPWCBaN9wGVcOtSFn4FE8Ia3h+4FjQIyKBvt59izDw== X-Received: by 2002:a65:6119:: with SMTP id z25mr19908670pgu.52.1599546015707; Mon, 07 Sep 2020 23:20:15 -0700 (PDT) Received: from localhost ([122.181.54.133]) by smtp.gmail.com with ESMTPSA id d15sm16974514pfh.151.2020.09.07.23.20.13 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Sep 2020 23:20:15 -0700 (PDT) From: Viresh Kumar To: ltp@lists.linux.it Date: Tue, 8 Sep 2020 11:49:24 +0530 Message-Id: <9282311ec60bb1bb2181e79d14336d26d3f073d0.1599545766.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.25.0.rc1.19.g042ed3e048af In-Reply-To: References: MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.102.4 at in-7.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-7.smtp.seeweb.it Subject: [LTP] [PATCH 11/16] syscalls: sendmmsg: Reuse struct time64_variants X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Viresh Kumar , Vincent Guittot Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Lets reuse the common structure here. Signed-off-by: Viresh Kumar --- .../kernel/syscalls/sendmmsg/sendmmsg01.c | 24 +++++++------------ 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/testcases/kernel/syscalls/sendmmsg/sendmmsg01.c b/testcases/kernel/syscalls/sendmmsg/sendmmsg01.c index 54febf661530..d6a717687ee7 100644 --- a/testcases/kernel/syscalls/sendmmsg/sendmmsg01.c +++ b/testcases/kernel/syscalls/sendmmsg/sendmmsg01.c @@ -11,6 +11,7 @@ #include #include +#include "time64_variants.h" #include "tst_test.h" #include "lapi/socket.h" #include "tst_safe_macros.h" @@ -24,32 +25,25 @@ static int receive_sockfd; static struct mmsghdr *snd_msg, *rcv_msg; static struct iovec *snd1, *snd2, *rcv1, *rcv2; -static struct test_variants { - int (*receive)(int sockfd, struct mmsghdr *msgvec, unsigned int vlen, - unsigned int flags, void *timeout); - int (*send)(int sockfd, struct mmsghdr *msgvec, unsigned int vlen, - unsigned int flags); - enum tst_ts_type type; - char *desc; -} variants[] = { - { .receive = libc_recvmmsg, .send = libc_sendmmsg, .type = TST_LIBC_TIMESPEC, .desc = "vDSO or syscall with libc spec"}, +static struct time64_variants variants[] = { + { .recvmmsg = libc_recvmmsg, .sendmmsg = libc_sendmmsg, .ts_type = TST_LIBC_TIMESPEC, .desc = "vDSO or syscall with libc spec"}, #if (__NR_recvmmsg != __LTP__NR_INVALID_SYSCALL) - { .receive = sys_recvmmsg, .send = sys_sendmmsg, .type = TST_KERN_OLD_TIMESPEC, .desc = "syscall with old kernel spec"}, + { .recvmmsg = sys_recvmmsg, .sendmmsg = sys_sendmmsg, .ts_type = TST_KERN_OLD_TIMESPEC, .desc = "syscall with old kernel spec"}, #endif #if (__NR_recvmmsg_time64 != __LTP__NR_INVALID_SYSCALL) - { .receive = sys_recvmmsg64, .send = sys_sendmmsg, .type = TST_KERN_TIMESPEC, .desc = "syscall time64 with kernel spec"}, + { .recvmmsg = sys_recvmmsg64, .sendmmsg = sys_sendmmsg, .ts_type = TST_KERN_TIMESPEC, .desc = "syscall time64 with kernel spec"}, #endif }; static void run(void) { - struct test_variants *tv = &variants[tst_variant]; + struct time64_variants *tv = &variants[tst_variant]; struct tst_ts timeout; int retval; - retval = tv->send(send_sockfd, snd_msg, VLEN, 0); + retval = tv->sendmmsg(send_sockfd, snd_msg, VLEN, 0); if (retval < 0 || snd_msg[0].msg_len != 6 || snd_msg[1].msg_len != 6) { tst_res(TFAIL | TERRNO, "sendmmsg() failed"); return; @@ -58,11 +52,11 @@ static void run(void) memset(rcv1->iov_base, 0, rcv1->iov_len); memset(rcv2->iov_base, 0, rcv2->iov_len); - timeout.type = tv->type; + timeout.type = tv->ts_type; tst_ts_set_sec(&timeout, 1); tst_ts_set_nsec(&timeout, 0); - retval = tv->receive(receive_sockfd, rcv_msg, VLEN, 0, tst_ts_get(&timeout)); + retval = tv->recvmmsg(receive_sockfd, rcv_msg, VLEN, 0, tst_ts_get(&timeout)); if (retval == -1) { tst_res(TFAIL | TERRNO, "recvmmsg() failed"); From patchwork Tue Sep 8 06:19:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 1359489 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=2001:1418:10:5::2; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=FJrX6eTI; dkim-atps=neutral Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Blw5y37Lbz9sT6 for ; Tue, 8 Sep 2020 16:21:42 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id C13C23C53C2 for ; Tue, 8 Sep 2020 08:21:39 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-7.smtp.seeweb.it (in-7.smtp.seeweb.it [IPv6:2001:4b78:1:20::7]) by picard.linux.it (Postfix) with ESMTP id 9D4DA3C53F4 for ; Tue, 8 Sep 2020 08:20:20 +0200 (CEST) Received: from mail-pj1-x1042.google.com (mail-pj1-x1042.google.com [IPv6:2607:f8b0:4864:20::1042]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by in-7.smtp.seeweb.it (Postfix) with ESMTPS id 13EEE201008 for ; Tue, 8 Sep 2020 08:20:20 +0200 (CEST) Received: by mail-pj1-x1042.google.com with SMTP id mm21so7730125pjb.4 for ; Mon, 07 Sep 2020 23:20:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=5CU7f+O91bpJCj2wracDBqxaz6T4VC11JvTQalKp7ZY=; b=FJrX6eTIrNFeEHZ7d0acVXCtbfZrzwX+45AclxrREubve4Sx168pA9nWVkI603M3pI 80EVzzHxjpBiGv9BVcJwrb7CdvPPIfpejBzzIzO8jfs1wzlMCrSjyETQX5MIVXKCLLYw H2MPhzJkfLuOixtfw3xmLolB4TKlngrNxQ2SCK333ilh8agVGR8IGl7s/K3ZRjvwzRkp MgHT93hMfJ5yhHJQ3yKAE1GXESuDNNhWRietkeIr5FB++ZcmlPRqyePjOa8/CY1zmyPd nZ8mKKARFEdUOtcB9f9TbrRXQOkhpJ+u+cywpNIJt5Cho4EsDesw+CtcsbTqH07W0l6Z h/5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=5CU7f+O91bpJCj2wracDBqxaz6T4VC11JvTQalKp7ZY=; b=X1HTQjjAhOyfWCxEY9Jn6b28semCK4c7P/Um6djR35G/q3tWhR/Efpv2GcNrDH3RA4 dsNo/jbePMgr8bYT4yW8cjDVuY5Wf6NFDne06o3vM0cbWV9RIM23ctdNndYwUlE6RV/b jNh8BzYBujHEYRjaNe6z/yi6XyjlWYRGLEcRGmfkbtF8EfIkiMXD1Dx+VjpCaLzJrTRk aLBKbI2qo5FL+qvVyIoVCIA+zBILwOZ1kRfL0x9HMHqcEzbMJx1YLnjbNjAmmSIdOzBs FelAAzGJtFHfQ2ylT/e9LVSaZdpC/nYvb/t6h7luNXU9uWoUDY/kMid3QPp5dH7HHYpV evTw== X-Gm-Message-State: AOAM5337zKWD0EMzqKE6ULRWvUNSno2E3HDpRtufzgMY9cVMV218uc05 ovga8+Uu/70kxz2aAamF3gWVo1V9ef7iyw== X-Google-Smtp-Source: ABdhPJy2v3fMDGLi63Si+1F97MDzKRLpxpJoVYVHQTNMlyToFFlUXET3sGYryCOnb/wV2dOaBaBXig== X-Received: by 2002:a17:90a:d485:: with SMTP id s5mr2523171pju.193.1599546018230; Mon, 07 Sep 2020 23:20:18 -0700 (PDT) Received: from localhost ([122.181.54.133]) by smtp.gmail.com with ESMTPSA id z7sm7420032pfj.75.2020.09.07.23.20.17 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Sep 2020 23:20:17 -0700 (PDT) From: Viresh Kumar To: ltp@lists.linux.it Date: Tue, 8 Sep 2020 11:49:25 +0530 Message-Id: X-Mailer: git-send-email 2.25.0.rc1.19.g042ed3e048af In-Reply-To: References: MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.102.4 at in-7.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-7.smtp.seeweb.it Subject: [LTP] [PATCH 12/16] syscalls: timer_settime: Reuse struct time64_variants X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Viresh Kumar , Vincent Guittot Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Lets reuse the common structure here. Signed-off-by: Viresh Kumar --- .../syscalls/timer_settime/timer_settime01.c | 25 ++++++++----------- .../syscalls/timer_settime/timer_settime02.c | 18 ++++++------- 2 files changed, 17 insertions(+), 26 deletions(-) diff --git a/testcases/kernel/syscalls/timer_settime/timer_settime01.c b/testcases/kernel/syscalls/timer_settime/timer_settime01.c index 415c6290fe2f..67143e8f88b2 100644 --- a/testcases/kernel/syscalls/timer_settime/timer_settime01.c +++ b/testcases/kernel/syscalls/timer_settime/timer_settime01.c @@ -26,6 +26,7 @@ #include #include #include +#include "time64_variants.h" #include "tst_timer.h" static struct tst_ts timenow; @@ -45,19 +46,13 @@ static struct testcase { {&old_set, 50000, 0, TIMER_ABSTIME, "using absolute time"}, }; -static struct test_variants { - int (*cgettime)(clockid_t clk_id, void *ts); - int (*tgettime)(kernel_timer_t timer, void *its); - int (*func)(kernel_timer_t timerid, int flags, void *its, void *old_its); - enum tst_ts_type type; - char *desc; -} variants[] = { +static struct time64_variants variants[] = { #if (__NR_timer_settime != __LTP__NR_INVALID_SYSCALL) - { .cgettime = sys_clock_gettime, .tgettime = sys_timer_gettime, .func = sys_timer_settime, .type = TST_KERN_OLD_TIMESPEC, .desc = "syscall with old kernel spec"}, + { .clock_gettime = sys_clock_gettime, .timer_gettime = sys_timer_gettime, .timer_settime = sys_timer_settime, .ts_type = TST_KERN_OLD_TIMESPEC, .desc = "syscall with old kernel spec"}, #endif #if (__NR_timer_settime64 != __LTP__NR_INVALID_SYSCALL) - { .cgettime = sys_clock_gettime64, .tgettime = sys_timer_gettime64, .func = sys_timer_settime64, .type = TST_KERN_TIMESPEC, .desc = "syscall time64 with kernel spec"}, + { .clock_gettime = sys_clock_gettime64, .timer_gettime = sys_timer_gettime64, .timer_settime = sys_timer_settime64, .ts_type = TST_KERN_TIMESPEC, .desc = "syscall time64 with kernel spec"}, #endif }; @@ -93,7 +88,7 @@ static void setup(void) static void run(unsigned int n) { - struct test_variants *tv = &variants[tst_variant]; + struct time64_variants *tv = &variants[tst_variant]; struct testcase *tc = &tcases[n]; long long val; unsigned int i; @@ -126,12 +121,12 @@ static void run(unsigned int n) memset(&new_set, 0, sizeof(new_set)); memset(&old_set, 0, sizeof(old_set)); - new_set.type = old_set.type = tv->type; + new_set.type = old_set.type = tv->ts_type; val = tc->it_value_tv_usec; if (tc->flag & TIMER_ABSTIME) { - timenow.type = tv->type; - if (tv->cgettime(clock, tst_ts_get(&timenow)) < 0) { + timenow.type = tv->ts_type; + if (tv->clock_gettime(clock, tst_ts_get(&timenow)) < 0) { tst_res(TFAIL, "clock_gettime(%s) failed - skipping the test", get_clock_str(clock)); @@ -143,14 +138,14 @@ static void run(unsigned int n) tst_its_set_interval_from_us(&new_set, tc->it_interval_tv_usec); tst_its_set_value_from_us(&new_set, val); - TEST(tv->func(timer, tc->flag, tst_its_get(&new_set), tst_its_get(tc->old_ptr))); + TEST(tv->timer_settime(timer, tc->flag, tst_its_get(&new_set), tst_its_get(tc->old_ptr))); if (TST_RET != 0) { tst_res(TFAIL | TTERRNO, "timer_settime(%s) failed", get_clock_str(clock)); } - TEST(tv->tgettime(timer, tst_its_get(&new_set))); + TEST(tv->timer_gettime(timer, tst_its_get(&new_set))); if (TST_RET != 0) { tst_res(TFAIL | TTERRNO, "timer_gettime(%s) failed", get_clock_str(clock)); diff --git a/testcases/kernel/syscalls/timer_settime/timer_settime02.c b/testcases/kernel/syscalls/timer_settime/timer_settime02.c index f1225c1ccfad..564f1c2ce323 100644 --- a/testcases/kernel/syscalls/timer_settime/timer_settime02.c +++ b/testcases/kernel/syscalls/timer_settime/timer_settime02.c @@ -25,6 +25,7 @@ #include #include +#include "time64_variants.h" #include "tst_timer.h" static struct tst_its new_set, old_set; @@ -58,18 +59,13 @@ static struct testcase { {&timer, &pnew_set, (struct tst_its **)&faulty_set, 0, EFAULT}, }; -static struct test_variants { - int (*func)(kernel_timer_t timerid, int flags, void *its, - void *old_its); - enum tst_ts_type type; - char *desc; -} variants[] = { +static struct time64_variants variants[] = { #if (__NR_timer_settime != __LTP__NR_INVALID_SYSCALL) - { .func = sys_timer_settime, .type = TST_KERN_OLD_TIMESPEC, .desc = "syscall with old kernel spec"}, + { .timer_settime = sys_timer_settime, .ts_type = TST_KERN_OLD_TIMESPEC, .desc = "syscall with old kernel spec"}, #endif #if (__NR_timer_settime64 != __LTP__NR_INVALID_SYSCALL) - { .func = sys_timer_settime64, .type = TST_KERN_TIMESPEC, .desc = "syscall time64 with kernel spec"}, + { .timer_settime = sys_timer_settime64, .ts_type = TST_KERN_TIMESPEC, .desc = "syscall time64 with kernel spec"}, #endif }; @@ -81,7 +77,7 @@ static void setup(void) static void run(unsigned int n) { - struct test_variants *tv = &variants[tst_variant]; + struct time64_variants *tv = &variants[tst_variant]; struct testcase *tc = &tcases[n]; void *new, *old; unsigned int i; @@ -115,7 +111,7 @@ static void run(unsigned int n) memset(&new_set, 0, sizeof(new_set)); memset(&old_set, 0, sizeof(old_set)); - new_set.type = old_set.type = tv->type; + new_set.type = old_set.type = tv->ts_type; tst_its_set_interval_sec(&new_set, 0); tst_its_set_interval_nsec(&new_set, 0); tst_its_set_value_sec(&new_set, 5); @@ -124,7 +120,7 @@ static void run(unsigned int n) new = (tc->new_ptr == (struct tst_its **)&faulty_set) ? faulty_set : tst_its_get(*tc->new_ptr); old = (tc->old_ptr == (struct tst_its **)&faulty_set) ? faulty_set : tst_its_get(*tc->old_ptr); - TEST(tv->func(*tc->timer_id, 0, new, old)); + TEST(tv->timer_settime(*tc->timer_id, 0, new, old)); if (tc->error != TST_ERR) { tst_res(TFAIL | TTERRNO, From patchwork Tue Sep 8 06:19:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 1359490 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=2001:1418:10:5::2; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=iu2Da5OE; dkim-atps=neutral Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Blw696ZLLz9sT6 for ; Tue, 8 Sep 2020 16:21:53 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 4F5603C53D9 for ; Tue, 8 Sep 2020 08:21:51 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-2.smtp.seeweb.it (in-2.smtp.seeweb.it [IPv6:2001:4b78:1:20::2]) by picard.linux.it (Postfix) with ESMTP id 1FA463C2C41 for ; Tue, 8 Sep 2020 08:20:22 +0200 (CEST) Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by in-2.smtp.seeweb.it (Postfix) with ESMTPS id 87F7460083F for ; Tue, 8 Sep 2020 08:20:22 +0200 (CEST) Received: by mail-pf1-x441.google.com with SMTP id c142so10084601pfb.7 for ; Mon, 07 Sep 2020 23:20:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Rj4tLi3ylE5QHlYd1AL0cL2PdwhrZQ3Kft57ts8Ntxg=; b=iu2Da5OE53HovMzWVosYNa/0c3xZfpv64YhiQHZ7EZzc3Y6V9apkwQV4g42LNdsie9 ZR9f3SGak3QMdTScvNrJ8g2HyoAQxQ4wOWywoubcXL6/Q/0cvrCviHM1MkmWMSXTc1Rk Bjt3hUMCs77dTuSxDv1JWspmuUTwHjNt8QYVK3QPidYVRQNeQZQnfCFiV7ukeTlbL0xH RcOtdaqHdX6bQVIJFU0LsL7iMjQecwMvaPhNjDz2sqCQHd3DkK9cnXyumWSWWT2asfP0 Exfu17J97/CWW1B96cp0YhcqUg3FycMNqm0HYb/Lax/52NOUVD/lVOl1ar96qvn3zZ3L dIWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Rj4tLi3ylE5QHlYd1AL0cL2PdwhrZQ3Kft57ts8Ntxg=; b=dqzAvhfj+nSN49g8oXgHhiuXPTT7n+uGRGlNcPbaQbUaLClfOoyGBXSv5TIg/bS8mc gCfBgJlQrEp/5zB+wMW+1jk9RMaUeFv+GPtMODaCDBjFTf2a36DXuPXEklrzCak6soFP r5h8nDxv08eupMGbfglrgqGjlRV/MIC60BqDRgUPp73+W0zywhGSrJZj/kYUVm0bg0+J ySBSvGqjbp6JSSYvyL0IP9f5L9m3ZBlPfLICB+PVo9xUpt2iAVrXnalarBLeEyVHlQme eaxsZYIzel1N8plhg1SeF2ouUW2RU2n0YzSf8IxUmxi6APHhJ/cDiCuskIJp2CeFWaO/ SpVA== X-Gm-Message-State: AOAM531Yo02ROqk7GBYXh9lZdxSm23xuwALTncTmcM2vCgnLkkHhw//h /YryuGeH0Ge3iVrAD3ELFOMQwLw/Guz//A== X-Google-Smtp-Source: ABdhPJw4cl0Q5MxWNpq5Q5eyfhel/eMcgNO5MO8RP8oeWq2t5lS8915S5JzsRTCdSyuk2mTOthmFbA== X-Received: by 2002:a62:e108:: with SMTP id q8mr6039744pfh.214.1599546020774; Mon, 07 Sep 2020 23:20:20 -0700 (PDT) Received: from localhost ([122.181.54.133]) by smtp.gmail.com with ESMTPSA id 190sm17599366pfy.22.2020.09.07.23.20.19 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Sep 2020 23:20:20 -0700 (PDT) From: Viresh Kumar To: ltp@lists.linux.it Date: Tue, 8 Sep 2020 11:49:26 +0530 Message-Id: X-Mailer: git-send-email 2.25.0.rc1.19.g042ed3e048af In-Reply-To: References: MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.102.4 at in-2.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-2.smtp.seeweb.it Subject: [LTP] [PATCH 13/16] syscalls: timer_gettime: Reuse struct time64_variants X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Viresh Kumar , Vincent Guittot Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Lets reuse the common structure here. Signed-off-by: Viresh Kumar --- .../syscalls/timer_gettime/timer_gettime01.c | 21 ++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/testcases/kernel/syscalls/timer_gettime/timer_gettime01.c b/testcases/kernel/syscalls/timer_gettime/timer_gettime01.c index 02d5b416d1a2..7ac83546224c 100644 --- a/testcases/kernel/syscalls/timer_gettime/timer_gettime01.c +++ b/testcases/kernel/syscalls/timer_gettime/timer_gettime01.c @@ -12,19 +12,16 @@ #include #include +#include "time64_variants.h" #include "tst_timer.h" -static struct test_variants { - int (*func)(kernel_timer_t timer, void *its); - enum tst_ts_type type; - char *desc; -} variants[] = { +static struct time64_variants variants[] = { #if (__NR_timer_gettime != __LTP__NR_INVALID_SYSCALL) - { .func = sys_timer_gettime, .type = TST_KERN_OLD_TIMESPEC, .desc = "syscall with old kernel spec"}, + { .timer_gettime = sys_timer_gettime, .ts_type = TST_KERN_OLD_TIMESPEC, .desc = "syscall with old kernel spec"}, #endif #if (__NR_timer_gettime64 != __LTP__NR_INVALID_SYSCALL) - { .func = sys_timer_gettime64, .type = TST_KERN_TIMESPEC, .desc = "syscall time64 with kernel spec"}, + { .timer_gettime = sys_timer_gettime64, .ts_type = TST_KERN_TIMESPEC, .desc = "syscall time64 with kernel spec"}, #endif }; @@ -50,10 +47,10 @@ static void setup(void) static void verify(void) { - struct test_variants *tv = &variants[tst_variant]; - struct tst_its spec = {.type = tv->type, }; + struct time64_variants *tv = &variants[tst_variant]; + struct tst_its spec = {.type = tv->ts_type, }; - TEST(tv->func(timer, tst_its_get(&spec))); + TEST(tv->timer_gettime(timer, tst_its_get(&spec))); if (TST_RET == 0) { if (tst_its_get_interval_sec(spec) || tst_its_get_interval_nsec(spec) || @@ -66,13 +63,13 @@ static void verify(void) tst_res(TFAIL | TTERRNO, "timer_gettime() Failed"); } - TEST(tv->func((kernel_timer_t)-1, tst_its_get(&spec))); + TEST(tv->timer_gettime((kernel_timer_t)-1, tst_its_get(&spec))); if (TST_RET == -1 && TST_ERR == EINVAL) tst_res(TPASS, "timer_gettime(-1) Failed: EINVAL"); else tst_res(TFAIL | TTERRNO, "timer_gettime(-1) = %li", TST_RET); - TEST(tv->func(timer, NULL)); + TEST(tv->timer_gettime(timer, NULL)); if (TST_RET == -1 && TST_ERR == EFAULT) tst_res(TPASS, "timer_gettime(NULL) Failed: EFAULT"); else From patchwork Tue Sep 8 06:19:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 1359491 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=213.254.12.146; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=j1D5prUo; dkim-atps=neutral Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Blw6L5hnTz9sT6 for ; Tue, 8 Sep 2020 16:22:02 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 449203C2C2F for ; Tue, 8 Sep 2020 08:22:00 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-5.smtp.seeweb.it (in-5.smtp.seeweb.it [217.194.8.5]) by picard.linux.it (Postfix) with ESMTP id AD2D53C53E6 for ; Tue, 8 Sep 2020 08:20:28 +0200 (CEST) Received: from mail-pj1-x1042.google.com (mail-pj1-x1042.google.com [IPv6:2607:f8b0:4864:20::1042]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by in-5.smtp.seeweb.it (Postfix) with ESMTPS id 3FBC7600BC5 for ; Tue, 8 Sep 2020 08:20:28 +0200 (CEST) Received: by mail-pj1-x1042.google.com with SMTP id np15so8277661pjb.0 for ; Mon, 07 Sep 2020 23:20:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=GWy0uWZeo6ljRwWDS/gLrb1Oi0Lsbp5dMByqTvjrTXY=; b=j1D5prUoCp5ozeeZ3ypqHq1SuEdfoUbuQL8sAjgT7P9S9PEmpc3bl4dRgSCstfDhqt 25es1KBt7O0q5x1EhOrTVZ+9+2sugAcDPUNI4OCTvf9JAgtisqc6DEZ3AFdgStFbE+l6 +VvX7LM+62ScuY9A6iiZoKDQhvLhNTf3vR92jszc8tyvues+vyW8ctfHOdVny5DqQgIv vPntjPvbuCLYhH4FkgE+oUusK3qzSImbTVX2LowQgp1JKplnl70sgKFAj4dyehiTDGRp 7TCiGRJ0L7i08tsomNxnDjypb4JwWcfrv+WL8yBIqX20uzecGWoTnYyIy45on3igg2WS eIBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=GWy0uWZeo6ljRwWDS/gLrb1Oi0Lsbp5dMByqTvjrTXY=; b=Y+0QYiem+KOlqTfdE6WVrWhWBd/ju5OmAkDqNDo2v1K+O6TOlGfmL2Vqhc6QXJRqiN ZXueOns843xqthp/RXsgOpKW68lGNU5BOevVVm8R6LGD7IU1c3ICywUBqy5JRC3tVrBt yrR5HQnmiMq371BilepbLJTJCYiDM3CSZtpRQBDbJ0Cs6CObNhjNSji/RJD2CGxoubUr u86ZbHjeJmfLma1IZVe+LJF4k/UxdLj60QuVK3PlaB7QLtyyU5caW/rwjPYsiNw/L9LL yYs7NITo7/22vke/nUIWAo697RTEGHY30e01/m2/xw7IkAn6+v+tIYRrg6b+yup+dDRq +VzQ== X-Gm-Message-State: AOAM530K6tg9htBuXVdwyT93cYrlqUVihGcSilTEhk6NFLTRZRm4vznI 2w4UYpSCaAQUt6tAQ+UNdmkGC5kR8MCC/A== X-Google-Smtp-Source: ABdhPJwWTWsd2vI37RTpvg+LDAz61MpYsD9NINQgj6rDcVXfRCoUm8M6yeMAMhBcA/HZBGVAxEVgJA== X-Received: by 2002:a17:90b:4b11:: with SMTP id lx17mr2597386pjb.22.1599546026263; Mon, 07 Sep 2020 23:20:26 -0700 (PDT) Received: from localhost ([122.181.54.133]) by smtp.gmail.com with ESMTPSA id ih12sm11594464pjb.24.2020.09.07.23.20.25 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Sep 2020 23:20:25 -0700 (PDT) From: Viresh Kumar To: ltp@lists.linux.it Date: Tue, 8 Sep 2020 11:49:27 +0530 Message-Id: X-Mailer: git-send-email 2.25.0.rc1.19.g042ed3e048af In-Reply-To: References: MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.102.4 at in-5.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-5.smtp.seeweb.it Subject: [LTP] [PATCH 14/16] syscalls: timerfd: Reuse struct time64_variants X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Viresh Kumar , Vincent Guittot Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Lets reuse the common structure here. Signed-off-by: Viresh Kumar --- testcases/kernel/syscalls/timerfd/timerfd01.c | 27 ++++++++----------- testcases/kernel/syscalls/timerfd/timerfd04.c | 20 ++++++-------- .../syscalls/timerfd/timerfd_gettime01.c | 8 +++--- .../syscalls/timerfd/timerfd_settime01.c | 17 +++++------- .../syscalls/timerfd/timerfd_settime02.c | 15 +++++------ 5 files changed, 35 insertions(+), 52 deletions(-) diff --git a/testcases/kernel/syscalls/timerfd/timerfd01.c b/testcases/kernel/syscalls/timerfd/timerfd01.c index 039d962ca228..cede40dafb2b 100644 --- a/testcases/kernel/syscalls/timerfd/timerfd01.c +++ b/testcases/kernel/syscalls/timerfd/timerfd01.c @@ -17,6 +17,7 @@ #define _GNU_SOURCE #include +#include "time64_variants.h" #include "tst_timer.h" #include "tst_safe_timerfd.h" @@ -28,28 +29,22 @@ static struct tcase { {CLOCK_REALTIME, "CLOCK REALTIME"}, }; -static struct test_variants { - int (*cgettime)(clockid_t clk_id, void *ts); - int (*tfd_gettime)(int fd, void *its); - int (*tfd_settime)(int fd, int flags, void *new_value, void *old_value); - enum tst_ts_type type; - char *desc; -} variants[] = { +static struct time64_variants variants[] = { #if (__NR_timerfd_gettime != __LTP__NR_INVALID_SYSCALL) - { .cgettime = sys_clock_gettime, .tfd_gettime = sys_timerfd_gettime, .tfd_settime = sys_timerfd_settime, .type = TST_KERN_OLD_TIMESPEC, .desc = "syscall with old kernel spec"}, + { .clock_gettime = sys_clock_gettime, .tfd_gettime = sys_timerfd_gettime, .tfd_settime = sys_timerfd_settime, .ts_type = TST_KERN_OLD_TIMESPEC, .desc = "syscall with old kernel spec"}, #endif #if (__NR_timerfd_gettime64 != __LTP__NR_INVALID_SYSCALL) - { .cgettime = sys_clock_gettime64, .tfd_gettime = sys_timerfd_gettime64, .tfd_settime = sys_timerfd_settime64, .type = TST_KERN_TIMESPEC, .desc = "syscall time64 with kernel spec"}, + { .clock_gettime = sys_clock_gettime64, .tfd_gettime = sys_timerfd_gettime64, .tfd_settime = sys_timerfd_settime64, .ts_type = TST_KERN_TIMESPEC, .desc = "syscall time64 with kernel spec"}, #endif }; static unsigned long long getustime(int clockid) { - struct test_variants *tv = &variants[tst_variant]; - struct tst_ts tp = {.type = tv->type, }; + struct time64_variants *tv = &variants[tst_variant]; + struct tst_ts tp = {.type = tv->ts_type, }; - if (tv->cgettime((clockid_t) clockid, tst_ts_get(&tp))) { + if (tv->clock_gettime((clockid_t) clockid, tst_ts_get(&tp))) { tst_res(TFAIL | TERRNO, "clock_gettime() failed"); return 0; } @@ -60,7 +55,7 @@ static unsigned long long getustime(int clockid) static void settime(int tfd, struct tst_its *tmr, int tflags, unsigned long long tvalue, int tinterval) { - struct test_variants *tv = &variants[tst_variant]; + struct time64_variants *tv = &variants[tst_variant]; tst_its_set_value_from_us(tmr, tvalue); tst_its_set_interval_from_us(tmr, tinterval); @@ -97,11 +92,11 @@ static void waittmr(int tfd, unsigned int exp_ticks) static void run(unsigned int n) { - struct test_variants *tv = &variants[tst_variant]; + struct time64_variants *tv = &variants[tst_variant]; int tfd; unsigned long long tnow; uint64_t uticks; - struct tst_its tmr = {.type = tv->type, }; + struct tst_its tmr = {.type = tv->ts_type, }; struct tcase *clks = &tcases[n]; tst_res(TINFO, "testing %s", clks->name); @@ -122,7 +117,7 @@ static void run(unsigned int n) settime(tfd, &tmr, TFD_TIMER_ABSTIME, tnow + 50 * 1000, 50 * 1000); memset(&tmr, 0, sizeof(tmr)); - tmr.type = tv->type; + tmr.type = tv->ts_type; if (tv->tfd_gettime(tfd, tst_its_get(&tmr))) tst_res(TFAIL | TERRNO, "timerfd_gettime() failed"); diff --git a/testcases/kernel/syscalls/timerfd/timerfd04.c b/testcases/kernel/syscalls/timerfd/timerfd04.c index b6409574a219..798d95e607ed 100644 --- a/testcases/kernel/syscalls/timerfd/timerfd04.c +++ b/testcases/kernel/syscalls/timerfd/timerfd04.c @@ -15,6 +15,7 @@ */ #include +#include "time64_variants.h" #include "tst_safe_clocks.h" #include "tst_safe_timerfd.h" #include "tst_timer.h" @@ -34,18 +35,13 @@ static struct tcase { {CLOCK_BOOTTIME, CLOCK_BOOTTIME, -10}, }; -static struct test_variants { - int (*cgettime)(clockid_t clk_id, void *ts); - int (*tfd_settime)(int fd, int flags, void *new_value, void *old_value); - enum tst_ts_type type; - char *desc; -} variants[] = { +static struct time64_variants variants[] = { #if (__NR_timerfd_settime != __LTP__NR_INVALID_SYSCALL) - { .cgettime = sys_clock_gettime, .tfd_settime = sys_timerfd_settime, .type = TST_KERN_OLD_TIMESPEC, .desc = "syscall with old kernel spec"}, + { .clock_gettime = sys_clock_gettime, .tfd_settime = sys_timerfd_settime, .ts_type = TST_KERN_OLD_TIMESPEC, .desc = "syscall with old kernel spec"}, #endif #if (__NR_timerfd_settime64 != __LTP__NR_INVALID_SYSCALL) - { .cgettime = sys_clock_gettime64, .tfd_settime = sys_timerfd_settime64, .type = TST_KERN_TIMESPEC, .desc = "syscall time64 with kernel spec"}, + { .clock_gettime = sys_clock_gettime64, .tfd_settime = sys_timerfd_settime64, .ts_type = TST_KERN_TIMESPEC, .desc = "syscall time64 with kernel spec"}, #endif }; @@ -56,18 +52,18 @@ static void setup(void) static void verify_timerfd(unsigned int n) { - struct test_variants *tv = &variants[tst_variant]; + struct time64_variants *tv = &variants[tst_variant]; struct tst_ts start, end; struct tst_its it; struct tcase *tc = &tcases[n]; - start.type = end.type = it.type = tv->type; + start.type = end.type = it.type = tv->ts_type; SAFE_UNSHARE(CLONE_NEWTIME); SAFE_FILE_PRINTF("/proc/self/timens_offsets", "%d %d 0", tc->clk_off, tc->off); - if (tv->cgettime(tc->clk_id, tst_ts_get(&start))) { + if (tv->clock_gettime(tc->clk_id, tst_ts_get(&start))) { tst_res(TFAIL | TTERRNO, "clock_gettime(2) failed for clock %s", tst_clock_name(tc->clk_id)); return; @@ -98,7 +94,7 @@ static void verify_timerfd(unsigned int n) SAFE_WAIT(NULL); - if (tv->cgettime(CLOCK_MONOTONIC, tst_ts_get(&end))) { + if (tv->clock_gettime(CLOCK_MONOTONIC, tst_ts_get(&end))) { tst_res(TFAIL | TTERRNO, "clock_gettime(2) failed for clock %s", tst_clock_name(CLOCK_MONOTONIC)); return; diff --git a/testcases/kernel/syscalls/timerfd/timerfd_gettime01.c b/testcases/kernel/syscalls/timerfd/timerfd_gettime01.c index 49f5aa59a96b..aba77c05d796 100644 --- a/testcases/kernel/syscalls/timerfd/timerfd_gettime01.c +++ b/testcases/kernel/syscalls/timerfd/timerfd_gettime01.c @@ -12,6 +12,7 @@ #define _GNU_SOURCE +#include "time64_variants.h" #include "tst_timer.h" #include "tst_safe_timerfd.h" @@ -32,10 +33,7 @@ static struct test_case_t { {&fd, NULL, EINVAL}, }; -static struct test_variants { - int (*tfd_gettime)(int fd, void *its); - char *desc; -} variants[] = { +static struct time64_variants variants[] = { #if (__NR_timerfd_gettime != __LTP__NR_INVALID_SYSCALL) { .tfd_gettime = sys_timerfd_gettime, .desc = "syscall with old kernel spec"}, #endif @@ -70,7 +68,7 @@ static void cleanup(void) static void run(unsigned int n) { - struct test_variants *tv = &variants[tst_variant]; + struct time64_variants *tv = &variants[tst_variant]; struct test_case_t *test = &test_cases[n]; void *its; diff --git a/testcases/kernel/syscalls/timerfd/timerfd_settime01.c b/testcases/kernel/syscalls/timerfd/timerfd_settime01.c index 781c0fdb1cb7..36577e2c4c0b 100644 --- a/testcases/kernel/syscalls/timerfd/timerfd_settime01.c +++ b/testcases/kernel/syscalls/timerfd/timerfd_settime01.c @@ -13,6 +13,7 @@ #define _GNU_SOURCE +#include "time64_variants.h" #include "tst_timer.h" #include "lapi/timerfd.h" @@ -35,27 +36,23 @@ static struct test_case_t { static struct tst_its new_value; -static struct test_variants { - int (*tfd_settime)(int fd, int flags, void *new_value, void *old_value); - enum tst_ts_type type; - char *desc; -} variants[] = { +static struct time64_variants variants[] = { #if (__NR_timerfd_settime != __LTP__NR_INVALID_SYSCALL) - { .tfd_settime = sys_timerfd_settime, .type = TST_KERN_OLD_TIMESPEC, .desc = "syscall with old kernel spec"}, + { .tfd_settime = sys_timerfd_settime, .ts_type = TST_KERN_OLD_TIMESPEC, .desc = "syscall with old kernel spec"}, #endif #if (__NR_timerfd_settime64 != __LTP__NR_INVALID_SYSCALL) - { .tfd_settime = sys_timerfd_settime64, .type = TST_KERN_TIMESPEC, .desc = "syscall time64 with kernel spec"}, + { .tfd_settime = sys_timerfd_settime64, .ts_type = TST_KERN_TIMESPEC, .desc = "syscall time64 with kernel spec"}, #endif }; static void setup(void) { - struct test_variants *tv = &variants[tst_variant]; + struct time64_variants *tv = &variants[tst_variant]; tst_res(TINFO, "Testing variant: %s", tv->desc); bad_addr = tst_get_bad_addr(NULL); - new_value.type = tv->type; + new_value.type = tv->ts_type; clockfd = timerfd_create(CLOCK_REALTIME, 0); if (clockfd == -1) { @@ -77,7 +74,7 @@ static void cleanup(void) static void run(unsigned int n) { - struct test_variants *tv = &variants[tst_variant]; + struct time64_variants *tv = &variants[tst_variant]; struct test_case_t *test = &test_cases[n]; void *its; diff --git a/testcases/kernel/syscalls/timerfd/timerfd_settime02.c b/testcases/kernel/syscalls/timerfd/timerfd_settime02.c index ab978bde5820..bd92ee964644 100644 --- a/testcases/kernel/syscalls/timerfd/timerfd_settime02.c +++ b/testcases/kernel/syscalls/timerfd/timerfd_settime02.c @@ -15,6 +15,7 @@ * timerfd: Protect the might cancel mechanism proper */ #include +#include "time64_variants.h" #include "tst_timer.h" #include "tst_safe_timerfd.h" #include "tst_fuzzy_sync.h" @@ -29,26 +30,22 @@ static int fd = -1; static struct tst_its its; static struct tst_fzsync_pair fzsync_pair; -static struct test_variants { - int (*tfd_settime)(int fd, int flags, void *new_value, void *old_value); - enum tst_ts_type type; - char *desc; -} variants[] = { +static struct time64_variants variants[] = { #if (__NR_timerfd_settime != __LTP__NR_INVALID_SYSCALL) - { .tfd_settime = sys_timerfd_settime, .type = TST_KERN_OLD_TIMESPEC, .desc = "syscall with old kernel spec"}, + { .tfd_settime = sys_timerfd_settime, .ts_type = TST_KERN_OLD_TIMESPEC, .desc = "syscall with old kernel spec"}, #endif #if (__NR_timerfd_settime64 != __LTP__NR_INVALID_SYSCALL) - { .tfd_settime = sys_timerfd_settime64, .type = TST_KERN_TIMESPEC, .desc = "syscall time64 with kernel spec"}, + { .tfd_settime = sys_timerfd_settime64, .ts_type = TST_KERN_TIMESPEC, .desc = "syscall time64 with kernel spec"}, #endif }; static void setup(void) { - struct test_variants *tv = &variants[tst_variant]; + struct time64_variants *tv = &variants[tst_variant]; tst_res(TINFO, "Testing variant: %s", tv->desc); - its.type = tv->type; + its.type = tv->ts_type; fd = SAFE_TIMERFD_CREATE(CLOCK_REALTIME, 0); From patchwork Tue Sep 8 06:19:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 1359492 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=213.254.12.146; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=uSjq/fdM; dkim-atps=neutral Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Blw6W1wCZz9sT6 for ; Tue, 8 Sep 2020 16:22:11 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id BD19D3C2C2F for ; Tue, 8 Sep 2020 08:22:08 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-4.smtp.seeweb.it (in-4.smtp.seeweb.it [IPv6:2001:4b78:1:20::4]) by picard.linux.it (Postfix) with ESMTP id 4CF083C53D9 for ; Tue, 8 Sep 2020 08:20:30 +0200 (CEST) Received: from mail-pj1-x1043.google.com (mail-pj1-x1043.google.com [IPv6:2607:f8b0:4864:20::1043]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by in-4.smtp.seeweb.it (Postfix) with ESMTPS id B7FA11000C2C for ; Tue, 8 Sep 2020 08:20:30 +0200 (CEST) Received: by mail-pj1-x1043.google.com with SMTP id np15so8277707pjb.0 for ; Mon, 07 Sep 2020 23:20:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+WXxt2+K3zz1iUJ6bKAxx+vlZShet13/HWRGozJuV4w=; b=uSjq/fdMsmCDX85MJagmrr1FFgtIWfSeFa6PTDikO13S0JN7IJAeRxVhmRI6irYeqN 0NR0SxusmJXvcKxRJMKXeXzOe+Lwgrt4jem7lzVt2MxmuAVK0mpVJm43wb1EBz1ZVyB8 cEwo+AsOiF13HXcboqmtS1OSBV+NAas6LBImC59V5R4KaTNElO775BNeux8BqIQ5mthH aa/UYu+BxrKGf40F3XwxUEoMZ2FW/hv+52QlAA3ThcyRXJpQmYxt8Ogcl3wDd0ab5QK2 I/bhY12OoWFENCLvKEtmnnXzU5buAIHYmRaC/+wjwxwklltGf8hELega+IxvlK6viMem qALg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+WXxt2+K3zz1iUJ6bKAxx+vlZShet13/HWRGozJuV4w=; b=WLe6OE4KQWv2B0COM9UNkyw+/WyHh5811ApLu4jFU9QLQj2hdrK7mG6oC90DIr0D6+ rDUeboNNpj+oc40EQoTuRcSeU2gAIuHOICBRFnZAGg/UyWz5Dkvq6RC5I8X4wowKhTtN Zrm/Gf1p+UF1wt/gT/8R5IOqQC1tA/KWeVnPwAlKglIKkn6pt5+c8lUCHgZrp1SVSVwl Z+H4Sd1Su0Z234NHaVo5yYpfL0fBokEUfnhFFxRAPNr4v3MBNb2O8r6CQT4hwDKkLHwR HaWZVsEIqzvg0bE0F9m9U0zI2GgEYtHtTy4eAo4mw/XyMw15+0WEA6Ap6veg677Sepjk hF+g== X-Gm-Message-State: AOAM533s3dT+P232s5fOGWXOwBev0oRxk+AAAnCi456OW1EJg9KFcl96 Y0ciDigPmDM5Fxf/mh6sAY+TbJ+jKJPovA== X-Google-Smtp-Source: ABdhPJzJcCEzHzA/Wdiq53o5fkYFFrebrlCeBlqEYHT9mo7kBX8RaXZmHt8+H4wGNcMNBaz0oEvrUg== X-Received: by 2002:a17:90a:481:: with SMTP id g1mr2510288pjg.157.1599546028837; Mon, 07 Sep 2020 23:20:28 -0700 (PDT) Received: from localhost ([122.181.54.133]) by smtp.gmail.com with ESMTPSA id x19sm9490119pge.22.2020.09.07.23.20.28 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Sep 2020 23:20:28 -0700 (PDT) From: Viresh Kumar To: ltp@lists.linux.it Date: Tue, 8 Sep 2020 11:49:28 +0530 Message-Id: <9ed6ce7ed42f38432c318c8b95fe7170f709d896.1599545766.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.25.0.rc1.19.g042ed3e048af In-Reply-To: References: MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.102.4 at in-4.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-4.smtp.seeweb.it Subject: [LTP] [PATCH 15/16] syscalls: utimensat: Reuse struct time64_variants X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Viresh Kumar , Vincent Guittot Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Lets reuse the common structure here. Signed-off-by: Viresh Kumar --- .../kernel/syscalls/utimensat/utimensat01.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/testcases/kernel/syscalls/utimensat/utimensat01.c b/testcases/kernel/syscalls/utimensat/utimensat01.c index e2d4fee3e433..fe490f4415e6 100644 --- a/testcases/kernel/syscalls/utimensat/utimensat01.c +++ b/testcases/kernel/syscalls/utimensat/utimensat01.c @@ -18,6 +18,7 @@ #include #include "lapi/fs.h" #include "lapi/utime.h" +#include "time64_variants.h" #include "tst_timer.h" #define TEST_FILE "test_file" @@ -109,18 +110,13 @@ static inline int sys_utimensat_time64(int dirfd, const char *pathname, return tst_syscall(__NR_utimensat_time64, dirfd, pathname, times, flags); } -static struct test_variants { - int (*utimensat)(int dirfd, const char *pathname, void *times, - int flags); - enum tst_ts_type type; - char *desc; -} variants[] = { +static struct time64_variants variants[] = { #if (__NR_utimensat != __LTP__NR_INVALID_SYSCALL) - { .utimensat = sys_utimensat, .type = TST_KERN_OLD_TIMESPEC, .desc = "syscall with old kernel spec"}, + { .utimensat = sys_utimensat, .ts_type = TST_KERN_OLD_TIMESPEC, .desc = "syscall with old kernel spec"}, #endif #if (__NR_utimensat_time64 != __LTP__NR_INVALID_SYSCALL) - { .utimensat = sys_utimensat_time64, .type = TST_KERN_TIMESPEC, .desc = "syscall time64 with kernel spec"}, + { .utimensat = sys_utimensat_time64, .ts_type = TST_KERN_TIMESPEC, .desc = "syscall time64 with kernel spec"}, #endif }; @@ -198,7 +194,7 @@ static void change_attr(struct test_case *tc, int fd, int set) static void reset_time(char *pathname, int dfd, int flags, int i) { - struct test_variants *tv = &variants[tst_variant]; + struct time64_variants *tv = &variants[tst_variant]; struct stat sb; memset(&ts, 0, sizeof(ts)); @@ -215,7 +211,7 @@ static void reset_time(char *pathname, int dfd, int flags, int i) static void run(unsigned int i) { - struct test_variants *tv = &variants[tst_variant]; + struct time64_variants *tv = &variants[tst_variant]; struct test_case *tc = &tcase[i]; int dfd = AT_FDCWD, fd = 0, atime_change, mtime_change; struct mytime *mytime = tc->mytime; @@ -237,7 +233,7 @@ static void run(unsigned int i) } if (mytime) { - tst_multi_set_time(tv->type, mytime); + tst_multi_set_time(tv->ts_type, mytime); tsp = &ts; } else if (tc->exp_err == EFAULT) { tsp = bad_addr; From patchwork Tue Sep 8 06:19:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 1359493 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=213.254.12.146; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=wgi85som; dkim-atps=neutral Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Blw6g41r4z9sT6 for ; Tue, 8 Sep 2020 16:22:19 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id EE8D73C53BF for ; Tue, 8 Sep 2020 08:22:16 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-4.smtp.seeweb.it (in-4.smtp.seeweb.it [IPv6:2001:4b78:1:20::4]) by picard.linux.it (Postfix) with ESMTP id 2C45A3C53D8 for ; Tue, 8 Sep 2020 08:20:34 +0200 (CEST) Received: from mail-pj1-x1043.google.com (mail-pj1-x1043.google.com [IPv6:2607:f8b0:4864:20::1043]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by in-4.smtp.seeweb.it (Postfix) with ESMTPS id 6C6341000C29 for ; Tue, 8 Sep 2020 08:20:33 +0200 (CEST) Received: by mail-pj1-x1043.google.com with SMTP id o16so7740268pjr.2 for ; Mon, 07 Sep 2020 23:20:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=8VK8ZGI/EVdxy+fSq7txCc34ThKPYtcx23erBO48QoQ=; b=wgi85somgtiss0bIUTB9FTCY1RquxBwWfQ4VGu9akQ5lgObDWtIUgtWS8JEXL+fJ0q sIEnR4XYf26g9CuKVLK83NcWrI/AobJYnC2bjRkFHcfWrgOS9wwvv3x7TMUmsAqQqpSu cZzVojJcqxtq99C8MVExLVG1hm1j5uVUfI7phtp73Q7ZMv0TdBB/UPoxwJQzOX8LJUNC eZE7k+3E3VjZq6ZFoPLqT10v4nQZeakuqq3d6l+f3uC4MO5TfS/SBBGpHLGag04Q/h/e PqTulqI6LYkJj9UYUNbqVeJUrkAJc0GiX2AAXuBmn+gMmZOi3OqK+SB/JUSnnrPw7rri lgrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=8VK8ZGI/EVdxy+fSq7txCc34ThKPYtcx23erBO48QoQ=; b=ir4bLwQLol3ZXsZrRflve2duKCKWO8cJbmJzHx0nxclMhSuVyg1/cvizrGVi1Gif7M ad6PGrUrPHv2vr3d7mmIiVUocLw0LIN/2y0HYQBAJOoIj8J6lOQvt6chLZmLNoOVkvlo 0Ff3/wkfJWiBIYy4BNZ+sYNUjCGeoXaSsNR10Fw7XhzFmrYtRRD1Zy5mNxJ7v/hES8GK BvgKYwaSpSDrKTt9Um9midkA7++cDRIWvrBsVysLXqR7UsN+pFS8lnDmL14nD9qllmve 7gs3u8By1BJRbpaQeoPrFf0U7xYAMqZtHHFODLe/fdimyjC0HO1ZXtBCt8UlPgs4G1Y5 QPYQ== X-Gm-Message-State: AOAM532FCKSs5nz0K+N2+TFHTwJlfgAXfpfyt7jJaTrV0VxhEANdqkHU TmzVY3s9C/0o6G7LlVEG4uhAeuTk7k1uxA== X-Google-Smtp-Source: ABdhPJyJ9FzhRm4PSNHfge3TizBjfr5vfrDiltsOs8zCg9pvYOoMIhunaCBduaAV3uwKPKvDqnqjsw== X-Received: by 2002:a17:90a:9403:: with SMTP id r3mr2671942pjo.52.1599546031430; Mon, 07 Sep 2020 23:20:31 -0700 (PDT) Received: from localhost ([122.181.54.133]) by smtp.gmail.com with ESMTPSA id s198sm13964354pgc.4.2020.09.07.23.20.30 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Sep 2020 23:20:30 -0700 (PDT) From: Viresh Kumar To: ltp@lists.linux.it Date: Tue, 8 Sep 2020 11:49:29 +0530 Message-Id: <695ce1e3c736c61f64ed96d195aa4460c4790cb4.1599545766.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.25.0.rc1.19.g042ed3e048af In-Reply-To: References: MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.102.4 at in-4.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-4.smtp.seeweb.it Subject: [LTP] [PATCH 16/16] futex: Move variants struct definition to common header X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Viresh Kumar , Vincent Guittot Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Use a single definition of the structure and move it to a common place. Signed-off-by: Viresh Kumar --- .../kernel/syscalls/futex/futex_cmp_requeue01.c | 12 ++++-------- .../kernel/syscalls/futex/futex_cmp_requeue02.c | 9 +++------ testcases/kernel/syscalls/futex/futex_wait01.c | 10 +++------- testcases/kernel/syscalls/futex/futex_wait02.c | 11 ++++------- testcases/kernel/syscalls/futex/futex_wait03.c | 11 ++++------- testcases/kernel/syscalls/futex/futex_wait04.c | 10 +++------- .../kernel/syscalls/futex/futex_wait_bitset01.c | 11 +++-------- testcases/kernel/syscalls/futex/futex_wake01.c | 9 +++------ testcases/kernel/syscalls/futex/futex_wake02.c | 11 ++++------- testcases/kernel/syscalls/futex/futex_wake03.c | 13 +++++-------- testcases/kernel/syscalls/futex/futex_wake04.c | 14 +++++--------- testcases/kernel/syscalls/futex/futextest.h | 7 +++++++ 12 files changed, 48 insertions(+), 80 deletions(-) diff --git a/testcases/kernel/syscalls/futex/futex_cmp_requeue01.c b/testcases/kernel/syscalls/futex/futex_cmp_requeue01.c index 537641766357..13e67c758bed 100644 --- a/testcases/kernel/syscalls/futex/futex_cmp_requeue01.c +++ b/testcases/kernel/syscalls/futex/futex_cmp_requeue01.c @@ -42,11 +42,7 @@ static struct tcase { {1000, 300, 500}, }; -static struct test_variants { - enum futex_fn_type fntype; - enum tst_ts_type tstype; - char *desc; -} variants[] = { +static struct futex_test_variants variants[] = { #if (__NR_futex != __LTP__NR_INVALID_SYSCALL) { .fntype = FUTEX_FN_FUTEX, .tstype = TST_KERN_OLD_TIMESPEC, .desc = "syscall with old kernel spec"}, #endif @@ -58,7 +54,7 @@ static struct test_variants { static void do_child(void) { - struct test_variants *tv = &variants[tst_variant]; + struct futex_test_variants *tv = &variants[tst_variant]; struct tst_ts usec = tst_ts_from_ms(tv->tstype, max_sleep_ms); int slept_for_ms = 0; int pid = getpid(); @@ -87,7 +83,7 @@ static void do_child(void) static void verify_futex_cmp_requeue(unsigned int n) { - struct test_variants *tv = &variants[tst_variant]; + struct futex_test_variants *tv = &variants[tst_variant]; int num_requeues = 0, num_waits = 0, num_total = 0; int i, status, spurious, woken_up; struct tcase *tc = &tcases[n]; @@ -194,7 +190,7 @@ static void verify_futex_cmp_requeue(unsigned int n) static void setup(void) { - struct test_variants *tv = &variants[tst_variant]; + struct futex_test_variants *tv = &variants[tst_variant]; tst_res(TINFO, "Testing variant: %s", tv->desc); futex_supported_by_kernel(tv->fntype); diff --git a/testcases/kernel/syscalls/futex/futex_cmp_requeue02.c b/testcases/kernel/syscalls/futex/futex_cmp_requeue02.c index dd8fafb3ee38..0514b0ba4e69 100644 --- a/testcases/kernel/syscalls/futex/futex_cmp_requeue02.c +++ b/testcases/kernel/syscalls/futex/futex_cmp_requeue02.c @@ -32,10 +32,7 @@ static struct tcase { {1, 1, FUTEX_INITIALIZER + 1, EAGAIN}, }; -static struct test_variants { - enum futex_fn_type fntype; - char *desc; -} variants[] = { +static struct futex_test_variants variants[] = { #if (__NR_futex != __LTP__NR_INVALID_SYSCALL) { .fntype = FUTEX_FN_FUTEX, .desc = "syscall with old kernel spec"}, #endif @@ -47,7 +44,7 @@ static struct test_variants { static void verify_futex_cmp_requeue(unsigned int n) { - struct test_variants *tv = &variants[tst_variant]; + struct futex_test_variants *tv = &variants[tst_variant]; struct tcase *tc = &tcases[n]; TEST(futex_cmp_requeue(tv->fntype, &futexes[0], tc->exp_val, @@ -69,7 +66,7 @@ static void verify_futex_cmp_requeue(unsigned int n) static void setup(void) { - struct test_variants *tv = &variants[tst_variant]; + struct futex_test_variants *tv = &variants[tst_variant]; tst_res(TINFO, "Testing variant: %s", tv->desc); futex_supported_by_kernel(tv->fntype); diff --git a/testcases/kernel/syscalls/futex/futex_wait01.c b/testcases/kernel/syscalls/futex/futex_wait01.c index 09a95aa2ca0d..02a3fca3501f 100644 --- a/testcases/kernel/syscalls/futex/futex_wait01.c +++ b/testcases/kernel/syscalls/futex/futex_wait01.c @@ -29,11 +29,7 @@ static struct testcase testcases[] = { {&futex, FUTEX_INITIALIZER+1, FUTEX_PRIVATE_FLAG, EWOULDBLOCK}, }; -static struct test_variants { - enum futex_fn_type fntype; - enum tst_ts_type tstype; - char *desc; -} variants[] = { +static struct futex_test_variants variants[] = { #if (__NR_futex != __LTP__NR_INVALID_SYSCALL) { .fntype = FUTEX_FN_FUTEX, .tstype = TST_KERN_OLD_TIMESPEC, .desc = "syscall with old kernel spec"}, #endif @@ -45,7 +41,7 @@ static struct test_variants { static void run(unsigned int n) { - struct test_variants *tv = &variants[tst_variant]; + struct futex_test_variants *tv = &variants[tst_variant]; struct testcase *tc = &testcases[n]; struct tst_ts to = tst_ts_from_ns(tv->tstype, 10000); int res; @@ -68,7 +64,7 @@ static void run(unsigned int n) static void setup(void) { - struct test_variants *tv = &variants[tst_variant]; + struct futex_test_variants *tv = &variants[tst_variant]; tst_res(TINFO, "Testing variant: %s", tv->desc); futex_supported_by_kernel(tv->fntype); diff --git a/testcases/kernel/syscalls/futex/futex_wait02.c b/testcases/kernel/syscalls/futex/futex_wait02.c index 32bcfd1e744a..c83e6cce44b5 100644 --- a/testcases/kernel/syscalls/futex/futex_wait02.c +++ b/testcases/kernel/syscalls/futex/futex_wait02.c @@ -15,10 +15,7 @@ static futex_t *futex; -static struct test_variants { - enum futex_fn_type fntype; - char *desc; -} variants[] = { +static struct futex_test_variants variants[] = { #if (__NR_futex != __LTP__NR_INVALID_SYSCALL) { .fntype = FUTEX_FN_FUTEX, .desc = "syscall with old kernel spec"}, #endif @@ -30,7 +27,7 @@ static struct test_variants { static void do_child(void) { - struct test_variants *tv = &variants[tst_variant]; + struct futex_test_variants *tv = &variants[tst_variant]; int ret; TST_PROCESS_STATE_WAIT(getppid(), 'S', 1000); @@ -45,7 +42,7 @@ static void do_child(void) static void run(void) { - struct test_variants *tv = &variants[tst_variant]; + struct futex_test_variants *tv = &variants[tst_variant]; int res, pid; pid = SAFE_FORK(); @@ -64,7 +61,7 @@ static void run(void) static void setup(void) { - struct test_variants *tv = &variants[tst_variant]; + struct futex_test_variants *tv = &variants[tst_variant]; tst_res(TINFO, "Testing variant: %s", tv->desc); futex_supported_by_kernel(tv->fntype); diff --git a/testcases/kernel/syscalls/futex/futex_wait03.c b/testcases/kernel/syscalls/futex/futex_wait03.c index 3e3a7ce2373e..50eb61f7e49d 100644 --- a/testcases/kernel/syscalls/futex/futex_wait03.c +++ b/testcases/kernel/syscalls/futex/futex_wait03.c @@ -13,10 +13,7 @@ static futex_t futex = FUTEX_INITIALIZER; -static struct test_variants { - enum futex_fn_type fntype; - char *desc; -} variants[] = { +static struct futex_test_variants variants[] = { #if (__NR_futex != __LTP__NR_INVALID_SYSCALL) { .fntype = FUTEX_FN_FUTEX, .desc = "syscall with old kernel spec"}, #endif @@ -28,7 +25,7 @@ static struct test_variants { static void *threaded(void *arg) { - struct test_variants *tv = &variants[tst_variant]; + struct futex_test_variants *tv = &variants[tst_variant]; long ret, pid = (long)arg; TST_PROCESS_STATE_WAIT(pid, 'S', 0); @@ -42,7 +39,7 @@ static void *threaded(void *arg) static void run(void) { - struct test_variants *tv = &variants[tst_variant]; + struct futex_test_variants *tv = &variants[tst_variant]; long res, pid = getpid(); pthread_t t; @@ -61,7 +58,7 @@ static void run(void) static void setup(void) { - struct test_variants *tv = &variants[tst_variant]; + struct futex_test_variants *tv = &variants[tst_variant]; tst_res(TINFO, "Testing variant: %s", tv->desc); futex_supported_by_kernel(tv->fntype); diff --git a/testcases/kernel/syscalls/futex/futex_wait04.c b/testcases/kernel/syscalls/futex/futex_wait04.c index f2885c8b27d5..500b74ae1ef9 100644 --- a/testcases/kernel/syscalls/futex/futex_wait04.c +++ b/testcases/kernel/syscalls/futex/futex_wait04.c @@ -13,11 +13,7 @@ #include "futextest.h" -static struct test_variants { - enum futex_fn_type fntype; - enum tst_ts_type tstype; - char *desc; -} variants[] = { +static struct futex_test_variants variants[] = { #if (__NR_futex != __LTP__NR_INVALID_SYSCALL) { .fntype = FUTEX_FN_FUTEX, .tstype = TST_KERN_OLD_TIMESPEC, .desc = "syscall with old kernel spec"}, #endif @@ -29,7 +25,7 @@ static struct test_variants { static void run(void) { - struct test_variants *tv = &variants[tst_variant]; + struct futex_test_variants *tv = &variants[tst_variant]; struct tst_ts to = tst_ts_from_ns(tv->tstype, 10000); size_t pagesize = getpagesize(); void *buf; @@ -49,7 +45,7 @@ static void run(void) static void setup(void) { - struct test_variants *tv = &variants[tst_variant]; + struct futex_test_variants *tv = &variants[tst_variant]; tst_res(TINFO, "Testing variant: %s", tv->desc); futex_supported_by_kernel(tv->fntype); diff --git a/testcases/kernel/syscalls/futex/futex_wait_bitset01.c b/testcases/kernel/syscalls/futex/futex_wait_bitset01.c index 358a5cd4542c..6880df6a554e 100644 --- a/testcases/kernel/syscalls/futex/futex_wait_bitset01.c +++ b/testcases/kernel/syscalls/futex/futex_wait_bitset01.c @@ -21,12 +21,7 @@ static struct test_case_t { { CLOCK_REALTIME } }; -static struct test_variants { - enum futex_fn_type fntype; - enum tst_ts_type tstype; - int (*gettime)(clockid_t clk_id, void *ts); - char *desc; -} variants[] = { +static struct futex_test_variants variants[] = { #if (__NR_futex != __LTP__NR_INVALID_SYSCALL) { .fntype = FUTEX_FN_FUTEX, .tstype = TST_KERN_OLD_TIMESPEC, .gettime = sys_clock_gettime, .desc = "syscall with old kernel spec"}, #endif @@ -38,7 +33,7 @@ static struct test_variants { static void verify_futex_wait_bitset(long long wait_us, clock_t clk_id) { - struct test_variants *tv = &variants[tst_variant]; + struct futex_test_variants *tv = &variants[tst_variant]; struct tst_ts start, to, end; futex_t futex = FUTEX_INITIALIZER; u_int32_t bitset = 0xffffffff; @@ -99,7 +94,7 @@ static void run(unsigned int n) static void setup(void) { - struct test_variants *tv = &variants[tst_variant]; + struct futex_test_variants *tv = &variants[tst_variant]; tst_res(TINFO, "Testing variant: %s", tv->desc); futex_supported_by_kernel(tv->fntype); diff --git a/testcases/kernel/syscalls/futex/futex_wake01.c b/testcases/kernel/syscalls/futex/futex_wake01.c index a2f225a9cd1a..1dcf2f094e0c 100644 --- a/testcases/kernel/syscalls/futex/futex_wake01.c +++ b/testcases/kernel/syscalls/futex/futex_wake01.c @@ -27,10 +27,7 @@ static struct testcase testcases[] = { {&futex, INT_MAX, FUTEX_PRIVATE_FLAG}, }; -static struct test_variants { - enum futex_fn_type fntype; - char *desc; -} variants[] = { +static struct futex_test_variants variants[] = { #if (__NR_futex != __LTP__NR_INVALID_SYSCALL) { .fntype = FUTEX_FN_FUTEX, .desc = "syscall with old kernel spec"}, #endif @@ -42,7 +39,7 @@ static struct test_variants { static void run(unsigned int n) { - struct test_variants *tv = &variants[tst_variant]; + struct futex_test_variants *tv = &variants[tst_variant]; struct testcase *tc = &testcases[n]; int res; @@ -57,7 +54,7 @@ static void run(unsigned int n) static void setup(void) { - struct test_variants *tv = &variants[tst_variant]; + struct futex_test_variants *tv = &variants[tst_variant]; tst_res(TINFO, "Testing variant: %s", tv->desc); futex_supported_by_kernel(tv->fntype); diff --git a/testcases/kernel/syscalls/futex/futex_wake02.c b/testcases/kernel/syscalls/futex/futex_wake02.c index de80738bd73f..2eeec959d480 100644 --- a/testcases/kernel/syscalls/futex/futex_wake02.c +++ b/testcases/kernel/syscalls/futex/futex_wake02.c @@ -15,10 +15,7 @@ static futex_t futex = FUTEX_INITIALIZER; static volatile int threads_flags[55]; -static struct test_variants { - enum futex_fn_type fntype; - char *desc; -} variants[] = { +static struct futex_test_variants variants[] = { #if (__NR_futex != __LTP__NR_INVALID_SYSCALL) { .fntype = FUTEX_FN_FUTEX, .desc = "syscall with old kernel spec"}, #endif @@ -51,7 +48,7 @@ static void clear_threads_awake(void) static void *threaded(void *arg) { - struct test_variants *tv = &variants[tst_variant]; + struct futex_test_variants *tv = &variants[tst_variant]; long i = (long)arg; futex_wait(tv->fntype, &futex, futex, NULL, FUTEX_PRIVATE_FLAG); @@ -63,7 +60,7 @@ static void *threaded(void *arg) static void do_child(void) { - struct test_variants *tv = &variants[tst_variant]; + struct futex_test_variants *tv = &variants[tst_variant]; int i, j, awake; pthread_t t[55]; @@ -132,7 +129,7 @@ static void run(void) static void setup(void) { - struct test_variants *tv = &variants[tst_variant]; + struct futex_test_variants *tv = &variants[tst_variant]; tst_res(TINFO, "Testing variant: %s", tv->desc); futex_supported_by_kernel(tv->fntype); diff --git a/testcases/kernel/syscalls/futex/futex_wake03.c b/testcases/kernel/syscalls/futex/futex_wake03.c index 02b291e1a29e..a56ae92221f6 100644 --- a/testcases/kernel/syscalls/futex/futex_wake03.c +++ b/testcases/kernel/syscalls/futex/futex_wake03.c @@ -13,10 +13,7 @@ static futex_t *futex; -static struct test_variants { - enum futex_fn_type fntype; - char *desc; -} variants[] = { +static struct futex_test_variants variants[] = { #if (__NR_futex != __LTP__NR_INVALID_SYSCALL) { .fntype = FUTEX_FN_FUTEX, .desc = "syscall with old kernel spec"}, #endif @@ -28,7 +25,7 @@ static struct test_variants { static void do_child(void) { - struct test_variants *tv = &variants[tst_variant]; + struct futex_test_variants *tv = &variants[tst_variant]; futex_wait(tv->fntype, futex, *futex, NULL, 0); exit(0); @@ -36,7 +33,7 @@ static void do_child(void) static void do_wake(int nr_children) { - struct test_variants *tv = &variants[tst_variant]; + struct futex_test_variants *tv = &variants[tst_variant]; int res, i, cnt; TEST(futex_wake(tv->fntype, futex, nr_children, 0)); @@ -67,7 +64,7 @@ static void do_wake(int nr_children) static void run(void) { - struct test_variants *tv = &variants[tst_variant]; + struct futex_test_variants *tv = &variants[tst_variant]; pid_t pids[55]; unsigned int i; @@ -95,7 +92,7 @@ static void run(void) static void setup(void) { - struct test_variants *tv = &variants[tst_variant]; + struct futex_test_variants *tv = &variants[tst_variant]; tst_res(TINFO, "Testing variant: %s", tv->desc); futex_supported_by_kernel(tv->fntype); diff --git a/testcases/kernel/syscalls/futex/futex_wake04.c b/testcases/kernel/syscalls/futex/futex_wake04.c index f6f571ac4bff..2260a3936d6e 100644 --- a/testcases/kernel/syscalls/futex/futex_wake04.c +++ b/testcases/kernel/syscalls/futex/futex_wake04.c @@ -36,11 +36,7 @@ static futex_t *futex1, *futex2; static struct tst_ts to; -static struct test_variants { - enum futex_fn_type fntype; - enum tst_ts_type tstype; - char *desc; -} variants[] = { +static struct futex_test_variants variants[] = { #if (__NR_futex != __LTP__NR_INVALID_SYSCALL) { .fntype = FUTEX_FN_FUTEX, .tstype = TST_KERN_OLD_TIMESPEC, .desc = "syscall with old kernel spec"}, #endif @@ -55,7 +51,7 @@ static void setup(void) if (tst_hugepages == 0) tst_brk(TCONF, "No enough hugepages for testing."); - struct test_variants *tv = &variants[tst_variant]; + struct futex_test_variants *tv = &variants[tst_variant]; tst_res(TINFO, "Testing variant: %s", tv->desc); futex_supported_by_kernel(tv->fntype); @@ -65,7 +61,7 @@ static void setup(void) static void *wait_thread1(void *arg LTP_ATTRIBUTE_UNUSED) { - struct test_variants *tv = &variants[tst_variant]; + struct futex_test_variants *tv = &variants[tst_variant]; futex_wait(tv->fntype, futex1, *futex1, &to, 0); @@ -74,7 +70,7 @@ static void *wait_thread1(void *arg LTP_ATTRIBUTE_UNUSED) static void *wait_thread2(void *arg LTP_ATTRIBUTE_UNUSED) { - struct test_variants *tv = &variants[tst_variant]; + struct futex_test_variants *tv = &variants[tst_variant]; int res; errno = 0; @@ -89,7 +85,7 @@ static void *wait_thread2(void *arg LTP_ATTRIBUTE_UNUSED) static void wakeup_thread2(void) { - struct test_variants *tv = &variants[tst_variant]; + struct futex_test_variants *tv = &variants[tst_variant]; void *addr; int hpsz, pgsz; pthread_t th1, th2; diff --git a/testcases/kernel/syscalls/futex/futextest.h b/testcases/kernel/syscalls/futex/futextest.h index c50876fa67d4..3f2f36fef4ea 100644 --- a/testcases/kernel/syscalls/futex/futextest.h +++ b/testcases/kernel/syscalls/futex/futextest.h @@ -67,6 +67,13 @@ enum futex_fn_type { FUTEX_FN_FUTEX64, }; +struct futex_test_variants { + enum futex_fn_type fntype; + enum tst_ts_type tstype; + int (*gettime)(clockid_t clk_id, void *ts); + char *desc; +}; + static inline void futex_supported_by_kernel(enum futex_fn_type fntype) { if (fntype != FUTEX_FN_FUTEX64)