From patchwork Tue May 5 09:12:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 1283381 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=dXBF+CAs; 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 49GYrz6Nncz9sRf for ; Tue, 5 May 2020 19:12:19 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 309303C57E8 for ; Tue, 5 May 2020 11:12:17 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-3.smtp.seeweb.it (in-3.smtp.seeweb.it [217.194.8.3]) by picard.linux.it (Postfix) with ESMTP id 042E73C2671 for ; Tue, 5 May 2020 11:12:15 +0200 (CEST) Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by in-3.smtp.seeweb.it (Postfix) with ESMTPS id E6DC91A01201 for ; Tue, 5 May 2020 11:12:14 +0200 (CEST) Received: by mail-pf1-x443.google.com with SMTP id 18so577164pfx.6 for ; Tue, 05 May 2020 02:12:14 -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:mime-version :content-transfer-encoding; bh=DZv9qjNPyJAB+XmfsFLfqriRBrQbKVP9dqUipWpIJw8=; b=dXBF+CAs+QzF/CbCHFgVOBSDJa7lhHIDArZfXB0RCrfXDs7CBuramLqmo56soWNWtx 2VTsoGs4HItm8mLEzKs9hcoRs1HoijlHMNoUJmEl0hMEofb9Z8T7YV9985qjA1aw6WkD PsGQs5BTLtOFeCUd3XfYtzVjLGAyVaiRWXnRqiyE6PEYKojesyB0/PIqyjrq/XtuGcHo tTIVAnAYD/r5WHJiElrzfftAspiaOEvfhsm8dj4ebgmYmyjCbBd7z/dQDPBLRs2wnGpp NnxTUylF004dWBy1Xv/W8ljWAIJCB3083O1j3GGf64hgNJVqY6MoKH0J/nw/eetq8RLP oqOg== 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:mime-version :content-transfer-encoding; bh=DZv9qjNPyJAB+XmfsFLfqriRBrQbKVP9dqUipWpIJw8=; b=QueXMBAIF8VO+47V0U/1/ZyF1OW4LXVlyjQBPHcBlwC4uW0kbNITyudJ8XyyNQ0Xzo NYbvbapJCq2bR9y27h4xs9TwWWyujwYDzruGZXRA2og7UgddE/OOqJpvr/vh9Rfihk4d NPdPyxUVb1Gx/GVVXk8t1yN6+kMmQh6mfqIPO5mPF6A5TVNPoB3e6mnhzKR0Op+EDxPW 8tax3uz4+Ak52gr8Xqv3U5dmSpyCu89+fT8PgEM79YHxV04e53YgUx0mTI9BiGcetN6s oWjOq2Vf1bj04YFVjXEM+xClBh+khsecxCA4zGNpaXNHOVqE/UPoAxXXj6EumhOZjLIr zvlw== X-Gm-Message-State: AGi0PuZdOmXIYhVcp7IK0Ot5O4CtQJxosrLCAniM9zCjd/JgEPx9NRNy /wmAYqloQt+U/rC/NoTAkxttPlxOozs= X-Google-Smtp-Source: APiQypJr1RPTtICpSZfLhUTMLSAS67XeVkZ/wRlv2TiM1Rbcu5P0cpBnp8XKIiYgkCjVK4sKiJbtIA== X-Received: by 2002:a63:d84e:: with SMTP id k14mr947467pgj.91.1588669932940; Tue, 05 May 2020 02:12:12 -0700 (PDT) Received: from localhost ([122.171.118.46]) by smtp.gmail.com with ESMTPSA id d74sm1481168pfd.70.2020.05.05.02.12.11 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 May 2020 02:12:12 -0700 (PDT) From: Viresh Kumar To: ltp@lists.linux.it Date: Tue, 5 May 2020 14:42:01 +0530 Message-Id: <7e037dacaeb0c7f3bfd73cd11d80f3e1567dc052.1588669892.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.25.0.rc1.19.g042ed3e048af MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.99.2 at in-3.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-3.smtp.seeweb.it Subject: [LTP] [PATCH 1/8] syscalls/futex: Merge futex_wait_bitset 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" We can handle them easily in a single test, lets do it. Signed-off-by: Viresh Kumar Reviewed-by: Petr Vorel --- runtest/syscalls | 1 - testcases/kernel/syscalls/futex/.gitignore | 1 - testcases/kernel/syscalls/futex/Makefile | 1 - .../kernel/syscalls/futex/futex_wait_bitset.h | 75 ------------------- .../syscalls/futex/futex_wait_bitset01.c | 73 +++++++++++++++++- .../syscalls/futex/futex_wait_bitset02.c | 18 ----- 6 files changed, 71 insertions(+), 98 deletions(-) delete mode 100644 testcases/kernel/syscalls/futex/futex_wait_bitset.h delete mode 100644 testcases/kernel/syscalls/futex/futex_wait_bitset02.c diff --git a/runtest/syscalls b/runtest/syscalls index cbab5730c12e..d13f69fce829 100644 --- a/runtest/syscalls +++ b/runtest/syscalls @@ -1663,7 +1663,6 @@ futex_wake02 futex_wake02 futex_wake03 futex_wake03 futex_wake04 futex_wake04 futex_wait_bitset01 futex_wait_bitset01 -futex_wait_bitset02 futex_wait_bitset02 memfd_create01 memfd_create01 memfd_create02 memfd_create02 diff --git a/testcases/kernel/syscalls/futex/.gitignore b/testcases/kernel/syscalls/futex/.gitignore index 68bc2028e1b2..54cd02b0223f 100644 --- a/testcases/kernel/syscalls/futex/.gitignore +++ b/testcases/kernel/syscalls/futex/.gitignore @@ -6,7 +6,6 @@ /futex_wait04 /futex_wait05 /futex_wait_bitset01 -/futex_wait_bitset02 /futex_wake01 /futex_wake02 /futex_wake03 diff --git a/testcases/kernel/syscalls/futex/Makefile b/testcases/kernel/syscalls/futex/Makefile index 8dd239301e63..c88af7c9643b 100644 --- a/testcases/kernel/syscalls/futex/Makefile +++ b/testcases/kernel/syscalls/futex/Makefile @@ -12,7 +12,6 @@ futex_wake02: CFLAGS+=-pthread futex_wake04: CFLAGS+=-pthread futex_wait05: LDLIBS+=-lrt futex_wait_bitset01: LDLIBS+=-lrt -futex_wait_bitset02: LDLIBS+=-lrt include $(top_srcdir)/include/mk/testcases.mk include $(top_srcdir)/include/mk/generic_leaf_target.mk diff --git a/testcases/kernel/syscalls/futex/futex_wait_bitset.h b/testcases/kernel/syscalls/futex/futex_wait_bitset.h deleted file mode 100644 index 84712816bfe8..000000000000 --- a/testcases/kernel/syscalls/futex/futex_wait_bitset.h +++ /dev/null @@ -1,75 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -/* - * Copyright (C) 2015 Cyril Hrubis - */ - -#define THRESHOLD_US 100000 -#define DEFAULT_TIMEOUT_US 100010 - -static void verify_futex_wait_bitset(long long wait_us, clock_t clk_id) -{ - struct timespec start, to, end; - futex_t futex = FUTEX_INITIALIZER; - u_int32_t bitset = 0xffffffff; - int flags = clk_id == CLOCK_REALTIME ? FUTEX_CLOCK_REALTIME : 0; - - tst_res(TINFO, "testing futex_wait_bitset() timeout with %s", - clk_id == CLOCK_REALTIME ? "CLOCK_REALTIME" : "CLOCK_MONOTONIC"); - - clock_gettime(clk_id, &start); - to = tst_timespec_add_us(start, wait_us); - - TEST(futex_wait_bitset(&futex, futex, &to, bitset, flags)); - - clock_gettime(clk_id, &end); - - if (TST_RET != -1) { - tst_res(TFAIL, "futex_wait_bitset() returned %li, expected -1", - TST_RET); - return; - } - - if (TST_ERR == ENOSYS) { - tst_res(TCONF, - "In this kernel, futex() does not support FUTEX_WAIT_BITSET operation"); - return; - } - - if (TST_ERR != ETIMEDOUT) { - tst_res(TFAIL | TTERRNO, "expected %s", - tst_strerrno(ETIMEDOUT)); - return; - } - - if (tst_timespec_lt(end, to)) { - tst_res(TFAIL, - "futex_wait_bitset() woken up prematurely %llius, expected %llius", - tst_timespec_diff_us(end, start), wait_us); - return; - } - - if (tst_timespec_diff_us(end, to) > THRESHOLD_US) { - tst_res(TFAIL, - "futex_wait_bitset() waited too long %llius, expected %llius", - tst_timespec_diff_us(end, start), wait_us); - return; - } - - tst_res(TPASS, "futex_wait_bitset() waited %llius, expected %llius", - tst_timespec_diff_us(end, start), wait_us); -} - -static void setup(void) -{ - tst_timer_check(USE_CLOCK); -} - -static void run(void) -{ - verify_futex_wait_bitset(DEFAULT_TIMEOUT_US, USE_CLOCK); -} - -static struct tst_test test = { - .setup = setup, - .test_all = run, -}; diff --git a/testcases/kernel/syscalls/futex/futex_wait_bitset01.c b/testcases/kernel/syscalls/futex/futex_wait_bitset01.c index 1ae3253cfe13..b8546c3e640c 100644 --- a/testcases/kernel/syscalls/futex/futex_wait_bitset01.c +++ b/testcases/kernel/syscalls/futex/futex_wait_bitset01.c @@ -13,7 +13,76 @@ #include "tst_timer.h" #include "futextest.h" -#define USE_CLOCK CLOCK_MONOTONIC +#define THRESHOLD_US 100000 +#define DEFAULT_TIMEOUT_US 100010 -#include "futex_wait_bitset.h" +static struct test_case_t { + clockid_t clk_id; +} tcases[] = { + { CLOCK_MONOTONIC }, + { CLOCK_REALTIME } +}; +static void verify_futex_wait_bitset(long long wait_us, clock_t clk_id) +{ + struct timespec start, to, end; + futex_t futex = FUTEX_INITIALIZER; + u_int32_t bitset = 0xffffffff; + int flags = clk_id == CLOCK_REALTIME ? FUTEX_CLOCK_REALTIME : 0; + + tst_res(TINFO, "testing futex_wait_bitset() timeout with %s", + clk_id == CLOCK_REALTIME ? "CLOCK_REALTIME" : "CLOCK_MONOTONIC"); + + clock_gettime(clk_id, &start); + to = tst_timespec_add_us(start, wait_us); + + TEST(futex_wait_bitset(&futex, futex, &to, bitset, flags)); + + clock_gettime(clk_id, &end); + + if (TST_RET != -1) { + tst_res(TFAIL, "futex_wait_bitset() returned %li, expected -1", + TST_RET); + return; + } + + if (TST_ERR == ENOSYS) { + tst_res(TCONF, + "In this kernel, futex() does not support FUTEX_WAIT_BITSET operation"); + return; + } + + if (TST_ERR != ETIMEDOUT) { + tst_res(TFAIL | TTERRNO, "expected %s", + tst_strerrno(ETIMEDOUT)); + return; + } + + if (tst_timespec_lt(end, to)) { + tst_res(TFAIL, + "futex_wait_bitset() woken up prematurely %llius, expected %llius", + tst_timespec_diff_us(end, start), wait_us); + return; + } + + if (tst_timespec_diff_us(end, to) > THRESHOLD_US) { + tst_res(TFAIL, + "futex_wait_bitset() waited too long %llius, expected %llius", + tst_timespec_diff_us(end, start), wait_us); + return; + } + + tst_res(TPASS, "futex_wait_bitset() waited %llius, expected %llius", + tst_timespec_diff_us(end, start), wait_us); +} + +static void run(unsigned int n) +{ + tst_timer_check(tcases[n].clk_id); + verify_futex_wait_bitset(DEFAULT_TIMEOUT_US, tcases[n].clk_id); +} + +static struct tst_test test = { + .test = run, + .tcnt = ARRAY_SIZE(tcases), +}; diff --git a/testcases/kernel/syscalls/futex/futex_wait_bitset02.c b/testcases/kernel/syscalls/futex/futex_wait_bitset02.c deleted file mode 100644 index 4d532fc07775..000000000000 --- a/testcases/kernel/syscalls/futex/futex_wait_bitset02.c +++ /dev/null @@ -1,18 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -/* - * Copyright (C) 2015 Cyril Hrubis - * - * 1. Block on a bitset futex and wait for timeout, the difference between - * normal futex and bitset futex is that that the later have absolute timeout. - * 2. Check that the futex waited for expected time. - */ - -#include - -#include "tst_test.h" -#include "tst_timer.h" -#include "futextest.h" - -#define USE_CLOCK CLOCK_REALTIME - -#include "futex_wait_bitset.h" From patchwork Tue May 5 09:12:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 1283382 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=yWG7aA9z; 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 49GYs9458qz9sRf for ; Tue, 5 May 2020 19:12:29 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id D44F43C57F1 for ; Tue, 5 May 2020 11:12:26 +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 A35CF3C5809 for ; Tue, 5 May 2020 11:12:20 +0200 (CEST) Received: from mail-pj1-x1044.google.com (mail-pj1-x1044.google.com [IPv6:2607:f8b0:4864:20::1044]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by in-4.smtp.seeweb.it (Postfix) with ESMTPS id B2F6C1000B5B for ; Tue, 5 May 2020 11:12:18 +0200 (CEST) Received: by mail-pj1-x1044.google.com with SMTP id fu13so745959pjb.5 for ; Tue, 05 May 2020 02:12:18 -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=bemAAMKwHkm/QrzhaN6SUzbkxwnZAqXdW9SzvKGjpLY=; b=yWG7aA9zL3y6vTiAzJ7ZtKFW0F4ILMsWmR9iFHk03Gfb3I4Y1VUhsHWllzPCjXW9Nx FIYHjArlw8uBDUZokJcXM4ihYsO1YbEhhzjyA+Pn1JCwhoIn8M00nZpLWMmEhJ8Ch2vu KIAz4fL9Gvjepf7rSQ4mOn9bi+BYFR/8EYWssl9sV9d8YHFZRMg63fJM8lXjMFlYkHVJ al3fyof9yFHsGycZBpjipQGFkd+NDFgX7l++YesXZXSrXhXHA5MHaZ+EBSkDTFEgiUfP ND+CZfX31Nk21Ss0tcQbD8/Jb1lgf9FxuWDLvEoVDuAmZ4XJmWuYLCka28HnEmVUWy/Y mR3g== 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=bemAAMKwHkm/QrzhaN6SUzbkxwnZAqXdW9SzvKGjpLY=; b=N77uroOiWFyX/PmjJp/ealPas2EmwJkbRaeNJmz/tBgAcZ2KnmGQHLB8GzVMlHXmaE NNZdYM2vKnWAe+v6S5BYNw1RUl2mVVlRSFgcSm5a05f4O1fF65bnuykz/zxEwP1NzpaD FNaW3SsQYvEi1pPatfyusLWFyYHwb6SVEOhzrRKzGUenyBPrJKyaL2vdM02D3rl6vaaw I6752FH2UCRTtmV9L0ELKP7EzFcKIS/clGmSND8nTzWMoX31MGTcEpMOJN++klhXGm1N m2xouGJoauwUTXwrlA9Mo8TCr2qaI70zz5Ikwk6OHQ/nLfNhmjNF9ArbLqF+of2W7vKf XxXg== X-Gm-Message-State: AGi0PuY5P+ecenCnPsP3QLMZvTeuvGeUslakYvgHEnqRk7LXf+GPqHEC cze/Ma9GaplCisEeAGY/7cuvCixXBKQ= X-Google-Smtp-Source: APiQypIpvzKbB0nA1CbIW638U+YOvCYy4jTP6Sx6J9xC0k5g2D9G5T720CaN6vJxzuPmwI29LIIosQ== X-Received: by 2002:a17:90a:9295:: with SMTP id n21mr1791900pjo.195.1588669936060; Tue, 05 May 2020 02:12:16 -0700 (PDT) Received: from localhost ([122.171.118.46]) by smtp.gmail.com with ESMTPSA id mn1sm1358998pjb.24.2020.05.05.02.12.14 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 May 2020 02:12:15 -0700 (PDT) From: Viresh Kumar To: ltp@lists.linux.it Date: Tue, 5 May 2020 14:42:02 +0530 Message-Id: <379f4d58e86b5249f56ff58e1907dee69d67e451.1588669892.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.25.0.rc1.19.g042ed3e048af In-Reply-To: <7e037dacaeb0c7f3bfd73cd11d80f3e1567dc052.1588669892.git.viresh.kumar@linaro.org> References: <7e037dacaeb0c7f3bfd73cd11d80f3e1567dc052.1588669892.git.viresh.kumar@linaro.org> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.99.2 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,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-4.smtp.seeweb.it Subject: [LTP] [PATCH 2/8] syscalls/futex: 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 futex() syscall tests. Signed-off-by: Viresh Kumar Reviewed-by: Petr Vorel --- include/tst_timer.h | 12 ++ .../syscalls/futex/futex_cmp_requeue01.c | 35 ++++- .../syscalls/futex/futex_cmp_requeue02.c | 25 +++- testcases/kernel/syscalls/futex/futex_utils.h | 52 +++++-- .../kernel/syscalls/futex/futex_wait01.c | 60 +++++--- .../kernel/syscalls/futex/futex_wait02.c | 83 +++++------ .../kernel/syscalls/futex/futex_wait03.c | 70 ++++++---- .../kernel/syscalls/futex/futex_wait04.c | 64 ++++++--- .../kernel/syscalls/futex/futex_wait05.c | 2 +- .../syscalls/futex/futex_wait_bitset01.c | 50 +++++-- .../kernel/syscalls/futex/futex_wake01.c | 52 ++++--- .../kernel/syscalls/futex/futex_wake02.c | 80 ++++++----- .../kernel/syscalls/futex/futex_wake03.c | 92 ++++++------ .../kernel/syscalls/futex/futex_wake04.c | 132 ++++++++++-------- testcases/kernel/syscalls/futex/futextest.h | 111 +++++++++------ 15 files changed, 588 insertions(+), 332 deletions(-) diff --git a/include/tst_timer.h b/include/tst_timer.h index a726298b407d..b4280042c77f 100644 --- a/include/tst_timer.h +++ b/include/tst_timer.h @@ -243,6 +243,18 @@ static inline int sys_clock_nanosleep64(clockid_t clk_id, int flags, request, remain); } +static inline int sys_futex(int *uaddr, int futex_op, int val, void *to, + int *uaddr2, int val3) +{ + return tst_syscall(__NR_futex, uaddr, futex_op, val, to, uaddr2, val3); +} + +static inline int sys_futex_time64(int *uaddr, int futex_op, int val, void *to, + int *uaddr2, int val3) +{ + return tst_syscall(__NR_futex_time64, uaddr, futex_op, val, to, uaddr2, val3); +} + static inline int libc_sched_rr_get_interval(pid_t pid, void *ts) { return sched_rr_get_interval(pid, ts); diff --git a/testcases/kernel/syscalls/futex/futex_cmp_requeue01.c b/testcases/kernel/syscalls/futex/futex_cmp_requeue01.c index c50fade9f969..bc9d2a6bee37 100644 --- a/testcases/kernel/syscalls/futex/futex_cmp_requeue01.c +++ b/testcases/kernel/syscalls/futex/futex_cmp_requeue01.c @@ -18,6 +18,7 @@ #include "tst_timer_test.h" #include "tst_test.h" #include "futextest.h" +#include "lapi/abisize.h" struct shared_data { futex_t futexes[2]; @@ -42,14 +43,33 @@ static struct tcase { {1000, 300, 500}, }; +static struct test_variants { + enum futex_fn_type fntype; + enum tst_ts_type tstype; + char *desc; +} variants[] = { +#if defined(TST_ABI32) + { .fntype = FUTEX_FN_FUTEX, .tstype = TST_KERN_OLD_TIMESPEC, .desc = "syscall with kernel spec32"}, +#endif + +#if defined(TST_ABI64) + { .fntype = FUTEX_FN_FUTEX, .tstype = TST_KERN_TIMESPEC, .desc = "syscall with kernel spec64"}, +#endif + +#if (__NR_futex_time64 != __LTP__NR_INVALID_SYSCALL) + { .fntype = FUTEX_FN_FUTEX64, .tstype = TST_KERN_TIMESPEC, .desc = "syscall time64 with kernel spec64"}, +#endif +}; + static void do_child(void) { + struct test_variants *tv = &variants[tst_variant]; + struct tst_ts usec = tst_ts_from_ms(tv->tstype, max_sleep_ms); int slept_for_ms = 0; - struct timespec usec = tst_timespec_from_ms(max_sleep_ms); int pid = getpid(); int ret = 0; - if (futex_wait(&sd->futexes[0], sd->futexes[0], &usec, 0) == -1) { + if (futex_wait(tv->fntype, &sd->futexes[0], sd->futexes[0], &usec, 0) == -1) { if (errno == EAGAIN) { /* spurious wakeup or signal */ tst_atomic_inc(&sd->spurious); @@ -72,6 +92,7 @@ static void do_child(void) static void verify_futex_cmp_requeue(unsigned int n) { + struct 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]; @@ -104,8 +125,8 @@ static void verify_futex_cmp_requeue(unsigned int n) * specifies an upper limit on the number of waiters that are requeued. * Returns the total number of waiters that were woken up or requeued. */ - TEST(futex_cmp_requeue(&sd->futexes[0], sd->futexes[0], &sd->futexes[1], - tc->set_wakes, tc->set_requeues, 0)); + TEST(futex_cmp_requeue(tv->fntype, &sd->futexes[0], sd->futexes[0], + &sd->futexes[1], tc->set_wakes, tc->set_requeues, 0)); /* Fail if more than requested wakes + requeues were returned */ if (TST_RET > exp_ret) { @@ -115,8 +136,8 @@ static void verify_futex_cmp_requeue(unsigned int n) tst_res(TINFO, "futex_cmp_requeue() returned %ld", TST_RET); } - num_requeues = futex_wake(&sd->futexes[1], tc->num_waiters, 0); - num_waits = futex_wake(&sd->futexes[0], tc->num_waiters, 0); + num_requeues = futex_wake(tv->fntype, &sd->futexes[1], tc->num_waiters, 0); + num_waits = futex_wake(tv->fntype, &sd->futexes[0], tc->num_waiters, 0); tst_atomic_store(1, &sd->test_done); for (i = 0; i < tc->num_waiters; i++) { @@ -178,6 +199,7 @@ static void verify_futex_cmp_requeue(unsigned int n) static void setup(void) { + tst_res(TINFO, "Testing variant: %s", variants[tst_variant].desc); max_sleep_ms = tst_multiply_timeout(5000); sd = SAFE_MMAP(NULL, sizeof(*sd), PROT_READ | PROT_WRITE, @@ -198,5 +220,6 @@ static struct tst_test test = { .cleanup = cleanup, .tcnt = ARRAY_SIZE(tcases), .test = verify_futex_cmp_requeue, + .test_variants = ARRAY_SIZE(variants), .forks_child = 1, }; diff --git a/testcases/kernel/syscalls/futex/futex_cmp_requeue02.c b/testcases/kernel/syscalls/futex/futex_cmp_requeue02.c index 228d8cff6ea0..5559b72a3a45 100644 --- a/testcases/kernel/syscalls/futex/futex_cmp_requeue02.c +++ b/testcases/kernel/syscalls/futex/futex_cmp_requeue02.c @@ -18,6 +18,7 @@ #include "tst_test.h" #include "futextest.h" +#include "lapi/abisize.h" static futex_t *futexes; @@ -32,12 +33,30 @@ static struct tcase { {1, 1, FUTEX_INITIALIZER + 1, EAGAIN}, }; +static struct test_variants { + enum futex_fn_type fntype; + char *desc; +} variants[] = { +#if defined(TST_ABI32) + { .fntype = FUTEX_FN_FUTEX, .desc = "syscall with kernel spec32"}, +#endif + +#if defined(TST_ABI64) + { .fntype = FUTEX_FN_FUTEX, .desc = "syscall with kernel spec64"}, +#endif + +#if (__NR_futex_time64 != __LTP__NR_INVALID_SYSCALL) + { .fntype = FUTEX_FN_FUTEX64, .desc = "syscall time64 with kernel spec64"}, +#endif +}; + static void verify_futex_cmp_requeue(unsigned int n) { + struct test_variants *tv = &variants[tst_variant]; struct tcase *tc = &tcases[n]; - TEST(futex_cmp_requeue(&futexes[0], tc->exp_val, &futexes[1], - tc->set_wakes, tc->set_requeues, 0)); + TEST(futex_cmp_requeue(tv->fntype, &futexes[0], tc->exp_val, + &futexes[1], tc->set_wakes, tc->set_requeues, 0)); if (TST_RET != -1) { tst_res(TFAIL, "futex_cmp_requeue() succeeded unexpectedly"); return; @@ -55,6 +74,7 @@ static void verify_futex_cmp_requeue(unsigned int n) static void setup(void) { + tst_res(TINFO, "Testing variant: %s", variants[tst_variant].desc); futexes = SAFE_MMAP(NULL, sizeof(futex_t) * 2, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_SHARED, -1, 0); @@ -73,6 +93,7 @@ static struct tst_test test = { .cleanup = cleanup, .test = verify_futex_cmp_requeue, .tcnt = ARRAY_SIZE(tcases), + .test_variants = ARRAY_SIZE(variants), .tags = (const struct tst_tag[]) { {"CVE", "2018-6927"}, {"linux-git", "fbe0e839d1e2"}, diff --git a/testcases/kernel/syscalls/futex/futex_utils.h b/testcases/kernel/syscalls/futex/futex_utils.h index 63b97c00b631..f77b9d6b3b8a 100644 --- a/testcases/kernel/syscalls/futex/futex_utils.h +++ b/testcases/kernel/syscalls/futex/futex_utils.h @@ -20,10 +20,13 @@ #ifndef FUTEX_UTILS_H__ #define FUTEX_UTILS_H__ +#include +#include + /* * Wait for nr_threads to be sleeping */ -static int wait_for_threads(unsigned int nr_threads) +static inline int wait_for_threads(unsigned int nr_threads) { char thread_state, name[1024]; DIR *dir; @@ -32,34 +35,63 @@ static int wait_for_threads(unsigned int nr_threads) snprintf(name, sizeof(name), "/proc/%i/task/", getpid()); - dir = SAFE_OPENDIR(NULL, name); + dir = SAFE_OPENDIR(name); - while ((dent = SAFE_READDIR(NULL, dir))) { + while ((dent = SAFE_READDIR(dir))) { /* skip ".", ".." and the main thread */ if (atoi(dent->d_name) == getpid() || atoi(dent->d_name) == 0) continue; snprintf(name, sizeof(name), "/proc/%i/task/%s/stat", - getpid(), dent->d_name); + getpid(), dent->d_name); - SAFE_FILE_SCANF(NULL, name, "%*i %*s %c", &thread_state); + SAFE_FILE_SCANF(name, "%*i %*s %c", &thread_state); if (thread_state != 'S') { - tst_resm(TINFO, "Thread %s not sleeping yet", dent->d_name); - SAFE_CLOSEDIR(NULL, dir); + tst_res(TINFO, "Thread %s not sleeping yet", dent->d_name); + SAFE_CLOSEDIR(dir); return 1; } cnt++; } - SAFE_CLOSEDIR(NULL, dir); + SAFE_CLOSEDIR(dir); if (cnt != nr_threads) { - tst_resm(TINFO, "%u threads sleeping, expected %u", - cnt, nr_threads); + tst_res(TINFO, "%u threads sleeping, expected %u", cnt, + nr_threads); } return 0; } +static inline int process_state_wait2(pid_t pid, const char state) +{ + char proc_path[128], cur_state; + + snprintf(proc_path, sizeof(proc_path), "/proc/%i/stat", pid); + + for (;;) { + FILE *f = fopen(proc_path, "r"); + if (!f) { + tst_res(TFAIL, "Failed to open '%s': %s\n", proc_path, + strerror(errno)); + return 1; + } + + if (fscanf(f, "%*i %*s %c", &cur_state) != 1) { + fclose(f); + tst_res(TFAIL, "Failed to read '%s': %s\n", proc_path, + strerror(errno)); + return 1; + } + fclose(f); + + if (state == cur_state) + return 0; + + usleep(10000); + } +} + #endif /* FUTEX_UTILS_H__ */ diff --git a/testcases/kernel/syscalls/futex/futex_wait01.c b/testcases/kernel/syscalls/futex/futex_wait01.c index 51a540d9e315..e7a283b69f9d 100644 --- a/testcases/kernel/syscalls/futex/futex_wait01.c +++ b/testcases/kernel/syscalls/futex/futex_wait01.c @@ -28,10 +28,8 @@ #include -#include "test.h" #include "futextest.h" - -const char *TCID="futex_wait01"; +#include "lapi/abisize.h" struct testcase { futex_t *f_addr; @@ -41,7 +39,6 @@ struct testcase { }; static futex_t futex = FUTEX_INITIALIZER; -static struct timespec to = {.tv_sec = 0, .tv_nsec = 10000}; static struct testcase testcases[] = { {&futex, FUTEX_INITIALIZER, 0, ETIMEDOUT}, @@ -50,38 +47,59 @@ static struct testcase testcases[] = { {&futex, FUTEX_INITIALIZER+1, FUTEX_PRIVATE_FLAG, EWOULDBLOCK}, }; -const int TST_TOTAL=ARRAY_SIZE(testcases); +static struct test_variants { + enum futex_fn_type fntype; + enum tst_ts_type tstype; + char *desc; +} variants[] = { +#if defined(TST_ABI32) + { .fntype = FUTEX_FN_FUTEX, .tstype = TST_KERN_OLD_TIMESPEC, .desc = "syscall with kernel spec32"}, +#endif + +#if defined(TST_ABI64) + { .fntype = FUTEX_FN_FUTEX, .tstype = TST_KERN_TIMESPEC, .desc = "syscall with kernel spec64"}, +#endif + +#if (__NR_futex_time64 != __LTP__NR_INVALID_SYSCALL) + { .fntype = FUTEX_FN_FUTEX64, .tstype = TST_KERN_TIMESPEC, .desc = "syscall time64 with kernel spec64"}, +#endif +}; -static void verify_futex_wait(struct testcase *tc) +static void run(unsigned int n) { + struct test_variants *tv = &variants[tst_variant]; + struct testcase *tc = &testcases[n]; + static struct tst_ts to; int res; - res = futex_wait(tc->f_addr, tc->f_val, &to, tc->opflags); + to.type = tv->tstype; + tst_ts_set_sec(&to, 0); + tst_ts_set_nsec(&to, 10000); + + res = futex_wait(tv->fntype, tc->f_addr, tc->f_val, &to, tc->opflags); if (res != -1) { - tst_resm(TFAIL, "futex_wait() returned %i, expected -1", res); + tst_res(TFAIL, "futex_wait() succeeded unexpectedly"); return; } if (errno != tc->exp_errno) { - tst_resm(TFAIL | TERRNO, "expected errno=%s", + tst_res(TFAIL | TTERRNO, "futex_wait() failed with incorrect error, expected errno=%s", tst_strerrno(tc->exp_errno)); return; } - tst_resm(TPASS | TERRNO, "futex_wait()"); + tst_res(TPASS | TERRNO, "futex_wait() passed"); } -int main(int argc, char *argv[]) +static void setup(void) { - int lc, i; - - tst_parse_opts(argc, argv, NULL, NULL); - - for (lc = 0; TEST_LOOPING(lc); lc++) { - for (i = 0; i < TST_TOTAL; i++) - verify_futex_wait(testcases + i); - } - - tst_exit(); + tst_res(TINFO, "Testing variant: %s", variants[tst_variant].desc); } + +static struct tst_test test = { + .setup = setup, + .test = run, + .tcnt = ARRAY_SIZE(testcases), + .test_variants = ARRAY_SIZE(variants), +}; diff --git a/testcases/kernel/syscalls/futex/futex_wait02.c b/testcases/kernel/syscalls/futex/futex_wait02.c index 1ca1df457b4a..027d0e9a4eec 100644 --- a/testcases/kernel/syscalls/futex/futex_wait02.c +++ b/testcases/kernel/syscalls/futex/futex_wait02.c @@ -26,80 +26,85 @@ #include #include -#include "test.h" -#include "safe_macros.h" #include "futextest.h" - -const char *TCID="futex_wait02"; -const int TST_TOTAL=1; +#include "futex_utils.h" +#include "lapi/abisize.h" static futex_t *futex; +static struct test_variants { + enum futex_fn_type fntype; + char *desc; +} variants[] = { +#if defined(TST_ABI32) + { .fntype = FUTEX_FN_FUTEX, .desc = "syscall with kernel spec32"}, +#endif + +#if defined(TST_ABI64) + { .fntype = FUTEX_FN_FUTEX, .desc = "syscall with kernel spec64"}, +#endif + +#if (__NR_futex_time64 != __LTP__NR_INVALID_SYSCALL) + { .fntype = FUTEX_FN_FUTEX64, .desc = "syscall time64 with kernel spec64"}, +#endif +}; + static void do_child(void) { + struct test_variants *tv = &variants[tst_variant]; int ret; - tst_process_state_wait2(getppid(), 'S'); + process_state_wait2(getppid(), 'S'); - ret = futex_wake(futex, 1, 0); + ret = futex_wake(tv->fntype, futex, 1, 0); if (ret != 1) - tst_brkm(TFAIL, NULL, "futex_wake() returned %i", ret); + tst_res(TFAIL | TTERRNO, "futex_wake() failed"); - exit(TPASS); + exit(0); } -static void verify_futex_wait(void) +static void run(void) { - int res; - int pid; + struct test_variants *tv = &variants[tst_variant]; + int res, pid; - pid = tst_fork(); + pid = SAFE_FORK(); switch (pid) { case 0: do_child(); - break; - case -1: - tst_brkm(TBROK | TERRNO, NULL, "fork() failed"); - break; default: - break; + break; } - res = futex_wait(futex, *futex, NULL, 0); - + res = futex_wait(tv->fntype, futex, *futex, NULL, 0); if (res) { - tst_resm(TFAIL, "futex_wait() returned %i, errno %s", - res, tst_strerrno(errno)); + tst_res(TFAIL | TTERRNO, "futex_wait() failed"); + return; } - SAFE_WAIT(NULL, &res); + SAFE_WAIT(&res); if (WIFEXITED(res) && WEXITSTATUS(res) == TPASS) - tst_resm(TPASS, "futex_wait() woken up"); + tst_res(TPASS, "futex_wait() woken up"); else - tst_resm(TFAIL, "child failed"); + tst_res(TFAIL, "child failed"); } static void setup(void) { - futex = SAFE_MMAP(NULL, NULL, sizeof(*futex), PROT_READ | PROT_WRITE, + tst_res(TINFO, "Testing variant: %s", variants[tst_variant].desc); + + futex = SAFE_MMAP(NULL, sizeof(*futex), PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_SHARED, -1, 0); *futex = FUTEX_INITIALIZER; } -int main(int argc, char *argv[]) -{ - int lc; - - tst_parse_opts(argc, argv, NULL, NULL); - - setup(); - - for (lc = 0; TEST_LOOPING(lc); lc++) - verify_futex_wait(); - - tst_exit(); -} +static struct tst_test test = { + .setup = setup, + .test_all = run, + .test_variants = ARRAY_SIZE(variants), + .forks_child = 1, +}; diff --git a/testcases/kernel/syscalls/futex/futex_wait03.c b/testcases/kernel/syscalls/futex/futex_wait03.c index 9683e76503c0..d2105716c941 100644 --- a/testcases/kernel/syscalls/futex/futex_wait03.c +++ b/testcases/kernel/syscalls/futex/futex_wait03.c @@ -25,63 +25,79 @@ #include #include -#include "test.h" #include "futextest.h" - -const char *TCID="futex_wait03"; -const int TST_TOTAL=1; +#include "futex_utils.h" +#include "lapi/abisize.h" static futex_t futex = FUTEX_INITIALIZER; +static struct test_variants { + enum futex_fn_type fntype; + char *desc; +} variants[] = { +#if defined(TST_ABI32) + { .fntype = FUTEX_FN_FUTEX, .desc = "syscall with kernel spec32"}, +#endif + +#if defined(TST_ABI64) + { .fntype = FUTEX_FN_FUTEX, .desc = "syscall with kernel spec64"}, +#endif + +#if (__NR_futex_time64 != __LTP__NR_INVALID_SYSCALL) + { .fntype = FUTEX_FN_FUTEX64, .desc = "syscall time64 with kernel spec64"}, +#endif +}; + static void *threaded(void *arg LTP_ATTRIBUTE_UNUSED) { + struct test_variants *tv = &variants[tst_variant]; long ret; - tst_process_state_wait2(getpid(), 'S'); + process_state_wait2(getpid(), 'S'); - ret = futex_wake(&futex, 1, FUTEX_PRIVATE_FLAG); + ret = futex_wake(tv->fntype, &futex, 1, FUTEX_PRIVATE_FLAG); return (void*)ret; } -static void verify_futex_wait(void) +static void run(void) { - long ret; - int res; + struct test_variants *tv = &variants[tst_variant]; + long ret, res; pthread_t t; res = pthread_create(&t, NULL, threaded, NULL); if (res) { - tst_brkm(TBROK, NULL, "pthread_create(): %s", - tst_strerrno(res)); + tst_res(TFAIL | TTERRNO, "pthread_create() failed"); + return; } - res = futex_wait(&futex, futex, NULL, FUTEX_PRIVATE_FLAG); + res = futex_wait(tv->fntype, &futex, futex, NULL, FUTEX_PRIVATE_FLAG); if (res) { - tst_resm(TFAIL, "futex_wait() returned %i, errno %s", - res, tst_strerrno(errno)); + tst_res(TFAIL | TTERRNO, "futex_wait() failed"); pthread_join(t, NULL); return; } res = pthread_join(t, (void*)&ret); - if (res) - tst_brkm(TBROK, NULL, "pthread_join(): %s", tst_strerrno(res)); + if (res) { + tst_res(TFAIL | TTERRNO, "pthread_join() failed"); + return; + } if (ret != 1) - tst_resm(TFAIL, "futex_wake() returned %li", ret); + tst_res(TFAIL, "futex_wake() returned %li", ret); else - tst_resm(TPASS, "futex_wait() woken up"); + tst_res(TPASS, "futex_wait() woken up"); } -int main(int argc, char *argv[]) +static void setup(void) { - int lc; - - tst_parse_opts(argc, argv, NULL, NULL); - - for (lc = 0; TEST_LOOPING(lc); lc++) - verify_futex_wait(); - - tst_exit(); + tst_res(TINFO, "Testing variant: %s", variants[tst_variant].desc); } + +static struct tst_test test = { + .setup = setup, + .test_all = run, + .test_variants = ARRAY_SIZE(variants), +}; diff --git a/testcases/kernel/syscalls/futex/futex_wait04.c b/testcases/kernel/syscalls/futex/futex_wait04.c index b8360ff80914..57085c5dd9c0 100644 --- a/testcases/kernel/syscalls/futex/futex_wait04.c +++ b/testcases/kernel/syscalls/futex/futex_wait04.c @@ -26,40 +26,58 @@ #include -#include "test.h" -#include "safe_macros.h" #include "futextest.h" +#include "lapi/abisize.h" -const char *TCID="futex_wait04"; -const int TST_TOTAL=1; -static struct timespec to = {.tv_sec = 0, .tv_nsec = 10000}; +static struct test_variants { + enum futex_fn_type fntype; + enum tst_ts_type tstype; + char *desc; +} variants[] = { +#if defined(TST_ABI32) + { .fntype = FUTEX_FN_FUTEX, .tstype = TST_KERN_OLD_TIMESPEC, .desc = "syscall with kernel spec32"}, +#endif -static void verify_futex_wait(void) +#if defined(TST_ABI64) + { .fntype = FUTEX_FN_FUTEX, .tstype = TST_KERN_TIMESPEC, .desc = "syscall with kernel spec64"}, +#endif + +#if (__NR_futex_time64 != __LTP__NR_INVALID_SYSCALL) + { .fntype = FUTEX_FN_FUTEX64, .tstype = TST_KERN_TIMESPEC, .desc = "syscall time64 with kernel spec64"}, +#endif +}; + +static void run(void) { - int res; - void *buf; + struct test_variants *tv = &variants[tst_variant]; + static struct tst_ts to; size_t pagesize = getpagesize(); - buf = SAFE_MMAP(NULL, NULL, pagesize, PROT_READ|PROT_WRITE, - MAP_PRIVATE|MAP_ANONYMOUS, 0, 0); + void *buf; + int res; - res = futex_wait(buf, 1, &to, 0); + buf = SAFE_MMAP(NULL, pagesize, PROT_READ|PROT_WRITE, + MAP_PRIVATE|MAP_ANONYMOUS, 0, 0); + to.type = tv->tstype; + tst_ts_set_sec(&to, 0); + tst_ts_set_nsec(&to, 10000); + + res = futex_wait(tv->fntype, buf, 1, &to, 0); if (res == -1 && errno == EWOULDBLOCK) - tst_resm(TPASS | TERRNO, "futex_wait() returned %i", res); + tst_res(TPASS | TERRNO, "futex_wait() returned %i", res); else - tst_resm(TFAIL | TERRNO, "futex_wait() returned %i", res); + tst_res(TFAIL | TERRNO, "futex_wait() returned %i", res); - SAFE_MUNMAP(NULL, buf, pagesize); + SAFE_MUNMAP(buf, pagesize); } -int main(int argc, char *argv[]) +static void setup(void) { - int lc; - - tst_parse_opts(argc, argv, NULL, NULL); - - for (lc = 0; TEST_LOOPING(lc); lc++) - verify_futex_wait(); - - tst_exit(); + tst_res(TINFO, "Testing variant: %s", variants[tst_variant].desc); } + +static struct tst_test test = { + .setup = setup, + .test_all = run, + .test_variants = ARRAY_SIZE(variants), +}; diff --git a/testcases/kernel/syscalls/futex/futex_wait05.c b/testcases/kernel/syscalls/futex/futex_wait05.c index 2573ae177d5b..8fad5d858716 100644 --- a/testcases/kernel/syscalls/futex/futex_wait05.c +++ b/testcases/kernel/syscalls/futex/futex_wait05.c @@ -19,7 +19,7 @@ int sample_fn(int clk_id, long long usec) futex_t futex = FUTEX_INITIALIZER; tst_timer_start(clk_id); - TEST(futex_wait(&futex, futex, &to, 0)); + TEST(syscall(SYS_futex, &futex, FUTEX_WAIT, futex, &to, NULL, 0)); tst_timer_stop(); tst_timer_sample(); diff --git a/testcases/kernel/syscalls/futex/futex_wait_bitset01.c b/testcases/kernel/syscalls/futex/futex_wait_bitset01.c index b8546c3e640c..f3856697a964 100644 --- a/testcases/kernel/syscalls/futex/futex_wait_bitset01.c +++ b/testcases/kernel/syscalls/futex/futex_wait_bitset01.c @@ -12,6 +12,7 @@ #include "tst_test.h" #include "tst_timer.h" #include "futextest.h" +#include "lapi/abisize.h" #define THRESHOLD_US 100000 #define DEFAULT_TIMEOUT_US 100010 @@ -23,22 +24,44 @@ 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[] = { +#if defined(TST_ABI32) + { .fntype = FUTEX_FN_FUTEX, .tstype = TST_KERN_OLD_TIMESPEC, .gettime = sys_clock_gettime, .desc = "syscall with kernel spec32"}, +#endif + +#if defined(TST_ABI64) + { .fntype = FUTEX_FN_FUTEX, .tstype = TST_KERN_TIMESPEC, .gettime = sys_clock_gettime, .desc = "syscall with kernel spec64"}, +#endif + +#if (__NR_futex_time64 != __LTP__NR_INVALID_SYSCALL) + { .fntype = FUTEX_FN_FUTEX64, .tstype = TST_KERN_TIMESPEC, .gettime = sys_clock_gettime64, .desc = "syscall time64 with kernel spec64"}, +#endif +}; + static void verify_futex_wait_bitset(long long wait_us, clock_t clk_id) { - struct timespec start, to, end; + struct test_variants *tv = &variants[tst_variant]; + struct tst_ts start, to, end; futex_t futex = FUTEX_INITIALIZER; u_int32_t bitset = 0xffffffff; int flags = clk_id == CLOCK_REALTIME ? FUTEX_CLOCK_REALTIME : 0; + start.type = end.type = to.type = tv->tstype; + tst_res(TINFO, "testing futex_wait_bitset() timeout with %s", clk_id == CLOCK_REALTIME ? "CLOCK_REALTIME" : "CLOCK_MONOTONIC"); - clock_gettime(clk_id, &start); - to = tst_timespec_add_us(start, wait_us); + tv->gettime(clk_id, tst_ts_get(&start)); + to = tst_ts_add_us(start, wait_us); - TEST(futex_wait_bitset(&futex, futex, &to, bitset, flags)); + TEST(futex_wait_bitset(tv->fntype, &futex, futex, &to, bitset, flags)); - clock_gettime(clk_id, &end); + tv->gettime(clk_id, tst_ts_get(&end)); if (TST_RET != -1) { tst_res(TFAIL, "futex_wait_bitset() returned %li, expected -1", @@ -58,22 +81,22 @@ static void verify_futex_wait_bitset(long long wait_us, clock_t clk_id) return; } - if (tst_timespec_lt(end, to)) { + if (tst_ts_lt(end, to)) { tst_res(TFAIL, "futex_wait_bitset() woken up prematurely %llius, expected %llius", - tst_timespec_diff_us(end, start), wait_us); + tst_ts_diff_us(end, start), wait_us); return; } - if (tst_timespec_diff_us(end, to) > THRESHOLD_US) { + if (tst_ts_diff_us(end, to) > THRESHOLD_US) { tst_res(TFAIL, "futex_wait_bitset() waited too long %llius, expected %llius", - tst_timespec_diff_us(end, start), wait_us); + tst_ts_diff_us(end, start), wait_us); return; } tst_res(TPASS, "futex_wait_bitset() waited %llius, expected %llius", - tst_timespec_diff_us(end, start), wait_us); + tst_ts_diff_us(end, start), wait_us); } static void run(unsigned int n) @@ -82,7 +105,14 @@ static void run(unsigned int n) verify_futex_wait_bitset(DEFAULT_TIMEOUT_US, tcases[n].clk_id); } +static void setup(void) +{ + tst_res(TINFO, "Testing variant: %s", variants[tst_variant].desc); +} + static struct tst_test test = { + .setup = setup, .test = run, .tcnt = ARRAY_SIZE(tcases), + .test_variants = ARRAY_SIZE(variants), }; diff --git a/testcases/kernel/syscalls/futex/futex_wake01.c b/testcases/kernel/syscalls/futex/futex_wake01.c index 42ea6f6e6a75..795f11ed8af1 100644 --- a/testcases/kernel/syscalls/futex/futex_wake01.c +++ b/testcases/kernel/syscalls/futex/futex_wake01.c @@ -23,10 +23,8 @@ #include #include -#include "test.h" #include "futextest.h" - -const char *TCID="futex_wake01"; +#include "lapi/abisize.h" struct testcase { futex_t *f_addr; @@ -46,32 +44,46 @@ static struct testcase testcases[] = { {&futex, INT_MAX, FUTEX_PRIVATE_FLAG}, }; -const int TST_TOTAL=ARRAY_SIZE(testcases); +static struct test_variants { + enum futex_fn_type fntype; + char *desc; +} variants[] = { +#if defined(TST_ABI32) + { .fntype = FUTEX_FN_FUTEX, .desc = "syscall with kernel spec32"}, +#endif + +#if defined(TST_ABI64) + { .fntype = FUTEX_FN_FUTEX, .desc = "syscall with kernel spec64"}, +#endif + +#if (__NR_futex_time64 != __LTP__NR_INVALID_SYSCALL) + { .fntype = FUTEX_FN_FUTEX64, .desc = "syscall time64 with kernel spec64"}, +#endif +}; -static void verify_futex_wake(struct testcase *tc) +static void run(unsigned int n) { + struct test_variants *tv = &variants[tst_variant]; + struct testcase *tc = &testcases[n]; int res; - res = futex_wake(tc->f_addr, tc->nr_wake, tc->opflags); - + res = futex_wake(tv->fntype, tc->f_addr, tc->nr_wake, tc->opflags); if (res != 0) { - tst_resm(TFAIL, "futex_wake() returned %i, expected 0", res); + tst_res(TFAIL | TTERRNO, "futex_wake() failed"); return; } - tst_resm(TPASS, "futex_wake() returned 0"); + tst_res(TPASS, "futex_wake() passed"); } -int main(int argc, char *argv[]) +static void setup(void) { - int lc, i; - - tst_parse_opts(argc, argv, NULL, NULL); - - for (lc = 0; TEST_LOOPING(lc); lc++) { - for (i = 0; i < TST_TOTAL; i++) - verify_futex_wake(testcases + i); - } - - tst_exit(); + tst_res(TINFO, "Testing variant: %s", variants[tst_variant].desc); } + +static struct tst_test test = { + .setup = setup, + .test = run, + .tcnt = ARRAY_SIZE(testcases), + .test_variants = ARRAY_SIZE(variants), +}; diff --git a/testcases/kernel/syscalls/futex/futex_wake02.c b/testcases/kernel/syscalls/futex/futex_wake02.c index 8a4c2d58e4b9..d1030529c082 100644 --- a/testcases/kernel/syscalls/futex/futex_wake02.c +++ b/testcases/kernel/syscalls/futex/futex_wake02.c @@ -22,19 +22,33 @@ #include #include +#include -#include "test.h" -#include "safe_macros.h" #include "futextest.h" #include "futex_utils.h" - -const char *TCID="futex_wake02"; -const int TST_TOTAL=11; +#include "lapi/abisize.h" static futex_t futex = FUTEX_INITIALIZER; static volatile int threads_flags[55]; +static struct test_variants { + enum futex_fn_type fntype; + char *desc; +} variants[] = { +#if defined(TST_ABI32) + { .fntype = FUTEX_FN_FUTEX, .desc = "syscall with kernel spec32"}, +#endif + +#if defined(TST_ABI64) + { .fntype = FUTEX_FN_FUTEX, .desc = "syscall with kernel spec64"}, +#endif + +#if (__NR_futex_time64 != __LTP__NR_INVALID_SYSCALL) + { .fntype = FUTEX_FN_FUTEX64, .desc = "syscall time64 with kernel spec64"}, +#endif +}; + static int threads_awake(void) { int ret = 0; @@ -58,9 +72,10 @@ static void clear_threads_awake(void) static void *threaded(void *arg) { + struct test_variants *tv = &variants[tst_variant]; long i = (long)arg; - futex_wait(&futex, futex, NULL, FUTEX_PRIVATE_FLAG); + futex_wait(tv->fntype, &futex, futex, NULL, FUTEX_PRIVATE_FLAG); threads_flags[i] = 1; @@ -69,14 +84,15 @@ static void *threaded(void *arg) static void do_child(void) { + struct test_variants *tv = &variants[tst_variant]; int res, i, j, awake; pthread_t t[55]; for (i = 0; i < (int)ARRAY_SIZE(t); i++) { res = pthread_create(&t[i], NULL, threaded, (void*)((long)i)); if (res) { - tst_brkm(TBROK, NULL, "pthread_create(): %s", - tst_strerrno(res)); + tst_res(TFAIL | TTERRNO, "pthread_create() failed"); + return; } } @@ -85,9 +101,9 @@ static void do_child(void) for (i = 1; i <= 10; i++) { clear_threads_awake(); - res = futex_wake(&futex, i, FUTEX_PRIVATE_FLAG); + res = futex_wake(tv->fntype, &futex, i, FUTEX_PRIVATE_FLAG); if (i != res) { - tst_resm(TFAIL, + tst_res(TFAIL | TTERRNO, "futex_wake() woken up %i threads, expected %i", res, i); } @@ -101,26 +117,26 @@ static void do_child(void) } if (awake == i) { - tst_resm(TPASS, "futex_wake() woken up %i threads", i); + tst_res(TPASS, "futex_wake() woken up %i threads", i); } else { - tst_resm(TFAIL, "Woken up %i threads, expected %i", - awake, i); + tst_res(TFAIL | TTERRNO, "Woken up %i threads, expected %i", + awake, i); } } - res = futex_wake(&futex, 1, FUTEX_PRIVATE_FLAG); + res = futex_wake(tv->fntype, &futex, 1, FUTEX_PRIVATE_FLAG); if (res) { - tst_resm(TFAIL, "futex_wake() woken up %i, none were waiting", - res); + tst_res(TFAIL | TTERRNO, "futex_wake() woken up %i, none were waiting", + res); } else { - tst_resm(TPASS, "futex_wake() woken up 0 threads"); + tst_res(TPASS, "futex_wake() woken up 0 threads"); } for (i = 0; i < (int)ARRAY_SIZE(t); i++) pthread_join(t[i], NULL); - tst_exit(); + exit(0); } /* @@ -135,30 +151,28 @@ static void do_child(void) * under /proc/$PID/tasks/, but the subsequent open() fails with ENOENT because * the thread was removed meanwhile. */ -static void verify_futex_wake(void) +static void run(void) { - int pid; + int status, pid; - pid = tst_fork(); + pid = SAFE_FORK(); switch (pid) { case 0: do_child(); - case -1: - tst_brkm(TBROK | TERRNO, NULL, "fork() failed"); default: - tst_record_childstatus(NULL, pid); + SAFE_WAITPID(pid, &status, 0); } } -int main(int argc, char *argv[]) +static void setup(void) { - int lc; - - tst_parse_opts(argc, argv, NULL, NULL); - - for (lc = 0; TEST_LOOPING(lc); lc++) - verify_futex_wake(); - - tst_exit(); + tst_res(TINFO, "Testing variant: %s", variants[tst_variant].desc); } + +static struct tst_test test = { + .setup = setup, + .test_all = run, + .test_variants = ARRAY_SIZE(variants), + .forks_child = 1, +}; diff --git a/testcases/kernel/syscalls/futex/futex_wake03.c b/testcases/kernel/syscalls/futex/futex_wake03.c index d6e5e5422db9..5af9093c0178 100644 --- a/testcases/kernel/syscalls/futex/futex_wake03.c +++ b/testcases/kernel/syscalls/futex/futex_wake03.c @@ -24,31 +24,48 @@ #include #include -#include "test.h" -#include "safe_macros.h" #include "futextest.h" - -const char *TCID="futex_wake03"; -const int TST_TOTAL=11; +#include "futex_utils.h" +#include "lapi/abisize.h" static futex_t *futex; +static struct test_variants { + enum futex_fn_type fntype; + char *desc; +} variants[] = { +#if defined(TST_ABI32) + { .fntype = FUTEX_FN_FUTEX, .desc = "syscall with kernel spec32"}, +#endif + +#if defined(TST_ABI64) + { .fntype = FUTEX_FN_FUTEX, .desc = "syscall with kernel spec64"}, +#endif + +#if (__NR_futex_time64 != __LTP__NR_INVALID_SYSCALL) + { .fntype = FUTEX_FN_FUTEX64, .desc = "syscall time64 with kernel spec64"}, +#endif +}; + static void do_child(void) { - futex_wait(futex, *futex, NULL, 0); + struct test_variants *tv = &variants[tst_variant]; + + futex_wait(tv->fntype, futex, *futex, NULL, 0); exit(0); } static void do_wake(int nr_children) { + struct test_variants *tv = &variants[tst_variant]; int res, i, cnt; - res = futex_wake(futex, nr_children, 0); + res = futex_wake(tv->fntype, futex, nr_children, 0); if (res != nr_children) { - tst_resm(TFAIL, - "futex_wake() woken up %i children, expected %i", - res, nr_children); + tst_res(TFAIL | TTERRNO, + "futex_wake() woken up %i children, expected %i", + res, nr_children); return; } @@ -63,65 +80,60 @@ static void do_wake(int nr_children) } if (cnt != nr_children) { - tst_resm(TFAIL, "reaped only %i childs, expected %i", - cnt, nr_children); + tst_res(TFAIL | TTERRNO, "reaped only %i childs, expected %i", + cnt, nr_children); } else { - tst_resm(TPASS, "futex_wake() woken up %i childs", cnt); + tst_res(TPASS, "futex_wake() woken up %i childs", cnt); } } -static void verify_futex_wake(void) +static void run(void) { - int i, res; + struct test_variants *tv = &variants[tst_variant]; pid_t pids[55]; + unsigned int i; + int res; - for (i = 0; i < (int)ARRAY_SIZE(pids); i++) { - pids[i] = tst_fork(); + for (i = 0; i < ARRAY_SIZE(pids); i++) { + pids[i] = SAFE_FORK(); switch (pids[i]) { - case -1: - tst_brkm(TBROK | TERRNO, NULL, "fork()"); case 0: do_child(); default: - break; + break; } } - for (i = 0; i < (int)ARRAY_SIZE(pids); i++) - tst_process_state_wait2(pids[i], 'S'); + for (i = 0; i < ARRAY_SIZE(pids); i++) + process_state_wait2(pids[i], 'S'); for (i = 1; i <= 10; i++) do_wake(i); - res = futex_wake(futex, 1, 0); + res = futex_wake(tv->fntype, futex, 1, 0); if (res) { - tst_resm(TFAIL, "futex_wake() woken up %u, none were waiting", - res); + tst_res(TFAIL | TTERRNO, "futex_wake() woken up %u, none were waiting", + res); } else { - tst_resm(TPASS, "futex_wake() woken up 0 children"); + tst_res(TPASS, "futex_wake() woken up 0 children"); } } static void setup(void) { - futex = SAFE_MMAP(NULL, NULL, sizeof(*futex), PROT_READ | PROT_WRITE, + tst_res(TINFO, "Testing variant: %s", variants[tst_variant].desc); + + futex = SAFE_MMAP(NULL, sizeof(*futex), PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_SHARED, -1, 0); *futex = FUTEX_INITIALIZER; } -int main(int argc, char *argv[]) -{ - int lc; - - tst_parse_opts(argc, argv, NULL, NULL); - - setup(); - - for (lc = 0; TEST_LOOPING(lc); lc++) - verify_futex_wake(); - - tst_exit(); -} +static struct tst_test test = { + .setup = setup, + .test_all = run, + .test_variants = ARRAY_SIZE(variants), + .forks_child = 1, +}; diff --git a/testcases/kernel/syscalls/futex/futex_wake04.c b/testcases/kernel/syscalls/futex/futex_wake04.c index f92bda53f6c7..f063c48c4449 100644 --- a/testcases/kernel/syscalls/futex/futex_wake04.c +++ b/testcases/kernel/syscalls/futex/futex_wake04.c @@ -42,53 +42,63 @@ #include #include -#include "test.h" -#include "safe_macros.h" #include "futextest.h" #include "futex_utils.h" #include "lapi/mmap.h" +#include "lapi/abisize.h" +#include "tst_safe_stdio.h" #define PATH_MEMINFO "/proc/meminfo" #define PATH_NR_HUGEPAGES "/proc/sys/vm/nr_hugepages" #define PATH_HUGEPAGES "/sys/kernel/mm/hugepages/" -const char *TCID = "futex_wake04"; -const int TST_TOTAL = 1; - static futex_t *futex1, *futex2; -static struct timespec to = {.tv_sec = 30, .tv_nsec = 0}; +static struct tst_ts to; static long orig_hugepages; +static struct test_variants { + enum futex_fn_type fntype; + enum tst_ts_type tstype; + char *desc; +} variants[] = { +#if defined(TST_ABI32) + { .fntype = FUTEX_FN_FUTEX, .tstype = TST_KERN_OLD_TIMESPEC, .desc = "syscall with kernel spec32"}, +#endif + +#if defined(TST_ABI64) + { .fntype = FUTEX_FN_FUTEX, .tstype = TST_KERN_TIMESPEC, .desc = "syscall with kernel spec64"}, +#endif + +#if (__NR_futex_time64 != __LTP__NR_INVALID_SYSCALL) + { .fntype = FUTEX_FN_FUTEX64, .tstype = TST_KERN_TIMESPEC, .desc = "syscall time64 with kernel spec64"}, +#endif +}; + static void setup(void) { - tst_require_root(); + struct test_variants *tv = &variants[tst_variant]; - if ((tst_kvercmp(2, 6, 32)) < 0) { - tst_brkm(TCONF, NULL, "This test can only run on kernels " - "that are 2.6.32 or higher"); - } + tst_res(TINFO, "Testing variant: %s", tv->desc); - if (access(PATH_HUGEPAGES, F_OK)) - tst_brkm(TCONF, NULL, "Huge page is not supported."); + to.type = tv->tstype; + tst_ts_set_sec(&to, 30); + tst_ts_set_nsec(&to, 0); - tst_tmpdir(); + if (access(PATH_HUGEPAGES, F_OK)) + tst_brk(TCONF, "Huge page is not supported."); - SAFE_FILE_SCANF(NULL, PATH_NR_HUGEPAGES, "%ld", &orig_hugepages); + SAFE_FILE_SCANF(PATH_NR_HUGEPAGES, "%ld", &orig_hugepages); if (orig_hugepages <= 0) - SAFE_FILE_PRINTF(NULL, PATH_NR_HUGEPAGES, "%d", 1); - - TEST_PAUSE; + SAFE_FILE_PRINTF(PATH_NR_HUGEPAGES, "%d", 1); } static void cleanup(void) { if (orig_hugepages <= 0) - SAFE_FILE_PRINTF(NULL, PATH_NR_HUGEPAGES, "%ld", orig_hugepages); - - tst_rmdir(); + SAFE_FILE_PRINTF(PATH_NR_HUGEPAGES, "%ld", orig_hugepages); } static int read_hugepagesize(void) @@ -97,60 +107,64 @@ static int read_hugepagesize(void) char line[BUFSIZ], buf[BUFSIZ]; int val; - fp = SAFE_FOPEN(cleanup, PATH_MEMINFO, "r"); + fp = SAFE_FOPEN(PATH_MEMINFO, "r"); while (fgets(line, BUFSIZ, fp) != NULL) { if (sscanf(line, "%64s %d", buf, &val) == 2) if (strcmp(buf, "Hugepagesize:") == 0) { - SAFE_FCLOSE(cleanup, fp); + SAFE_FCLOSE(fp); return 1024 * val; } } - SAFE_FCLOSE(cleanup, fp); - tst_brkm(TBROK, NULL, "can't find \"%s\" in %s", - "Hugepagesize:", PATH_MEMINFO); + SAFE_FCLOSE(fp); + tst_res(TFAIL, "can't find \"%s\" in %s", "Hugepagesize:", + PATH_MEMINFO); + return 0; } static void *wait_thread1(void *arg LTP_ATTRIBUTE_UNUSED) { - futex_wait(futex1, *futex1, &to, 0); + struct test_variants *tv = &variants[tst_variant]; + + futex_wait(tv->fntype, futex1, *futex1, &to, 0); return NULL; } static void *wait_thread2(void *arg LTP_ATTRIBUTE_UNUSED) { + struct test_variants *tv = &variants[tst_variant]; int res; - res = futex_wait(futex2, *futex2, &to, 0); + res = futex_wait(tv->fntype, futex2, *futex2, &to, 0); if (!res) - tst_resm(TPASS, "Hi hydra, thread2 awake!"); + tst_res(TPASS, "Hi hydra, thread2 awake!"); else - tst_resm(TFAIL, "Bug: wait_thread2 did not wake after 30 secs."); + tst_res(TFAIL | TTERRNO, "Bug: wait_thread2 did not wake after 30 secs."); return NULL; } static void wakeup_thread2(void) { + struct test_variants *tv = &variants[tst_variant]; void *addr; int hpsz, pgsz, res; pthread_t th1, th2; hpsz = read_hugepagesize(); - tst_resm(TINFO, "Hugepagesize %i", hpsz); + tst_res(TINFO, "Hugepagesize %i", hpsz); /*allocate some shared memory*/ addr = mmap(NULL, hpsz, PROT_WRITE | PROT_READ, MAP_SHARED | MAP_ANONYMOUS | MAP_HUGETLB, -1, 0); if (addr == MAP_FAILED) { - if (errno == ENOMEM) { - tst_brkm(TCONF, NULL, - "Cannot allocate hugepage, memory too fragmented?"); - } + if (errno == ENOMEM) + tst_res(TCONF, "Cannot allocate hugepage, memory too fragmented?"); - tst_brkm(TBROK | TERRNO, NULL, "Cannot allocate hugepage"); + tst_res(TFAIL | TERRNO, "Cannot allocate hugepage"); + return; } pgsz = getpagesize(); @@ -165,45 +179,47 @@ static void wakeup_thread2(void) /*thread1 block on futex1 first,then thread2 block on futex2*/ res = pthread_create(&th1, NULL, wait_thread1, NULL); if (res) { - tst_brkm(TBROK, NULL, "pthread_create(): %s", - tst_strerrno(res)); + tst_res(TFAIL | TTERRNO, "pthread_create() failed"); + return; } res = pthread_create(&th2, NULL, wait_thread2, NULL); if (res) { - tst_brkm(TBROK, NULL, "pthread_create(): %s", - tst_strerrno(res)); + tst_res(TFAIL | TTERRNO, "pthread_create() failed"); + return; } while (wait_for_threads(2)) usleep(1000); - futex_wake(futex2, 1, 0); + futex_wake(tv->fntype, futex2, 1, 0); res = pthread_join(th2, NULL); - if (res) - tst_brkm(TBROK, NULL, "pthread_join(): %s", tst_strerrno(res)); + if (res) { + tst_res(TFAIL | TTERRNO, "pthread_join() failed"); + return; + } - futex_wake(futex1, 1, 0); + futex_wake(tv->fntype, futex1, 1, 0); res = pthread_join(th1, NULL); if (res) - tst_brkm(TBROK, NULL, "pthread_join(): %s", tst_strerrno(res)); + tst_res(TFAIL | TTERRNO, "pthread_join() failed"); - SAFE_MUNMAP(NULL, addr, hpsz); + SAFE_MUNMAP(addr, hpsz); } -int main(int argc, char *argv[]) +static void run(void) { - int lc; - - tst_parse_opts(argc, argv, NULL, NULL); - - setup(); - - for (lc = 0; TEST_LOOPING(lc); lc++) - wakeup_thread2(); - - cleanup(); - tst_exit(); + wakeup_thread2(); } + +static struct tst_test test = { + .setup = setup, + .cleanup = cleanup, + .test_all = run, + .test_variants = ARRAY_SIZE(variants), + .needs_root = 1, + .min_kver = "2.6.32", + .needs_tmpdir = 1, +}; diff --git a/testcases/kernel/syscalls/futex/futextest.h b/testcases/kernel/syscalls/futex/futextest.h index 5754d36dae51..a9dcbbedd249 100644 --- a/testcases/kernel/syscalls/futex/futextest.h +++ b/testcases/kernel/syscalls/futex/futextest.h @@ -39,6 +39,7 @@ #include #include #include "lapi/futex.h" +#include "tst_timer.h" #define FUTEX_INITIALIZER 0 @@ -82,18 +83,24 @@ # define FUTEX_CLOCK_REALTIME 256 #endif +enum futex_fn_type { + FUTEX_FN_FUTEX, + FUTEX_FN_FUTEX64, +}; + /** - * futex() - SYS_futex syscall wrapper + * futex_syscall() - futex syscall wrapper + * @fntype: Futex function type * @uaddr: address of first futex * @op: futex op code * @val: typically expected value of uaddr, but varies by op - * @timeout: typically an absolute struct timespec (except where noted + * @timeout: typically an absolute struct tst_ts (except where noted * otherwise). Overloaded by some ops * @uaddr2: address of second futex for some ops\ * @val3: varies by op * @opflags: flags to be bitwise OR'd with op, such as FUTEX_PRIVATE_FLAG * - * futex() is used by all the following futex op wrappers. It can also be + * futex_syscall() is used by all the following futex op wrappers. It can also be * used for misuse and abuse testing. Generally, the specific op wrappers * should be used instead. It is a macro instead of an static inline function as * some of the types over overloaded (timeout is used for nr_requeue for @@ -102,17 +109,30 @@ * These argument descriptions are the defaults for all * like-named arguments in the following wrappers except where noted below. */ -#define futex(uaddr, op, val, timeout, uaddr2, val3, opflags) \ - syscall(SYS_futex, uaddr, op | opflags, val, timeout, uaddr2, val3) +static inline int futex_syscall(enum futex_fn_type fntype, futex_t *uaddr, + int futex_op, futex_t val, void *timeout, + futex_t *uaddr2, int val3, int opflags) +{ + int (*func)(int *uaddr, int futex_op, int val, void *to, int *uaddr2, int val3); + + if (fntype == FUTEX_FN_FUTEX) + func = sys_futex; + else + func = sys_futex_time64; + + return func((int *)uaddr, futex_op | opflags, val, timeout, (int *)uaddr2, val3); +} /** * futex_wait() - block on uaddr with optional timeout * @timeout: relative timeout */ static inline int -futex_wait(futex_t *uaddr, futex_t val, struct timespec *timeout, int opflags) +futex_wait(enum futex_fn_type fntype, futex_t *uaddr, futex_t val, + struct tst_ts *timeout, int opflags) { - return futex(uaddr, FUTEX_WAIT, val, timeout, NULL, 0, opflags); + return futex_syscall(fntype, uaddr, FUTEX_WAIT, val, + tst_ts_get(timeout), NULL, 0, opflags); } /** @@ -120,9 +140,10 @@ futex_wait(futex_t *uaddr, futex_t val, struct timespec *timeout, int opflags) * @nr_wake: wake up to this many tasks */ static inline int -futex_wake(futex_t *uaddr, int nr_wake, int opflags) +futex_wake(enum futex_fn_type fntype, futex_t *uaddr, int nr_wake, int opflags) { - return futex(uaddr, FUTEX_WAKE, nr_wake, NULL, NULL, 0, opflags); + return futex_syscall(fntype, uaddr, FUTEX_WAKE, nr_wake, NULL, NULL, 0, + opflags); } /** @@ -130,11 +151,11 @@ futex_wake(futex_t *uaddr, int nr_wake, int opflags) * @bitset: bitset to be used with futex_wake_bitset */ static inline int -futex_wait_bitset(futex_t *uaddr, futex_t val, struct timespec *timeout, - u_int32_t bitset, int opflags) +futex_wait_bitset(enum futex_fn_type fntype, futex_t *uaddr, futex_t val, + struct tst_ts *timeout, u_int32_t bitset, int opflags) { - return futex(uaddr, FUTEX_WAIT_BITSET, val, timeout, NULL, bitset, - opflags); + return futex_syscall(fntype, uaddr, FUTEX_WAIT_BITSET, val, + tst_ts_get(timeout), NULL, bitset, opflags); } /** @@ -142,10 +163,11 @@ futex_wait_bitset(futex_t *uaddr, futex_t val, struct timespec *timeout, * @bitset: bitset to compare with that used in futex_wait_bitset */ static inline int -futex_wake_bitset(futex_t *uaddr, int nr_wake, u_int32_t bitset, int opflags) +futex_wake_bitset(enum futex_fn_type fntype, futex_t *uaddr, int nr_wake, + u_int32_t bitset, int opflags) { - return futex(uaddr, FUTEX_WAKE_BITSET, nr_wake, NULL, NULL, bitset, - opflags); + return futex_syscall(fntype, uaddr, FUTEX_WAKE_BITSET, nr_wake, NULL, + NULL, bitset, opflags); } /** @@ -153,30 +175,32 @@ futex_wake_bitset(futex_t *uaddr, int nr_wake, u_int32_t bitset, int opflags) * @detect: whether (1) or not (0) to perform deadlock detection */ static inline int -futex_lock_pi(futex_t *uaddr, struct timespec *timeout, int detect, - int opflags) +futex_lock_pi(enum futex_fn_type fntype, futex_t *uaddr, struct tst_ts *timeout, + int detect, int opflags) { - return futex(uaddr, FUTEX_LOCK_PI, detect, timeout, NULL, 0, opflags); + return futex_syscall(fntype, uaddr, FUTEX_LOCK_PI, detect, + tst_ts_get(timeout), NULL, 0, opflags); } /** * futex_unlock_pi() - release uaddr as a PI mutex, waking the top waiter */ static inline int -futex_unlock_pi(futex_t *uaddr, int opflags) +futex_unlock_pi(enum futex_fn_type fntype, futex_t *uaddr, int opflags) { - return futex(uaddr, FUTEX_UNLOCK_PI, 0, NULL, NULL, 0, opflags); -} + return futex_syscall(fntype, uaddr, FUTEX_UNLOCK_PI, 0, NULL, NULL, 0, + opflags); } /** * futex_wake_op() - FIXME: COME UP WITH A GOOD ONE LINE DESCRIPTION */ static inline int -futex_wake_op(futex_t *uaddr, futex_t *uaddr2, int nr_wake, int nr_wake2, - int wake_op, int opflags) +futex_wake_op(enum futex_fn_type fntype, futex_t *uaddr, futex_t *uaddr2, + int nr_wake, int nr_wake2, int wake_op, int opflags) { - return futex(uaddr, FUTEX_WAKE_OP, nr_wake, nr_wake2, uaddr2, wake_op, - opflags); + return futex_syscall(fntype, uaddr, FUTEX_WAKE_OP, nr_wake, + (void *)((unsigned long)nr_wake2), uaddr2, wake_op, + opflags); } /** @@ -188,11 +212,12 @@ futex_wake_op(futex_t *uaddr, futex_t *uaddr2, int nr_wake, int nr_wake2, * favor of futex_cmp_requeue(). */ static inline int -futex_requeue(futex_t *uaddr, futex_t *uaddr2, int nr_wake, int nr_requeue, - int opflags) +futex_requeue(enum futex_fn_type fntype, futex_t *uaddr, futex_t *uaddr2, + int nr_wake, int nr_requeue, int opflags) { - return futex(uaddr, FUTEX_REQUEUE, nr_wake, nr_requeue, uaddr2, 0, - opflags); + return futex_syscall(fntype, uaddr, FUTEX_REQUEUE, nr_wake, + (void *)((unsigned long)nr_requeue), uaddr2, 0, + opflags); } /** @@ -201,11 +226,12 @@ futex_requeue(futex_t *uaddr, futex_t *uaddr2, int nr_wake, int nr_requeue, * @nr_requeue: requeue up to this many tasks */ static inline int -futex_cmp_requeue(futex_t *uaddr, futex_t val, futex_t *uaddr2, int nr_wake, - int nr_requeue, int opflags) +futex_cmp_requeue(enum futex_fn_type fntype, futex_t *uaddr, futex_t val, + futex_t *uaddr2, int nr_wake, int nr_requeue, int opflags) { - return futex(uaddr, FUTEX_CMP_REQUEUE, nr_wake, nr_requeue, uaddr2, - val, opflags); + return futex_syscall(fntype, uaddr, FUTEX_CMP_REQUEUE, nr_wake, + (void *)((unsigned long)nr_requeue), uaddr2, val, + opflags); } /** @@ -217,11 +243,11 @@ futex_cmp_requeue(futex_t *uaddr, futex_t val, futex_t *uaddr2, int nr_wake, * paired with futex_cmp_requeue_pi(). */ static inline int -futex_wait_requeue_pi(futex_t *uaddr, futex_t val, futex_t *uaddr2, - struct timespec *timeout, int opflags) +futex_wait_requeue_pi(enum futex_fn_type fntype, futex_t *uaddr, futex_t val, + futex_t *uaddr2, struct tst_ts *timeout, int opflags) { - return futex(uaddr, FUTEX_WAIT_REQUEUE_PI, val, timeout, uaddr2, 0, - opflags); + return futex_syscall(fntype, uaddr, FUTEX_WAIT_REQUEUE_PI, val, + tst_ts_get(timeout), uaddr2, 0, opflags); } /** @@ -232,11 +258,12 @@ futex_wait_requeue_pi(futex_t *uaddr, futex_t val, futex_t *uaddr2, * @nr_requeue: requeue up to this many tasks */ static inline int -futex_cmp_requeue_pi(futex_t *uaddr, futex_t val, futex_t *uaddr2, int nr_wake, - int nr_requeue, int opflags) +futex_cmp_requeue_pi(enum futex_fn_type fntype, futex_t *uaddr, futex_t val, + futex_t *uaddr2, int nr_wake, int nr_requeue, int opflags) { - return futex(uaddr, FUTEX_CMP_REQUEUE_PI, nr_wake, nr_requeue, uaddr2, val, - opflags); + return futex_syscall(fntype, uaddr, FUTEX_CMP_REQUEUE_PI, nr_wake, + (void *)((unsigned long)nr_requeue), uaddr2, val, + opflags); } /** From patchwork Tue May 5 09:12:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 1283383 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=vu/0hDlI; 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 49GYsQ3dRWz9sSk for ; Tue, 5 May 2020 19:12:42 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id DE4963C5811 for ; Tue, 5 May 2020 11:12:39 +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 B80513C57FF for ; Tue, 5 May 2020 11:12:21 +0200 (CEST) Received: from mail-pl1-x642.google.com (mail-pl1-x642.google.com [IPv6:2607:f8b0:4864:20::642]) (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 AC8956009E8 for ; Tue, 5 May 2020 11:12:08 +0200 (CEST) Received: by mail-pl1-x642.google.com with SMTP id s10so570614plr.1 for ; Tue, 05 May 2020 02:12:20 -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=53MIWNOl3rWxmNN/ZYA8LeZSTRKvJ93ltqDKbqzVRd0=; b=vu/0hDlIfwXTYrzZu8zD2gb7EmF3+xTv1K1mTCKCzfLhco6pW5d1XUcOqpcAANztZ+ 1eajC0MVZ7JGdwji3Qobm6rhoXdsiyTdPMJ4PNsQVQhb9gGBIJCw7lRiphxh7ZHwstpk 4lUcmxZwLiT1a6DlpLWsQKLbhKNJo/vAj4zv6yfmyliWGyiRVgXCCCGDzqi35wo09+9R xHtTXC1fSMyssskqOhVi1aKZMjMsxc7lv9apFCvq24pRtatvWVBsRcJEDg2euCIWow4X eWkMNUGIiiyRqE3sRvSggEiRy+yM3pbjQySIlftT5R/2KYF6ToJUgg+biHPoB472KiIN MxfQ== 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=53MIWNOl3rWxmNN/ZYA8LeZSTRKvJ93ltqDKbqzVRd0=; b=eR9s2JuqeTpMsvMMeonVGFWgYJJk6Q5ZEq1pAFwtMznSHl6O2mY6irKC+eQ8fqPSEU b8fZ0S4ZTtxt2TrYbhRyLoEWz/PvyNWubflLOyzzr1wSnm6ZvWNSl8bA/9rJBAYzB9jY 6azW8de3tLUKumml9CutGZYICIRm6AwoQqh0hCKzvRhimA6qPCogw9nCRR2B8Nq5HYHs 8J098tcBeNInvMUryi5FJ1PYQfc2JP6FEo1Gi9a7WGC+cQ3IBkCQaK8O8Ry3zAdmkEtG 6Bk9T5Ldx0YwfgrtbIIMo560TZFulkotYDLQ9sHiEWqlDK8QijRe8N/awcq7jakSskaq Yi2w== X-Gm-Message-State: AGi0Pubq/BhD3JdGOQjxaNaSBGNQRK5QJJ4No8ONYBwR6iu5fHJhcyqb Kg+uZndUSFGtBpm4cskxj7jkUvv0/H0= X-Google-Smtp-Source: APiQypLUfoiQ8jx+JSH8BzE/+FkFX0rnonBoVxOwPb13DcyIwkK8D8nN7SnztyJZcRmDDkF3MMGLXA== X-Received: by 2002:a17:902:a981:: with SMTP id bh1mr2225535plb.43.1588669938718; Tue, 05 May 2020 02:12:18 -0700 (PDT) Received: from localhost ([122.171.118.46]) by smtp.gmail.com with ESMTPSA id v133sm1502986pfc.113.2020.05.05.02.12.17 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 May 2020 02:12:18 -0700 (PDT) From: Viresh Kumar To: ltp@lists.linux.it Date: Tue, 5 May 2020 14:42:03 +0530 Message-Id: X-Mailer: git-send-email 2.25.0.rc1.19.g042ed3e048af In-Reply-To: <7e037dacaeb0c7f3bfd73cd11d80f3e1567dc052.1588669892.git.viresh.kumar@linaro.org> References: <7e037dacaeb0c7f3bfd73cd11d80f3e1567dc052.1588669892.git.viresh.kumar@linaro.org> 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 3/8] 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 | 41 ++++++++++++- .../syscalls/io_pgetevents/io_pgetevents02.c | 59 +++++++++++++++---- 3 files changed, 97 insertions(+), 18 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 50d2c5f9a3ab..f99879c07ea6 100644 --- a/testcases/kernel/syscalls/io_pgetevents/io_pgetevents01.c +++ b/testcases/kernel/syscalls/io_pgetevents/io_pgetevents01.c @@ -6,11 +6,38 @@ * Basic io_pgetevents() test to receive 1 event successfully. */ #include "tst_test.h" +#include "tst_timer.h" #include "lapi/io_pgetevents.h" +#include "lapi/abisize.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 defined(TST_ABI32) + { .io_pgetevents = sys_io_pgetevents, .type = TST_LIBC_TIMESPEC, .desc = "syscall with libc spec"}, + { .io_pgetevents = sys_io_pgetevents, .type = TST_KERN_OLD_TIMESPEC, .desc = "syscall with kernel spec32"}, +#endif + +#if defined(TST_ABI64) + { .io_pgetevents = sys_io_pgetevents, .type = TST_KERN_TIMESPEC, .desc = "syscall with kernel spec64"}, +#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 spec64"}, +#endif +}; + +static void setup(void) +{ + tst_res(TINFO, "Testing variant: %s", variants[tst_variant].desc); +} + static void cleanup(void) { if (fd > 0) @@ -19,17 +46,23 @@ 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); - fd = SAFE_OPEN("io_pgetevents_file", O_RDWR | O_CREAT); + fd = SAFE_OPEN("io_pgetevents_file", O_RDWR | O_CREAT, 0644); io_prep_pwrite(&cb, fd, data, 4096, 0); ret = io_setup(1, &ctx); @@ -41,7 +74,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 +88,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 7cca7fc08567..7c0c6806d005 100644 --- a/testcases/kernel/syscalls/io_pgetevents/io_pgetevents02.c +++ b/testcases/kernel/syscalls/io_pgetevents/io_pgetevents02.c @@ -6,7 +6,9 @@ * Basic io_pgetevents() test to check various failures. */ #include "tst_test.h" +#include "tst_timer.h" #include "lapi/io_pgetevents.h" +#include "lapi/abisize.h" #ifdef HAVE_LIBAIO static sigset_t sigmask; @@ -14,35 +16,65 @@ 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 defined(TST_ABI32) + { .io_pgetevents = sys_io_pgetevents, .type = TST_LIBC_TIMESPEC, .desc = "syscall with libc spec"}, + { .io_pgetevents = sys_io_pgetevents, .type = TST_KERN_OLD_TIMESPEC, .desc = "syscall with kernel spec32"}, +#endif + +#if defined(TST_ABI64) + { .io_pgetevents = sys_io_pgetevents, .type = TST_KERN_TIMESPEC, .desc = "syscall with kernel spec64"}, +#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 spec64"}, +#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); - fd = SAFE_OPEN("io_pgetevents_file", O_RDWR | O_CREAT); + fd = SAFE_OPEN("io_pgetevents_file", O_RDWR | O_CREAT, 0644); io_prep_pwrite(&cb, fd, data, 4096, 0); ret = io_setup(1, &ctx); @@ -69,10 +101,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 +133,7 @@ static struct tst_test test = { .needs_tmpdir = 1, .tcnt = ARRAY_SIZE(tcases), .test = run, + .test_variants = ARRAY_SIZE(variants), .setup = setup, .cleanup = cleanup, }; From patchwork Tue May 5 09:12:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 1283384 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=PdnJXEpK; 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 49GYsf2q8Nz9sRf for ; Tue, 5 May 2020 19:12:54 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 220783C267E for ; Tue, 5 May 2020 11:12:49 +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 A52AC3C5801 for ; Tue, 5 May 2020 11:12:24 +0200 (CEST) Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) (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 4460F600479 for ; Tue, 5 May 2020 11:12:11 +0200 (CEST) Received: by mail-pl1-x643.google.com with SMTP id b6so525584plz.13 for ; Tue, 05 May 2020 02:12:23 -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=qVl+9xs0lXeHWf7pONqnLl5zqzU2X5fv8S6AdVPqQ70=; b=PdnJXEpKM4QJW6R2iN9ykOKEgiT34nOcXG3cMCF/YglomXkxkFA+GpNN1FGOANpDpi rQVR+VOQSo9FdtKmCclyc2ZgCDhCKfBPNVNyO9T04D2XYe/7MlsV3OYVA/uTlKBdmRzB kYPf5/tprVpXzinnqP5+I7ZVYlkds+UWj19nvsE0mZdxdwnRc7GQKT5DcQsknm3eHjFZ 4cQVx3uDbXxQnNDEcr7rAfaUAZyCJ9oYcHELLHvB8FrKKAD8Xs8AFUMkJHSX5tqudS14 R7FKz5pVu9ioxBiFrgACZGmmoew6vOiVN/X2XZ5MhL6knjeljmOC6z7KBwDfG/D6EmKg APqw== 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=qVl+9xs0lXeHWf7pONqnLl5zqzU2X5fv8S6AdVPqQ70=; b=owwl6Zgi3wQJ+Yxf3I5qjq37AxgOEQ2eW7He2yKyJEHwjhmB4807wyUz7WwfU7iiO5 4V6caCbxzTEp47NLXE1JxHV7lGKNmqbrwS5K82NPFAREkeknqoFDUWh3ZfwcIqTVvi8o GqgtuJdvSPo44v7cVucwybSTYihNRl2moui4O5nM+QAWkteyFBPLCXLLNUKmS/YXn+5I plVgdpjc69F3xlSkUfA44S+6NkKAUJKv4dzdN6BgxZ37Mkt0+yxCQ4Xyfg59IOQTFiHI LHAkOCKxALWd0t6KvlsVpKnf5V2XOcRv4E6yjZxwGUOwsjGZ3PG88MKpw6Pw5+7Q32zd isvw== X-Gm-Message-State: AGi0PuaH2aOoc7Rj2KLGr2ToXvf0pwN6hPEi7AGLUJhWAakBgVRKeO/w wlhHq8UN13/uGcX7LqkfyDqQYctmtlY= X-Google-Smtp-Source: APiQypI8rvU47Q5OJFQWSHFfJ8XuoV9YKvmQFVMl/VciFzEOSF8D6VgIj/1lgtzq4a82Dl49LeCq6w== X-Received: by 2002:a17:90a:8815:: with SMTP id s21mr1792818pjn.154.1588669941497; Tue, 05 May 2020 02:12:21 -0700 (PDT) Received: from localhost ([122.171.118.46]) by smtp.gmail.com with ESMTPSA id w13sm1423269pfn.192.2020.05.05.02.12.20 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 May 2020 02:12:21 -0700 (PDT) From: Viresh Kumar To: ltp@lists.linux.it Date: Tue, 5 May 2020 14:42:04 +0530 Message-Id: X-Mailer: git-send-email 2.25.0.rc1.19.g042ed3e048af In-Reply-To: <7e037dacaeb0c7f3bfd73cd11d80f3e1567dc052.1588669892.git.viresh.kumar@linaro.org> References: <7e037dacaeb0c7f3bfd73cd11d80f3e1567dc052.1588669892.git.viresh.kumar@linaro.org> 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 4/8] syscalls/sigwaitinfo: Migrate to new test framework 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 migrates the sigwaitinfo tests to use the new test framework. Signed-off-by: Viresh Kumar --- .../syscalls/sigwaitinfo/sigwaitinfo01.c | 184 ++++++++---------- 1 file changed, 81 insertions(+), 103 deletions(-) diff --git a/testcases/kernel/syscalls/sigwaitinfo/sigwaitinfo01.c b/testcases/kernel/syscalls/sigwaitinfo/sigwaitinfo01.c index 6a30c27f6f2f..4eee27b0db29 100644 --- a/testcases/kernel/syscalls/sigwaitinfo/sigwaitinfo01.c +++ b/testcases/kernel/syscalls/sigwaitinfo/sigwaitinfo01.c @@ -20,74 +20,58 @@ * with this program; if not, write the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include "test.h" +#include "tst_test.h" #include +#include #include -#include "../utils/include_j_h.h" -#include "../utils/common_j_h.c" #include #include "lapi/syscalls.h" +#include "tst_sig_proc.h" #define SUCCEED_OR_DIE(syscall, message, ...) \ (errno = 0, \ ({int ret=syscall(__VA_ARGS__); \ if (ret==-1) \ - tst_brkm(TBROK|TERRNO, cleanup, message);\ + tst_brk(TBROK|TERRNO, message);\ ret;})) -/* Report success iff TEST_RETURN and TEST_ERRNO are equal to +/* Report success iff TST_RET and TST_ERR are equal to exp_return and exp_errno, resp., and cond is true. If cond is not true, report condition_errmsg */ -static void report_success_cond(const char *func, const char *file, int line, +static void report_success_cond(const char *func, int line, long exp_return, int exp_errno, int condition, char *condition_errmsg) { - if (exp_return == TEST_RETURN - && (exp_return != -1 || exp_errno == TEST_ERRNO)) + if (exp_return == TST_RET + && (exp_return != -1 || exp_errno == TST_ERR)) if (condition) - tst_resm(TPASS, "Test passed"); + tst_res(TPASS, "%s (%d): Test passed", func, line); else - tst_resm(TFAIL, "%s (%s: %d): %s", func, file, line, + tst_res(TFAIL, "%s (%d): %s", func, line, condition_errmsg); - else if (TEST_RETURN != -1) - tst_resm(TFAIL, - "%s (%s: %d): Unexpected return value; expected %ld, got %ld", - func, file, line, exp_return, TEST_RETURN); + else if (TST_RET != -1) + tst_res(TFAIL, + "%s (%d): Unexpected return value; expected %ld, got %ld", + func, line, exp_return, TST_RET); else - tst_resm(TFAIL | TTERRNO, "%s (%s: %d): Unexpected failure", - func, file, line); + tst_res(TFAIL | TTERRNO, "%s (%d): Unexpected failure", + func, line); } #define REPORT_SUCCESS_COND(exp_return, exp_errno, condition, condition_errmsg) \ - report_success_cond(__FUNCTION__, __FILE__, __LINE__, exp_return, exp_errno, condition, condition_errmsg); + report_success_cond(__FUNCTION__, __LINE__, exp_return, exp_errno, condition, condition_errmsg); -/* Report success iff TEST_RETURN and TEST_ERRNO are equal to +/* Report success iff TST_RET and TST_ERR are equal to exp_return and exp_errno, resp. */ #define REPORT_SUCCESS(exp_return, exp_errno) \ REPORT_SUCCESS_COND(exp_return, exp_errno, 1, ""); -static void cleanup(void); - static void empty_handler(int sig) { } -static void setup(void) -{ - tst_sig(FORK, DEF_HANDLER, cleanup); - signal(SIGUSR1, empty_handler); - signal(SIGALRM, empty_handler); - signal(SIGUSR2, SIG_IGN); - - TEST_PAUSE; -} - -static void cleanup(void) -{ -} - typedef int (*swi_func) (const sigset_t * set, siginfo_t * info, struct timespec * timeout); typedef void (*test_func) (swi_func, int); @@ -110,7 +94,6 @@ static int my_sigwait(const sigset_t * set, siginfo_t * info, static int my_sigwaitinfo(const sigset_t * set, siginfo_t * info, struct timespec *timeout) { - return sigwaitinfo(set, info); } #endif @@ -119,7 +102,6 @@ static int my_sigwaitinfo(const sigset_t * set, siginfo_t * info, static int my_sigtimedwait(const sigset_t * set, siginfo_t * info, struct timespec *timeout) { - return sigtimedwait(set, info, timeout); } #endif @@ -129,7 +111,7 @@ static int my_rt_sigtimedwait(const sigset_t * set, siginfo_t * info, struct timespec *timeout) { /* _NSIG is always the right number of bits of signal map for all arches */ - return ltp_syscall(__NR_rt_sigtimedwait, set, info, timeout, _NSIG/8); + return tst_syscall(__NR_rt_sigtimedwait, set, info, timeout, _NSIG/8); } #endif @@ -141,12 +123,13 @@ void test_empty_set(swi_func sigwaitinfo, int signo) SUCCEED_OR_DIE(sigemptyset, "sigemptyset failed", &sigs); /* Run a child that will wake us up */ - child = create_sig_proc(100000, signo, UINT_MAX); + child = create_sig_proc(signo, INT_MAX, 100000); TEST(sigwaitinfo(&sigs, &si, NULL)); REPORT_SUCCESS(-1, EINTR); - kill(child, SIGTERM); + SAFE_KILL(child, SIGTERM); + SAFE_WAIT(NULL); } void test_timeout(swi_func sigwaitinfo, int signo) @@ -159,12 +142,13 @@ void test_timeout(swi_func sigwaitinfo, int signo) SUCCEED_OR_DIE(sigemptyset, "sigemptyset failed", &sigs); /* Run a child that will wake us up */ - child = create_sig_proc(100000, signo, UINT_MAX); + child = create_sig_proc(signo, INT_MAX, 100000); TEST(sigwaitinfo(&sigs, &si, &ts)); REPORT_SUCCESS(-1, EAGAIN); - kill(child, SIGTERM); + SAFE_KILL(child, SIGTERM); + SAFE_WAIT(NULL); } /* Note: sigwait-ing for a signal that is not blocked is unspecified @@ -180,14 +164,15 @@ void test_unmasked_matching(swi_func sigwaitinfo, int signo) SUCCEED_OR_DIE(sigaddset, "sigaddset failed", &sigs, signo); /* Run a child that will wake us up */ - child = create_sig_proc(100000, signo, UINT_MAX); + child = create_sig_proc(signo, INT_MAX, 100000); TEST(sigwaitinfo(&sigs, &si, NULL)); REPORT_SUCCESS_COND(signo, 0, si.si_pid == child && si.si_code == SI_USER && si.si_signo == signo, "Struct siginfo mismatch"); - kill(child, SIGTERM); + SAFE_KILL(child, SIGTERM); + SAFE_WAIT(NULL); } void test_unmasked_matching_noinfo(swi_func sigwaitinfo, int signo) @@ -198,12 +183,13 @@ void test_unmasked_matching_noinfo(swi_func sigwaitinfo, int signo) SUCCEED_OR_DIE(sigemptyset, "sigemptyset failed", &sigs); SUCCEED_OR_DIE(sigaddset, "sigaddset failed", &sigs, signo); /* Run a child that will wake us up */ - child = create_sig_proc(100000, signo, UINT_MAX); + child = create_sig_proc(signo, INT_MAX, 100000); TEST(sigwaitinfo(&sigs, NULL, NULL)); REPORT_SUCCESS(signo, 0); - kill(child, SIGTERM); + SAFE_KILL(child, SIGTERM); + SAFE_WAIT(NULL); } void test_masked_matching(swi_func sigwaitinfo, int signo) @@ -224,7 +210,7 @@ void test_masked_matching(swi_func sigwaitinfo, int signo) SUCCEED_OR_DIE(sigdelset, "sigaddset failed", &sigs, SIGCHLD); /* Run a child that will wake us up */ - child = create_sig_proc(0, signo, 1); + child = create_sig_proc(signo, 1, 0); TEST(sigwaitinfo(&sigs, &si, NULL)); REPORT_SUCCESS_COND(signo, 0, si.si_pid == child @@ -234,13 +220,14 @@ void test_masked_matching(swi_func sigwaitinfo, int signo) SUCCEED_OR_DIE(sigprocmask, "restoring original signal mask failed", SIG_SETMASK, &oldmask, &oldmask); - tst_count--; - if (sigismember(&oldmask, signo)) - tst_resm(TPASS, "sigwaitinfo restored the original mask"); + tst_res(TPASS, "sigwaitinfo restored the original mask"); else - tst_resm(TFAIL, + tst_res(TFAIL, "sigwaitinfo failed to restore the original mask"); + + SAFE_KILL(child, SIGTERM); + SAFE_WAIT(NULL); } void test_masked_matching_rt(swi_func sigwaitinfo, int signo) @@ -265,12 +252,12 @@ void test_masked_matching_rt(swi_func sigwaitinfo, int signo) SUCCEED_OR_DIE(sigdelset, "sigdelset failed", &sigs, SIGCHLD); /* Run a child that will wake us up */ - child[0] = create_sig_proc(0, signo, 1); - child[1] = create_sig_proc(0, signo + 1, 1); + child[0] = create_sig_proc(signo, 1, 0); + child[1] = create_sig_proc(signo + 1, 1, 0); /* Ensure that the signals have been sent */ - waitpid(child[0], &status, 0); - waitpid(child[1], &status, 0); + SAFE_WAITPID(child[0], &status, 0); + SAFE_WAITPID(child[1], &status, 0); TEST(sigwaitinfo(&sigs, &si, NULL)); REPORT_SUCCESS_COND(signo, 0, si.si_pid == child[0] @@ -278,7 +265,6 @@ void test_masked_matching_rt(swi_func sigwaitinfo, int signo) && si.si_signo == signo, "Struct siginfo mismatch"); /* eat the other signal */ - tst_count--; TEST(sigwaitinfo(&sigs, &si, NULL)); REPORT_SUCCESS_COND(signo + 1, 0, si.si_pid == child[1] && si.si_code == SI_USER @@ -288,12 +274,10 @@ void test_masked_matching_rt(swi_func sigwaitinfo, int signo) SUCCEED_OR_DIE(sigprocmask, "restoring original signal mask failed", SIG_SETMASK, &oldmask, &oldmask); - tst_count--; - if (sigismember(&oldmask, signo)) - tst_resm(TPASS, "sigwaitinfo restored the original mask"); + tst_res(TPASS, "sigwaitinfo restored the original mask"); else - tst_resm(TFAIL, + tst_res(TFAIL, "sigwaitinfo failed to restore the original mask"); } @@ -314,7 +298,7 @@ void test_masked_matching_noinfo(swi_func sigwaitinfo, int signo) SUCCEED_OR_DIE(sigdelset, "sigaddset failed", &sigs, SIGCHLD); /* Run a child that will wake us up */ - child = create_sig_proc(0, signo, 1); + child = create_sig_proc(signo, 1, 0); TEST(sigwaitinfo(&sigs, NULL, NULL)); REPORT_SUCCESS(signo, 0); @@ -322,14 +306,14 @@ void test_masked_matching_noinfo(swi_func sigwaitinfo, int signo) SUCCEED_OR_DIE(sigprocmask, "restoring original signal mask failed", SIG_SETMASK, &oldmask, &oldmask); - tst_count--; - if (sigismember(&oldmask, signo)) - tst_resm(TPASS, "sigwaitinfo restored the original mask"); + tst_res(TPASS, "sigwaitinfo restored the original mask"); else - tst_resm(TFAIL, + tst_res(TFAIL, "sigwaitinfo failed to restore the original mask"); + SAFE_KILL(child, SIGTERM); + SAFE_WAIT(NULL); } void test_bad_address(swi_func sigwaitinfo, int signo) @@ -349,7 +333,7 @@ void test_bad_address(swi_func sigwaitinfo, int signo) SUCCEED_OR_DIE(sigdelset, "sigaddset failed", &sigs, SIGCHLD); /* Run a child that will wake us up */ - child = create_sig_proc(0, signo, 1); + child = create_sig_proc(signo, 1, 0); TEST(sigwaitinfo(&sigs, (void *)1, NULL)); REPORT_SUCCESS(-1, EFAULT); @@ -357,7 +341,8 @@ void test_bad_address(swi_func sigwaitinfo, int signo) SUCCEED_OR_DIE(sigprocmask, "sigprocmask failed", SIG_SETMASK, &oldmask, &oldmask); - kill(child, SIGTERM); + SAFE_KILL(child, SIGTERM); + SAFE_WAIT(NULL); } void test_bad_address2(swi_func sigwaitinfo, int signo) @@ -367,7 +352,7 @@ void test_bad_address2(swi_func sigwaitinfo, int signo) switch (pid = fork()) { case -1: - tst_brkm(TBROK | TERRNO, NULL, "fork() failed"); + tst_brk(TBROK | TERRNO, "fork() failed"); case 0: signal(SIGSEGV, SIG_DFL); @@ -377,31 +362,31 @@ void test_bad_address2(swi_func sigwaitinfo, int signo) */ TEST(sigwaitinfo((void *)1, NULL, NULL)); - if (TEST_RETURN == -1 && TEST_ERRNO == EFAULT) + if (TST_RET == -1 && TST_ERR == EFAULT) _exit(0); - tst_resm(TINFO | TTERRNO, "swi_func returned: %ld", - TEST_RETURN); + tst_res(TINFO | TTERRNO, "swi_func returned: %ld", + TST_RET); _exit(1); break; default: break; } - SUCCEED_OR_DIE(waitpid, "waitpid failed", pid, &status, 0); + SAFE_WAITPID(pid, &status, 0); if ((WIFSIGNALED(status) && WTERMSIG(status) == SIGSEGV) || (WIFEXITED(status) && WEXITSTATUS(status) == 0)) { - tst_resm(TPASS, "Test passed"); + tst_res(TPASS, "Test passed"); return; } if (WIFEXITED(status)) { - tst_resm(TFAIL, "Unrecognised child exit code: %d", + tst_res(TFAIL, "Unrecognised child exit code: %d", WEXITSTATUS(status)); } if (WIFSIGNALED(status)) { - tst_resm(TFAIL, "Unrecognised child termsig: %d", + tst_res(TFAIL, "Unrecognised child termsig: %d", WTERMSIG(status)); } } @@ -474,38 +459,31 @@ struct test_desc { #endif }; -#if defined TEST_SIGWAITINFO -const char *TCID = "sigwaitinfo01"; -#elif defined TEST_RT_SIGTIMEDWAIT -const char *TCID = "rt_sigtimedwait01"; -#elif defined TEST_SIGTIMEDWAIT -const char *TCID = "sigtimedwait01"; -#elif defined TEST_SIGWAIT -const char *TCID = "sigwait01"; -#endif - -int TST_TOTAL = ARRAY_SIZE(tests); - -int main(int argc, char **argv) +static void run(unsigned int i) { - unsigned i; - int lc; + struct test_desc *tc = &tests[i]; - tst_parse_opts(argc, argv, NULL, NULL); - - setup(); + tc->tf(tc->swi, tc->signo); +} - for (lc = 0; TEST_LOOPING(lc); ++lc) { - tst_count = 0; +static void setup(void) +{ + signal(SIGUSR1, empty_handler); + signal(SIGALRM, empty_handler); + signal(SIGUSR2, SIG_IGN); - for (i = 0; i < ARRAY_SIZE(tests); i++) { - alarm(10); /* arrange a 10 second timeout */ - tst_resm(TINFO, "%p, %d", tests[i].swi, tests[i].signo); - tests[i].tf(tests[i].swi, tests[i].signo); - } - alarm(0); - } + alarm(10); /* arrange a 10 second timeout */ +} - cleanup(); - tst_exit(); +static void cleanup(void) +{ + alarm(0); } + +static struct tst_test test = { + .test= run, + .tcnt = ARRAY_SIZE(tests), + .setup = setup, + .cleanup = cleanup, + .forks_child = 1, +}; From patchwork Tue May 5 09:12:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 1283385 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=JINE83Su; 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 49GYsq2M1rz9sRf for ; Tue, 5 May 2020 19:13:03 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id C9F8A3C284A for ; Tue, 5 May 2020 11:13:00 +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 E9C923C57F3 for ; Tue, 5 May 2020 11:12:26 +0200 (CEST) Received: from mail-pj1-x1044.google.com (mail-pj1-x1044.google.com [IPv6:2607:f8b0:4864:20::1044]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by in-2.smtp.seeweb.it (Postfix) with ESMTPS id 13376601015 for ; Tue, 5 May 2020 11:12:26 +0200 (CEST) Received: by mail-pj1-x1044.google.com with SMTP id t40so745326pjb.3 for ; Tue, 05 May 2020 02:12:26 -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=qeA7BBgB5Q/d3zj9MJtjPaWCar97dattvlPue4GTaaE=; b=JINE83SukpU6eTz1b10Mzj4dmPYG0YVMTpLoIOZJZGfy4OtERMiEPSTBDyl4z7K0dg 2ltx/6ec1GPsp+ige2w2OWALo4/VZc+JH0//GrIYKZWHRs06DEubGBxNTHt9X0jVC/qN vETN3LbQmeBy2irDvEvXxlkZKYPUbd+0YUD7FXaMwYev0vrwcm7gKFD0Fggp0qapBgMq YpzInOVaUPvmY14qvbK5AsjifS5Q5Ntby8HYbUUQbplBUNmxLY8i+cTeiOlkYgmd1yoa Xu6idpNL/g+miR48nCj3RC/xIdGJF+CS71YvtR6I8s9dDBKCnJ93toItrGS0e63yp4+T SaSA== 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=qeA7BBgB5Q/d3zj9MJtjPaWCar97dattvlPue4GTaaE=; b=ImAZZgHQGIUJbkFsmSHAr9a+mpl9Wn51437p5wLAZku6NXYfAlResMcZ14DLxMJcQt pmmVHpfOXxlrHfUQ3YLX3K8V68H8DiIlfv7T1qZKVluesTIfuY3r9inNStdOs1cE0JKs 5+jccbI2Yeo19NNO/HyQA1pCGm71kC7NGTeU2Vbq5E9NkGjSa5erYw3rcNWIB/tCrizS XR9spIZyUz8hC1L5Y7VGQx4srdE1lRCh8IQwQUeji23z+AOfcbKCQQTQnN3P2XYOr5c9 x8PpK6dppwMmJi0QnWEcHFLRAXf1jNAxMTRIlQ1HbNuy3PV6ABywH1g0+mrmOxB7GRyI hFyA== X-Gm-Message-State: AGi0PuYh8qQ6xoFBEttWm1zpKFuwVNkukYJXX3OlQing5X84U1+sNkRK Sx6Q0E25vee1ixmYorEyDDhHDJ1Z1qg= X-Google-Smtp-Source: APiQypLYSMJT3y9gXhkQE66Nkndvz6AV9YrsY27pU5EJ6rJAr3z5vE4VsvykC2VCtlDffGkR0d7PRg== X-Received: by 2002:a17:90b:19cc:: with SMTP id nm12mr1916267pjb.34.1588669944188; Tue, 05 May 2020 02:12:24 -0700 (PDT) Received: from localhost ([122.171.118.46]) by smtp.gmail.com with ESMTPSA id s4sm1136647pgv.78.2020.05.05.02.12.23 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 May 2020 02:12:23 -0700 (PDT) From: Viresh Kumar To: ltp@lists.linux.it Date: Tue, 5 May 2020 14:42:05 +0530 Message-Id: <26cbca717c2c04f16c0818f2f9ccfa1c5a0887f8.1588669892.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.25.0.rc1.19.g042ed3e048af In-Reply-To: <7e037dacaeb0c7f3bfd73cd11d80f3e1567dc052.1588669892.git.viresh.kumar@linaro.org> References: <7e037dacaeb0c7f3bfd73cd11d80f3e1567dc052.1588669892.git.viresh.kumar@linaro.org> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.99.2 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,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-2.smtp.seeweb.it Subject: [LTP] [PATCH 5/8] syscalls/rt_sigtimedwait: 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 rt_sigtimedwait() syscall tests. Signed-off-by: Viresh Kumar --- .../syscalls/sigwaitinfo/sigwaitinfo01.c | 118 +++++++++++++----- 1 file changed, 86 insertions(+), 32 deletions(-) diff --git a/testcases/kernel/syscalls/sigwaitinfo/sigwaitinfo01.c b/testcases/kernel/syscalls/sigwaitinfo/sigwaitinfo01.c index 4eee27b0db29..404036c40aac 100644 --- a/testcases/kernel/syscalls/sigwaitinfo/sigwaitinfo01.c +++ b/testcases/kernel/syscalls/sigwaitinfo/sigwaitinfo01.c @@ -21,11 +21,13 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include "tst_test.h" +#include "tst_timer.h" #include #include #include #include #include "lapi/syscalls.h" +#include "lapi/abisize.h" #include "tst_sig_proc.h" #define SUCCEED_OR_DIE(syscall, message, ...) \ @@ -73,12 +75,12 @@ static void empty_handler(int sig) } typedef int (*swi_func) (const sigset_t * set, siginfo_t * info, - struct timespec * timeout); -typedef void (*test_func) (swi_func, int); + void * timeout); +typedef void (*test_func) (swi_func, int, enum tst_ts_type type); #ifdef TEST_SIGWAIT static int my_sigwait(const sigset_t * set, siginfo_t * info, - struct timespec *timeout) + void *timeout) { int ret; int err = sigwait(set, &ret); @@ -92,7 +94,7 @@ static int my_sigwait(const sigset_t * set, siginfo_t * info, #ifdef TEST_SIGWAITINFO static int my_sigwaitinfo(const sigset_t * set, siginfo_t * info, - struct timespec *timeout) + void *timeout) { return sigwaitinfo(set, info); } @@ -100,7 +102,7 @@ static int my_sigwaitinfo(const sigset_t * set, siginfo_t * info, #ifdef TEST_SIGTIMEDWAIT static int my_sigtimedwait(const sigset_t * set, siginfo_t * info, - struct timespec *timeout) + void *timeout) { return sigtimedwait(set, info, timeout); } @@ -108,14 +110,23 @@ static int my_sigtimedwait(const sigset_t * set, siginfo_t * info, #ifdef TEST_RT_SIGTIMEDWAIT static int my_rt_sigtimedwait(const sigset_t * set, siginfo_t * info, - struct timespec *timeout) + void *timeout) { /* _NSIG is always the right number of bits of signal map for all arches */ return tst_syscall(__NR_rt_sigtimedwait, set, info, timeout, _NSIG/8); } + +#if (__NR_rt_sigtimedwait_time64 != __LTP__NR_INVALID_SYSCALL) +static int my_rt_sigtimedwait_time64(const sigset_t * set, siginfo_t * info, + void *timeout) +{ + /* _NSIG is always the right number of bits of signal map for all arches */ + return tst_syscall(__NR_rt_sigtimedwait_time64, set, info, timeout, _NSIG/8); +} +#endif #endif -void test_empty_set(swi_func sigwaitinfo, int signo) +void test_empty_set(swi_func sigwaitinfo, int signo, enum tst_ts_type type) { sigset_t sigs; siginfo_t si; @@ -132,19 +143,23 @@ void test_empty_set(swi_func sigwaitinfo, int signo) SAFE_WAIT(NULL); } -void test_timeout(swi_func sigwaitinfo, int signo) +void test_timeout(swi_func sigwaitinfo, int signo, enum tst_ts_type type) { sigset_t sigs; siginfo_t si; pid_t child; - struct timespec ts = {.tv_sec = 1 }; + struct tst_ts ts; + + ts.type = type; + tst_ts_set_sec(&ts, 1); + tst_ts_set_nsec(&ts, 0); SUCCEED_OR_DIE(sigemptyset, "sigemptyset failed", &sigs); /* Run a child that will wake us up */ child = create_sig_proc(signo, INT_MAX, 100000); - TEST(sigwaitinfo(&sigs, &si, &ts)); + TEST(sigwaitinfo(&sigs, &si, tst_ts_get(&ts))); REPORT_SUCCESS(-1, EAGAIN); SAFE_KILL(child, SIGTERM); @@ -154,7 +169,8 @@ void test_timeout(swi_func sigwaitinfo, int signo) /* Note: sigwait-ing for a signal that is not blocked is unspecified * by POSIX; but works for non-ignored signals under Linux */ -void test_unmasked_matching(swi_func sigwaitinfo, int signo) +void test_unmasked_matching(swi_func sigwaitinfo, int signo, + enum tst_ts_type type) { sigset_t sigs; siginfo_t si; @@ -175,7 +191,8 @@ void test_unmasked_matching(swi_func sigwaitinfo, int signo) SAFE_WAIT(NULL); } -void test_unmasked_matching_noinfo(swi_func sigwaitinfo, int signo) +void test_unmasked_matching_noinfo(swi_func sigwaitinfo, int signo, + enum tst_ts_type type) { sigset_t sigs; pid_t child; @@ -192,7 +209,8 @@ void test_unmasked_matching_noinfo(swi_func sigwaitinfo, int signo) SAFE_WAIT(NULL); } -void test_masked_matching(swi_func sigwaitinfo, int signo) +void test_masked_matching(swi_func sigwaitinfo, int signo, + enum tst_ts_type type) { sigset_t sigs, oldmask; siginfo_t si; @@ -230,7 +248,8 @@ void test_masked_matching(swi_func sigwaitinfo, int signo) SAFE_WAIT(NULL); } -void test_masked_matching_rt(swi_func sigwaitinfo, int signo) +void test_masked_matching_rt(swi_func sigwaitinfo, int signo, + enum tst_ts_type type) { sigset_t sigs, oldmask; siginfo_t si; @@ -281,7 +300,8 @@ void test_masked_matching_rt(swi_func sigwaitinfo, int signo) "sigwaitinfo failed to restore the original mask"); } -void test_masked_matching_noinfo(swi_func sigwaitinfo, int signo) +void test_masked_matching_noinfo(swi_func sigwaitinfo, int signo, + enum tst_ts_type type) { sigset_t sigs, oldmask; pid_t child; @@ -316,7 +336,7 @@ void test_masked_matching_noinfo(swi_func sigwaitinfo, int signo) SAFE_WAIT(NULL); } -void test_bad_address(swi_func sigwaitinfo, int signo) +void test_bad_address(swi_func sigwaitinfo, int signo, enum tst_ts_type type) { sigset_t sigs, oldmask; pid_t child; @@ -345,7 +365,7 @@ void test_bad_address(swi_func sigwaitinfo, int signo) SAFE_WAIT(NULL); } -void test_bad_address2(swi_func sigwaitinfo, int signo) +void test_bad_address2(swi_func sigwaitinfo, int signo, enum tst_ts_type type) { pid_t pid; int status; @@ -391,7 +411,7 @@ void test_bad_address2(swi_func sigwaitinfo, int signo) } } -void test_bad_address3(swi_func sigwaitinfo, int signo) +void test_bad_address3(swi_func sigwaitinfo, int signo, enum tst_ts_type type) { sigset_t sigs; SUCCEED_OR_DIE(sigemptyset, "sigemptyset failed", &sigs); @@ -407,28 +427,28 @@ struct test_desc { } tests[] = { #ifdef TEST_RT_SIGTIMEDWAIT { - test_empty_set, my_rt_sigtimedwait, SIGUSR1}, { - test_unmasked_matching, my_rt_sigtimedwait, SIGUSR1}, { - test_masked_matching, my_rt_sigtimedwait, SIGUSR1}, { - test_unmasked_matching_noinfo, my_rt_sigtimedwait, SIGUSR1}, { - test_masked_matching_noinfo, my_rt_sigtimedwait, SIGUSR1}, { - test_bad_address, my_rt_sigtimedwait, SIGUSR1}, { - test_bad_address2, my_rt_sigtimedwait, SIGUSR1}, { - test_bad_address3, my_rt_sigtimedwait, SIGUSR1}, { - test_timeout, my_rt_sigtimedwait, 0}, + test_empty_set, NULL, SIGUSR1}, { + test_unmasked_matching, NULL, SIGUSR1}, { + test_masked_matching, NULL, SIGUSR1}, { + test_unmasked_matching_noinfo, NULL, SIGUSR1}, { + test_masked_matching_noinfo, NULL, SIGUSR1}, { + test_bad_address, NULL, SIGUSR1}, { + test_bad_address2, NULL, SIGUSR1}, { + test_bad_address3, NULL, SIGUSR1}, { + test_timeout, NULL, 0}, /* Special cases */ /* 1: sigwaitinfo does respond to ignored signal */ { - test_masked_matching, my_rt_sigtimedwait, SIGUSR2}, + test_masked_matching, NULL, SIGUSR2}, /* 2: An ignored signal doesn't cause sigwaitinfo to return EINTR */ { - test_timeout, my_rt_sigtimedwait, SIGUSR2}, + test_timeout, NULL, SIGUSR2}, /* 3: The handler is not called when the signal is waited for by sigwaitinfo */ { - test_masked_matching, my_rt_sigtimedwait, SIGTERM}, + test_masked_matching, NULL, SIGTERM}, /* 4: Simultaneous realtime signals are delivered in the order of increasing signal number */ { - test_masked_matching_rt, my_rt_sigtimedwait, -1}, + test_masked_matching_rt, NULL, -1}, #endif #if defined TEST_SIGWAIT { @@ -459,15 +479,48 @@ struct test_desc { #endif }; +static struct test_variants { + swi_func swi; + enum tst_ts_type type; + char *desc; +} variants[] = { +#ifdef TEST_RT_SIGTIMEDWAIT + +#if defined(TST_ABI32) + { .swi = my_rt_sigtimedwait, .type = TST_LIBC_TIMESPEC, .desc = "syscall with libc spec"}, + { .swi = my_rt_sigtimedwait, .type = TST_KERN_OLD_TIMESPEC, .desc = "syscall with kernel spec32"}, +#endif + +#if defined(TST_ABI64) + { .swi = my_rt_sigtimedwait, .type = TST_KERN_TIMESPEC, .desc = "syscall with kernel spec64"}, +#endif + +#if (__NR_rt_sigtimedwait_time64 != __LTP__NR_INVALID_SYSCALL) + { .swi = my_rt_sigtimedwait_time64, .type = TST_KERN_TIMESPEC, .desc = "syscall time64 with kernel spec64"}, +#endif + +#else /* !TEST_RT_SIGTIMEDWAIT */ + + { .swi = NULL, .type = TST_LIBC_TIMESPEC, .desc = "syscall with libc spec"}, + +#endif /* TEST_RT_SIGTIMEDWAIT */ +}; + static void run(unsigned int i) { + struct test_variants *tv = &variants[tst_variant]; struct test_desc *tc = &tests[i]; + swi_func swi; - tc->tf(tc->swi, tc->signo); + swi = tv->swi ? tv->swi : tc->swi; + + tc->tf(swi, tc->signo, tv->type); } static void setup(void) { + tst_res(TINFO, "Testing variant: %s", variants[tst_variant].desc); + signal(SIGUSR1, empty_handler); signal(SIGALRM, empty_handler); signal(SIGUSR2, SIG_IGN); @@ -483,6 +536,7 @@ static void cleanup(void) static struct tst_test test = { .test= run, .tcnt = ARRAY_SIZE(tests), + .test_variants = ARRAY_SIZE(variants), .setup = setup, .cleanup = cleanup, .forks_child = 1, From patchwork Tue May 5 09:12:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 1283387 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=SCwOSkiP; 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 49GYtC1RY6z9sRf for ; Tue, 5 May 2020 19:13:23 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id AB2ED3C580D for ; Tue, 5 May 2020 11:13:20 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-3.smtp.seeweb.it (in-3.smtp.seeweb.it [IPv6:2001:4b78:1:20::3]) by picard.linux.it (Postfix) with ESMTP id 6BAD73C5800 for ; Tue, 5 May 2020 11:12:30 +0200 (CEST) Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by in-3.smtp.seeweb.it (Postfix) with ESMTPS id E330D1A01203 for ; Tue, 5 May 2020 11:12:28 +0200 (CEST) Received: by mail-pg1-x541.google.com with SMTP id j21so748669pgb.7 for ; Tue, 05 May 2020 02:12: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=OVPv+BrHLYaiYvYiE991nA1I3ifdnNY3ZQfgJbUYoio=; b=SCwOSkiPkYugWlMybaxcGiS3CG0Ic0mvL4R7JV/vt1NzJBeXf5Jg8iUkRXe8OtDsE/ HtB+O9mPkzxLPhOenDH2GYt1zA8GUDFkIjvW5c+jhFg1i3GbCWzB7XvvTFkjDdqQeYGA o6Ca47sqPUJFNM1oBnZtJX+PtpscZzCaTkxfFzQMZiEerVdjqmcICQQ80+pLF37aVj4y 5oAjYIM5SM0F4vmNBP3pI+RQtukVpPcgz+ZIRn+O14A9Zstkd91bRaFBUeVBW5vMh8Lh Jg0Dy6F+03aD2NtNnZunMXJ2WSIElJJ2qA3jsbnNffIBTEmBJynbdKWin5AYhmpKBJEo AKzA== 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=OVPv+BrHLYaiYvYiE991nA1I3ifdnNY3ZQfgJbUYoio=; b=lCzJhbAsdVydjQ3QQJTQULvgDsVc52ZqE/x16/g+2Mip6ILBnoPXG7LV33EQYh4LlP 17PjTsiVGFTqTrad2RnLhvnsey0Vb2S3R6PsBsQ75aO87BfGp8Y8us/CUst0GRX/v7JT /+khG+7KxN9okQc6hE0JdmeY5QX75idjC0CZByKzIjyG6S5zcT/Nthyjce0svkAcGUz9 T6LJCnQuNCAPKKBA4TxS8Q7Kdj9FHrEevUdP3h9OVJd3q6LgDcLpdd577XxStIBJ0LcF juPmQHzdZ4xTJiUNbHtFCQBa8GuLsCqMaIxdl0ZRIG3cTCWuuQne4FDDPYRVANEAalxk +BLA== X-Gm-Message-State: AGi0PuaFgruJrJLldmMASFwfGVj5kE+jwqjzwqlBXJgn9evtYLpvY3jI j+LYQSKHQcy7rk85hAeZN1fB2uxz/EQ= X-Google-Smtp-Source: APiQypKx7dM6Gh8f91RfohdJiV3NnnicoYwTMEFwuyLtlKwvY/pC/bivgsR01g/Qib/FD49UBlIM6w== X-Received: by 2002:aa7:9491:: with SMTP id z17mr2204076pfk.264.1588669946804; Tue, 05 May 2020 02:12:26 -0700 (PDT) Received: from localhost ([122.171.118.46]) by smtp.gmail.com with ESMTPSA id 23sm1152532pgm.18.2020.05.05.02.12.25 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 May 2020 02:12:26 -0700 (PDT) From: Viresh Kumar To: ltp@lists.linux.it Date: Tue, 5 May 2020 14:42:06 +0530 Message-Id: <62c763ca63684f75d3b9fcf3185edfffb7affafb.1588669892.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.25.0.rc1.19.g042ed3e048af In-Reply-To: <7e037dacaeb0c7f3bfd73cd11d80f3e1567dc052.1588669892.git.viresh.kumar@linaro.org> References: <7e037dacaeb0c7f3bfd73cd11d80f3e1567dc052.1588669892.git.viresh.kumar@linaro.org> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.99.2 at in-3.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-3.smtp.seeweb.it Subject: [LTP] [PATCH 6/8] syscalls/mq_timed{send|receive}: 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 mq_timed{send|receive}() syscall tests. Signed-off-by: Viresh Kumar --- include/tst_timer.h | 41 +++++++++ .../mq_timedreceive/mq_timedreceive01.c | 83 ++++++++++++++---- .../syscalls/mq_timedsend/mq_timedsend01.c | 87 +++++++++++++++---- testcases/kernel/syscalls/utils/mq_timed.h | 28 +++--- 4 files changed, 189 insertions(+), 50 deletions(-) diff --git a/include/tst_timer.h b/include/tst_timer.h index b4280042c77f..28f11c7376b4 100644 --- a/include/tst_timer.h +++ b/include/tst_timer.h @@ -14,6 +14,7 @@ #include #include +#include #include #include "tst_test.h" #include "lapi/common_timers.h" @@ -255,6 +256,46 @@ static inline int sys_futex_time64(int *uaddr, int futex_op, int val, void *to, return tst_syscall(__NR_futex_time64, uaddr, futex_op, val, to, uaddr2, val3); } +static inline int libc_mq_timedsend(mqd_t mqdes, const char *msg_ptr, + size_t msg_len, unsigned int msg_prio, void *abs_timeout) +{ + return mq_timedsend(mqdes, msg_ptr, msg_len, msg_prio, abs_timeout); +} + +static inline int sys_mq_timedsend(mqd_t mqdes, const char *msg_ptr, + size_t msg_len, unsigned int msg_prio, void *abs_timeout) +{ + return tst_syscall(__NR_mq_timedsend, mqdes, msg_ptr, msg_len, msg_prio, + abs_timeout); +} + +static inline int sys_mq_timedsend64(mqd_t mqdes, const char *msg_ptr, + size_t msg_len, unsigned int msg_prio, void *abs_timeout) +{ + return tst_syscall(__NR_mq_timedsend_time64, mqdes, msg_ptr, msg_len, + msg_prio, abs_timeout); +} + +static inline ssize_t libc_mq_timedreceive(mqd_t mqdes, char *msg_ptr, + size_t msg_len, unsigned int *msg_prio, void *abs_timeout) +{ + return mq_timedreceive(mqdes, msg_ptr, msg_len, msg_prio, abs_timeout); +} + +static inline ssize_t sys_mq_timedreceive(mqd_t mqdes, char *msg_ptr, + size_t msg_len, unsigned int *msg_prio, void *abs_timeout) +{ + return tst_syscall(__NR_mq_timedreceive, mqdes, msg_ptr, msg_len, + msg_prio, abs_timeout); +} + +static inline ssize_t sys_mq_timedreceive64(mqd_t mqdes, char *msg_ptr, + size_t msg_len, unsigned int *msg_prio, void *abs_timeout) +{ + return tst_syscall(__NR_mq_timedreceive_time64, mqdes, msg_ptr, msg_len, + msg_prio, abs_timeout); +} + static inline int libc_sched_rr_get_interval(pid_t pid, void *ts) { return sched_rr_get_interval(pid, ts); diff --git a/testcases/kernel/syscalls/mq_timedreceive/mq_timedreceive01.c b/testcases/kernel/syscalls/mq_timedreceive/mq_timedreceive01.c index 1be515ced671..0ba88b9552cc 100644 --- a/testcases/kernel/syscalls/mq_timedreceive/mq_timedreceive01.c +++ b/testcases/kernel/syscalls/mq_timedreceive/mq_timedreceive01.c @@ -23,12 +23,13 @@ #include #include +#include "lapi/abisize.h" static int fd, fd_root, fd_nonblock, fd_maxint = INT_MAX - 1, fd_invalid = -1; #include "mq_timed.h" -static struct timespec ts; +static struct tst_ts ts; static struct test_case tcase[] = { { @@ -95,21 +96,27 @@ static struct test_case tcase[] = { { .fd = &fd, .len = 16, - .rq = &(struct timespec) {.tv_sec = -1, .tv_nsec = 0}, + .tv_sec = -1, + .tv_nsec = 0, + .rq = &ts, .ret = -1, .err = EINVAL, }, { .fd = &fd, .len = 16, - .rq = &(struct timespec) {.tv_sec = 0, .tv_nsec = -1}, + .tv_sec = 0, + .tv_nsec = -1, + .rq = &ts, .ret = -1, .err = EINVAL, }, { .fd = &fd, .len = 16, - .rq = &(struct timespec) {.tv_sec = 0, .tv_nsec = 1000000000}, + .tv_sec = 0, + .tv_nsec = 1000000000, + .rq = &ts, .ret = -1, .err = EINVAL, }, @@ -131,8 +138,44 @@ static struct test_case tcase[] = { }, }; +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[] = { +#if defined(TST_ABI32) + { .gettime = libc_clock_gettime, .send = libc_mq_timedsend, .receive = libc_mq_timedreceive, .type = TST_LIBC_TIMESPEC, .desc = "vDSO or syscall with libc spec"}, + { .gettime = sys_clock_gettime, .send = sys_mq_timedsend, .receive = sys_mq_timedreceive, .type = TST_LIBC_TIMESPEC, .desc = "syscall with libc spec"}, + { .gettime = sys_clock_gettime, .send = sys_mq_timedsend, .receive = sys_mq_timedreceive, .type = TST_KERN_OLD_TIMESPEC, .desc = "syscall with kernel spec32"}, +#endif + +#if defined(TST_ABI64) + { .gettime = sys_clock_gettime, .send = sys_mq_timedsend, .receive = sys_mq_timedreceive, .type = TST_KERN_TIMESPEC, .desc = "syscall with kernel spec64"}, +#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 spec64"}, +#endif +}; + +static void setup(void) +{ + struct test_variants *tv = &variants[tst_variant]; + + tst_res(TINFO, "Testing variant: %s", tv->desc); + ts.type = tv->type; + + setup_common(); +} + static void do_test(unsigned int i) { + struct test_variants *tv = &variants[tst_variant]; const struct test_case *tc = &tcase[i]; unsigned int j; unsigned int prio; @@ -140,19 +183,26 @@ static void do_test(unsigned int i) char rmsg[len]; pid_t pid = -1; + tst_ts_set_sec(&ts, tc->tv_sec); + tst_ts_set_nsec(&ts, tc->tv_nsec); + if (tc->signal) - pid = set_sig(tc->rq); + pid = set_sig(tc->rq, tv->gettime); if (tc->timeout) - set_timeout(tc->rq); + set_timeout(tc->rq, tv->gettime); - if (tc->send) - send_msg(*tc->fd, tc->len, tc->prio); + if (tc->send) { + if (tv->send(*tc->fd, smsg, tc->len, tc->prio, NULL) < 0) { + tst_res(TFAIL | TTERRNO, "mq_timedsend() failed"); + return; + } + } if (tc->invalid_msg) len -= 1; - TEST(mq_timedreceive(*tc->fd, rmsg, len, &prio, tc->rq)); + TEST(tv->receive(*tc->fd, rmsg, len, &prio, tst_ts_get(tc->rq))); if (pid > 0) kill_pid(pid); @@ -163,22 +213,22 @@ static void do_test(unsigned int i) if (TST_RET < 0) { if (tc->err != TST_ERR) tst_res(TFAIL | TTERRNO, - "mq_timedreceive failed unexpectedly, expected %s", + "mq_timedreceive() failed unexpectedly, expected %s", tst_strerrno(tc->err)); else - tst_res(TPASS | TTERRNO, "mq_timedreceive failed expectedly"); + tst_res(TPASS | TTERRNO, "mq_timedreceive() failed expectedly"); return; } if (tc->len != TST_RET) { - tst_res(TFAIL, "mq_timedreceive wrong length %ld, expected %zu", + tst_res(TFAIL, "mq_timedreceive() wrong length %ld, expected %u", TST_RET, tc->len); return; } if (tc->prio != prio) { - tst_res(TFAIL, "mq_timedreceive wrong prio %d, expected %d", + tst_res(TFAIL, "mq_timedreceive() wrong prio %d, expected %d", prio, tc->prio); return; } @@ -186,20 +236,21 @@ static void do_test(unsigned int i) for (j = 0; j < tc->len; j++) { if (rmsg[j] != smsg[j]) { tst_res(TFAIL, - "mq_timedreceive wrong data %d in %u, expected %d", + "mq_timedreceive() wrong data %d in %u, expected %d", rmsg[j], i, smsg[j]); return; } } - tst_res(TPASS, "mq_timedreceive returned %ld, priority %u, length: %zu", + tst_res(TPASS, "mq_timedreceive() returned %ld, priority %u, length: %zu", TST_RET, prio, len); } static struct tst_test test = { .tcnt = ARRAY_SIZE(tcase), .test = do_test, - .setup = setup_common, + .test_variants = ARRAY_SIZE(variants), + .setup = setup, .cleanup = cleanup_common, .forks_child = 1, }; diff --git a/testcases/kernel/syscalls/mq_timedsend/mq_timedsend01.c b/testcases/kernel/syscalls/mq_timedsend/mq_timedsend01.c index 8f209d396040..2206b5199ab8 100644 --- a/testcases/kernel/syscalls/mq_timedsend/mq_timedsend01.c +++ b/testcases/kernel/syscalls/mq_timedsend/mq_timedsend01.c @@ -23,12 +23,14 @@ #include #include +#include "lapi/abisize.h" static int fd, fd_root, fd_nonblock, fd_maxint = INT_MAX - 1, fd_invalid = -1; -static struct timespec ts; #include "mq_timed.h" +static struct tst_ts ts; + static struct test_case tcase[] = { { .fd = &fd, @@ -95,7 +97,9 @@ static struct test_case tcase[] = { { .fd = &fd, .len = 16, - .rq = &(struct timespec) {.tv_sec = -1, .tv_nsec = 0}, + .tv_sec = -1, + .tv_nsec = 0, + .rq = &ts, .send = 1, .ret = -1, .err = EINVAL, @@ -103,7 +107,9 @@ static struct test_case tcase[] = { { .fd = &fd, .len = 16, - .rq = &(struct timespec) {.tv_sec = 0, .tv_nsec = -1}, + .tv_sec = 0, + .tv_nsec = -1, + .rq = &ts, .send = 1, .ret = -1, .err = EINVAL, @@ -111,7 +117,9 @@ static struct test_case tcase[] = { { .fd = &fd, .len = 16, - .rq = &(struct timespec) {.tv_sec = 0, .tv_nsec = 1000000000}, + .tv_sec = 0, + .tv_nsec = 1000000000, + .rq = &ts, .send = 1, .ret = -1, .err = EINVAL, @@ -136,8 +144,44 @@ static struct test_case tcase[] = { }, }; +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[] = { +#if defined(TST_ABI32) + { .gettime = libc_clock_gettime, .send = libc_mq_timedsend, .receive = libc_mq_timedreceive, .type = TST_LIBC_TIMESPEC, .desc = "vDSO or syscall with libc spec"}, + { .gettime = sys_clock_gettime, .send = sys_mq_timedsend, .receive = sys_mq_timedreceive, .type = TST_LIBC_TIMESPEC, .desc = "syscall with libc spec"}, + { .gettime = sys_clock_gettime, .send = sys_mq_timedsend, .receive = sys_mq_timedreceive, .type = TST_KERN_OLD_TIMESPEC, .desc = "syscall with kernel spec32"}, +#endif + +#if defined(TST_ABI64) + { .gettime = sys_clock_gettime, .send = sys_mq_timedsend, .receive = sys_mq_timedreceive, .type = TST_KERN_TIMESPEC, .desc = "syscall with kernel spec64"}, +#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 spec64"}, +#endif +}; + +static void setup(void) +{ + struct test_variants *tv = &variants[tst_variant]; + + tst_res(TINFO, "Testing variant: %s", tv->desc); + ts.type = tv->type; + + setup_common(); +} + static void do_test(unsigned int i) { + struct test_variants *tv = &variants[tst_variant]; const struct test_case *tc = &tcase[i]; unsigned int j; unsigned int prio; @@ -145,18 +189,24 @@ static void do_test(unsigned int i) char rmsg[len]; pid_t pid = -1; + tst_ts_set_sec(&ts, tc->tv_sec); + tst_ts_set_nsec(&ts, tc->tv_nsec); + if (tc->signal) - pid = set_sig(tc->rq); + pid = set_sig(tc->rq, tv->gettime); if (tc->timeout) - set_timeout(tc->rq); + set_timeout(tc->rq, tv->gettime); if (tc->send) { for (j = 0; j < MSG_LENGTH; j++) - send_msg(*tc->fd, tc->len, tc->prio); + if (tv->send(*tc->fd, smsg, tc->len, tc->prio, NULL) < 0) { + tst_res(TFAIL | TTERRNO, "mq_timedsend() failed"); + return; + } } - TEST(mq_timedsend(*tc->fd, smsg, tc->len, tc->prio, tc->rq)); + TEST(tv->send(*tc->fd, smsg, tc->len, tc->prio, tst_ts_get(tc->rq))); if (pid > 0) kill_pid(pid); @@ -164,10 +214,10 @@ static void do_test(unsigned int i) if (TST_RET < 0) { if (tc->err != TST_ERR) tst_res(TFAIL | TTERRNO, - "mq_timedsend failed unexpectedly, expected %s", + "mq_timedsend() failed unexpectedly, expected %s", tst_strerrno(tc->err)); else - tst_res(TPASS | TTERRNO, "mq_timedreceive failed expectedly"); + tst_res(TPASS | TTERRNO, "mq_timedreceive() failed expectedly"); if (*tc->fd == fd) cleanup_queue(fd); @@ -175,7 +225,7 @@ static void do_test(unsigned int i) return; } - TEST(mq_timedreceive(*tc->fd, rmsg, len, &prio, tc->rq)); + TEST(tv->receive(*tc->fd, rmsg, len, &prio, tst_ts_get(tc->rq))); if (*tc->fd == fd) cleanup_queue(fd); @@ -183,26 +233,26 @@ static void do_test(unsigned int i) if (TST_RET < 0) { if (tc->err != TST_ERR) { tst_res(TFAIL | TTERRNO, - "mq_timedreceive failed unexpectedly, expected %s", + "mq_timedreceive() failed unexpectedly, expected %s", tst_strerrno(tc->err)); return; } if (tc->ret >= 0) { - tst_res(TFAIL | TTERRNO, "mq_timedreceive returned %ld, expected %d", + tst_res(TFAIL | TTERRNO, "mq_timedreceive() returned %ld, expected %d", TST_RET, tc->ret); return; } } if (tc->len != TST_RET) { - tst_res(TFAIL, "mq_timedreceive wrong length %ld, expected %d", + tst_res(TFAIL, "mq_timedreceive() wrong length %ld, expected %u", TST_RET, tc->len); return; } if (tc->prio != prio) { - tst_res(TFAIL, "mq_timedreceive wrong prio %d, expected %d", + tst_res(TFAIL, "mq_timedreceive() wrong prio %d, expected %d", prio, tc->prio); return; } @@ -210,20 +260,21 @@ static void do_test(unsigned int i) for (j = 0; j < tc->len; j++) { if (rmsg[j] != smsg[j]) { tst_res(TFAIL, - "mq_timedreceive wrong data %d in %u, expected %d", + "mq_timedreceive() wrong data %d in %u, expected %d", rmsg[j], i, smsg[j]); return; } } - tst_res(TPASS, "mq_timedreceive returned %ld, priority %u, length: %zu", + tst_res(TPASS, "mq_timedreceive() returned %ld, priority %u, length: %zu", TST_RET, prio, len); } static struct tst_test test = { .tcnt = ARRAY_SIZE(tcase), .test = do_test, - .setup = setup_common, + .test_variants = ARRAY_SIZE(variants), + .setup = setup, .cleanup = cleanup_common, .forks_child = 1, }; diff --git a/testcases/kernel/syscalls/utils/mq_timed.h b/testcases/kernel/syscalls/utils/mq_timed.h index a163ddcee3af..85b316334d7f 100644 --- a/testcases/kernel/syscalls/utils/mq_timed.h +++ b/testcases/kernel/syscalls/utils/mq_timed.h @@ -19,12 +19,15 @@ #define MQ_TIMED_H #include "mq.h" +#include "tst_timer.h" struct test_case { int *fd; unsigned int len; unsigned int prio; - struct timespec *rq; + struct tst_ts *rq; + long tv_sec; + long tv_nsec; int invalid_msg; int send; int signal; @@ -33,27 +36,20 @@ struct test_case { int err; }; -static pid_t set_sig(struct timespec *ts) +static pid_t set_sig(struct tst_ts *ts, + int (*gettime)(clockid_t clk_id, void *ts)) { - clock_gettime(CLOCK_REALTIME, ts); - ts->tv_sec += 3; + gettime(CLOCK_REALTIME, tst_ts_get(ts)); + *ts = tst_ts_add_us(*ts, 3000000); return create_sig_proc(SIGINT, 40, 200000); } -static void set_timeout(struct timespec *ts) +static void set_timeout(struct tst_ts *ts, + int (*gettime)(clockid_t clk_id, void *ts)) { - clock_gettime(CLOCK_REALTIME, ts); - ts->tv_nsec += 50000000; - ts->tv_sec += ts->tv_nsec / 1000000000; - ts->tv_nsec %= 1000000000; -} - -static void send_msg(int fd, int len, int prio) -{ - if (mq_timedsend(fd, smsg, len, prio, - &((struct timespec){0})) < 0) - tst_brk(TBROK | TERRNO, "mq_timedsend failed"); + gettime(CLOCK_REALTIME, tst_ts_get(ts)); + *ts = tst_ts_add_us(*ts, 50000); } static void kill_pid(pid_t pid) From patchwork Tue May 5 09:12:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 1283386 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=M6YYeplW; 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 49GYt23s0nz9sRf for ; Tue, 5 May 2020 19:13:14 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id AF0053C2671 for ; Tue, 5 May 2020 11:13:11 +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 F27BA3C2693 for ; Tue, 5 May 2020 11:12:31 +0200 (CEST) Received: from mail-pl1-x641.google.com (mail-pl1-x641.google.com [IPv6:2607:f8b0:4864:20::641]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by in-4.smtp.seeweb.it (Postfix) with ESMTPS id 3761D1000A81 for ; Tue, 5 May 2020 11:12:31 +0200 (CEST) Received: by mail-pl1-x641.google.com with SMTP id t16so559699plo.7 for ; Tue, 05 May 2020 02:12:31 -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=PZ7nhdh01PwwTLceqEUuXBelaPR7YrtjtVeXzJ+w5D4=; b=M6YYeplW1/PoFoawKlItJB2R8WiD//GmCzOeYAAxy+3Ig8WEmKt487ET6SdULOYCnT Qr8FfC+SsHUcWxw6vg4Pxc5+RiDmbg8MX6k7CLVWrrD+vaifGApxMSNF+kd30syYmUck FKUJ/NAjix5pQWJMbP6UNBaXxCtmChWPzI1pkjnWY5cqqofbyeHs7/zdZ5ecqoElFVe2 FJfe42Nyu/AA1Ag0knTFbOZfX7ek541PlGqwfBbpEhDdQqq1cSsRc2XYpOGjNJBCWcwd H2YOlX4RRpfn2zkm6rzouQX8NI1NpA6gZ6s1ao9uHqyoxnNJlrgrJc0puA+1URWFO2pE 3Kfw== 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=PZ7nhdh01PwwTLceqEUuXBelaPR7YrtjtVeXzJ+w5D4=; b=ti4KW55SbnwrGLVlYFnCELrWVm1sJmjQck/AGaW8PRA9GGIhl/evQC32g2sys2cEy/ eDemnyMwlEw03DcqJdzr77GW+dNfF+rmFs3JhPY9Q/UE//g7uLW8yIZcv79dOdna+qYb qSF/9AAGZx+HhpIe4Yc4GQpg3rRlKlV1f/GUNF4iZh5kGsmr/hBw7FBNCWSv7MHG4dFi pf/Q01ZKJycFCqfhBWjMu3orlRl9V/ITCg6lKCpf0vk0eYvUuOaFT6yPQ02V2/eWXAjh 5LATjjV8j4FK8MsInwvx3HHK2JJaOTT1Hq/rRPcTkuamXtnQbiEqZHKOaLy+RJ/RwYgY Ae0Q== X-Gm-Message-State: AGi0PuZrjXK7hcqNXMV5jnuiELryPKszNsr4HNiHHF8FhiDa3gQWL0To dKeYKK+DCGS+3IWfoY4BpFSb3/UQG44= X-Google-Smtp-Source: APiQypJTvhe6AlBNkDUc+UifeddZzzt89j89sQB6QghNhkNq7sFWZMSO1nyWU1gWAUXzNCt9FTBWzw== X-Received: by 2002:a17:902:aa94:: with SMTP id d20mr2125164plr.15.1588669949401; Tue, 05 May 2020 02:12:29 -0700 (PDT) Received: from localhost ([122.171.118.46]) by smtp.gmail.com with ESMTPSA id a7sm1497748pfg.157.2020.05.05.02.12.28 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 May 2020 02:12:28 -0700 (PDT) From: Viresh Kumar To: ltp@lists.linux.it Date: Tue, 5 May 2020 14:42:07 +0530 Message-Id: <5a1c2899e7001bb14c0b2987f72d28329522d63b.1588669892.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.25.0.rc1.19.g042ed3e048af In-Reply-To: <7e037dacaeb0c7f3bfd73cd11d80f3e1567dc052.1588669892.git.viresh.kumar@linaro.org> References: <7e037dacaeb0c7f3bfd73cd11d80f3e1567dc052.1588669892.git.viresh.kumar@linaro.org> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.99.2 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,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-4.smtp.seeweb.it Subject: [LTP] [PATCH 7/8] syscalls/recvmmsg: 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 recvmmsg() syscall tests. Signed-off-by: Viresh Kumar --- .../kernel/syscalls/sendmmsg/sendmmsg01.c | 45 +++++++++++---- .../kernel/syscalls/sendmmsg/sendmmsg_var.h | 55 ++++++++----------- 2 files changed, 58 insertions(+), 42 deletions(-) diff --git a/testcases/kernel/syscalls/sendmmsg/sendmmsg01.c b/testcases/kernel/syscalls/sendmmsg/sendmmsg01.c index 37084102ee09..5d1fd1b6b9fa 100644 --- a/testcases/kernel/syscalls/sendmmsg/sendmmsg01.c +++ b/testcases/kernel/syscalls/sendmmsg/sendmmsg01.c @@ -14,8 +14,8 @@ #include "tst_test.h" #include "lapi/socket.h" #include "tst_safe_macros.h" - #include "sendmmsg_var.h" +#include "lapi/abisize.h" #define BUFSIZE 16 #define VLEN 2 @@ -25,27 +25,52 @@ 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[] = { +#if defined(TST_ABI32) + { .receive = libc_recvmmsg, .send = libc_sendmmsg, .type = TST_LIBC_TIMESPEC, .desc = "vDSO or syscall with libc spec"}, + { .receive = sys_recvmmsg, .send = sys_sendmmsg, .type = TST_LIBC_TIMESPEC, .desc = "syscall with libc spec"}, + { .receive = sys_recvmmsg, .send = sys_sendmmsg, .type = TST_KERN_OLD_TIMESPEC, .desc = "syscall with kernel spec32"}, +#endif + +#if defined(TST_ABI64) + { .receive = sys_recvmmsg, .send = sys_sendmmsg, .type = TST_KERN_TIMESPEC, .desc = "syscall with kernel spec64"}, +#endif + +#if (__NR_recvmmsg_time64 != __LTP__NR_INVALID_SYSCALL) + { .receive = sys_recvmmsg64, .send = sys_sendmmsg, .type = TST_KERN_TIMESPEC, .desc = "syscall time64 with kernel spec64"}, +#endif +}; + static void run(void) { - struct timespec timeout; + struct test_variants *tv = &variants[tst_variant]; + struct tst_ts timeout; int retval; - retval = do_sendmmsg(send_sockfd, snd_msg, VLEN, 0); + retval = tv->send(send_sockfd, snd_msg, VLEN, 0); if (retval < 0 || snd_msg[0].msg_len != 6 || snd_msg[1].msg_len != 6) { - tst_res(TFAIL|TTERRNO, "sendmmsg failed"); + tst_res(TFAIL|TTERRNO, "sendmmsg() failed"); return; } memset(rcv1->iov_base, 0, rcv1->iov_len); memset(rcv2->iov_base, 0, rcv2->iov_len); - timeout.tv_sec = 1; - timeout.tv_nsec = 0; + timeout.type = tv->type; + tst_ts_set_sec(&timeout, 1); + tst_ts_set_nsec(&timeout, 0); - retval = do_recvmmsg(receive_sockfd, rcv_msg, VLEN, 0, &timeout); + retval = tv->receive(receive_sockfd, rcv_msg, VLEN, 0, tst_ts_get(&timeout)); if (retval == -1) { - tst_res(TFAIL | TTERRNO, "recvmmsg failed"); + tst_res(TFAIL | TTERRNO, "recvmmsg() failed"); return; } if (retval != 2) { @@ -96,7 +121,7 @@ static void setup(void) rcv_msg[1].msg_hdr.msg_iov = rcv2; rcv_msg[1].msg_hdr.msg_iovlen = 1; - test_info(); + tst_res(TINFO, "Testing variant: %s", variants[tst_variant].desc); } static void cleanup(void) @@ -111,7 +136,7 @@ static struct tst_test test = { .test_all = run, .setup = setup, .cleanup = cleanup, - .test_variants = TEST_VARIANTS, + .test_variants = ARRAY_SIZE(variants), .bufs = (struct tst_buffers []) { {&snd1, .iov_sizes = (int[]){3, 3, -1}}, {&snd2, .iov_sizes = (int[]){6, -1}}, diff --git a/testcases/kernel/syscalls/sendmmsg/sendmmsg_var.h b/testcases/kernel/syscalls/sendmmsg/sendmmsg_var.h index f00cf056a747..a142b17f9718 100644 --- a/testcases/kernel/syscalls/sendmmsg/sendmmsg_var.h +++ b/testcases/kernel/syscalls/sendmmsg/sendmmsg_var.h @@ -6,55 +6,46 @@ #ifndef SENDMMSG_VAR__ #define SENDMMSG_VAR__ +#include "tst_timer.h" #include "lapi/syscalls.h" -static int do_sendmmsg(int sockfd, struct mmsghdr *msgvec, unsigned int vlen, - int flags) +static inline int libc_sendmmsg(int sockfd, struct mmsghdr *msgvec, + unsigned int vlen, unsigned int flags) { - switch (tst_variant) { - case 0: - return tst_syscall(__NR_sendmmsg, sockfd, msgvec, vlen, flags); - case 1: #ifdef HAVE_SENDMMSG - return sendmmsg(sockfd, msgvec, vlen, flags); + return sendmmsg(sockfd, msgvec, vlen, flags); #else - tst_brk(TCONF, "libc sendmmsg not present"); + tst_brk(TCONF, "libc sendmmsg not present"); #endif - } +} - return -1; +static inline int sys_sendmmsg(int sockfd, struct mmsghdr *msgvec, + unsigned int vlen, unsigned int flags) +{ + return tst_syscall(__NR_sendmmsg, sockfd, msgvec, vlen, flags); } -static int do_recvmmsg(int sockfd, struct mmsghdr *msgvec, unsigned int vlen, - int flags, struct timespec *timeout) +static inline int libc_recvmmsg(int sockfd, struct mmsghdr *msgvec, + unsigned int vlen, unsigned int flags, void *timeout) { - switch (tst_variant) { - case 0: - return tst_syscall(__NR_recvmmsg, sockfd, msgvec, vlen, flags, - timeout); - case 1: #ifdef HAVE_RECVMMSG - return recvmmsg(sockfd, msgvec, vlen, flags, timeout); + return recvmmsg(sockfd, msgvec, vlen, flags, timeout); #else - tst_brk(TCONF, "libc recvmmsg not present"); + tst_brk(TCONF, "libc recvmmsg not present"); #endif - } - - return -1; } -static void test_info(void) +static inline int sys_recvmmsg(int sockfd, struct mmsghdr *msgvec, + unsigned int vlen, unsigned int flags, void *timeout) { - switch (tst_variant) { - case 0: - tst_res(TINFO, "Testing direct sendmmsg and recvmmsg syscalls"); - break; - case 1: - tst_res(TINFO, "Testing libc sendmmsg and recvmmsg syscalls"); - break; - } + return tst_syscall(__NR_recvmmsg, sockfd, msgvec, vlen, flags, timeout); } -#define TEST_VARIANTS 2 +static inline int sys_recvmmsg64(int sockfd, struct mmsghdr *msgvec, + unsigned int vlen, unsigned int flags, void *timeout) +{ + return tst_syscall(__NR_recvmmsg_time64, sockfd, msgvec, vlen, flags, + timeout); +} #endif /* SENDMMSG_VAR__ */ From patchwork Tue May 5 09:12:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 1283388 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=PzjuHx9N; 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 49GYtS0Kkxz9sRf for ; Tue, 5 May 2020 19:13:36 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 38E1D3C284A for ; Tue, 5 May 2020 11:13:33 +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 A48C83C2850 for ; Tue, 5 May 2020 11:12:34 +0200 (CEST) Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by in-4.smtp.seeweb.it (Postfix) with ESMTPS id EB8C51000604 for ; Tue, 5 May 2020 11:12:33 +0200 (CEST) Received: by mail-pl1-x644.google.com with SMTP id f8so567568plt.2 for ; Tue, 05 May 2020 02:12: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=bwq71tWgG/WrUMhraO8MmoGq1Vbh9a5BN4uN/QvtwEU=; b=PzjuHx9NEN2MUzI0eIWL8DzZZx63bGFParAClgREml2KiiwTS+cxlmgNbbh34Jl2ik K/557nXJZNwAsMAO4Y8UgPdHMIjy8tlyT8wtlwdNn3YSl4RhgYOnHEH+XuqffZdhTp/q Bt0tOXD1CIOYOmRDD15FBrRqRPtopxGtGpjZqzs9jXQIUGocctMii6YZDCEmGJyevPaf dn1cARpzXmu21AfTaJFwj25vaqMTWNKJlKmYqzb3HdtlNY5HSTJ5sqUU2+vn0cI0EHFE 9928ffL4q74aaSgTpb7gHT03Ee94Y5JNe58HZ8/u8y6QEZC0Xg24+jYo/vfNni/iILL0 4XMg== 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=bwq71tWgG/WrUMhraO8MmoGq1Vbh9a5BN4uN/QvtwEU=; b=B4h2aBkW0NsjbgcN7y3B6ByoY5qqt3yw1qceVNPxkIz7uakIyl8pAut0G5ibxtO4eh z0BLGB4KY69O0MhgfRH5OHiNQs4COEHs5bO8fGrA0V8/P4dkxpqi4wbA3yFxksKL7NA9 nNvvEHupMyibOvd/kxkam8Pc5d9UBZm91pTW6jK4v+nUG8Fhv/raql5GqKkptWaCEYyZ MqrHtnk5Xo6PGj05ICdL+nd5NYIyoWmU1jegIDgobrKeMqCtph/77WhP9axv9kqHFZ/g esr3vrg+XG4tE8BQnLlIRJFH1EOZ1AL+BXEtyO4mZOoA34K29CvsDDYKtPr9wrz7TyAP nVxw== X-Gm-Message-State: AGi0PuYkYk2MBtqBl+Z8kwDf0rUSQ6Az1xXLfosnZTR1P/zbX7B+8BFx zBmbsf1tjUgpKqW2Z+HEB1M2f8UoM0k= X-Google-Smtp-Source: APiQypLADjpgZb7NSgEIL9xEkJajivYo0uHfyhWC6WUMGME/psrRlXUTUlCazJncwE9tmozYSam08g== X-Received: by 2002:a17:90a:d56:: with SMTP id 22mr1644946pju.187.1588669952112; Tue, 05 May 2020 02:12:32 -0700 (PDT) Received: from localhost ([122.171.118.46]) by smtp.gmail.com with ESMTPSA id w11sm1136615pgj.4.2020.05.05.02.12.31 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 May 2020 02:12:31 -0700 (PDT) From: Viresh Kumar To: ltp@lists.linux.it Date: Tue, 5 May 2020 14:42:08 +0530 Message-Id: <3e96a3fa8df22b49edabdbce30ac72e744d6c1d4.1588669892.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.25.0.rc1.19.g042ed3e048af In-Reply-To: <7e037dacaeb0c7f3bfd73cd11d80f3e1567dc052.1588669892.git.viresh.kumar@linaro.org> References: <7e037dacaeb0c7f3bfd73cd11d80f3e1567dc052.1588669892.git.viresh.kumar@linaro.org> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.99.2 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,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-4.smtp.seeweb.it Subject: [LTP] [PATCH 8/8] syscalls/ppoll: 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 ppoll() syscall tests. Note that the O_EXCL flag is removed from SAFE_OPEN() calls as it made the tests failed when run for the second variant as the file existed. Signed-off-by: Viresh Kumar --- testcases/kernel/syscalls/ppoll/ppoll01.c | 76 ++++++++++++++++++----- 1 file changed, 60 insertions(+), 16 deletions(-) diff --git a/testcases/kernel/syscalls/ppoll/ppoll01.c b/testcases/kernel/syscalls/ppoll/ppoll01.c index 2fadd0653948..eb8a14534e2e 100644 --- a/testcases/kernel/syscalls/ppoll/ppoll01.c +++ b/testcases/kernel/syscalls/ppoll/ppoll01.c @@ -21,6 +21,8 @@ #include "ltp_signal.h" #include "tst_sig_proc.h" #include "tst_test.h" +#include "tst_timer.h" +#include "lapi/abisize.h" /* Older versions of glibc don't publish this constant's value. */ #ifndef POLLRDHUP @@ -38,7 +40,7 @@ struct test_case { unsigned int nfds; /* nfds ppoll parameter */ sigset_t *sigmask; /* sigmask ppoll parameter */ sigset_t *sigmask_cur; /* sigmask set for current process */ - struct timespec *ts; /* ts ppoll parameter */ + struct tst_ts *ts; /* ts ppoll parameter */ struct pollfd *fds; /* fds ppoll parameter */ int sigint_count; /* if > 0, spawn process to send SIGINT */ /* 'count' times to current process */ @@ -60,14 +62,7 @@ static int fd1 = -1; static sigset_t sigmask_empty, sigmask_sigint; static struct pollfd fds_good[1], fds_already_closed[1]; -static struct timespec ts_short = { - .tv_sec = 0, - .tv_nsec = 200000000, -}; -static struct timespec ts_long = { - .tv_sec = 2, - .tv_nsec = 0, -}; +static struct tst_ts ts_short, ts_long; /* Test cases * @@ -160,14 +155,57 @@ static struct test_case tcase[] = { }, }; +static inline int libc_ppoll(struct pollfd *fds, nfds_t nfds, void *tmo_p, + const sigset_t *sigmask, size_t sigsetsize) +{ + return ppoll(fds, nfds, tmo_p, sigmask); +} + +static inline int sys_ppoll(struct pollfd *fds, nfds_t nfds, void *tmo_p, + const sigset_t *sigmask, size_t sigsetsize) +{ + return tst_syscall(__NR_ppoll, fds, nfds, tmo_p, sigmask, sigsetsize); +} + +static inline int sys_ppoll_time64(struct pollfd *fds, nfds_t nfds, void *tmo_p, + const sigset_t *sigmask, size_t sigsetsize) +{ + return tst_syscall(__NR_ppoll_time64, fds, nfds, tmo_p, sigmask, + 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[] = { +#if defined(TST_ABI32) + { .ppoll = libc_ppoll, .type = TST_LIBC_TIMESPEC, .desc = "vDSO or syscall with libc spec"}, + { .ppoll = sys_ppoll, .type = TST_LIBC_TIMESPEC, .desc = "syscall with libc spec"}, + { .ppoll = sys_ppoll, .type = TST_KERN_OLD_TIMESPEC, .desc = "syscall with kernel spec32"}, +#endif + +#if defined(TST_ABI64) + { .ppoll = sys_ppoll, .type = TST_KERN_TIMESPEC, .desc = "syscall with kernel spec64"}, +#endif + +#if (__NR_ppoll_time64 != __LTP__NR_INVALID_SYSCALL) + { .ppoll = sys_ppoll_time64, .type = TST_KERN_TIMESPEC, .desc = "syscall time64 with kernel spec64"}, +#endif +}; + static void sighandler(int sig LTP_ATTRIBUTE_UNUSED) { } static void setup(void) { + struct test_variants *tv = &variants[tst_variant]; int fd2; + tst_res(TINFO, "Testing variant: %s", tv->desc); SAFE_SIGNAL(SIGINT, sighandler); if (sigemptyset(&sigmask_empty) == -1) @@ -177,18 +215,22 @@ static void setup(void) if (sigaddset(&sigmask_sigint, SIGINT) == -1) tst_brk(TBROK | TERRNO, "sigaddset"); - fd1 = SAFE_OPEN("testfile1", O_CREAT | O_EXCL | O_RDWR, - S_IRUSR | S_IWUSR); + fd1 = SAFE_OPEN("testfile1", O_CREAT | O_RDWR, S_IRUSR | S_IWUSR); fds_good[0].fd = fd1; fds_good[0].events = POLLIN | POLLPRI | POLLOUT | POLLRDHUP; fds_good[0].revents = 0; - fd2 = SAFE_OPEN("testfile2", O_CREAT | O_EXCL | O_RDWR, - S_IRUSR | S_IWUSR); + fd2 = SAFE_OPEN("testfile2", O_CREAT | O_RDWR, S_IRUSR | S_IWUSR); fds_already_closed[0].fd = fd2; fds_already_closed[0].events = POLLIN | POLLPRI | POLLOUT | POLLRDHUP; fds_already_closed[0].revents = 0; SAFE_CLOSE(fd2); + + ts_short.type = ts_long.type = tv->type; + tst_ts_set_sec(&ts_short, 0); + tst_ts_set_nsec(&ts_short, 200000000); + tst_ts_set_sec(&ts_long, 2); + tst_ts_set_nsec(&ts_long, 0); } static void cleanup(void) @@ -199,10 +241,11 @@ static void cleanup(void) static void do_test(unsigned int i) { + struct test_variants *tv = &variants[tst_variant]; pid_t pid = 0; int sys_ret, sys_errno = 0, dummy; struct test_case *tc = &tcase[i]; - struct timespec ts, *tsp = NULL; + struct tst_ts ts, *tsp = NULL; if (tc->ts) { memcpy(&ts, tc->ts, sizeof(ts)); @@ -223,8 +266,8 @@ static void do_test(unsigned int i) /* test */ errno = 0; - sys_ret = tst_syscall(__NR_ppoll, tc->fds, tc->nfds, tsp, - tc->sigmask, SIGSETSIZE); + sys_ret = tv->ppoll(tc->fds, tc->nfds, tst_ts_get(tsp), tc->sigmask, + SIGSETSIZE); sys_errno = errno; /* cleanup */ @@ -261,6 +304,7 @@ static void do_test(unsigned int i) static struct tst_test test = { .tcnt = ARRAY_SIZE(tcase), .test = do_test, + .test_variants = ARRAY_SIZE(variants), .setup = setup, .cleanup = cleanup, .forks_child = 1,