From patchwork Mon Nov 18 02:34:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Xu X-Patchwork-Id: 1196492 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=none (p=none dis=none) header.from=cn.fujitsu.com Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47GY3842jrz9sQp for ; Mon, 18 Nov 2019 13:35:31 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 4ED5E3C2078 for ; Mon, 18 Nov 2019 03:35:27 +0100 (CET) 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 B25EB3C1824 for ; Mon, 18 Nov 2019 03:35:24 +0100 (CET) Received: from heian.cn.fujitsu.com (mail.cn.fujitsu.com [183.91.158.132]) by in-4.smtp.seeweb.it (Postfix) with ESMTP id AB3B4100185A for ; Mon, 18 Nov 2019 03:35:21 +0100 (CET) X-IronPort-AV: E=Sophos;i="5.68,318,1569254400"; d="scan'208";a="78638947" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 18 Nov 2019 10:35:18 +0800 Received: from G08CNEXCHPEKD02.g08.fujitsu.local (unknown [10.167.33.83]) by cn.fujitsu.com (Postfix) with ESMTP id 85D7E4CE1A05 for ; Mon, 18 Nov 2019 10:27:00 +0800 (CST) Received: from localhost.localdomain (10.167.220.84) by G08CNEXCHPEKD02.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 18 Nov 2019 10:35:27 +0800 From: Yang Xu To: Date: Mon, 18 Nov 2019 10:34:54 +0800 Message-ID: <1574044495-2813-1-git-send-email-xuyang2018.jy@cn.fujitsu.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <20191115163517.GB25964@rei.lan> References: <20191115163517.GB25964@rei.lan> MIME-Version: 1.0 X-Originating-IP: [10.167.220.84] X-yoursite-MailScanner-ID: 85D7E4CE1A05.AB587 X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: xuyang2018.jy@cn.fujitsu.com X-Spam-Status: No, score=0.4 required=7.0 tests=KHOP_HELO_FCRDNS, SPF_HELO_NONE, SPF_NONE autolearn=disabled version=3.4.0 X-Virus-Scanned: clamav-milter 0.99.2 at in-4.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-4.smtp.seeweb.it Subject: [LTP] [PATCH v6 1/2] lib/tst_timer_test: move test setup function before PR_GET_TIMERSLACK 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: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Move test setup function before PR_GET_TIMERSLACK in timer setup function so that the library includes the newly set timerslack in the calculation. Signed-off-by: Yang Xu Reviewed-by: Cyril Hrubis --- lib/tst_timer_test.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/tst_timer_test.c b/lib/tst_timer_test.c index f6459e5c0..13e9deff2 100644 --- a/lib/tst_timer_test.c +++ b/lib/tst_timer_test.c @@ -340,6 +340,9 @@ static void timer_setup(void) struct timespec t; int ret; + if (setup) + setup(); + tst_clock_getres(CLOCK_MONOTONIC, &t); tst_res(TINFO, "CLOCK_MONOTONIC resolution %lins", (long)t.tv_nsec); @@ -360,16 +363,11 @@ static void timer_setup(void) tst_res(TINFO, "PR_GET_TIMERSLACK not defined, using %uus", timerslack); #endif /* PR_GET_TIMERSLACK */ - parse_timer_opts(); samples = SAFE_MALLOC(sizeof(long long) * MAX(MAX_SAMPLES, sample_cnt)); - if (set_latency() < 0) tst_res(TINFO, "Failed to set zero latency constraint: %m"); - - if (setup) - setup(); } static void timer_cleanup(void) From patchwork Mon Nov 18 02:34:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Xu X-Patchwork-Id: 1196493 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=none (p=none dis=none) header.from=cn.fujitsu.com 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 47GY3H6MsGz9sPj for ; Mon, 18 Nov 2019 13:35:39 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 41D1C3C2033 for ; Mon, 18 Nov 2019 03:35:37 +0100 (CET) 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 8AC283C2219 for ; Mon, 18 Nov 2019 03:35:34 +0100 (CET) Received: from heian.cn.fujitsu.com (mail.cn.fujitsu.com [183.91.158.132]) by in-2.smtp.seeweb.it (Postfix) with ESMTP id 4DE57602456 for ; Mon, 18 Nov 2019 03:35:32 +0100 (CET) X-IronPort-AV: E=Sophos;i="5.68,318,1569254400"; d="scan'208";a="78638954" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 18 Nov 2019 10:35:31 +0800 Received: from G08CNEXCHPEKD02.g08.fujitsu.local (unknown [10.167.33.83]) by cn.fujitsu.com (Postfix) with ESMTP id D1B624CE1513 for ; Mon, 18 Nov 2019 10:27:12 +0800 (CST) Received: from localhost.localdomain (10.167.220.84) by G08CNEXCHPEKD02.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 18 Nov 2019 10:35:39 +0800 From: Yang Xu To: Date: Mon, 18 Nov 2019 10:34:55 +0800 Message-ID: <1574044495-2813-2-git-send-email-xuyang2018.jy@cn.fujitsu.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1574044495-2813-1-git-send-email-xuyang2018.jy@cn.fujitsu.com> References: <20191115163517.GB25964@rei.lan> <1574044495-2813-1-git-send-email-xuyang2018.jy@cn.fujitsu.com> MIME-Version: 1.0 X-Originating-IP: [10.167.220.84] X-yoursite-MailScanner-ID: D1B624CE1513.AC5AD X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: xuyang2018.jy@cn.fujitsu.com X-Spam-Status: No, score=0.4 required=7.0 tests=KHOP_HELO_FCRDNS, SPF_HELO_NONE, SPF_NONE autolearn=disabled version=3.4.0 X-Virus-Scanned: clamav-milter 0.99.2 at in-2.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-2.smtp.seeweb.it Subject: [LTP] [PATCH v6 2/2] syscalls/prctl09: New timer sample test for PR_SET_TIMERSLACK 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: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Signed-off-by: Yang Xu Reviewed-by: Cyril Hrubis --- runtest/syscalls | 1 + testcases/kernel/syscalls/prctl/.gitignore | 1 + testcases/kernel/syscalls/prctl/Makefile | 2 +- testcases/kernel/syscalls/prctl/prctl09.c | 47 ++++++++++++++++++++++ 4 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 testcases/kernel/syscalls/prctl/prctl09.c diff --git a/runtest/syscalls b/runtest/syscalls index fee91f909..e4e162b23 100644 --- a/runtest/syscalls +++ b/runtest/syscalls @@ -880,6 +880,7 @@ prctl05 prctl05 prctl06 prctl06 prctl07 prctl07 prctl08 prctl08 +prctl09 prctl09 pread01 pread01 pread01_64 pread01_64 diff --git a/testcases/kernel/syscalls/prctl/.gitignore b/testcases/kernel/syscalls/prctl/.gitignore index fe36a8e0f..0f2c9b194 100644 --- a/testcases/kernel/syscalls/prctl/.gitignore +++ b/testcases/kernel/syscalls/prctl/.gitignore @@ -7,3 +7,4 @@ /prctl06_execve /prctl07 /prctl08 +/prctl09 diff --git a/testcases/kernel/syscalls/prctl/Makefile b/testcases/kernel/syscalls/prctl/Makefile index cf19507c0..c02b6d1de 100644 --- a/testcases/kernel/syscalls/prctl/Makefile +++ b/testcases/kernel/syscalls/prctl/Makefile @@ -21,5 +21,5 @@ top_srcdir ?= ../../../.. include $(top_srcdir)/include/mk/testcases.mk prctl07: LDLIBS += $(CAP_LIBS) - +prctl09: LDLIBS += -lrt include $(top_srcdir)/include/mk/generic_leaf_target.mk diff --git a/testcases/kernel/syscalls/prctl/prctl09.c b/testcases/kernel/syscalls/prctl/prctl09.c new file mode 100644 index 000000000..0d94df7b5 --- /dev/null +++ b/testcases/kernel/syscalls/prctl/prctl09.c @@ -0,0 +1,47 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) 2019 FUJITSU LIMITED. All rights reserved. + * Author: Yang Xu + */ + +/* + * Test Description: + * This is a timer sample test that timer slack is 200us. + */ + +#include +#include +#include "lapi/prctl.h" +#include "tst_timer_test.h" + +int sample_fn(int clk_id, long long usec) +{ + struct timespec t = tst_us_to_timespec(usec); + + tst_timer_start(clk_id); + TEST(nanosleep(&t, NULL)); + tst_timer_stop(); + tst_timer_sample(); + + if (TST_RET != 0) { + tst_res(TFAIL | TTERRNO, + "nanosleep() returned %li", TST_RET); + return 1; + } + + return 0; +} + +static void setup(void) +{ + TEST(prctl(PR_SET_TIMERSLACK, 200000)); + if (TST_RET != 0) + tst_brk(TBROK | TTERRNO, + "prctl set timerslack 200us failed"); +} + +static struct tst_test test = { + .setup = setup, + .scall = "prctl()", + .sample = sample_fn, +};