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");