From patchwork Mon Aug 20 06:42:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Palethorpe X-Patchwork-Id: 959525 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) 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=none (p=none dis=none) header.from=suse.com Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41v45K4s0Hz9ryn for ; Mon, 20 Aug 2018 16:43:33 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 815063E6413 for ; Mon, 20 Aug 2018 08:43:30 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-2.smtp.seeweb.it (in-2.smtp.seeweb.it [IPv6:2001:4b78:1:20::2]) by picard.linux.it (Postfix) with ESMTP id 32B0E3E6407 for ; Mon, 20 Aug 2018 08:43:28 +0200 (CEST) Received: from mx1.suse.de (mx2.suse.de [195.135.220.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by in-2.smtp.seeweb.it (Postfix) with ESMTPS id 17B9860015C for ; Mon, 20 Aug 2018 08:43:25 +0200 (CEST) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 67AD3B05F for ; Mon, 20 Aug 2018 06:43:24 +0000 (UTC) From: Richard Palethorpe To: ltp@lists.linux.it Date: Mon, 20 Aug 2018 08:42:56 +0200 Message-Id: <20180820064257.17974-5-rpalethorpe@suse.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180820064257.17974-1-rpalethorpe@suse.com> References: <20180820064257.17974-1-rpalethorpe@suse.com> X-Virus-Scanned: clamav-milter 0.99.2 at in-2.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=-0.0 required=7.0 tests=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 Cc: Richard Palethorpe Subject: [LTP] [PATCH 4/5] Convert futex_wait_bitset tests to newlib X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.18 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Signed-off-by: Richard Palethorpe --- .../kernel/syscalls/futex/futex_wait_bitset.h | 54 ++++++++++++------- .../syscalls/futex/futex_wait_bitset01.c | 22 ++------ .../syscalls/futex/futex_wait_bitset02.c | 23 ++------ 3 files changed, 43 insertions(+), 56 deletions(-) diff --git a/testcases/kernel/syscalls/futex/futex_wait_bitset.h b/testcases/kernel/syscalls/futex/futex_wait_bitset.h index 81a5d93ab..090dc51d2 100644 --- a/testcases/kernel/syscalls/futex/futex_wait_bitset.h +++ b/testcases/kernel/syscalls/futex/futex_wait_bitset.h @@ -18,6 +18,7 @@ */ #define TRESHOLD_US 100000 +#define DEFAULT_TIMEOUT_US 100010 static void verify_futex_wait_bitset(long long wait_us, clock_t clk_id) { @@ -26,8 +27,8 @@ static void verify_futex_wait_bitset(long long wait_us, clock_t clk_id) u_int32_t bitset = 0xffffffff; int flags = clk_id == CLOCK_REALTIME ? FUTEX_CLOCK_REALTIME : 0; - tst_resm(TINFO, "testing futex_wait_bitset() timeout with %s", - clk_id == CLOCK_REALTIME ? "CLOCK_REALTIME" : "CLOCK_MONOTONIC"); + 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); @@ -36,38 +37,53 @@ static void verify_futex_wait_bitset(long long wait_us, clock_t clk_id) clock_gettime(clk_id, &end); - if (TEST_RETURN != -1) { - tst_resm(TFAIL, "futex_wait_bitset() returned %li, expected -1", - TEST_RETURN); + if (TST_RET != -1) { + tst_res(TFAIL, "futex_wait_bitset() returned %li, expected -1", + TST_RET); return; } - if (TEST_ERRNO == ENOSYS) { - tst_resm(TCONF, "In this kernel, futex() does not support " - "FUTEX_WAIT_BITSET operation"); + if (TST_ERR == ENOSYS) { + tst_res(TCONF, + "In this kernel, futex() does not support FUTEX_WAIT_BITSET operation"); return; } - if (TEST_ERRNO != ETIMEDOUT) { - tst_resm(TFAIL | TTERRNO, "expected %s", - tst_strerrno(ETIMEDOUT)); + if (TST_ERR != ETIMEDOUT) { + tst_res(TFAIL | TTERRNO, "expected %s", + tst_strerrno(ETIMEDOUT)); return; } if (tst_timespec_lt(end, to)) { - tst_resm(TFAIL, - "futex_wait_bitset() woken up prematurely %llius, expected %llius", - tst_timespec_diff_us(end, start), wait_us); + 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) > TRESHOLD_US) { - tst_resm(TFAIL, - "futex_wait_bitset() waited too long %llius, expected %llius", - tst_timespec_diff_us(end, start), wait_us); + tst_res(TFAIL, + "futex_wait_bitset() waited too long %llius, expected %llius", + tst_timespec_diff_us(end, start), wait_us); return; } - tst_resm(TPASS, "futex_wait_bitset() waited %llius, expected %llius", - tst_timespec_diff_us(end, start), wait_us); + 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 e5fd621e5..371febb3b 100644 --- a/testcases/kernel/syscalls/futex/futex_wait_bitset01.c +++ b/testcases/kernel/syscalls/futex/futex_wait_bitset01.c @@ -24,25 +24,11 @@ #include -#include "test.h" +#include "tst_test.h" +#include "tst_timer.h" #include "futextest.h" -#include "futex_wait_bitset.h" - -const char *TCID="futex_wait_bitset01"; -const int TST_TOTAL=1; - -#define DEFAULT_TIMEOUT_US 100010 -int main(int argc, char *argv[]) -{ - int lc; +#define USE_CLOCK CLOCK_MONOTONIC - tst_timer_check(CLOCK_MONOTONIC); - - tst_parse_opts(argc, argv, NULL, NULL); - - for (lc = 0; TEST_LOOPING(lc); lc++) - verify_futex_wait_bitset(DEFAULT_TIMEOUT_US, CLOCK_MONOTONIC); +#include "futex_wait_bitset.h" - tst_exit(); -} diff --git a/testcases/kernel/syscalls/futex/futex_wait_bitset02.c b/testcases/kernel/syscalls/futex/futex_wait_bitset02.c index 820c65c26..e727a1b38 100644 --- a/testcases/kernel/syscalls/futex/futex_wait_bitset02.c +++ b/testcases/kernel/syscalls/futex/futex_wait_bitset02.c @@ -24,25 +24,10 @@ #include -#include "test.h" +#include "tst_test.h" +#include "tst_timer.h" #include "futextest.h" -#include "futex_wait_bitset.h" - -const char *TCID="futex_wait_bitset02"; -const int TST_TOTAL=1; - -#define DEFAULT_TIMEOUT_US 100010 - -int main(int argc, char *argv[]) -{ - int lc; - tst_timer_check(CLOCK_REALTIME); +#define USE_CLOCK CLOCK_REALTIME - tst_parse_opts(argc, argv, NULL, NULL); - - for (lc = 0; TEST_LOOPING(lc); lc++) - verify_futex_wait_bitset(DEFAULT_TIMEOUT_US, CLOCK_REALTIME); - - tst_exit(); -} +#include "futex_wait_bitset.h"