From patchwork Tue Jan 29 17:36:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rafael David Tinoco X-Patchwork-Id: 157001 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp4935144jaa; Tue, 29 Jan 2019 09:37:11 -0800 (PST) X-Google-Smtp-Source: ALg8bN5+IHGLR6vUr5XVJTEDAFOXorBciDHSkZZps3VBbuNQIvlWzSQxM2eMAqex2Jgc1fC2nIhF X-Received: by 2002:a17:906:3105:: with SMTP id 5-v6mr23529491ejx.122.1548783431222; Tue, 29 Jan 2019 09:37:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548783431; cv=none; d=google.com; s=arc-20160816; b=ousralmiMxWdHZZlM6MNnvqEctkDyDsM3UfLva4IlmaiegDTXqPPFJj9FbgNY0Gtw3 k/8VD/GH+FXNAqOJfVltSEaMET3MzTi3sa3wx5gGB9RR7LsqgVnTqDitk72G8eRIirRB UIDrqF/WcN3cxpcCI8awwEq+K2e1Ey+WghKhAALnX3LFQY5B5/l17b7IklnNsN3O/llY YtVU54ibRa/K6aNthRX3CKbQjsre4RwkyoM8SK1TizbWKhgpl2LkvJWXNGegitaOwXqF +TpkVi8GZvVtRPs/Djb3gOgv5XVqy4TF3fdwG9+d7BxE997C5Sfk1KCnGSqOD+Qt2beu 9mlA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :dkim-signature:delivered-to; bh=/W8q7wtpBgkGwvykbI08MJ7lvoOZePXucEoD41PzcHI=; b=ivtkMZx2uqmNST0+SRY52/CKx6r8S0OxfTfAOzNPhW+S2rdaHiXMsya2qXaimb0O/i F9gc+jjWErurWQrKGxrdmhmjgWoaqshgNXSLNAcJtq1pFr7w295KANOpvx5zFRGI8Ml+ qOgQbY8rdL6eKt2lXTylfOHPZPGU61LW4GUHB2qmeGmjQqcHPo81PMNNlSFyaIh4nVSO 1hb7tTLPPjwXtVOTPbgI1q6O8xIpghqpNLRhfy/xOnMgDQzdCML9rY2jwEyvcUUWf3Wj d0M2+eECe0hNtk3ELArcBY7056IRqaYbLU5Jdr2n+dq+CdP9wuGIxTVMlcwZ1oQhYL6u gsrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=IyRQ2CTE; spf=pass (google.com: domain of ltp-bounces+patch=linaro.org@lists.linux.it designates 2001:1418:10:5::2 as permitted sender) smtp.mailfrom="ltp-bounces+patch=linaro.org@lists.linux.it"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from picard.linux.it (picard.linux.it. [2001:1418:10:5::2]) by mx.google.com with ESMTPS id z31si2351946ede.13.2019.01.29.09.37.11 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 Jan 2019 09:37:11 -0800 (PST) Received-SPF: pass (google.com: domain of ltp-bounces+patch=linaro.org@lists.linux.it designates 2001:1418:10:5::2 as permitted sender) client-ip=2001:1418:10:5::2; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=IyRQ2CTE; spf=pass (google.com: domain of ltp-bounces+patch=linaro.org@lists.linux.it designates 2001:1418:10:5::2 as permitted sender) smtp.mailfrom="ltp-bounces+patch=linaro.org@lists.linux.it"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id C51B73EAD13 for ; Tue, 29 Jan 2019 18:37:10 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-6.smtp.seeweb.it (in-6.smtp.seeweb.it [217.194.8.6]) by picard.linux.it (Postfix) with ESMTP id 8F5543EA022 for ; Tue, 29 Jan 2019 18:37:05 +0100 (CET) Received: from mail-qt1-x842.google.com (mail-qt1-x842.google.com [IPv6:2607:f8b0:4864:20::842]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by in-6.smtp.seeweb.it (Postfix) with ESMTPS id 639E21401143 for ; Tue, 29 Jan 2019 18:37:04 +0100 (CET) Received: by mail-qt1-x842.google.com with SMTP id t13so23167034qtn.3 for ; Tue, 29 Jan 2019 09:37:04 -0800 (PST) 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=8eZWFlZjo2a2QlPx6EwjutYpOVDtflVFqk4ndPqEq38=; b=IyRQ2CTEDKfoJkWGguhaL+Vaj+K1uf2Gy3LLXNQ9wJT9FQzrk3loznuYn6j0KLHMHJ aOqN2osYwcP1rqNmznYmjR8QNFqgkNpo1kPCKe8XCPSbGhE6N8oG0oUDS9O7NfPXPlC5 8VK8JbEAlP8C8EqyUGWPkuxr1WZT9JliDncJU= 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=8eZWFlZjo2a2QlPx6EwjutYpOVDtflVFqk4ndPqEq38=; b=YacDP35LBowS5ssyixfpsG6IRDaCOZPlGXAHE48rr4kyqdNX9tC8YTIw5cHiRiCsbq uFF/yNMmhs7Hg6e/ARbw9z1Zax4vq4JJv8Ma97sioRLt10+kqcIvM8G5O9N6FxPFkqun eAzCPqsJ2ZXrUtRwIqx3Ere9Fxo38793tNzEqO8EarvB3PzWQhpVg32h3HXQoXn+3nT6 4BhGn9i47eaSrzzHtNgbF/r0if/qiXK+MWnGRDE5WFOpCR3wshh5INEkHcCpPfhSPZmJ mTotI4Y6b2jliomAeSXZHi1WLcO0EXKEABXgTSu9CSFjSsMnZ6dnPCTYkOzUKqm/A9in n/8Q== X-Gm-Message-State: AJcUukfAdwrvySzlsP4MkPeKRYZN+Xm7StptDIWmycglik/cPPxwvJSR usVZ8kh3a9EBhEcX4Zek7inWmPXBd9E= X-Received: by 2002:a0c:b6c3:: with SMTP id h3mr26164344qve.128.1548783422941; Tue, 29 Jan 2019 09:37:02 -0800 (PST) Received: from workstation.celeiro.br. ([168.194.163.64]) by smtp.gmail.com with ESMTPSA id a20sm56890855qkj.28.2019.01.29.09.37.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 Jan 2019 09:37:02 -0800 (PST) From: Rafael David Tinoco To: ltp@lists.linux.it Date: Tue, 29 Jan 2019 15:36:52 -0200 Message-Id: <20190129173659.27901-1-rafael.tinoco@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190124161159.GC16804@rei.lan> References: <20190124161159.GC16804@rei.lan> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.99.2 at in-6.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_PASS autolearn=disabled version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-6.smtp.seeweb.it Subject: [LTP] [PATCH v4 1/8] lib: add tst_clock_settime() to tst_clocks.h 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: , Errors-To: ltp-bounces+patch=linaro.org@lists.linux.it Sender: "ltp" Adds tst_clock_settime() function to the lib. Signed-off-by: Rafael David Tinoco --- include/tst_clocks.h | 2 ++ lib/tst_clocks.c | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/include/tst_clocks.h b/include/tst_clocks.h index ee2f645c7..90784a3fd 100644 --- a/include/tst_clocks.h +++ b/include/tst_clocks.h @@ -26,4 +26,6 @@ int tst_clock_getres(clockid_t clk_id, struct timespec *res); int tst_clock_gettime(clockid_t clk_id, struct timespec *ts); +int tst_clock_settime(clockid_t clk_id, struct timespec *ts); + #endif /* TST_CLOCKS__ */ diff --git a/lib/tst_clocks.c b/lib/tst_clocks.c index 87413a339..35798a4aa 100644 --- a/lib/tst_clocks.c +++ b/lib/tst_clocks.c @@ -35,3 +35,8 @@ int tst_clock_gettime(clockid_t clk_id, struct timespec *ts) { return syscall(SYS_clock_gettime, clk_id, ts); } + +int tst_clock_settime(clockid_t clk_id, struct timespec *ts) +{ + return syscall(SYS_clock_settime, clk_id, ts); +} From patchwork Tue Jan 29 17:36:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rafael David Tinoco X-Patchwork-Id: 157002 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp4935238jaa; Tue, 29 Jan 2019 09:37:17 -0800 (PST) X-Google-Smtp-Source: AHgI3IYOP96+cgAry+Py5U/4B22WYW3O7UB/oTjvqKMHokStKtpPENEegspsL0GTl/7Oe+CItwo6 X-Received: by 2002:a1c:e10a:: with SMTP id y10mr12554787wmg.73.1548783437092; Tue, 29 Jan 2019 09:37:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548783437; cv=none; d=google.com; s=arc-20160816; b=ZabtZuQMQWDmuTgU32BYQjsmZL7+lBZLT1eNgmLBVCRBe5vk/EBlqvXpFdpUvD/fhG gHgGFQtvRKp9Q8wbzhM9EWj76QVHhrqjzsRyHbGAATrR837UgLodprOjEEQTaGoBeDo6 Y97uzA78iwUdE8NwPii4RuW74HM6YNZWyZdvQpsa2b7nEWRFCt/T9Iuk4TOQo5mmfE8p 691sReyXSMOmktyLS5gA8VG4kZ+ig9wCgK6qI/eBf4eV71fgL+TCP+bbNPrTA2GJKL1t UECe/YDfBBRRp8YUbGju1rIP9Vs1PIZrV/ss5m7gym2bxg5hdN+EqUTjz3VOP6aCjXDb syrg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :dkim-signature:delivered-to; bh=CDLLaQZE3VgTZPdFf+OG7fnQ3a4864B4SLYxd+iw484=; b=bxGeUHbS9TrBoc/+0/OZElnj49x5cvmAmpvyiRXaejNCYIw0KSctpCh73AUWErpHmq BofBuJ5fi3e8q9YQnw4DdImGZY4RtfSiHU8hReXuEBsyGZI4R5ZdoR2egE0gdSZrCl31 hyHHR/Qmdmz/SpWJv0B16fVvlbd6JOTrgviLQaS4uHQFM9bgJltfsamiKj4I8Xxltyat mwhoOx0lGBj6FP/EC+EWV+K/Vd+Ysd8V8tKiq/MnoBX+CnWWf+dhdE88F1rlMz6wTfIj JrmOLBIJcZpP38dmpo91hnUQ9TSX6keAdWVclDPXUTsS6l/oiljigdjYcnsnHCfE4Ehn AuWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=UKZa1nhu; spf=pass (google.com: domain of ltp-bounces+patch=linaro.org@lists.linux.it designates 213.254.12.146 as permitted sender) smtp.mailfrom="ltp-bounces+patch=linaro.org@lists.linux.it"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from picard.linux.it (picard.linux.it. [213.254.12.146]) by mx.google.com with ESMTPS id h19si2461254wme.135.2019.01.29.09.37.16 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 Jan 2019 09:37:17 -0800 (PST) Received-SPF: pass (google.com: domain of ltp-bounces+patch=linaro.org@lists.linux.it designates 213.254.12.146 as permitted sender) client-ip=213.254.12.146; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=UKZa1nhu; spf=pass (google.com: domain of ltp-bounces+patch=linaro.org@lists.linux.it designates 213.254.12.146 as permitted sender) smtp.mailfrom="ltp-bounces+patch=linaro.org@lists.linux.it"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id A13893EAD18 for ; Tue, 29 Jan 2019 18:37:16 +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 DE0DD3EA022 for ; Tue, 29 Jan 2019 18:37:06 +0100 (CET) Received: from mail-qk1-x744.google.com (mail-qk1-x744.google.com [IPv6:2607:f8b0:4864:20::744]) (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 8FDAA1000150 for ; Tue, 29 Jan 2019 18:37:05 +0100 (CET) Received: by mail-qk1-x744.google.com with SMTP id w204so12028595qka.2 for ; Tue, 29 Jan 2019 09:37:06 -0800 (PST) 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=nZi5PyMITqgHb+ggA7163PudKqSlxIGTd8pn1MubtZE=; b=UKZa1nhujvjdvTjwxJn+Id9R1DkxKGPHAQbvuURsV0wbkqQT98wkK5HxM7Yrjg3Z0X Is5kh1Sax00S4kCGHlkoJIbJPbOyhRk+YtujXjtiAqedNnSnF6st8s77eYYhb35gKWW5 YzpHOdWgfDHB2UN3I82GgTHsNrv/VlhPTnnn8= 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=nZi5PyMITqgHb+ggA7163PudKqSlxIGTd8pn1MubtZE=; b=jxoyvakm4CCJMZix0+UyDE3uBVCx0yWO6mtCK7/OOfkwqN740B/qD2Sbvsd6rc3bUC qqYMN9He9wnb1EviguCVnma0DnoALV2DobwbXWqdEVSGARMbIz9Sydd9glJWZhFaJlxN JcPSEKzHZjQJgXtJpCMn5aIWwBJkI/noC5VHw3F+QaeiS/QvGhDH6KBSVq0yEg6qkGKD s/shJsfPMBbAcrHvEamXrMcq8nD1Ia+O7lFGtuAJ/eoXRtcDbHrwemhjL9eWaDYRdYX7 Ia9CMifKU0WC7sv29ftxlmlISAOIQiyFBica7TeNVYQeaVNiNWLlMskNATbJv5LodbbL 11sw== X-Gm-Message-State: AJcUukfhvdWZhKTDA1pJ3tACB0gfZ02L4/WkC9vUbG7hpVyqWVsqG0KO a7VaB0j4Fxpn6GYDmxBHocUrqlT7/VA= X-Received: by 2002:a37:7d05:: with SMTP id y5mr23138294qkc.310.1548783424922; Tue, 29 Jan 2019 09:37:04 -0800 (PST) Received: from workstation.celeiro.br. ([168.194.163.64]) by smtp.gmail.com with ESMTPSA id a20sm56890855qkj.28.2019.01.29.09.37.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 Jan 2019 09:37:04 -0800 (PST) From: Rafael David Tinoco To: ltp@lists.linux.it Date: Tue, 29 Jan 2019 15:36:53 -0200 Message-Id: <20190129173659.27901-2-rafael.tinoco@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190129173659.27901-1-rafael.tinoco@linaro.org> References: <20190124161159.GC16804@rei.lan> <20190129173659.27901-1-rafael.tinoco@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_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 v4 2/8] lib: include SAFE_CLOCK_SETTIME() macro 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: , Errors-To: ltp-bounces+patch=linaro.org@lists.linux.it Sender: "ltp" Adds SAFE_CLOCK_SETTIME() macro to tst_safe_clocks.h. Signed-off-by: Rafael David Tinoco --- include/tst_safe_clocks.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/include/tst_safe_clocks.h b/include/tst_safe_clocks.h index 1b4d48543..553f8464a 100644 --- a/include/tst_safe_clocks.h +++ b/include/tst_safe_clocks.h @@ -30,9 +30,23 @@ static inline void safe_clock_gettime(const char *file, const int lineno, "%s:%d clock_gettime() failed", file, lineno); } + +static inline void safe_clock_settime(const char *file, const int lineno, + clockid_t clk_id, struct timespec *tp) +{ + int rval; + + rval = clock_settime(clk_id, tp); + if (rval != 0) + tst_brk(TBROK | TERRNO, + "%s:%d clock_gettime() failed", file, lineno); +} + #define SAFE_CLOCK_GETRES(clk_id, res)\ safe_clock_getres(__FILE__, __LINE__, (clk_id), (res)) #define SAFE_CLOCK_GETTIME(clk_id, tp)\ safe_clock_gettime(__FILE__, __LINE__, (clk_id), (tp)) +#define SAFE_CLOCK_SETTIME(clk_id, tp)\ + safe_clock_settime(__FILE__, __LINE__, (clk_id), (tp)) From patchwork Tue Jan 29 17:36:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rafael David Tinoco X-Patchwork-Id: 157003 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp4935380jaa; Tue, 29 Jan 2019 09:37:25 -0800 (PST) X-Google-Smtp-Source: ALg8bN6/YJdrPegLMj6Gd8JTnq5xE4SnpJoRTuIO6YMvH6cOrENIL6Z0OdoMYBBeYP9YCrJmwNoZ X-Received: by 2002:a5d:5607:: with SMTP id l7mr27069615wrv.25.1548783444957; Tue, 29 Jan 2019 09:37:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548783444; cv=none; d=google.com; s=arc-20160816; b=J1w7N1uHP2X/jvcWEUKLtQVyB8l1USqu+L7S/nzOeA3VnZ7vLA2dX7epfFWh5UKkjF VrIw3f2Cc1eWeKwWmfElglRpWcEOivQHFn2G6kMEt3D4aPd6nb2ADkKXHkeYoSObR6Y8 TEcbxI4/AiWzazi3qTEEoBmG9KMcq05gSjavV1QD5YWlShV/vF3biDvtVUFfoPvKCUzX +uGCBJGBfEH/EGy3v44MvQaj5Ayu7md7M+aeDWP2jfc0Tz9dF8CzzjLWhFlSTmjD2NHb BL0IpQ17rue7yYHnY8fmi5haCj8xB1Tyocs43/W29gk69JA0zYOARjGBAYz++brP8DvT Pugw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :dkim-signature:delivered-to; bh=S9jp2inM0K+jfdu3zJmjERXtONQpXybiiEzGtADULh8=; b=Njs9tZ0H2gfaCbHmlqAljGHkDRadSu2U66Fc0N2ABycNUNMcG/N5jtL6LsWvZtX789 RfM9311NxDeRMLlZiaOO8F6zKcw5mVnkWofus5Rq6V9Hk5K/ydOZT1SIbkDSxLp24sJf bNJQaeFTQV2sa2iYGXXMWVfmzMrloDtH4D0aGmTHTX72R9tR1GG4mVn4DHHweM9hvTrD HgcRQJYU2XhJRZ1fSRbffn2jfZyIoDgRNxikfdPcWLe37+jnVK795/yyzX+kjg66ALVN /yEdKwO5Ghkkw7lc3eXJ93R0Ca19AC/vFpRbgLK3U+mRzXJqn4YZUPcxq95GXvhfr/vC zRZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=XzNT6uGc; spf=pass (google.com: domain of ltp-bounces+patch=linaro.org@lists.linux.it designates 213.254.12.146 as permitted sender) smtp.mailfrom="ltp-bounces+patch=linaro.org@lists.linux.it"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from picard.linux.it (picard.linux.it. [213.254.12.146]) by mx.google.com with ESMTPS id n123si2498810wmb.157.2019.01.29.09.37.24 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 Jan 2019 09:37:24 -0800 (PST) Received-SPF: pass (google.com: domain of ltp-bounces+patch=linaro.org@lists.linux.it designates 213.254.12.146 as permitted sender) client-ip=213.254.12.146; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=XzNT6uGc; spf=pass (google.com: domain of ltp-bounces+patch=linaro.org@lists.linux.it designates 213.254.12.146 as permitted sender) smtp.mailfrom="ltp-bounces+patch=linaro.org@lists.linux.it"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 65FDB3EA11D for ; Tue, 29 Jan 2019 18:37:24 +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 930FF3EA141 for ; Tue, 29 Jan 2019 18:37:08 +0100 (CET) Received: from mail-qk1-x744.google.com (mail-qk1-x744.google.com [IPv6:2607:f8b0:4864:20::744]) (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 65A701000344 for ; Tue, 29 Jan 2019 18:37:07 +0100 (CET) Received: by mail-qk1-x744.google.com with SMTP id 189so12004373qkj.8 for ; Tue, 29 Jan 2019 09:37:07 -0800 (PST) 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=Ta7mmR7EcqJxkjjzwzpOa8yt//xNRN7Al5Qvzt2G2hA=; b=XzNT6uGcol183FSACQixHDra8BhIE6dDFzc0XiHHhXmTcEUqd59XPQV98I2uj91AHr D6GImZikfmLrBtub0kYtKfmgo7lZZ8xrRXXG44N3/Cz4WbNwe6rTzK6maJV8GLtQW8/Q Kj4exOOt2kShvg9q1Z4RJwiGNuIeQVWtJ4huc= 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=Ta7mmR7EcqJxkjjzwzpOa8yt//xNRN7Al5Qvzt2G2hA=; b=npQRy1hKGs6Zn0kAniHRVcc9740Cb0D4+EQQmQOEKlmVrTHyAvX9ismO9TJMw6v2t7 +Xpev+z8n4vWHl1w+tdOxi4aZInB/i3TN4/6AgTTR81dZdklL6ZnaiF9BLEgqlK+zCH7 TfGJMiaKJkYscRsYzRceTKhGhZq3Wa3qiZVVd0gjcLmMTTevBz31X59BEhfHBnGxy9J7 qiXZPOGiMrNi4gyT/jwn8JeJ7ROrXb0HVOQIC7sYuZQgplsRXBdTnLBikzMxJwjTXhLs gyJe6S0f5Le7+O0yqrrmy4wMjVd2wAdHqSqka3iqOz7YpvgskerOozLXYCeP+vaJjjK7 7Cvw== X-Gm-Message-State: AJcUukeuwq5vSHq8xcNJ4Bk4Shah3RJRi3uxhGkGP6b1xHQE+UZ3y0rX 1LgRnL8iWFqKOrEVAFG2cZTmYNF90Ac= X-Received: by 2002:a37:a80a:: with SMTP id r10mr25298811qke.2.1548783426777; Tue, 29 Jan 2019 09:37:06 -0800 (PST) Received: from workstation.celeiro.br. ([168.194.163.64]) by smtp.gmail.com with ESMTPSA id a20sm56890855qkj.28.2019.01.29.09.37.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 Jan 2019 09:37:06 -0800 (PST) From: Rafael David Tinoco To: ltp@lists.linux.it Date: Tue, 29 Jan 2019 15:36:54 -0200 Message-Id: <20190129173659.27901-3-rafael.tinoco@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190129173659.27901-1-rafael.tinoco@linaro.org> References: <20190124161159.GC16804@rei.lan> <20190129173659.27901-1-rafael.tinoco@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_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 v4 3/8] tst_timer: Add tst_timespec_add() 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: , Errors-To: ltp-bounces+patch=linaro.org@lists.linux.it Sender: "ltp" This commit adds a tst_timespec_add() function that adds two given timespec structs. It is needed in order to avoid unneeded ns <-> us conversions because, so far, there is only tst_timespec_add_us() available. Signed-off-by: Rafael David Tinoco --- include/tst_timer.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/include/tst_timer.h b/include/tst_timer.h index 577bc88ef..b57adf7aa 100644 --- a/include/tst_timer.h +++ b/include/tst_timer.h @@ -151,6 +151,25 @@ static inline struct timespec tst_timespec_add_us(struct timespec t, return t; } +/* + * Adds two timespec structures. + */ +static inline struct timespec tst_timespec_add(struct timespec t1, + struct timespec t2) +{ + struct timespec res; + + res.tv_sec = t1.tv_sec + t2.tv_sec; + res.tv_nsec = t1.tv_nsec + t2.tv_nsec; + + if (res.tv_nsec >= 1000000000) { + res.tv_sec++; + res.tv_nsec -= 1000000000; + } + + return res; +} + /* * Returns difference between two timespec structures. */ From patchwork Tue Jan 29 17:36:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rafael David Tinoco X-Patchwork-Id: 157004 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp4935563jaa; Tue, 29 Jan 2019 09:37:35 -0800 (PST) X-Google-Smtp-Source: ALg8bN6YMvqXDIq9myyP7BJ/oOxEGGjKxV1fkk0zGG93kUGoajE5YrpirtKxEqPQHOpzB3L42c1v X-Received: by 2002:a1c:5dd1:: with SMTP id r200mr22845404wmb.93.1548783455655; Tue, 29 Jan 2019 09:37:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548783455; cv=none; d=google.com; s=arc-20160816; b=lJ3bk5K8G+E0dALgJwgY7Qw+cpDsdd+FrzRMl1TW2RL2ctKRateDP1FoJ/xR5kNUwQ JsZI617+g/BSSWuwiOWifRogkA8b5+Z7TpNiASkkIFI92FEZ7wKZWE/nT2i76n97LZtI Bl9fUZEkQTap4rw6mSn/Ilhc/XldNAuOMTEPQ85EcJXsFIphz4/ZcXV4SBuMfdNAUFm4 okBb/b51reBYwQFzx6AjHB9HMtxVQACRassjKXtHbGwKLXzZScBS1LOLScvf6OAsrPFS 7Avct9K1Zb8bD/yubv9obO5G7QrrCk+pF83ZgQHN3e1t9m8Vas4rxOW86Y1ajFW24vzh n9pQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :dkim-signature:delivered-to; bh=yHGqupB5dXRc2wE1zQ4DNrsfCAIgMHcJ92Rd21V7nS4=; b=Y/1gexyzF8Av2yKdVSBIatYW6whh5F3GdUwV31suZisRbDWEfaG6mjzTM6bxJ8kLyd kjnoXTinIQBlxkjMCdlcR8puyWT2pEnP7CE+yBOOBe3ndz/Z9rB4qZ7cHBw5VPTKFY6e zgU16cPGOUb+gjOZb0MrisisjuIUk//1HJVflkmF3l3gasaAqZx3ROZ8pFHysEF2pS0o ZC+FGiFC//oF+Dl3GktvwTd/dVVd+G2l4OwgszK5VBNtlRJA10S5c76a2ra9k0J5eDW4 xvPVCDICo3FnJ2+wfMbL0/yfpH117OmV1DZ7iTdwxxng0yHnR9+LvpUPz1Z782jk8/1k p/Wg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=RlSCJu8i; spf=pass (google.com: domain of ltp-bounces+patch=linaro.org@lists.linux.it designates 213.254.12.146 as permitted sender) smtp.mailfrom="ltp-bounces+patch=linaro.org@lists.linux.it"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from picard.linux.it (picard.linux.it. [213.254.12.146]) by mx.google.com with ESMTPS id b8si2349699wmd.74.2019.01.29.09.37.35 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 Jan 2019 09:37:35 -0800 (PST) Received-SPF: pass (google.com: domain of ltp-bounces+patch=linaro.org@lists.linux.it designates 213.254.12.146 as permitted sender) client-ip=213.254.12.146; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=RlSCJu8i; spf=pass (google.com: domain of ltp-bounces+patch=linaro.org@lists.linux.it designates 213.254.12.146 as permitted sender) smtp.mailfrom="ltp-bounces+patch=linaro.org@lists.linux.it"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 2D7993EAD14 for ; Tue, 29 Jan 2019 18:37:35 +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 [217.194.8.2]) by picard.linux.it (Postfix) with ESMTP id 83E9F3EAD54 for ; Tue, 29 Jan 2019 18:37:11 +0100 (CET) Received: from mail-qk1-x741.google.com (mail-qk1-x741.google.com [IPv6:2607:f8b0:4864:20::741]) (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 AC4C8600701 for ; Tue, 29 Jan 2019 18:37:10 +0100 (CET) Received: by mail-qk1-x741.google.com with SMTP id 189so12004456qkj.8 for ; Tue, 29 Jan 2019 09:37:10 -0800 (PST) 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=K/bsbfubyS7N3hRl+G5c90yvZbCJrRE/2SG7sgH16rc=; b=RlSCJu8ik0VDJTON1rZoloqhbQ3CE0ycb59c30HfMcw+gLF15q3bDrdE9PPOvUfsy9 Limw5aFo5UA78E/3d90mgRRG9O5YYeR9Bh0it3DxxSE7WjDr3jQm3KpPjWTYIe7Mj33U Qv2O5gqp+20/v68YzBL/nRMNadTZQbHYoDvMk= 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=K/bsbfubyS7N3hRl+G5c90yvZbCJrRE/2SG7sgH16rc=; b=UgrwIcFmMrUquGE8krnPg2a/NGE3hkBTgBdx7J8oa8OxE+wajufTVhJXw1Bf5jeEid ux0aqBQVvEvyX0RG+8xTibPIf+EDQOmh0mbg60oIR01s7ld/drxiN2ibVEvfeZacRrnX 7XGJtXoAOS579xLfB2wtmAZPL4yPa7Hu86BQyBoFO7ryrWWpkPyYEArwghL6ZM1CuSTn n9sN2EzE1iGGGaWOjoiOfxv6uuwqSq9rGA7hrybjQ6wslbQWYxy1DztB9AvTSLCD+8Fd 2k4AWNKZc7K3zaeBgSaUWrBmrA1nfiebiV9iUGYioHyGn6Nkihs35MOJvuPAi7YkqIW2 7YXQ== X-Gm-Message-State: AJcUukeEbwml7vz+CSUVhVpcRd3ZM9jSPzcd+NkxyLmvpimw9/uIzEjc 1W7c13kPBlSU1baAj9+01bB2j9aiYUY= X-Received: by 2002:a37:8107:: with SMTP id c7mr23330703qkd.77.1548783429017; Tue, 29 Jan 2019 09:37:09 -0800 (PST) Received: from workstation.celeiro.br. ([168.194.163.64]) by smtp.gmail.com with ESMTPSA id a20sm56890855qkj.28.2019.01.29.09.37.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 Jan 2019 09:37:08 -0800 (PST) From: Rafael David Tinoco To: ltp@lists.linux.it Date: Tue, 29 Jan 2019 15:36:55 -0200 Message-Id: <20190129173659.27901-4-rafael.tinoco@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190129173659.27901-1-rafael.tinoco@linaro.org> References: <20190124161159.GC16804@rei.lan> <20190129173659.27901-1-rafael.tinoco@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_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 v4 4/8] lib: new restore_wallclock field to restore realtime clock 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: , Errors-To: ltp-bounces+patch=linaro.org@lists.linux.it Sender: "ltp" Some tests that change the system-wide clock need to have a way to restore the correct time after their execution. This commit introduces a new field to tst_test struct called "restore_wallclock": it makes the test to save current realtime clock during setup phase, and, later, during cleanup, restore it to the appropriate time using a monotonic raw clock difference. Signed-off-by: Rafael David Tinoco --- doc/test-writing-guidelines.txt | 35 +++++++++++++++++++++++++ include/tst_test.h | 1 + include/tst_wallclock.h | 15 +++++++++++ lib/tst_test.c | 7 +++++ lib/tst_wallclock.c | 45 +++++++++++++++++++++++++++++++++ 5 files changed, 103 insertions(+) create mode 100644 include/tst_wallclock.h create mode 100644 lib/tst_wallclock.c diff --git a/doc/test-writing-guidelines.txt b/doc/test-writing-guidelines.txt index 731be7692..f2f72c4d6 100644 --- a/doc/test-writing-guidelines.txt +++ b/doc/test-writing-guidelines.txt @@ -1539,6 +1539,41 @@ static struct tst_test test = { }; ------------------------------------------------------------------------------- +2.2.29 Changing the Wall Clock Time during test execution +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +There are some tests that, for different reasons, might need to change the +system-wide clock time. Whenever this happens, it is imperative that the clock +is restored, at the end of test's execution, taking in consideration the amount +of time elapsed during that test. + +In order for that to happen, struct tst_test has a variable called +"restore_wallclock" that should be set to "1" so LTP knows it should: (1) +initialize a monotonic clock during test setup phase and (2) use that monotonic +clock to fix the system-wide clock time at the test cleanup phase. + +[source,c] +------------------------------------------------------------------------------- +#include "tst_test.h" + +static void setup(void) +{ + ... +} + +static void run(void) +{ + ... +} + +sturct tst_test test = { + ... + .setup = setup, + .test_all = run, + .restore_wallclock = 1, + ... +}; +------------------------------------------------------------------------------- 2.3 Writing a testcase in shell ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/include/tst_test.h b/include/tst_test.h index b37890959..12dda2e79 100644 --- a/include/tst_test.h +++ b/include/tst_test.h @@ -135,6 +135,7 @@ struct tst_test { int needs_rofs:1; int child_needs_reinit:1; int needs_devfs:1; + int restore_wallclock:1; /* * If set the test function will be executed for all available * filesystems and the current filesytem type would be set in the diff --git a/include/tst_wallclock.h b/include/tst_wallclock.h new file mode 100644 index 000000000..7d6723a7a --- /dev/null +++ b/include/tst_wallclock.h @@ -0,0 +1,15 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) 2019 Linaro Limited. All rights reserved. + * Author: Rafael David Tinoco + */ + + +#ifndef TST_WALLCLK_H__ +#define TST_WALLCLK_H__ + +void tst_wallclock_save(void); + +void tst_wallclock_restore(void); + +#endif /* TST_WALLCLK_H__ */ diff --git a/lib/tst_test.c b/lib/tst_test.c index da3e0c8a0..7dd890b8d 100644 --- a/lib/tst_test.c +++ b/lib/tst_test.c @@ -35,6 +35,7 @@ #include "tst_timer_test.h" #include "tst_clocks.h" #include "tst_timer.h" +#include "tst_wallclock.h" #include "tst_sys_conf.h" #include "tst_kconfig.h" @@ -872,6 +873,9 @@ static void do_setup(int argc, char *argv[]) if (tst_test->resource_files) copy_resources(); + + if (tst_test->restore_wallclock) + tst_wallclock_save(); } static void do_test_setup(void) @@ -903,6 +907,9 @@ static void do_cleanup(void) tst_sys_conf_restore(0); cleanup_ipc(); + + if (tst_test->restore_wallclock) + tst_wallclock_restore(); } static void run_tests(void) diff --git a/lib/tst_wallclock.c b/lib/tst_wallclock.c new file mode 100644 index 000000000..1513882f4 --- /dev/null +++ b/lib/tst_wallclock.c @@ -0,0 +1,45 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) 2019 Linaro Limited. All rights reserved. + * Author: Rafael David Tinoco + */ + +#include + +#define TST_NO_DEFAULT_MAIN + +#include "tst_test.h" +#include "tst_timer.h" +#include "tst_clocks.h" +#include "tst_wallclock.h" +#include "lapi/posix_clocks.h" + +static struct timespec real_begin, mono_begin; + +void tst_wallclock_save(void) +{ + /* save initial monotonic time to restore it when needed */ + + if (tst_clock_gettime(CLOCK_REALTIME, &real_begin)) + tst_brk(TBROK | TERRNO, "tst_clock_gettime() realtime failed"); + + if (tst_clock_gettime(CLOCK_MONOTONIC_RAW, &mono_begin)) + tst_brk(TBROK | TERRNO, "tst_clock_gettime() monotonic failed"); +} + +void tst_wallclock_restore(void) +{ + static struct timespec mono_end, elapsed, adjust; + + if (tst_clock_gettime(CLOCK_MONOTONIC_RAW, &mono_end)) + tst_brk(TBROK | TERRNO, "tst_clock_gettime() monotonic failed"); + + elapsed = tst_timespec_diff(mono_end, mono_begin); + + adjust = tst_timespec_add(real_begin, elapsed); + + /* restore realtime clock based on monotonic delta */ + + if (tst_clock_settime(CLOCK_REALTIME, &adjust)) + tst_brk(TBROK | TERRNO, "tst_clock_settime() realtime failed"); +} From patchwork Tue Jan 29 17:36:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rafael David Tinoco X-Patchwork-Id: 157005 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp4935743jaa; Tue, 29 Jan 2019 09:37:47 -0800 (PST) X-Google-Smtp-Source: ALg8bN7Vd6+nzjl2670Ge1L+x0CBBMLW14k/dnZeBUr4LsoVsMo/ouTYFu3SwsliZ0DzyCWvSugt X-Received: by 2002:a17:906:46:: with SMTP id 6-v6mr23321523ejg.221.1548783467232; Tue, 29 Jan 2019 09:37:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548783467; cv=none; d=google.com; s=arc-20160816; b=iqGHt3OE0GjwWxhlmURt2jA/y2PY4GIVNajU/qRG+4SuToYezrF3Ws3rDbisXB2HzG Zv/JzoYV/aM3Xm1Lsae4tIxsFcFdEK0o9SVvnmb5Zgu+YJKgcP5dQI9lzJpopa/hTn9N iSJhO3zAGQXVSurhTH9Pgo2qeujN9v0N/QNRamMXdrdPwtKpZ0Gao8lkgq/xU6sJUSAc Ity3ygJr/Sc1rDFEup+6G85IbgbqXfb5wzzHUScP2hPhc+XcjZjnL+OIz2JncUKHIlTM Pd8at165WpWFtlv2MWN9aUCUvDeVpa7c+XfT3m3+RKqzWJ1pgl+eP6YRCsQrr/G8jksC KqPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :dkim-signature:delivered-to; bh=hNVGPdrkui+5QOWcQGhY5HfyDtCZQn+9v7cWZxMa36Q=; b=XqTlVKiKeZEUSi/P/TrQOOJVYp2K+lKaVpQrZhSZuwvJ/ZhBkdyIP8in38zVgLyfM1 GMvOcryH9XRnd6sabw8RBb/IZhkT5sIaf01OMi8xz7+PkGEFzw5ivVG/kWQcjx0rRQ99 626yOSgWKMfri2BehaoJcpkWv5dCICzOEY4pTHem1IcfhsCpaTCYK6BAuB2/1A5VY0m+ KU9i7trwl/MNO6gSdgAp0z+3bp316HI25aKWb9pRFaxoFDlAfc+b1X994AChuw3p844P qxnyV5iGQGYYWtOtV/yZW3CzKnvLlwUVeDjrHJ6DuK0V/o34NVXsSWTrXMGN/a3GfU0R xr8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=epq7kPfk; spf=pass (google.com: domain of ltp-bounces+patch=linaro.org@lists.linux.it designates 2001:1418:10:5::2 as permitted sender) smtp.mailfrom="ltp-bounces+patch=linaro.org@lists.linux.it"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from picard.linux.it (picard.linux.it. [2001:1418:10:5::2]) by mx.google.com with ESMTPS id s16si2813876edd.300.2019.01.29.09.37.47 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 Jan 2019 09:37:47 -0800 (PST) Received-SPF: pass (google.com: domain of ltp-bounces+patch=linaro.org@lists.linux.it designates 2001:1418:10:5::2 as permitted sender) client-ip=2001:1418:10:5::2; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=epq7kPfk; spf=pass (google.com: domain of ltp-bounces+patch=linaro.org@lists.linux.it designates 2001:1418:10:5::2 as permitted sender) smtp.mailfrom="ltp-bounces+patch=linaro.org@lists.linux.it"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id B9AFA3EA178 for ; Tue, 29 Jan 2019 18:37:46 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-6.smtp.seeweb.it (in-6.smtp.seeweb.it [217.194.8.6]) by picard.linux.it (Postfix) with ESMTP id B31363EA13F for ; Tue, 29 Jan 2019 18:37:12 +0100 (CET) Received: from mail-qk1-x743.google.com (mail-qk1-x743.google.com [IPv6:2607:f8b0:4864:20::743]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by in-6.smtp.seeweb.it (Postfix) with ESMTPS id 28457140115F for ; Tue, 29 Jan 2019 18:37:12 +0100 (CET) Received: by mail-qk1-x743.google.com with SMTP id y78so11987854qka.12 for ; Tue, 29 Jan 2019 09:37:12 -0800 (PST) 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=1jSJjnLlFRAJUqF570G9oN8sKkMzhkVQW+qJGrTE3LQ=; b=epq7kPfkGMGx1bUHSwqKK/MviAatv0vbUG0eWfktrZUY8AdC6R8x3SedlR4qQ4xKjR 3+hOuJy7gl0vR/pdoj6b8ZALUUQSojX1nEgEo1RkO2tEO5HsAvKlRjix2mv7XQlG3aZB ZPsMVv/gYN/DUJT+589/RG0yyBeXFDXe3ValE= 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=1jSJjnLlFRAJUqF570G9oN8sKkMzhkVQW+qJGrTE3LQ=; b=JX9P5we1zSUPNIBWvW75Fy9295R7PD7fFVOcSYFm8h+CL6ZnXgNDRherq60qUCCdE1 JEGjLd0VSQL6+p4DxrGlW9JWzIp/2R6j69Oxt30xT1MyYi0V78h1i+6BsOzxJ3TKkbR3 P9wjsU4VqvX8v6fKXnQT+4uyrSPB2/R0iwaKzALurxZv5BMN2ycHVh4Dqm1dwy6s4FQ5 brywrIGNlO5eTzb1bqIzDzMI7SuUP+gJFBqgr7KVYimRgI6WJ9eWV0fQORHUpMeajQkw lFcOOEAU4fY6iMhxkDP2IHoErr8btsc3UXda7gItTVprq7rs/ZzvPvO/1EX97xtLP4NJ JC8A== X-Gm-Message-State: AJcUukewvlVWTJYPwChUfj8clabaOrdurnVXdL/huJHC2yL0o9DokEBE EDiWaA5vuwzydPL9qBDMSdKvsCS3Quc= X-Received: by 2002:a37:a884:: with SMTP id r126mr23204619qke.143.1548783430890; Tue, 29 Jan 2019 09:37:10 -0800 (PST) Received: from workstation.celeiro.br. ([168.194.163.64]) by smtp.gmail.com with ESMTPSA id a20sm56890855qkj.28.2019.01.29.09.37.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 Jan 2019 09:37:10 -0800 (PST) From: Rafael David Tinoco To: ltp@lists.linux.it Date: Tue, 29 Jan 2019 15:36:56 -0200 Message-Id: <20190129173659.27901-5-rafael.tinoco@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190129173659.27901-1-rafael.tinoco@linaro.org> References: <20190124161159.GC16804@rei.lan> <20190129173659.27901-1-rafael.tinoco@linaro.org> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.99.2 at in-6.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_PASS autolearn=disabled version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-6.smtp.seeweb.it Subject: [LTP] [PATCH v4 5/8] tst_timer: Add tst_timespec_sub_us() 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: , Errors-To: ltp-bounces+patch=linaro.org@lists.linux.it Sender: "ltp" This commit adds a tst_timespec_sub_us() function that subtracts microseconds from a given timespec struct. Signed-off-by: Rafael David Tinoco --- include/tst_timer.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/include/tst_timer.h b/include/tst_timer.h index b57adf7aa..043b71460 100644 --- a/include/tst_timer.h +++ b/include/tst_timer.h @@ -170,6 +170,23 @@ static inline struct timespec tst_timespec_add(struct timespec t1, return res; } +/* + * Subtracts us microseconds from t. + */ +static inline struct timespec tst_timespec_sub_us(struct timespec t, + long long us) +{ + t.tv_sec -= us / 1000000; + t.tv_nsec -= (us % 1000000) * 1000; + + if (t.tv_nsec < 0) { + t.tv_sec--; + t.tv_nsec += 1000000000; + } + + return t; +} + /* * Returns difference between two timespec structures. */ From patchwork Tue Jan 29 17:36:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rafael David Tinoco X-Patchwork-Id: 157006 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp4935899jaa; Tue, 29 Jan 2019 09:37:56 -0800 (PST) X-Google-Smtp-Source: ALg8bN6Q4aFv540jNvNKCP9bbTmcvVAt/9EepfhZ+8MmgiXCMyGS9LUqSaeCFtZhTtVs01nRdY78 X-Received: by 2002:a50:a3d1:: with SMTP id t17mr26915156edb.238.1548783476445; Tue, 29 Jan 2019 09:37:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548783476; cv=none; d=google.com; s=arc-20160816; b=BySH522+LzwzB9X5CQ+4Ip4inIdyrF6NgZNJgtCxx5j1GaaUpI4l76T1UabQWFAg96 yRFMxgM/nJSHs8omQpFn8Cm733CfvWVWZ9DGlF0CEPG5zqxJOupnn0JG8+tdw0ERbHXf sSKYFKAUNzO4fZU2RBw7M8IIhWq/m1uI5KoeU+DwcRYiYmcF349CdwhXfZ8f7/gdIwA+ om0ZOU7bgZfw6aASFWYbcH2K81KBy/ChOGK/I5ShMm4RzCItVcmetLJWpRNh3GNmLWY6 /AD150HMFZG3PCYsHCpaJFoLdILHakcVDcPuaKoYXxBzrU0Sbj39pco7dKWJX4TLWe2E tASw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :dkim-signature:delivered-to; bh=i0pbFV0KdtoBlGqCj0FaR83qwZroqDpBhA8Gds+cAZs=; b=w3hGn1b7f6mMK9PfOb1vay15byRjSLUKJuVb45ZvaBnPnxp54IYYLoSxnm8fzPMBjF JKum0itLr7IzVEWsX7KGk5BDaHIjLifW6MjlrlAbH0i2pufHJKm+UtE+uPC8/8Jo0HB2 ZiD4CbsGQbuPY643hsqzSKbciMb4+oTidlJxneDYUwmQdx7oeu2D7218z5F3UoN34Shk nKe/tidadgLT8tlQmheSUlyPhJH6ID6xvWpLpgqGTHZZVicGzykBcCVzSySvNxlOOQ0g DO4KSEYMjiTw5IYwdLKJzaeIySfWHSx0+Fq7UivFygVLPAf9Anqk4h1x/q49jfznesYi xbvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=JArB+1OA; spf=pass (google.com: domain of ltp-bounces+patch=linaro.org@lists.linux.it designates 213.254.12.146 as permitted sender) smtp.mailfrom="ltp-bounces+patch=linaro.org@lists.linux.it"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from picard.linux.it (picard.linux.it. [213.254.12.146]) by mx.google.com with ESMTPS id i3si3008687edk.411.2019.01.29.09.37.56 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 Jan 2019 09:37:56 -0800 (PST) Received-SPF: pass (google.com: domain of ltp-bounces+patch=linaro.org@lists.linux.it designates 213.254.12.146 as permitted sender) client-ip=213.254.12.146; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=JArB+1OA; spf=pass (google.com: domain of ltp-bounces+patch=linaro.org@lists.linux.it designates 213.254.12.146 as permitted sender) smtp.mailfrom="ltp-bounces+patch=linaro.org@lists.linux.it"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 0536E3EAD11 for ; Tue, 29 Jan 2019 18:37:56 +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 [217.194.8.2]) by picard.linux.it (Postfix) with ESMTP id AC39D3EAD5A for ; Tue, 29 Jan 2019 18:37:14 +0100 (CET) Received: from mail-qt1-x841.google.com (mail-qt1-x841.google.com [IPv6:2607:f8b0:4864:20::841]) (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 243C160165F for ; Tue, 29 Jan 2019 18:37:14 +0100 (CET) Received: by mail-qt1-x841.google.com with SMTP id n32so23107661qte.11 for ; Tue, 29 Jan 2019 09:37:14 -0800 (PST) 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=tBBiV1epWnJS+Ahn74Gjy8G0j2CXqGLXkM6kNwe3hvc=; b=JArB+1OAqZPfu7a/qTiGRGbpMVTJQU19DYKG/iPl+wlYGEiQ9GN+IqXmJHOPyO9IJ5 NXkTjqyOOTPqffgXie6RT/m9RLmy3kgtFAJ2n6y8MNZZ8ivo5FtvZsWqSFC60jDmXcoM D8N3orRJUxhADfiqcjRtSQr5/qny3VoGY37j8= 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=tBBiV1epWnJS+Ahn74Gjy8G0j2CXqGLXkM6kNwe3hvc=; b=hP05Hz4oO2eEM0+8nWZNF27N5/b8ft3Yz5jVtGLdUd9gjInCOgxfRkkTWpYWB7ZeNT xJ95XQuGhGYsl7hDHnsalyH9cHS2BxHDFviYtYoUZsrOLPidNTr6Nm36YlTuCdE+vMC4 tdX4DkJAeqpnjXqDij0rQEu+JFaUApUHzx+rav9VpLP8JmtkA9407S3lV0kOOzFTOrHC hhEvqZekm2I9GkU9ooLMMe8nNMKPU+RrsSI8A6qVoBwr2B7odIlkQVTLhbaZyZBr4DvN ZTixdFR4HsA1n2CzS7/kZX5gdA2GhIDQnCBgkEmPCMxGDYqqSz+akZ+iX4gWDTMpbYic /lnA== X-Gm-Message-State: AJcUukevZGUHLoP5V0xG/vdKv/4bBnJppE261vlSMKQp/Szgd0JM5Y0H 25Nd8zs+uzAKpj9pUB5rsfqrMamfnRI= X-Received: by 2002:a0c:d792:: with SMTP id z18mr25599758qvi.183.1548783432741; Tue, 29 Jan 2019 09:37:12 -0800 (PST) Received: from workstation.celeiro.br. ([168.194.163.64]) by smtp.gmail.com with ESMTPSA id a20sm56890855qkj.28.2019.01.29.09.37.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 Jan 2019 09:37:12 -0800 (PST) From: Rafael David Tinoco To: ltp@lists.linux.it Date: Tue, 29 Jan 2019 15:36:57 -0200 Message-Id: <20190129173659.27901-6-rafael.tinoco@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190129173659.27901-1-rafael.tinoco@linaro.org> References: <20190124161159.GC16804@rei.lan> <20190129173659.27901-1-rafael.tinoco@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_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 v4 6/8] tst_timer: Turn clock_name() function public 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: , Errors-To: ltp-bounces+patch=linaro.org@lists.linux.it Sender: "ltp" This commit exposes clock_name() function by removing its static definition and creating a public function prototype. This function is needed by clock/alarm tests and their error messages. Signed-off-by: Rafael David Tinoco --- include/tst_timer.h | 5 +++++ lib/tst_timer.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/include/tst_timer.h b/include/tst_timer.h index 043b71460..c66f630c4 100644 --- a/include/tst_timer.h +++ b/include/tst_timer.h @@ -332,4 +332,9 @@ static inline long long tst_timer_elapsed_us(void) return tst_timespec_to_us(tst_timer_elapsed()); } +/* + * Returns a string containing given clock type name + */ +const char *clock_name(clockid_t); + #endif /* TST_TIMER */ diff --git a/lib/tst_timer.c b/lib/tst_timer.c index dffaba0cb..e83da7ff6 100644 --- a/lib/tst_timer.c +++ b/lib/tst_timer.c @@ -15,7 +15,7 @@ static struct timespec start_time, stop_time; static clockid_t clock_id; -static const char *clock_name(clockid_t clk_id) +const char *clock_name(clockid_t clk_id) { switch (clk_id) { case CLOCK_REALTIME: From patchwork Tue Jan 29 17:36:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rafael David Tinoco X-Patchwork-Id: 157007 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp4936075jaa; Tue, 29 Jan 2019 09:38:06 -0800 (PST) X-Google-Smtp-Source: ALg8bN5WbMPcchYSFcJOFBn8ejCiOb2fD7NMAzqXpR9r0A5ly/7Egs/AqEujsCYopPmSJlRcZIqr X-Received: by 2002:a05:6402:121a:: with SMTP id c26mr25779717edw.104.1548783486793; Tue, 29 Jan 2019 09:38:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548783486; cv=none; d=google.com; s=arc-20160816; b=CzYNusIfz9vH+U2LyE/Cn3juwxPLqOzyWtLE1Ki1Ho3oIvrzBorYbUQClF5WQKTYCE CClG87nC5Yfa4KkHIf1TnCRqGvdYYCTEHVAySrzC2QvK8MLCpfwAUuEQHfNBX6EW7n0K 7d3ySTODoDQZE8AJoXZzVXyCp8FZ6vvFAelW0zN16gAIFN1h2q8BOpEL4/2u8GYGFsJt S5BGEUOGjgX90XoFC/AmcQ8Ix2Z5JZpy1P2OHd1V5t32OR4ymcwtsfyVejRdPKxjWMdv zH1svRcI+4NZUKXo3NCuR/fVEF3uc+kHlSjVf+8eq45B4AWQKQP6KGubWe1ybzW2Q+Kt 86eg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :dkim-signature:delivered-to; bh=EIQrI1xfULjAkr9ssC9wT3t2aVsKWT4R5opv8ZUmkis=; b=U/Rw5/OMTO8sTTDrq+Opq56vkEsT+Anp6vE/QGrOec1yFcxBQ5IfvMQzV2YA9Eojti y/vTo3HIIZqyfjinP5S8aL4E3juRaFggmOAhOxV2iTs2wdt6sKn5xr23zX+Li8adxi4S 4YjPYhDS+Z/Q0FkRof0COwAoOhBNG3lAuVua0+NkLXn/Ow8rkY0SY6nOM28NtslMIrg7 ORje7SqdUNxDzyZCandW/3kBQVBUXIuOhXp+pGPq3aRFkRFL+yA6wjKThRuYZZIYhw7K xj/9+lwkm27L3uAc0ckjl6ca3RNJmhClUu/kFjZ7ZJbvlbnOvj4ffG3uIarjW7Sz+4Kl J5PQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=UTVFh7sV; spf=pass (google.com: domain of ltp-bounces+patch=linaro.org@lists.linux.it designates 213.254.12.146 as permitted sender) smtp.mailfrom="ltp-bounces+patch=linaro.org@lists.linux.it"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from picard.linux.it (picard.linux.it. [213.254.12.146]) by mx.google.com with ESMTPS id n3si2844436edo.15.2019.01.29.09.38.06 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 Jan 2019 09:38:06 -0800 (PST) Received-SPF: pass (google.com: domain of ltp-bounces+patch=linaro.org@lists.linux.it designates 213.254.12.146 as permitted sender) client-ip=213.254.12.146; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=UTVFh7sV; spf=pass (google.com: domain of ltp-bounces+patch=linaro.org@lists.linux.it designates 213.254.12.146 as permitted sender) smtp.mailfrom="ltp-bounces+patch=linaro.org@lists.linux.it"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 4A6A23EAD10 for ; Tue, 29 Jan 2019 18:38:06 +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 [217.194.8.2]) by picard.linux.it (Postfix) with ESMTP id DDA1E3EAD16 for ; Tue, 29 Jan 2019 18:37:16 +0100 (CET) Received: from mail-qt1-x842.google.com (mail-qt1-x842.google.com [IPv6:2607:f8b0:4864:20::842]) (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 13662600258 for ; Tue, 29 Jan 2019 18:37:16 +0100 (CET) Received: by mail-qt1-x842.google.com with SMTP id p17so23172407qtl.5 for ; Tue, 29 Jan 2019 09:37:16 -0800 (PST) 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=/AkQJ1HT+MpG09Fhbnz31KN2+lWKYwwwosrDK2bi4rw=; b=UTVFh7sVpOYAMvddB5c3jEROVH6odckbStPILb00ic5EzphryLkpdA52ROBBB4gJx1 vDHJA4UcEMyKSKyBDIp5icRinRbEopAYHgWKOi7qvXhW4Y0InkZwwoIFcqgyCp1VaV56 3h3EXcFuVN78Vlta5vYUHrjpTWugfZAXchHRo= 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=/AkQJ1HT+MpG09Fhbnz31KN2+lWKYwwwosrDK2bi4rw=; b=srQdNV53efReR9X0HMG9IX3gkUvYVd1n8w9uj+3wVjPRF4Xjk2AMUKXB4S6ND/hx5V 0a8mrGfFQRP+TrwUQ/u9NhMgVXQEQq/qIF9LDUbBgm7XcrOD4XFdJBkIdoWn+WHbK6BL 2vREkAPyG7EjHf2Hbw6p1el05wZxxA8bPFILWxKqpWpHtnurh9oM1MF4EyYGog5ZLaoc Uhx5Me4lh4ZUkmx2OjGaJfKBg90pQNxsoz7koD42V6Vmh90mU3ZaiO3HR58npchKM9kH GxJWUAGoMyyQcMS9HUq8iTPuKiXFTztDfDqu/QGEVYqiNtyBTz9GHqsHi9gx3ggeX9o/ 1w7w== X-Gm-Message-State: AJcUukfugm7MrsUX8qMhXxISHQ316U0O9pJK47VfZVrTliqVIQ7za2TU CqmFuzlEM4slW7NPSiN+Nw5bo02VyPg= X-Received: by 2002:aed:2e63:: with SMTP id j90mr27087123qtd.35.1548783434708; Tue, 29 Jan 2019 09:37:14 -0800 (PST) Received: from workstation.celeiro.br. ([168.194.163.64]) by smtp.gmail.com with ESMTPSA id a20sm56890855qkj.28.2019.01.29.09.37.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 Jan 2019 09:37:14 -0800 (PST) From: Rafael David Tinoco To: ltp@lists.linux.it Date: Tue, 29 Jan 2019 15:36:58 -0200 Message-Id: <20190129173659.27901-7-rafael.tinoco@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190129173659.27901-1-rafael.tinoco@linaro.org> References: <20190124161159.GC16804@rei.lan> <20190129173659.27901-1-rafael.tinoco@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_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 v4 7/8] syscalls/clock_settime: create syscall clock_settime tests 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: , Errors-To: ltp-bounces+patch=linaro.org@lists.linux.it Sender: "ltp" Fixes: 343 clock_settime01 creates a new test, using new API, based on existing and older kernel/timers/clock_settime02 test. clock_settime02 creates another test based on older kernel/timers/clock_settime03 test. Both will be deleted in the next commits. Signed-off-by: Rafael David Tinoco --- runtest/syscalls | 3 + .../kernel/syscalls/clock_settime/.gitignore | 2 + .../kernel/syscalls/clock_settime/Makefile | 8 + .../syscalls/clock_settime/clock_settime01.c | 72 +++++++++ .../syscalls/clock_settime/clock_settime02.c | 148 ++++++++++++++++++ 5 files changed, 233 insertions(+) create mode 100644 testcases/kernel/syscalls/clock_settime/.gitignore create mode 100644 testcases/kernel/syscalls/clock_settime/Makefile create mode 100644 testcases/kernel/syscalls/clock_settime/clock_settime01.c create mode 100644 testcases/kernel/syscalls/clock_settime/clock_settime02.c diff --git a/runtest/syscalls b/runtest/syscalls index 45fcebdd9..668c87cd1 100644 --- a/runtest/syscalls +++ b/runtest/syscalls @@ -79,6 +79,9 @@ clock_nanosleep01 clock_nanosleep01 clock_nanosleep02 clock_nanosleep02 clock_nanosleep2_01 clock_nanosleep2_01 +clock_settime01 clock_settime01 +clock_settime02 clock_settime02 + clone01 clone01 clone02 clone02 clone03 clone03 diff --git a/testcases/kernel/syscalls/clock_settime/.gitignore b/testcases/kernel/syscalls/clock_settime/.gitignore new file mode 100644 index 000000000..281217550 --- /dev/null +++ b/testcases/kernel/syscalls/clock_settime/.gitignore @@ -0,0 +1,2 @@ +clock_settime01 +clock_settime02 diff --git a/testcases/kernel/syscalls/clock_settime/Makefile b/testcases/kernel/syscalls/clock_settime/Makefile new file mode 100644 index 000000000..e6674a6b2 --- /dev/null +++ b/testcases/kernel/syscalls/clock_settime/Makefile @@ -0,0 +1,8 @@ +# Copyright (c) 2018 - Linaro Limited. All rights reserved. +# SPDX-License-Identifier: GPL-2.0-or-later + +top_srcdir ?= ../../../.. + +include $(top_srcdir)/include/mk/testcases.mk + +include $(top_srcdir)/include/mk/generic_leaf_target.mk diff --git a/testcases/kernel/syscalls/clock_settime/clock_settime01.c b/testcases/kernel/syscalls/clock_settime/clock_settime01.c new file mode 100644 index 000000000..227cfe38f --- /dev/null +++ b/testcases/kernel/syscalls/clock_settime/clock_settime01.c @@ -0,0 +1,72 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) 2019 Linaro Limited. All rights reserved. + * Author: Rafael David Tinoco + */ + +/* + * Basic test for clock_settime(2) on REALTIME clock: + * + * 1) advance DELTA_SEC seconds + * 2) go backwards DELTA_SEC seconds + * + * Restore wall clock at the end of test. + */ + +#include "config.h" +#include "tst_timer.h" +#include "tst_safe_clocks.h" +#include "tst_test.h" +#include "lapi/syscalls.h" + +#define DELTA_SEC 10 +#define DELTA_US (long long) (DELTA_SEC * 1000000) +#define DELTA_EPS (long long) (DELTA_US * 0.1) + +static void verify_clock_settime(void) +{ + long long elapsed; + struct timespec begin, change, end; + + /* test 01: move forward */ + + SAFE_CLOCK_GETTIME(CLOCK_REALTIME, &begin); + + change = tst_timespec_add_us(begin, DELTA_US); + + if (clock_settime(CLOCK_REALTIME, &change) != 0) + tst_brk(TBROK | TTERRNO, "could not set realtime change"); + + SAFE_CLOCK_GETTIME(CLOCK_REALTIME, &end); + + elapsed = tst_timespec_diff_us(end, begin); + + if (elapsed > DELTA_US && elapsed < (DELTA_US + DELTA_EPS)) + tst_res(TPASS, "clock_settime(2): was able to advance time"); + else + tst_res(TFAIL, "clock_settime(2): could not advance time"); + + /* test 02: move backward */ + + SAFE_CLOCK_GETTIME(CLOCK_REALTIME, &begin); + + change = tst_timespec_sub_us(begin, DELTA_US); + + if (clock_settime(CLOCK_REALTIME, &change) != 0) + tst_brk(TBROK | TTERRNO, "could not set realtime change"); + + SAFE_CLOCK_GETTIME(CLOCK_REALTIME, &end); + + elapsed = tst_timespec_diff_us(end, begin); + + if (~(elapsed) < DELTA_US && ~(elapsed) > (DELTA_US - DELTA_EPS)) + tst_res(TPASS, "clock_settime(2): was able to recede time"); + else + tst_res(TFAIL, "clock_settime(2): could not recede time"); +} + +static struct tst_test test = { + .test_all = verify_clock_settime, + .needs_root = 1, + .restore_wallclock = 1, +}; diff --git a/testcases/kernel/syscalls/clock_settime/clock_settime02.c b/testcases/kernel/syscalls/clock_settime/clock_settime02.c new file mode 100644 index 000000000..09c9dc4a4 --- /dev/null +++ b/testcases/kernel/syscalls/clock_settime/clock_settime02.c @@ -0,0 +1,148 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) 2019 Linaro Limited. All rights reserved. + * Author: Rafael David Tinoco + */ + +/* + * Basic tests for errors of clock_settime(2) on different clock types. + */ + +#include "config.h" +#include "tst_test.h" +#include "lapi/syscalls.h" +#include "tst_timer.h" +#include "tst_safe_clocks.h" + +#define DELTA_SEC 10 +#define NSEC_PER_SEC (1000000000L) +#define MAX_CLOCKS 16 + +struct test_case { + clockid_t type; + struct timespec newtime; + int exp_err; + int replace; +}; + +struct test_case tc[] = { + { /* case 01: REALTIME: timespec NULL */ + .type = CLOCK_REALTIME, + .exp_err = EFAULT, + .replace = 1, + }, + { /* case 02: REALTIME: tv_sec = -1 */ + .type = CLOCK_REALTIME, + .newtime.tv_sec = -1, + .exp_err = EINVAL, + .replace = 1, + }, + { /* case 03: REALTIME: tv_nsec = -1 */ + .type = CLOCK_REALTIME, + .newtime.tv_nsec = -1, + .exp_err = EINVAL, + .replace = 1, + }, + { /* case 04: REALTIME: tv_nsec = 1s+1 */ + .type = CLOCK_REALTIME, + .newtime.tv_nsec = NSEC_PER_SEC + 1, + .exp_err = EINVAL, + .replace = 1, + }, + { /* case 05: MONOTONIC */ + .type = CLOCK_MONOTONIC, + .exp_err = EINVAL, + }, + { /* case 06: MAXCLOCK */ + .type = MAX_CLOCKS, + .exp_err = EINVAL, + }, + { /* case 07: MAXCLOCK+1 */ + .type = MAX_CLOCKS + 1, + .exp_err = EINVAL, + }, + /* Linux specific */ + { /* case 08: CLOCK_MONOTONIC_COARSE */ + .type = CLOCK_MONOTONIC_COARSE, + .exp_err = EINVAL, + }, + { /* case 09: CLOCK_MONOTONIC_RAW */ + .type = CLOCK_MONOTONIC_RAW, + .exp_err = EINVAL, + }, + { /* case 10: CLOCK_BOOTTIME */ + .type = CLOCK_BOOTTIME, + .exp_err = EINVAL, + }, + { /* case 11: CLOCK_PROCESS_CPUTIME_ID */ + .type = CLOCK_PROCESS_CPUTIME_ID, + .exp_err = EINVAL, + }, + { /* case 12: CLOCK_THREAD_CPUTIME_ID */ + .type = CLOCK_THREAD_CPUTIME_ID, + .exp_err = EINVAL, + }, +}; + +/* + * Some tests may cause libc to segfault when passing bad arguments. + */ +static int sys_clock_settime(clockid_t clk_id, struct timespec *tp) +{ + return tst_syscall(__NR_clock_settime, clk_id, tp); +} + +static void verify_clock_settime(unsigned int i) +{ + struct timespec spec, *specptr; + + specptr = &spec; + + if (tc[i].replace == 0) { + + SAFE_CLOCK_GETTIME(CLOCK_REALTIME, specptr); + + /* add 1 sec to wall clock */ + specptr->tv_sec += 1; + + } else { + + /* use given time spec */ + *specptr = tc[i].newtime; + } + + /* bad pointer case */ + if (tc[i].exp_err == EFAULT) + specptr = tst_get_bad_addr(NULL); + + TEST(sys_clock_settime(tc[i].type, specptr)); + + if (TST_RET == -1) { + + if (tc[i].exp_err == TST_ERR) { + + tst_res(TPASS, "clock_settime(2): failed as expected"); + + } else { + + tst_res(TFAIL | TTERRNO, "clock_settime(2): clock %s " + "expected %s, failed with %s instead.", + clock_name(tc[i].type), + tst_strerrno(tc[i].exp_err)); + } + + return; + } + + tst_res(TFAIL | TTERRNO, "clock_settime(2): clock %s passed " + "unexpectedly, expected %s", + clock_name(tc[i].type), + tst_strerrno(tc[i].exp_err)); +} + +static struct tst_test test = { + .test = verify_clock_settime, + .tcnt = ARRAY_SIZE(tc), + .needs_root = 1, + .restore_wallclock = 1, +}; From patchwork Tue Jan 29 17:36:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rafael David Tinoco X-Patchwork-Id: 157008 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp4936224jaa; Tue, 29 Jan 2019 09:38:17 -0800 (PST) X-Google-Smtp-Source: ALg8bN5xgZPMqDdNNMu9ZvBlPPRUWdsGcyDimAhJQU64I1eutk4/3AINnryFCp4XZbYIRbvADISg X-Received: by 2002:adf:8264:: with SMTP id 91mr25802383wrb.312.1548783496939; Tue, 29 Jan 2019 09:38:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548783496; cv=none; d=google.com; s=arc-20160816; b=AWhawX3guBQtf0AdK4jrVaq2rwElU1XPvDYZk9/QID5xpqmDhAbq6aGsY/HBQ6y/BY JwGBCVcYoh+IVMJmMq3jNJ5o7TVptQFdzYjz55W2BzvYiHJuXx4zVxlvki7weOUu+YMb LAi5CAUdQSr4XdDzFya3qjBhWjUZmWIPC7BfuaWTJwERnriWzaPJy8A49Bb8x4oawuOk ueievDIP7YdtFLR+Vh9Ld+zTQEqHiSsSvW2pG5QSLrbx0V/0IIdL/vUoP/1J0tEQFd1p 0Zj0P/5chDIayab+ggVmo1FwrHEstY24DMctFfF9q44Gub/7TbP2CekwjPwn8MnGhY4C KdyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :dkim-signature:delivered-to; bh=eeyVdp/LdP4qwznjZYgo9QRT1x0yh0LfoKkcQqXXUwE=; b=KxobeDYjM7uR7k/wUE5ljFBZ52WUoRHnrTpFP+oJ2ZZF62QuFyb3XxoHCiU9gNs4M5 xR+YsBm57juY6MmRcUHILiF40hL/v3/suJauLYktyGa9abaNocvPgf1srHKdkTKiGRWo pmWil9T9n7li/FkUVT3kqJM30qjkPeNsOWoxnDKEqGRmyg9WU94PISm92g1dDo9ApAjP inPZZRjJwPwC2eZxmXWSPus1nKPCNaTlKjbucNjjuSnh6ROpmCI0udjY+OJlaQQVTgXd GaIfDtAJV6yEXS5Yu4Lq4c8e9Y15Z8qWFq2DzleQI68VyiQOcJZf0tFk6CzZ2hdrqEFd Pl6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=cbD2KDZV; spf=pass (google.com: domain of ltp-bounces+patch=linaro.org@lists.linux.it designates 2001:1418:10:5::2 as permitted sender) smtp.mailfrom="ltp-bounces+patch=linaro.org@lists.linux.it"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from picard.linux.it (picard.linux.it. [2001:1418:10:5::2]) by mx.google.com with ESMTPS id n25si89186579wra.167.2019.01.29.09.38.16 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 Jan 2019 09:38:16 -0800 (PST) Received-SPF: pass (google.com: domain of ltp-bounces+patch=linaro.org@lists.linux.it designates 2001:1418:10:5::2 as permitted sender) client-ip=2001:1418:10:5::2; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=cbD2KDZV; spf=pass (google.com: domain of ltp-bounces+patch=linaro.org@lists.linux.it designates 2001:1418:10:5::2 as permitted sender) smtp.mailfrom="ltp-bounces+patch=linaro.org@lists.linux.it"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 6808C3EAD16 for ; Tue, 29 Jan 2019 18:38:16 +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 65D1B3EAD67 for ; Tue, 29 Jan 2019 18:37:19 +0100 (CET) Received: from mail-qt1-x844.google.com (mail-qt1-x844.google.com [IPv6:2607:f8b0:4864:20::844]) (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 942011000373 for ; Tue, 29 Jan 2019 18:37:17 +0100 (CET) Received: by mail-qt1-x844.google.com with SMTP id p17so23172567qtl.5 for ; Tue, 29 Jan 2019 09:37:18 -0800 (PST) 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=HF4PbO0abmXkMrlepd+9g54+SoBSirSFnGTjzyJ0BW8=; b=cbD2KDZVVOEJFEVH+QfGLSsW+eKJCnDsLlBgXXImUFTECjDVCGQJ5jTUsmQRFt/ilD QSh4ZJkDH/R6bf3o9I0CojW1YuqaR20963PsL/BceMTDRJyLf5jy+imD4VoeGyM76c5n 5riSVmKgKgleEfEGGMsR6OuKGUofSjYJp/Bes= 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=HF4PbO0abmXkMrlepd+9g54+SoBSirSFnGTjzyJ0BW8=; b=CHcjGy6Ut0YCTSdj+Zao5QMgdIZltR+2esVC27ld5hpvAFz7Gulq3sF3ncRq/VDWwz ugXlE8Jgl41t2dja+cND9HP6p2L5h6habbrXINb6Y5I7YFcM7RGg8D2xyaZOw8dA2+WE ccWwdJ/iriTE8qfbBjT7lWEI5tbKfY4rTgN/2UlEdeOTmqK+z9TMuj9rJjLXqOC423qa gY1o5PiQ0UBEPLSNZDYfziJZLP3Sqbji+YrCyOmJIAnIMcFc25WfuaGDaTeDw229EODx BsOVXPaWigIEw70x9+cNfN3/n9NGAabrcmfTzWrvGnhqhs5rxmji8cQfceIoWVRgaqUC kZzw== X-Gm-Message-State: AJcUuke++IGDDOIiMumzT1FYJ3TA1WZYxjy5PtHiHtd7WZGmPoVSz5i+ gnG4YfXgfEEWt81P0vqY1eLGe1vxjmo= X-Received: by 2002:ac8:6949:: with SMTP id n9mr26754995qtr.308.1548783436753; Tue, 29 Jan 2019 09:37:16 -0800 (PST) Received: from workstation.celeiro.br. ([168.194.163.64]) by smtp.gmail.com with ESMTPSA id a20sm56890855qkj.28.2019.01.29.09.37.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 Jan 2019 09:37:16 -0800 (PST) From: Rafael David Tinoco To: ltp@lists.linux.it Date: Tue, 29 Jan 2019 15:36:59 -0200 Message-Id: <20190129173659.27901-8-rafael.tinoco@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190129173659.27901-1-rafael.tinoco@linaro.org> References: <20190124161159.GC16804@rei.lan> <20190129173659.27901-1-rafael.tinoco@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_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 v4 8/8] timers/clock_settime: remove clock_settime tests 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: , Errors-To: ltp-bounces+patch=linaro.org@lists.linux.it Sender: "ltp" clock_settime{01,02} syscall tests were created, using the new API, based on existing and older kernel/timers/clock_settime{02,03} tests. This commit deletes older timers/clock_settime/* tests. Signed-off-by: Rafael David Tinoco --- runtest/timers | 2 - .../kernel/timers/clock_settime/.gitignore | 2 - .../kernel/timers/clock_settime/Makefile | 27 --- .../timers/clock_settime/clock_settime02.c | 128 ------------- .../timers/clock_settime/clock_settime03.c | 173 ------------------ 5 files changed, 332 deletions(-) delete mode 100644 testcases/kernel/timers/clock_settime/.gitignore delete mode 100644 testcases/kernel/timers/clock_settime/Makefile delete mode 100644 testcases/kernel/timers/clock_settime/clock_settime02.c delete mode 100644 testcases/kernel/timers/clock_settime/clock_settime03.c diff --git a/runtest/timers b/runtest/timers index a58ac57fc..618d2cb0c 100644 --- a/runtest/timers +++ b/runtest/timers @@ -1,8 +1,6 @@ #DESCRIPTION:Posix Timer Tests clock_gettime02 clock_gettime02 clock_gettime03 clock_gettime03 -clock_settime02 clock_settime02 -clock_settime03 clock_settime03 timer_create02 timer_create02 timer_create03 timer_create03 timer_create04 timer_create04 diff --git a/testcases/kernel/timers/clock_settime/.gitignore b/testcases/kernel/timers/clock_settime/.gitignore deleted file mode 100644 index 957c5ac26..000000000 --- a/testcases/kernel/timers/clock_settime/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/clock_settime02 -/clock_settime03 diff --git a/testcases/kernel/timers/clock_settime/Makefile b/testcases/kernel/timers/clock_settime/Makefile deleted file mode 100644 index 8de247075..000000000 --- a/testcases/kernel/timers/clock_settime/Makefile +++ /dev/null @@ -1,27 +0,0 @@ -# -# Copyright (c) International Business Machines Corp., 2001 -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See -# the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -# - -top_srcdir ?= ../../../.. - -include $(top_srcdir)/include/mk/testcases.mk - -CPPFLAGS += -D_GNU_SOURCE -I$(abs_srcdir)/../include - -LDLIBS += -lpthread -lrt - -include $(top_srcdir)/include/mk/generic_leaf_target.mk diff --git a/testcases/kernel/timers/clock_settime/clock_settime02.c b/testcases/kernel/timers/clock_settime/clock_settime02.c deleted file mode 100644 index 65721c1ae..000000000 --- a/testcases/kernel/timers/clock_settime/clock_settime02.c +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Copyright (c) Wipro Technologies Ltd, 2003. All Rights Reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it would be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - */ -/************************************************************************** - * - * TEST IDENTIFIER : clock_settime02 - * - * EXECUTED BY : root / superuser - * - * TEST TITLE : Basic test for clock_settime(2) - * - * TEST CASE TOTAL : 1 - * - * AUTHOR : Aniruddha Marathe - * - * SIGNALS - * Uses SIGUSR1 to pause before test if option set. - * (See the parse_opts(3) man page). - * - * DESCRIPTION - * This is a Phase I test for the clock_settime(2) system call. - * It is intended to provide a limited exposure of the system call. - * - * Setup: - * Setup signal handling. - * Pause for SIGUSR1 if option specified. - * - * Test: - * Loop if the proper options are given. - * Set the parameters of timespec struct - * Execute system call - * Check return code, if system call failed (return=-1) - * Log the errno and Issue a FAIL message. - * Otherwise, Issue a PASS message. - * - * Cleanup: - * Print errno log and/or timing stats if options given - * - * USAGE: - * clock_settime02 [-c n] [-e] [-i n] [-I x] [-P x] [-t] [-p] - * where: - * -c n : Run n copies simultaneously. - * -e : Turn on errno logging. - * -i n : Execute test n times. - * -I x : Execute test for x seconds. - * -p : Pause for SIGUSR1 before starting - * -P x : Pause for x seconds between iterations. - * -t : Turn on syscall timing. - * - *RESTRICTIONS: - * None - *****************************************************************************/ - -#include -#include -#include -#include - -#include "test.h" -#include "common_timers.h" - -static void setup(void); -static void cleanup(void); - -char *TCID = "clock_settime02"; -int TST_TOTAL = 1; -static struct timespec saved; - -int main(int ac, char **av) -{ - int lc; - struct timespec spec; - - tst_parse_opts(ac, av, NULL, NULL); - - setup(); - - for (lc = 0; TEST_LOOPING(lc); lc++) { - - tst_count = 0; - - spec.tv_sec = saved.tv_sec + 1; - spec.tv_nsec = 0; - - TEST(ltp_syscall(__NR_clock_settime, CLOCK_REALTIME, &spec)); - tst_resm((TEST_RETURN < 0 ? TFAIL | TTERRNO : TPASS), - "clock_settime %s", - (TEST_RETURN == 0 ? "passed" : "failed")); - } - - cleanup(); - tst_exit(); -} - -static void setup(void) -{ - tst_sig(NOFORK, DEF_HANDLER, cleanup); - - tst_require_root(); - - /* Save the current time specifications */ - if (ltp_syscall(__NR_clock_gettime, CLOCK_REALTIME, &saved) < 0) - tst_brkm(TBROK, NULL, "Could not save the current time"); - - TEST_PAUSE; -} - -static void cleanup(void) -{ - /* Set the saved time */ - if (clock_settime(CLOCK_REALTIME, &saved) < 0) { - tst_resm(TWARN, "FATAL COULD NOT RESET THE CLOCK"); - tst_resm(TFAIL, "Error Setting Time, errno=%d", errno); - } -} diff --git a/testcases/kernel/timers/clock_settime/clock_settime03.c b/testcases/kernel/timers/clock_settime/clock_settime03.c deleted file mode 100644 index 38b41d025..000000000 --- a/testcases/kernel/timers/clock_settime/clock_settime03.c +++ /dev/null @@ -1,173 +0,0 @@ -/* - * Copyright (c) Wipro Technologies Ltd, 2003. All Rights Reserved. - * Copyright (c) 2011 Cyril Hrubis - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it would be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - */ - -#include -#include -#include -#include - -#include "test.h" -#include "safe_macros.h" -#include "common_timers.h" - -static void setup(void); -static void cleanup(void); -static int setup_test(int option); - -clockid_t clocks[] = { - CLOCK_REALTIME, - CLOCK_MONOTONIC, - MAX_CLOCKS, - MAX_CLOCKS + 1, - CLOCK_REALTIME, - CLOCK_REALTIME, - CLOCK_REALTIME, - CLOCK_PROCESS_CPUTIME_ID, - CLOCK_THREAD_CPUTIME_ID -}; - -int testcases[] = { - EFAULT, /* tp bad */ - EINVAL, /* CLOCK_MONOTONIC */ - EINVAL, /* MAX_CLOCKS */ - EINVAL, /* MAX_CLOCKS + 1 */ - EINVAL, /* Invalid timespec */ - EINVAL, /* NSEC_PER_SEC + 1 */ - EPERM, /* non-root user */ - EINVAL, /* PROCESS_CPUTIME_ID */ - EINVAL, /* THREAD_CPUTIME_ID */ -}; - -char *TCID = "clock_settime03"; -int TST_TOTAL = ARRAY_SIZE(testcases); - -char nobody_uid[] = "nobody"; -struct passwd *ltpuser; -static struct timespec spec, *temp, saved; - -int main(int ac, char **av) -{ - int lc, i; - - tst_parse_opts(ac, av, NULL, NULL); - - setup(); - - for (lc = 0; TEST_LOOPING(lc); lc++) { - - tst_count = 0; - - for (i = 0; i < TST_TOTAL; i++) { - - if (setup_test(i) < 0) - continue; - - TEST(ltp_syscall(__NR_clock_settime, clocks[i], temp)); - - /* Change the UID back to root */ - if (i == TST_TOTAL - 1) { - SAFE_SETEUID(cleanup, 0); - } - - /* check return code */ - if (TEST_RETURN == -1 && TEST_ERRNO == testcases[i]) { - tst_resm(TPASS | TTERRNO, - "clock_settime(2) got expected " - "failure."); - } else { - tst_resm(TFAIL | TTERRNO, - "clock_settime(2) failed to produce " - "expected error (return code = %ld)", - TEST_RETURN); - /* Restore the clock to its previous state. */ - if (TEST_RETURN == 0) { - if (ltp_syscall(__NR_clock_settime, - CLOCK_REALTIME, - &saved) < 0) { - tst_resm(TWARN | TERRNO, - "FATAL: could not set " - "the clock!"); - } - } - } - - } - - } - - cleanup(); - tst_exit(); -} - -static int setup_test(int option) -{ - /* valid timespec */ - spec = saved; - temp = &spec; - - /* error sceanrios */ - switch (option) { - case 0: - /* Make tp argument bad pointer */ - temp = (struct timespec *)-1; - break; - case 4: - /* Make the parameter of timespec invalid */ - spec.tv_nsec = -1; - break; - case 5: - /* Make the parameter of timespec invalid */ - spec.tv_nsec = NSEC_PER_SEC + 1; - break; - case 6: - /* change the User to non-root */ - spec.tv_nsec = 0; - if ((ltpuser = getpwnam(nobody_uid)) == NULL) { - tst_resm(TWARN, "user \"nobody\" not present; " - "skipping test"); - return -1; - } - if (seteuid(ltpuser->pw_uid) == -1) { - tst_resm(TWARN | TERRNO, - "seteuid failed to set the effective " - "uid to %d (nobody)", ltpuser->pw_uid); - return -1; - } - break; - } - return 0; -} - -static void setup(void) -{ - tst_sig(NOFORK, DEF_HANDLER, cleanup); - - tst_require_root(); - - if (ltp_syscall(__NR_clock_gettime, CLOCK_REALTIME, &saved) < 0) - tst_brkm(TBROK, NULL, "Clock gettime failed"); - - spec.tv_sec = 1; - spec.tv_nsec = 0; - - TEST_PAUSE; -} - -static void cleanup(void) -{ -}