From patchwork Fri Jun 26 06:22: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: 1317398 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=AsQLStK0; 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 49tRfk2Nphz9sRR for ; Fri, 26 Jun 2020 16:23:58 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id B758C3C5853 for ; Fri, 26 Jun 2020 08:23:55 +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 3997A3C5837 for ; Fri, 26 Jun 2020 08:23:02 +0200 (CEST) Received: from mail-pj1-x1041.google.com (mail-pj1-x1041.google.com [IPv6:2607:f8b0:4864:20::1041]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by in-5.smtp.seeweb.it (Postfix) with ESMTPS id 4DCD7600BA3 for ; Fri, 26 Jun 2020 08:22:06 +0200 (CEST) Received: by mail-pj1-x1041.google.com with SMTP id u8so4274758pje.4 for ; Thu, 25 Jun 2020 23:23:01 -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=s0R7H3ESXy9BXi4x7K7Cc8ZDcyKc7QY2sKsGQcjvlo8=; b=AsQLStK0rg3ZJi9FAvMLa7Jfl76s1FAukJt4MrzLVmWJesOxOaD/Eev/jEbwjJQLOg hfkuqGCU/roANIRdg0SGMoXkh+4KpewQvuIqUEpB8S7rdeve2qv7tCK0yvJ4b20XPbId kYb51sqvMfvT44aYJzfjU3zRsYu+WLI0msAOYQupJGtszxAYakb9wsFWNvJx7cWyGXb3 gPqkDWTEus/Jvwpd2Zt6gg5uuW8+KzGk4Zp2xG7TMdskkU6y4E+Rp65/IqmPq3w3QTHW WeMR7izIqDXFwwMz02HmW6mol/QeCnCtFgRb3UW7o+SMccmlKPD/zdI2xtcPFmLDhg2k HSUA== 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=s0R7H3ESXy9BXi4x7K7Cc8ZDcyKc7QY2sKsGQcjvlo8=; b=WfVn7sHdShJmjfLkfgDMflKwNZGZxhERYCkp49b26gcmOTnboUQ/v5eZpGojyGcLHy OLT6th0wvinP+TRYIN/cNFvenJ5PvN8eyOOfLLqJPSRhvx7KLQO2CCiU2qrSOsHwHEgB pv+fK3U1A4dC69S1a9ITTwWP29j+c4bYaABgRuBQJNKO/ncQULqQW/4rzjY9aeunk7rq ac+3Mvc4wXnmvYzEH0DBIwCFeR9RP+4J7p95oSuXlA0AeK2MPyEwmNlWvttmFuCg08OG bnExm0C4ufB4Md1ch7yOkZsbaz6Q6rR2CCjwLF9UmmCAY5IG0XpreT2OWdS2TaMO6NDF YPIA== X-Gm-Message-State: AOAM530sSFMk62FuXcQfvYUNOcHGoB6JI6LHE4UtP3dH3dIF512OuqEr ve9LfxiqOjwqxLaGz+PjfZUlQgmD7YU= X-Google-Smtp-Source: ABdhPJxzT0Xcgsw3d3FpcO2aPpe6Y/G/PH51aIj/QQly63w2w140t3NFqa2EsSBjOFZYuR2rY5G97g== X-Received: by 2002:a17:902:854c:: with SMTP id d12mr1325639plo.343.1593152579662; Thu, 25 Jun 2020 23:22:59 -0700 (PDT) Received: from localhost ([122.172.127.76]) by smtp.gmail.com with ESMTPSA id h35sm10989487pje.29.2020.06.25.23.22.58 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 25 Jun 2020 23:22:59 -0700 (PDT) From: Viresh Kumar To: ltp@lists.linux.it Date: Fri, 26 Jun 2020 11:52:21 +0530 Message-Id: <2b946a2ec5c8083e326e4bb4ba08db3f0f9ad66f.1593152309.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.99.2 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,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-5.smtp.seeweb.it Subject: [LTP] [PATCH V7 08/19] syscalls/io_pgetevents: Add support for time64 tests 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: Vincent Guittot , arnd@arndb.de, Viresh Kumar Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" This adds support for time64 tests to the existing io_pgetevents() syscall tests. While at it, also pass mode to SAFE_OPEN() to avoid any errors when the tests are run for multiple variants together. Also get rid of an extra copy of local fd variable, which is incorrect. Signed-off-by: Viresh Kumar --- include/lapi/io_pgetevents.h | 15 ++++-- .../syscalls/io_pgetevents/io_pgetevents01.c | 33 +++++++++++- .../syscalls/io_pgetevents/io_pgetevents02.c | 51 +++++++++++++++---- 3 files changed, 83 insertions(+), 16 deletions(-) diff --git a/include/lapi/io_pgetevents.h b/include/lapi/io_pgetevents.h index 3c9d5b2d7618..5bb9a60c352a 100644 --- a/include/lapi/io_pgetevents.h +++ b/include/lapi/io_pgetevents.h @@ -16,15 +16,20 @@ #ifdef HAVE_LIBAIO #include -#ifndef HAVE_IO_PGETEVENTS -int io_pgetevents(io_context_t ctx, long min_nr, long max_nr, - struct io_event *events, struct timespec *timeout, - sigset_t *sigmask) +static inline int sys_io_pgetevents(io_context_t ctx, long min_nr, long max_nr, + struct io_event *events, void *timeout, sigset_t *sigmask) { return tst_syscall(__NR_io_pgetevents, ctx, min_nr, max_nr, events, timeout, sigmask); } -#endif /* HAVE_IO_PGETEVENTS */ + +static inline int sys_io_pgetevents_time64(io_context_t ctx, long min_nr, long max_nr, + struct io_event *events, void *timeout, sigset_t *sigmask) +{ + return tst_syscall(__NR_io_pgetevents_time64, ctx, min_nr, max_nr, + events, timeout, sigmask); +} + #endif /* HAVE_LIBAIO */ #endif /* IO_PGETEVENTS_H */ diff --git a/testcases/kernel/syscalls/io_pgetevents/io_pgetevents01.c b/testcases/kernel/syscalls/io_pgetevents/io_pgetevents01.c index e6077e47984d..fea380e52f4d 100644 --- a/testcases/kernel/syscalls/io_pgetevents/io_pgetevents01.c +++ b/testcases/kernel/syscalls/io_pgetevents/io_pgetevents01.c @@ -6,11 +6,32 @@ * Basic io_pgetevents() test to receive 1 event successfully. */ #include "tst_test.h" +#include "tst_timer.h" #include "lapi/io_pgetevents.h" #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[] = { +#if (__NR_io_pgetevents != __LTP__NR_INVALID_SYSCALL) + { .io_pgetevents = sys_io_pgetevents, .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"}, +#endif +}; + +static void setup(void) +{ + tst_res(TINFO, "Testing variant: %s", variants[tst_variant].desc); +} + static void cleanup(void) { if (fd > 0) @@ -19,12 +40,18 @@ static void cleanup(void) static void run(void) { + struct test_variants *tv = &variants[tst_variant]; struct io_event events[1]; struct iocb cb, *cbs[1]; io_context_t ctx = 0; + struct tst_ts to; sigset_t sigmask; char data[4096]; - int ret, fd; + int ret; + + to.type = tv->type; + tst_ts_set_sec(&to, 0); + tst_ts_set_nsec(&to, 10000); cbs[0] = &cb; sigemptyset(&sigmask); @@ -41,7 +68,7 @@ static void run(void) tst_brk(TBROK | TERRNO, "io_submit() failed"); /* get the reply */ - ret = io_pgetevents(ctx, 1, 1, events, NULL, &sigmask); + ret = tv->io_pgetevents(ctx, 1, 1, events, tst_ts_get(&to), &sigmask); if (ret == 1) tst_res(TPASS, "io_pgetevents() works as expected"); @@ -55,8 +82,10 @@ static void run(void) static struct tst_test test = { .min_kver = "4.18", .test_all = run, + .test_variants = ARRAY_SIZE(variants), .needs_tmpdir = 1, .cleanup = cleanup, + .setup = setup, }; #else diff --git a/testcases/kernel/syscalls/io_pgetevents/io_pgetevents02.c b/testcases/kernel/syscalls/io_pgetevents/io_pgetevents02.c index 62a8afba3bf1..a15b3d0dda92 100644 --- a/testcases/kernel/syscalls/io_pgetevents/io_pgetevents02.c +++ b/testcases/kernel/syscalls/io_pgetevents/io_pgetevents02.c @@ -6,6 +6,7 @@ * Basic io_pgetevents() test to check various failures. */ #include "tst_test.h" +#include "tst_timer.h" #include "lapi/io_pgetevents.h" #ifdef HAVE_LIBAIO @@ -14,30 +15,55 @@ static struct io_event events[1]; static io_context_t ctx, invalid_ctx = 0; static int fd, ctx_initialized; +static struct tst_ts to; +static void *bad_addr; + static struct tcase { char *name; io_context_t *ctx; long min_nr; long max_nr; struct io_event *events; - struct timespec *timeout; + struct tst_ts *timeout; sigset_t *sigmask; int exp_errno; } tcases[] = { - {"invalid ctx", &invalid_ctx, 1, 1, events, NULL, &sigmask, EINVAL}, - {"invalid min_nr", &ctx, -1, 1, events, NULL, &sigmask, EINVAL}, - {"invalid max_nr", &ctx, 1, -1, events, NULL, &sigmask, EINVAL}, - {"invalid events", &ctx, 1, 1, NULL, NULL, &sigmask, EFAULT}, - {"invalid timeout", &ctx, 1, 1, events, (void *)(0xDEAD), &sigmask, EFAULT}, - {"invalid sigmask", &ctx, 1, 1, events, NULL, (void *)(0xDEAD), EFAULT}, + {"invalid ctx", &invalid_ctx, 1, 1, events, &to, &sigmask, EINVAL}, + {"invalid min_nr", &ctx, -1, 1, events, &to, &sigmask, EINVAL}, + {"invalid max_nr", &ctx, 1, -1, events, &to, &sigmask, EINVAL}, + {"invalid events", &ctx, 1, 1, NULL, &to, &sigmask, EFAULT}, + {"invalid timeout", &ctx, 1, 1, events, NULL, &sigmask, EFAULT}, + {"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[] = { +#if (__NR_io_pgetevents != __LTP__NR_INVALID_SYSCALL) + { .io_pgetevents = sys_io_pgetevents, .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"}, +#endif }; static void setup(void) { + struct test_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.type = tv->type; + tst_ts_set_sec(&to, 0); + tst_ts_set_nsec(&to, 10000); + cbs[0] = &cb; sigemptyset(&sigmask); @@ -69,10 +95,16 @@ static void cleanup(void) static void run(unsigned int n) { + struct test_variants *tv = &variants[tst_variant]; struct tcase *tc = &tcases[n]; + struct timespec *to; + sigset_t *sigmask; + + sigmask = tc->sigmask ? tc->sigmask : bad_addr; + to = tc->timeout ? tc->timeout : bad_addr; - TEST(io_pgetevents(*tc->ctx, tc->min_nr, tc->max_nr, tc->events, - tc->timeout, tc->sigmask)); + TEST(tv->io_pgetevents(*tc->ctx, tc->min_nr, tc->max_nr, tc->events, to, + sigmask)); if (TST_RET == 1) { tst_res(TFAIL, "%s: io_pgetevents() passed unexpectedly", @@ -95,6 +127,7 @@ static struct tst_test test = { .needs_tmpdir = 1, .tcnt = ARRAY_SIZE(tcases), .test = run, + .test_variants = ARRAY_SIZE(variants), .setup = setup, .cleanup = cleanup, };