From patchwork Thu Mar 21 20:27:29 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: 160820 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp8399jan; Thu, 21 Mar 2019 13:27:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqwcBL0DLCm4hR1Muj3mB2fZ3QXQznVwyHmybExg9bs8v1KWqXSQ82owe3ufYuZ9jLYfULJw X-Received: by 2002:aa7:dd0e:: with SMTP id i14mr3814677edv.172.1553200064085; Thu, 21 Mar 2019 13:27:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553200064; cv=none; d=google.com; s=arc-20160816; b=ndf5IjF1vbSs0mMg00TPCakJeqO1qtsR16rOql//a0t3AAVIbYys3rYJKQeHuWjLYc 7tnOBHnydHdBhAl+ruPuEkUgDEenYZ4ja4oJFGvYYKMIzeRi30XtEZFfdi75H2giGovf 1iZRibRvtDjS225g1CctSDbAeDH+2ZpxEB6Vyl2KcRsXLHERgu5+Ur9WqhRx9IgjMH8b RTpsKGImekxu4TTlS9jNtg5uZHArrqA47hPsGWMzwsN+mnh67wTZG/7iukbUGEUbYT77 T8qXYLw5+cZWbts1wszaKixgPJaHynACPcKP3nsT5ppZsNwLXa0lM1ypiPqd+hYOw4eG WFwQ== 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 :cc:mime-version:references:in-reply-to:message-id:date:to:from :dkim-signature:delivered-to; bh=J4iDY3YyQWHimJT7P5e4Rwg5AXvpY7gEQDS2OgAq/bo=; b=lj3VVdSAfCD16LYduui/IqvwWvwJB2UstfggUxDHkzzhsF7DEyK2IQU7GwLynFpWHd MLu1KP6B3xF9B+qU+j5BBXrFDKk/pYfL8zTe8cffbEH1mgkKgIxA+gepl+j5ZusnAtBa tfX2EFdD5vz0r3SvemOD+HDrAuNFhxBnevimD+OakUk3p8il3t1VKw27bjEHUCZ24O39 sOJZJcGyyLrj94AnR/u7iA71dcA7lBvdaFuCEJWwsErdHZZXfb6atB29UkNRwkgAle72 GFntOPosLU9OjfxgQdODKX+LFpAujFmvy/ZNFbSpS3JyJuEFXXzKtJUw6u8aYeAoH/Ct mZxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=OdsCIc08; 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 i21si696151edg.95.2019.03.21.13.27.43 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Mar 2019 13:27:44 -0700 (PDT) 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=OdsCIc08; 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 A88473EA5BF for ; Thu, 21 Mar 2019 21:27:43 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-7.smtp.seeweb.it (in-7.smtp.seeweb.it [IPv6:2001:4b78:1:20::7]) by picard.linux.it (Postfix) with ESMTP id BF1B63EA1D7 for ; Thu, 21 Mar 2019 21:27:39 +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-7.smtp.seeweb.it (Postfix) with ESMTPS id 140B42009B2 for ; Thu, 21 Mar 2019 21:27:39 +0100 (CET) Received: by mail-qk1-x744.google.com with SMTP id b74so17158746qkg.9 for ; Thu, 21 Mar 2019 13:27:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=TdXXiGaRpeHTu5okHncaoNQzoyb/0cRHr1KE56BSNJ4=; b=OdsCIc08xYBmtgTU7lRJMl6HdG2Hs9uUALgfgbr6HFbCuL8BqU5p611F2LY6T2zj0Z dgWWpFy3pM3VZDicY7h7ye57zu71qFctlEDWHCqD4RRUdDvWNRrj+kw3Ts2kT2g4Ge3y wwGg62gTlgKYRnBGTDAX/e0hebgxFO0zj6dDB8GuwEN4YcyWy633rd3p99/p3tdQvJFs Ou28u6syWogpQyu/5oSTPGn79z5V8mLcp4UZ1SUwurnkoV/q5dtOs0nvGXPmDcK+euE6 H4+fF7aozSvLT+jqCWW0TmGxc84IlZD05kTI25Xq8yFPr/FxrU3NLlLNimtnot9MjnlX tDWw== 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=TdXXiGaRpeHTu5okHncaoNQzoyb/0cRHr1KE56BSNJ4=; b=WW/0n5+mLWJNPdISeP9V1YZlbliMnR3H/YowY9DBTCvMxZ0b5pV+QGgMgWeKC9Cs6e A9AYd5xU9b9SoCJeWGSU+UIrwKfg8Ncco0MCm4pLgtqyEaww7VzjWdXr4wDtkigkTVeE OEl/KPHvOpl2AnifHrRibMm7fdTH22XXtKa0yKwTF+kTEGsk28ou+gXszt+TQ8yX4I23 wSQZVTmxinOLn91svZaA+8JFS5l/2N4b5s7hPIioURlNlKkLIMeU2TGIzmJo7Sl74b+N rR4UwegQB8Tc4Wm2cy4bs/7a6lp7OB038bJtgdziqMGfPUcng9eAW5B6ypO2hszFEq/Y zXPg== X-Gm-Message-State: APjAAAUnYOrlt2CEsf2u29+dEdf7SdoQKLO5Xv7XyvK8xiKxyWL8IZj3 rhEE9VY5Z/2JapQ6eWexueiN/W1bp+H+XfeF X-Received: by 2002:a37:2fc1:: with SMTP id v184mr4499559qkh.71.1553200057615; Thu, 21 Mar 2019 13:27:37 -0700 (PDT) Received: from workstation.celeiro.br ([191.177.184.97]) by smtp.gmail.com with ESMTPSA id n5sm107446qkk.4.2019.03.21.13.27.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Mar 2019 13:27:36 -0700 (PDT) From: Rafael David Tinoco To: ltp@lists.linux.it Date: Thu, 21 Mar 2019 17:27:29 -0300 Message-Id: <20190321202732.3331-1-rafael.tinoco@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190321141015.GG1252@rei> References: <20190321141015.GG1252@rei> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.99.2 at in-7.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-7.smtp.seeweb.it Cc: rafael.tinoco@linaro.org Subject: [LTP] [PATCH v3 1/4] lib: include SAFE_CLOCK_ADJTIME() 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_ADJTIME() macro to tst_safe_clocks.h. Signed-off-by: Rafael David Tinoco --- include/tst_safe_clocks.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/include/tst_safe_clocks.h b/include/tst_safe_clocks.h index d5cd83394..596db4099 100644 --- a/include/tst_safe_clocks.h +++ b/include/tst_safe_clocks.h @@ -6,7 +6,9 @@ */ #include +#include #include "tst_test.h" +#include "lapi/syscalls.h" #include "lapi/posix_clocks.h" static inline void safe_clock_getres(const char *file, const int lineno, @@ -44,6 +46,19 @@ static inline void safe_clock_settime(const char *file, const int lineno, "%s:%d clock_gettime() failed", file, lineno); } +static inline int safe_clock_adjtime(const char *file, const int lineno, + clockid_t clk_id, struct timex *txc) +{ + int rval; + + rval = tst_syscall(__NR_clock_adjtime, clk_id, txc); + if (rval < 0) + tst_brk(TBROK | TERRNO, + "%s:%d clock_adjtime() failed %i", file, lineno, rval); + + return rval; +} + #define SAFE_CLOCK_GETRES(clk_id, res)\ safe_clock_getres(__FILE__, __LINE__, (clk_id), (res)) @@ -52,3 +67,6 @@ static inline void safe_clock_settime(const char *file, const int lineno, #define SAFE_CLOCK_SETTIME(clk_id, tp)\ safe_clock_settime(__FILE__, __LINE__, (clk_id), (tp)) + +#define SAFE_CLOCK_ADJTIME(clk_id, txc)\ + safe_clock_adjtime(__FILE__, __LINE__, (clk_id), (txc)) From patchwork Thu Mar 21 20:27:30 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: 160821 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp8474jan; Thu, 21 Mar 2019 13:27:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqwgmY+hJaa6e4K+waxTfwQlTdfCxDxkk5M1ZF7DdlRHbdfOxEmeFuRfmpjBzhHaNy4B0g1Y X-Received: by 2002:aa7:da09:: with SMTP id r9mr3761248eds.7.1553200069433; Thu, 21 Mar 2019 13:27:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553200069; cv=none; d=google.com; s=arc-20160816; b=a0P1FgoJcr05zBA9ZMTzL8WvFMvUuL5EjPvzeVRGKSMla5JsrZw1NMwDeEnIQRZWVP Lz3az55raytGGzfpx1doh7oCTPcRn5LkiOIxCiDJUIW5pdvDE66+ePX6EriOdAWny7fA UNgHG2DdHdER21eMxIedvwSAysHbOwRPK+1WZH9uZqE3P2ByWbrHl9K/zJBFZ7vNom1L wm/S8WbTFHlo3mvqvJ52pLyo8/aTdF8d3tkulkMcPYDgCYWZ59e2TDc9e3vKyKsKNz68 6JjaDLBaRYwJc+GNasRMRVd5keMqD9AnHDZ6SSFEqZGafdxxXBXvsmW25HKycuu3iMCB ruNQ== 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 :cc:mime-version:references:in-reply-to:message-id:date:to:from :dkim-signature:delivered-to; bh=7zyMgPTHcRoyLYsxOScy7TxtINZfG6xGcQcvXoJRA1E=; b=h29TARS0rh8Z25B1hQQCDRQCDBVtJqfDPuG9AWQeNlwWqNznMCq3PSw5lDUQy4cMwy 3fB5lMZ98b8qhP25LY9w//5hm9PZyftnmurlCVg8KvrJ1GSiHaA0Cw3pg8ngiv0/OFrR Vw4dSaTlfEf7+K4LW2OFIPCszmisDQNUw1dAX7fnMuIAcnmY1R382/8dGPHlfbUnLL8V 0qHD98T47rNHGZlIkKlpJN5+rqrB2CFyfe/rZnMp99w7bMzSg1s1H/3fJKQeTHQhmTsR aZJn3wAEIeCNvbtFMv9O9G280DVAe4ZfGM5H6NYrij7ciYKSI9KAIJfIHzMemMRbGi/D D2Tg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=ivMWZqQY; 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 p21si391973eja.65.2019.03.21.13.27.49 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Mar 2019 13:27:49 -0700 (PDT) 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=ivMWZqQY; 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 09A053EA52F for ; Thu, 21 Mar 2019 21:27:49 +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 B22FD3EA546 for ; Thu, 21 Mar 2019 21:27:41 +0100 (CET) Received: from mail-qt1-x834.google.com (mail-qt1-x834.google.com [IPv6:2607:f8b0:4864:20::834]) (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 51AED1000965 for ; Thu, 21 Mar 2019 21:27:39 +0100 (CET) Received: by mail-qt1-x834.google.com with SMTP id k14so161793qtb.0 for ; Thu, 21 Mar 2019 13:27:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=3WlocdOdsYn8gs9dnwzr5LRnLfp7+rQtD7Yxr90CPis=; b=ivMWZqQYSE2tEqzrnXk4hlsWxVsAHMbAgu3w3+/6L3ZbPrgWpv8VeMkmtiWJQ0nauI coqq2RsG/LUR2fTfrUK9bC1QR9jT5nk28ES1/FvX9xubqNAvne6WqvKzc+y3Oz2+3Lk/ kTl4DW8gpxl+OTPXiKrqp2YTacD06w9sFyiluYcKHH1jUVB9SfLOP1aCF+RFO4k4O+TY jhRFJAIURP4VGgAoz/RBvCBiiaAzXtfAslEqCF+Wpl7RezlptaX2U3/0qZDKMiJHDzZ6 X/Gdv9I6jjLy3OrzCVRMoS2Dz4FXqdjkB20977lgzEq1cyB9zcwGj2bN92I0x7dB4Fh+ wIqg== 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=3WlocdOdsYn8gs9dnwzr5LRnLfp7+rQtD7Yxr90CPis=; b=RhNdamAmNHitJPREkB0iD/Ndcyaksdxb6xROjMGE4N0858VYqVJFgcurplIZJnKU5b Gxin3v7UFIZmbMP6LPCuVcXSyyTOJtb0o90W9hvLsP638QvAJjYuFScH2zXx2yQcrHuU +Z2onAUqeAcNA300gWziQkcbkeknbn5QXY3Rr7q9he9VdC8MbwXyO/hjmOFRPnC65/6x 569L2wA1ZM8KYUguppnqb7kWFo0gFKO1uNgkwST5fSc3KCSqNJR/oezSeCyKpLzxfqpK InSx+BMN40IJ8ADSLFXvG729oppbnCVPxyv7n2PDwWGvOHjLmqljzLM+zGMlL1vtL54j oNQA== X-Gm-Message-State: APjAAAUrEo0Wh3tI91AhcB4DwK/1LUpzX9hVXKh1Tv01YlfAAN6nv17j mWs8vlAXPQuCp02eVSww0IINQutDmmhBYo2p X-Received: by 2002:ac8:a81:: with SMTP id d1mr4934586qti.213.1553200059687; Thu, 21 Mar 2019 13:27:39 -0700 (PDT) Received: from workstation.celeiro.br ([191.177.184.97]) by smtp.gmail.com with ESMTPSA id n5sm107446qkk.4.2019.03.21.13.27.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Mar 2019 13:27:38 -0700 (PDT) From: Rafael David Tinoco To: ltp@lists.linux.it Date: Thu, 21 Mar 2019 17:27:30 -0300 Message-Id: <20190321202732.3331-2-rafael.tinoco@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190321202732.3331-1-rafael.tinoco@linaro.org> References: <20190321141015.GG1252@rei> <20190321202732.3331-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 Cc: rafael.tinoco@linaro.org Subject: [LTP] [PATCH v3 2/4] lib: Add include guard to tst_safe_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" When adding a common header to my tests I missed this include guard when accidentally including tst_safe_clocks.h from .c and .h files. Since other tst_safe_*.h files have guards I thought it would be good to add to this one as well. Signed-off-by: Rafael David Tinoco --- include/tst_safe_clocks.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/tst_safe_clocks.h b/include/tst_safe_clocks.h index 596db4099..34ed953b4 100644 --- a/include/tst_safe_clocks.h +++ b/include/tst_safe_clocks.h @@ -5,6 +5,9 @@ * Email : code@zilogic.com */ +#ifndef TST_SAFE_CLOCKS_H__ +#define TST_SAFE_CLOCKS_H__ + #include #include #include "tst_test.h" @@ -70,3 +73,5 @@ static inline int safe_clock_adjtime(const char *file, const int lineno, #define SAFE_CLOCK_ADJTIME(clk_id, txc)\ safe_clock_adjtime(__FILE__, __LINE__, (clk_id), (txc)) + +#endif /* SAFE_CLOCKS_H__ */ From patchwork Thu Mar 21 20:27:31 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: 160822 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp8550jan; Thu, 21 Mar 2019 13:27:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqxOjyC4qcxwhW21Z9iu3xhRl2nJxllU3VDC3vZQbgrBOK+7EOb6+qhSUGFgNAzKLKsiTk2i X-Received: by 2002:aa7:d146:: with SMTP id r6mr3640362edo.235.1553200073694; Thu, 21 Mar 2019 13:27:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553200073; cv=none; d=google.com; s=arc-20160816; b=KFQX68ZbmNtTHFBPkSsc6pFoUJxvD47/LmkMdkpl4B8YQ3GcLtILkvI8Ko7z6F2in8 zPebD9YTKjO9Sv11q3wJRCXdVUUVcGOJoYMtyQZr6Jey8F4DGRj3Sg7B30ct5Q2Zuc1Z p5lemdsNgOm80j7HUry+V2/tFWQ/+W0rSxXkycMxXwSSbmsqc9cCM7iWUDaUR57vv56N oSzQugpW8CgoqDKqXGc+7hjBM5oPFvW4RYFuJkJ/1/BAoRG9+QUtKFS0N8X4etImY651 naDxrrQ0d4xUxsqG0OU+fZipnmGNlCOWYX92j5tTFUhBrbd6nX8i4Fwe3JG6XcgRg7UC QKzg== 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 :cc:mime-version:references:in-reply-to:message-id:date:to:from :dkim-signature:delivered-to; bh=QDRe0EHXgHAgX3KmjSQTBTaKTondGPg9kenr3vb7Dds=; b=y2ccabDqztyRqdlhD7sU6Ax0+sBGoDK9qI2DznbtGcJJnCpbcqV/hFijSanTNlpB5J SnqGCoja9xWKOMgPw+pI7oikLCDo8Nb1ajtHhyJCNPXTk6ytiBAsk7S34Ivme2F9wuio E76rGsqCbwwAymvfOQmIKb3NWSB9THZNpyqSSPDRh8iK+rHl9R8FcRHQFk78VXguxf0F 1haGP7FwebRavsXCKUA2DmarzD/aNW4MohX1S+QLmc0+b4YQqEm26BakS3Xej6hX9O7u QYfCLWQtd4U1p7PwXACU60XTRzh0j8iDdHGhGZN2V4OpsRScpmWWEC30/rsfucj/U1QQ Sy7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b="JO7/LBON"; 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 w8si2416189edx.351.2019.03.21.13.27.53 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Mar 2019 13:27:53 -0700 (PDT) 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="JO7/LBON"; 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 49D393EA5C1 for ; Thu, 21 Mar 2019 21:27:53 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-7.smtp.seeweb.it (in-7.smtp.seeweb.it [IPv6:2001:4b78:1:20::7]) by picard.linux.it (Postfix) with ESMTP id 886A83EA5E2 for ; Thu, 21 Mar 2019 21:27:43 +0100 (CET) Received: from mail-qt1-x843.google.com (mail-qt1-x843.google.com [IPv6:2607:f8b0:4864:20::843]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by in-7.smtp.seeweb.it (Postfix) with ESMTPS id E97CD2009B2 for ; Thu, 21 Mar 2019 21:27:42 +0100 (CET) Received: by mail-qt1-x843.google.com with SMTP id z16so131833qtn.4 for ; Thu, 21 Mar 2019 13:27:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=fDT14x0rF7AqqGJn6Cn+F6o/adLy612O8cGATgrbNtY=; b=JO7/LBONnflp4gwxjTS3ux7eaboaABLYcPVpAkMvkP9QGokYjp+aaXPSO6vuuOpbv5 lNtUiM7Uzem4MwAQsHlR63CZGduQ1Eu/O2/rFrFndL8RFEpPABxVwVSoRfjysrKGygC+ Q6HdI+NLFLTfUHGR8QssrYg1t5vh7un9+8X/HhqJS3bEQjvaAMn1z9zFaRlSgLtrqIa9 LGHATX4nrBwtIB2ydG/+LpHpyd4pbIXVh8wNwyR4whYab2o/3/D8txsdEtUywexzrs47 K5oZ5CeGMkNFQHhStWG3PJfBXPqbU+qQ6c177f2HQQ/Rk74rg9hHRFjNV70frqMRmOq0 puNA== 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=fDT14x0rF7AqqGJn6Cn+F6o/adLy612O8cGATgrbNtY=; b=HwYobSS1vEte6U4kW8fLur1RInHQ+F8BAO26U38sUFsyw57n8JTWm6DW9BGNhJPa3X 8gDLkLGXa8y9AdhEoV6rAcEX78rqgYWGQcs+zsUeExomRgyxKr8PwBpnh+kuzdc8oRfQ Awoet/vYedeT5NBjmwwdqQWOTS0oQIPiSmtMeIF6jEV4lHxLCyn7EcHVDTWWuBSU9HWH 6OLYmmtk+Mef0dKWNFFpi+n+4Dq+YVSk9b0OCb+D2tSf4JdwGtv/7LzT2E/af5ygaVE7 SR8+oqg8JNU54eApEwYEe8TdaVLR8xpyKt+hFBupnSyHiA8CexYUP1/FEmi21pMOlt+9 Du9w== X-Gm-Message-State: APjAAAWciKU1R9uz69WgXqif7Cxh7vxmbzkyl0VpaObEVsn0uxPktQvj PSWwVSmK1i5qpRiFUf/HtEwov2LX5t8JphUW X-Received: by 2002:ac8:2524:: with SMTP id 33mr4980094qtm.165.1553200061607; Thu, 21 Mar 2019 13:27:41 -0700 (PDT) Received: from workstation.celeiro.br ([191.177.184.97]) by smtp.gmail.com with ESMTPSA id n5sm107446qkk.4.2019.03.21.13.27.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Mar 2019 13:27:41 -0700 (PDT) From: Rafael David Tinoco To: ltp@lists.linux.it Date: Thu, 21 Mar 2019 17:27:31 -0300 Message-Id: <20190321202732.3331-3-rafael.tinoco@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190321202732.3331-1-rafael.tinoco@linaro.org> References: <20190321141015.GG1252@rei> <20190321202732.3331-1-rafael.tinoco@linaro.org> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.99.2 at in-7.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-7.smtp.seeweb.it Cc: rafael.tinoco@linaro.org Subject: [LTP] [PATCH v3 3/4] lapi/posix_clocks.h: add MAX_CLOCKS definition 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" Used by clock_XXXtime() tests, defining MAX_CLOCKS in common header. Signed-off-by: Rafael David Tinoco --- include/lapi/posix_clocks.h | 2 ++ testcases/kernel/syscalls/clock_gettime/clock_gettime02.c | 2 -- testcases/kernel/syscalls/clock_settime/clock_settime02.c | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/include/lapi/posix_clocks.h b/include/lapi/posix_clocks.h index 0d1f0e99c..4914479ac 100644 --- a/include/lapi/posix_clocks.h +++ b/include/lapi/posix_clocks.h @@ -9,6 +9,8 @@ #ifndef POSIX_CLOCKS_H__ #define POSIX_CLOCKS_H__ +#define MAX_CLOCKS 16 + #ifndef CLOCK_MONOTONIC_RAW # define CLOCK_MONOTONIC_RAW 4 #endif diff --git a/testcases/kernel/syscalls/clock_gettime/clock_gettime02.c b/testcases/kernel/syscalls/clock_gettime/clock_gettime02.c index 2a29a71e6..b4bc6e2d5 100644 --- a/testcases/kernel/syscalls/clock_gettime/clock_gettime02.c +++ b/testcases/kernel/syscalls/clock_gettime/clock_gettime02.c @@ -24,8 +24,6 @@ #include "tst_timer.h" #include "tst_safe_clocks.h" -#define MAX_CLOCKS 16 - struct test_case { clockid_t clktype; int exp_err; diff --git a/testcases/kernel/syscalls/clock_settime/clock_settime02.c b/testcases/kernel/syscalls/clock_settime/clock_settime02.c index 8db417b6b..e16e9061a 100644 --- a/testcases/kernel/syscalls/clock_settime/clock_settime02.c +++ b/testcases/kernel/syscalls/clock_settime/clock_settime02.c @@ -16,7 +16,6 @@ #define DELTA_SEC 10 #define NSEC_PER_SEC (1000000000L) -#define MAX_CLOCKS 16 struct test_case { clockid_t type; From patchwork Thu Mar 21 20:27:32 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: 160823 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp8616jan; Thu, 21 Mar 2019 13:27:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqy7Pw80G7GHP5UnsyQJ+vHXXcAxpdJ2axgwsZYcQQaQqrgadHhG8gQGqaLEJnO6v1dTiV+m X-Received: by 2002:a50:cb4a:: with SMTP id h10mr3701268edi.134.1553200077769; Thu, 21 Mar 2019 13:27:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553200077; cv=none; d=google.com; s=arc-20160816; b=YWgmAHEdaoTMKdr2YDFlYPIuI5t21R2RPqMTcbINhGVJr/vGj/JH6kA2xzp+HuVA4b BQZ3IfJtYMEZB8xNRRHFF6eq8ds4Ne4kfFDFBXqSeewhHnWJRC0JBvdMRHfs0QWK/58D 0kki2K5wy/jzuSCHvbCRW+sFJJAaNfj3afpzjqH79WD7mQORE3RYpLyAjGh64gebtSVB w+KACQgqKyATNSvxHsO7BzGNEAh6u4Z9zS5F3yf8fpy8ME/gHF/QUGHpRJtJ5OxZ86ec HJ8XoGKACVqFDR3uOx1HaNQnMoU5VsmAqOkaidj3t+lMVdev1wV//lB2a/9M1ICjQI8p j/5w== 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 :cc:mime-version:references:in-reply-to:message-id:date:to:from :dkim-signature:delivered-to; bh=l3VzdptMh8fdv0Uwa7mYmJ4MvyiVQDosScw4ISzbd6g=; b=wE4U6gHfP03slxc/GUso01b/7xSuQHs+/ZQR7gThWwUiBTMvpo+EgaupLAbuyv8cyU 8d/KH1G+32WkVKJLKOvLjTepUffJGWgY8MzeXFncLlsT/tuOcVsdI3uyq08SdKa5haY3 i5cSLFd+vw5A9shMeL+Kvf7iBbu85OJATqskuwxxStqM+SevIaXs9TUP7VyRHMHaIoWS JfTK34aCAXwyt6Oxn7OndAAfsqVBqVFb80xq+qsNvX8xRFCcnKfH3XecPXywtcO+a/90 2tv6Wjf+OIEUEf6ysPghDtnE5QRIMXYJ7i5IYkNJb2Ed5Q6NGjMjiFYCHGZ/5XD+Nb12 W18g== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=u7iXy+FI; 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 s16si695753eda.5.2019.03.21.13.27.57 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Mar 2019 13:27:57 -0700 (PDT) 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=u7iXy+FI; 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 538FB3EA5AC for ; Thu, 21 Mar 2019 21:27:57 +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 7C6E03EA5CC for ; Thu, 21 Mar 2019 21:27:46 +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-6.smtp.seeweb.it (Postfix) with ESMTPS id 43D3D1400BE2 for ; Thu, 21 Mar 2019 21:27:45 +0100 (CET) Received: by mail-qt1-x841.google.com with SMTP id h39so145188qte.2 for ; Thu, 21 Mar 2019 13:27:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=GdNAk47zizGkH/dTskkhrYv522eCbHDM/5VN2hhm2eM=; b=u7iXy+FIGwVMlbm7i4j1vOoYyVsDXE0wnVRdY4TWEIP0cjgX87AUFuceuSlR+OV20+ aRbMXGmPKq7EMV21gkC9tgdcxjeyhc9iTlHwBOVfs2w+8GxUlM+DTwUd5wo076lLqcrQ fQWeDOOyReTAYHk/lprpNysudEybipQgr9FdxNtMeoCr47WJjU/LBf6fZx6HpmXiYAwf oPC16MjyAvwi0Ipz35U0GuZANSnLMreIfrPbhaHdSWyptmFrZa7Shx8Bhh6bjsorx7Yk qAASypy1keCI9TUu+V15DAoW50P26b37I8ou8NoLp3Sj1EoUyS3M9N6W0k4jS/dbkK+R S4rg== 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=GdNAk47zizGkH/dTskkhrYv522eCbHDM/5VN2hhm2eM=; b=JaHPdga3aD7+52J07vfBMldT5OijyoQf/CQj6jE0NkuYD8uQYeQ43XNUytPnrY+GBj KEp8Lhu1l7/WwRaLIcm/51g50slClREnavQgdsvyi1FAYJHR4xfLedo7ttzqx3NuChc/ Mm6qg4JUqSAZkBk4QYjC7PFSYIcZmJ7vv25orp/X0sLMETfAmJTjCxjtOD8OkntPSQNF D4Anr9Pp1kCmIoeuJPVQDnuHNJ8rELpqjPKxAZTLEVTMfffhDu8VLTye8YsyUxw/9kVG q++p72D2yBgcf9Dz9BjOolPf1h1LABOkDi2iepV5JCnDHh2G2hma9pGs4uFCDgJwf+K+ stcw== X-Gm-Message-State: APjAAAVLn9Soujj72C8uPna+9T/ynKS7PyvnsS8mSfq9phPxWxVan4kM CkofmB0gu+34pbg4rzib3mNpJhikkvrUjPMe X-Received: by 2002:aed:2ea2:: with SMTP id k31mr4867765qtd.315.1553200063652; Thu, 21 Mar 2019 13:27:43 -0700 (PDT) Received: from workstation.celeiro.br ([191.177.184.97]) by smtp.gmail.com with ESMTPSA id n5sm107446qkk.4.2019.03.21.13.27.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Mar 2019 13:27:43 -0700 (PDT) From: Rafael David Tinoco To: ltp@lists.linux.it Date: Thu, 21 Mar 2019 17:27:32 -0300 Message-Id: <20190321202732.3331-4-rafael.tinoco@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190321202732.3331-1-rafael.tinoco@linaro.org> References: <20190321141015.GG1252@rei> <20190321202732.3331-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 Cc: rafael.tinoco@linaro.org Subject: [LTP] [PATCH v3 4/4] syscalls/clock_adjtime: create clock_adjtime syscall 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: 270 clock_adjtime{01,02} are created using the new API, based on existing adjtimex(2) tests. clock_adjtime() syscall might have as execution path: 1) a regular POSIX clock (only REALTIME clock implements adjtime()) - will behave exactly like adjtimex() system call. - only one being tested here. 2) a dynamic POSIX clock (which ops are implemented by PTP clocks) - will trigger the PTP clock driver function "adjtime()" - different implementations from one PTP clock to another - might return EOPNOTSUPP (like ptp_kvm_caps, for example) - no observed execution entry point for clock_adjtime() Signed-off-by: Rafael David Tinoco --- include/lapi/posix_clocks.h | 4 + runtest/syscalls | 3 + .../kernel/syscalls/clock_adjtime/.gitignore | 2 + .../kernel/syscalls/clock_adjtime/Makefile | 10 + .../syscalls/clock_adjtime/clock_adjtime.h | 57 +++++ .../syscalls/clock_adjtime/clock_adjtime01.c | 220 ++++++++++++++++++ .../syscalls/clock_adjtime/clock_adjtime02.c | 220 ++++++++++++++++++ 7 files changed, 516 insertions(+) create mode 100644 testcases/kernel/syscalls/clock_adjtime/.gitignore create mode 100644 testcases/kernel/syscalls/clock_adjtime/Makefile create mode 100644 testcases/kernel/syscalls/clock_adjtime/clock_adjtime.h create mode 100644 testcases/kernel/syscalls/clock_adjtime/clock_adjtime01.c create mode 100644 testcases/kernel/syscalls/clock_adjtime/clock_adjtime02.c diff --git a/include/lapi/posix_clocks.h b/include/lapi/posix_clocks.h index 4914479ac..b1f7a7c55 100644 --- a/include/lapi/posix_clocks.h +++ b/include/lapi/posix_clocks.h @@ -11,6 +11,10 @@ #define MAX_CLOCKS 16 +#define ADJ_ALL (ADJ_OFFSET | ADJ_FREQUENCY | ADJ_MAXERROR | \ + ADJ_ESTERROR | ADJ_STATUS | ADJ_TIMECONST | \ + ADJ_TICK) + #ifndef CLOCK_MONOTONIC_RAW # define CLOCK_MONOTONIC_RAW 4 #endif diff --git a/runtest/syscalls b/runtest/syscalls index a13d51918..817f3576b 100644 --- a/runtest/syscalls +++ b/runtest/syscalls @@ -74,6 +74,9 @@ chroot02 chroot02 chroot03 chroot03 chroot04 chroot04 +clock_adjtime01 clock_adjtime01 +clock_adjtime02 clock_adjtime02 + clock_getres01 clock_getres01 clock_nanosleep01 clock_nanosleep01 clock_nanosleep02 clock_nanosleep02 diff --git a/testcases/kernel/syscalls/clock_adjtime/.gitignore b/testcases/kernel/syscalls/clock_adjtime/.gitignore new file mode 100644 index 000000000..28d5a1d45 --- /dev/null +++ b/testcases/kernel/syscalls/clock_adjtime/.gitignore @@ -0,0 +1,2 @@ +clock_adjtime01 +clock_adjtime02 diff --git a/testcases/kernel/syscalls/clock_adjtime/Makefile b/testcases/kernel/syscalls/clock_adjtime/Makefile new file mode 100644 index 000000000..79f671f1c --- /dev/null +++ b/testcases/kernel/syscalls/clock_adjtime/Makefile @@ -0,0 +1,10 @@ +# Copyright (c) 2019 - Linaro Limited. All rights reserved. +# SPDX-License-Identifier: GPL-2.0-or-later + +top_srcdir ?= ../../../.. + +include $(top_srcdir)/include/mk/testcases.mk + +LDLIBS+=-lrt + +include $(top_srcdir)/include/mk/generic_leaf_target.mk \ No newline at end of file diff --git a/testcases/kernel/syscalls/clock_adjtime/clock_adjtime.h b/testcases/kernel/syscalls/clock_adjtime/clock_adjtime.h new file mode 100644 index 000000000..34b97fdfa --- /dev/null +++ b/testcases/kernel/syscalls/clock_adjtime/clock_adjtime.h @@ -0,0 +1,57 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) 2019 Linaro Limited. All rights reserved. + * Author: Rafael David Tinoco + */ + +#include "config.h" +#include "tst_test.h" +#include "tst_timer.h" +#include "tst_safe_clocks.h" +#include "lapi/syscalls.h" +#include "lapi/posix_clocks.h" +#include +#include +#include +#include + +static int sys_clock_adjtime(clockid_t, struct timex *); +static void timex_show(char *, struct timex); + +/* + * bad pointer w/ libc causes SIGSEGV signal, call syscall directly + */ +static int sys_clock_adjtime(clockid_t clk_id, struct timex *txc) +{ + return tst_syscall(__NR_clock_adjtime, clk_id, txc); +} + +static void timex_show(char *given, struct timex txc) +{ + tst_res(TINFO, "%s\n" + " mode: %d\n" + " offset: %ld\n" + " frequency: %ld\n" + " maxerror: %ld\n" + " esterror: %ld\n" + " status: %d (0x%x)\n" + " time_constant: %ld\n" + " precision: %ld\n" + " tolerance: %ld\n" + " tick: %ld\n" + " raw time: %d(s) %d(us)", + given, + txc.modes, + txc.offset, + txc.freq, + txc.maxerror, + txc.esterror, + txc.status, + txc.status, + txc.constant, + txc.precision, + txc.tolerance, + txc.tick, + (int)txc.time.tv_sec, + (int)txc.time.tv_usec); +} diff --git a/testcases/kernel/syscalls/clock_adjtime/clock_adjtime01.c b/testcases/kernel/syscalls/clock_adjtime/clock_adjtime01.c new file mode 100644 index 000000000..c5381c383 --- /dev/null +++ b/testcases/kernel/syscalls/clock_adjtime/clock_adjtime01.c @@ -0,0 +1,220 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) 2019 Linaro Limited. All rights reserved. + * Author: Rafael David Tinoco + */ + +/* + * clock_adjtime() syscall might have as execution path: + * + * 1) a regular POSIX clock (only REALTIME clock implements adjtime()) + * - will behave exactly like adjtimex() system call. + * - only one being tested here. + * + * 2) a dynamic POSIX clock (which ops are implemented by PTP clocks) + * - will trigger the PTP clock driver function "adjtime()" + * - different implementations from one PTP clock to another + * - might return EOPNOTSUPP (like ptp_kvm_caps, for example) + * - no entry point for clock_adjtime(), missing "CLOCK_PTP" model + * + * so it is sane to check possible adjustments: + * + * - ADJ_OFFSET - usec or nsec, kernel adjusts time gradually by offset + * (-512000 < offset < 512000) + * - ADJ_FREQUENCY - system clock frequency offset + * - ADJ_MAXERROR - maximum error (usec) + * - ADJ_ESTERROR - estimated time error in us + * - ADJ_STATUS - clock command/status of ntp implementation + * - ADJ_TIMECONST - PLL stiffness (jitter dependent) + poll int for PLL + * - ADJ_TICK - us between clock ticks + * (>= 900000/HZ, <= 1100000/HZ) + * + * and also the standalone ones (using .offset variable): + * + * - ADJ_OFFSET_SINGLESHOT - behave like adjtime() + * - ADJ_OFFSET_SS_READ - ret remaining time for completion after SINGLESHOT + * + * For ADJ_STATUS, consider the following flags: + * + * rw STA_PLL - enable phase-locked loop updates (ADJ_OFFSET) + * rw STA_PPSFREQ - enable PPS (pulse-per-second) freq discipline + * rw STA_PPSTIME - enable PPS time discipline + * rw STA_FLL - select freq-locked loop mode. + * rw STA_INS - ins leap sec after the last sec of UTC day (all days) + * rw STA_DEL - del leap sec at last sec of UTC day (all days) + * rw STA_UNSYNC - clock unsynced + * rw STA_FREQHOLD - hold freq. ADJ_OFFSET made w/out auto small adjs + * ro STA_PPSSIGNAL - valid PPS (pulse-per-second) signal is present + * ro STA_PPSJITTER - PPS signal jitter exceeded. + * ro STA_PPSWANDER - PPS signal wander exceeded. + * ro STA_PPSERROR - PPS signal calibration error. + * ro STA_CLOKERR - clock HW fault. + * ro STA_NANO - 0 = us, 1 = ns (set = ADJ_NANO, cl = ADJ_MICRO) + * rw STA_MODE - mode: 0 = phased locked loop. 1 = freq locked loop + * ro STA_CLK - clock source. unused. + */ + +#include "clock_adjtime.h" + +static long hz; +static struct timex saved, ttxc; + +struct test_case { + unsigned int modes; + long highlimit; + long *ptr; + long delta; +}; + +struct test_case tc[] = { + { + .modes = ADJ_OFFSET_SINGLESHOT, + }, + { + .modes = ADJ_OFFSET_SS_READ, + }, + { + .modes = ADJ_ALL, + }, + { + .modes = ADJ_OFFSET, + .highlimit = 500000, + .ptr = &ttxc.offset, + .delta = 10000, + }, + { + .modes = ADJ_FREQUENCY, + .ptr = &ttxc.freq, + .delta = 100, + }, + { + .modes = ADJ_MAXERROR, + .ptr = &ttxc.maxerror, + .delta = 100, + }, + { + .modes = ADJ_ESTERROR, + .ptr = &ttxc.esterror, + .delta = 100, + }, + { + .modes = ADJ_TIMECONST, + .ptr = &ttxc.constant, + .delta = 1, + }, + { + .modes = ADJ_TICK, + .highlimit = 1100000, + .ptr = &ttxc.tick, + .delta = 1000, + }, +}; + +static void verify_clock_adjtime(unsigned int i) +{ + long ptroff, *ptr = NULL; + struct timex verify; + + memset(&ttxc, 0, sizeof(struct timex)); + memset(&verify, 0, sizeof(struct timex)); + + SAFE_CLOCK_ADJTIME(CLOCK_REALTIME, &ttxc); + timex_show("GET", ttxc); + + ttxc.modes = tc[i].modes; + + if (tc[i].ptr && tc[i].delta) { + + *tc[i].ptr += tc[i].delta; + + /* fix limits, if existent, so no errors occur */ + + if (tc[i].highlimit) { + if (*tc[i].ptr >= tc[i].highlimit) + *tc[i].ptr = tc[i].highlimit; + } + } + + SAFE_CLOCK_ADJTIME(CLOCK_REALTIME, &ttxc); + timex_show("SET", ttxc); + + if (tc[i].ptr) { + + /* adjtimex field being tested so we can verify later */ + + ptroff = (long) tc[i].ptr - (long) &ttxc; + ptr = (void *) &verify + ptroff; + } + + TEST(sys_clock_adjtime(CLOCK_REALTIME, &verify)); + timex_show("VERIFY", verify); + + if (tc[i].ptr && *tc[i].ptr != *ptr) { + tst_res(TFAIL, "clock_adjtime(): could not set value (mode=%x)", + tc[i].modes); + } + + if (TST_RET < 0) { + tst_res(TFAIL | TTERRNO, "clock_adjtime(): mode=%x, returned " + "error", tc[i].modes); + } + + tst_res(TPASS, "clock_adjtime(): success (mode=%x)", tc[i].modes); +} + +static void setup(void) +{ + size_t i; + int rval; + + /* check if clock is TIME_OK and save original clock flags */ + + rval = SAFE_CLOCK_ADJTIME(CLOCK_REALTIME, &saved); + + if (rval != TIME_OK) + tst_brk(TBROK | TTERRNO, "unsynced clock or on-going leap"); + + hz = SAFE_SYSCONF(_SC_CLK_TCK); + + for (i = 0; i < ARRAY_SIZE(tc); i++) { + + /* fix high and low limits by dividing it per HZ value */ + + if (tc[i].modes == ADJ_TICK) + tc[i].highlimit /= hz; + + /* fix usec as being test default resolution */ + + if (saved.modes & ADJ_NANO) { + if (tc[i].modes == ADJ_OFFSET) { + tc[i].highlimit *= 1000; + tc[i].delta *= 1000; + } + } + } +} + +static void cleanup(void) +{ + saved.modes = ADJ_ALL; + + /* restore clock resolution based on original status flag */ + + if (saved.status & STA_NANO) + saved.modes |= ADJ_NANO; + else + saved.modes |= ADJ_MICRO; + + /* restore original clock flags */ + + SAFE_CLOCK_ADJTIME(CLOCK_REALTIME, &saved); +} + +static struct tst_test test = { + .test = verify_clock_adjtime, + .setup = setup, + .cleanup = cleanup, + .tcnt = ARRAY_SIZE(tc), + .needs_root = 1, + .restore_wallclock = 1, +}; diff --git a/testcases/kernel/syscalls/clock_adjtime/clock_adjtime02.c b/testcases/kernel/syscalls/clock_adjtime/clock_adjtime02.c new file mode 100644 index 000000000..ae590848c --- /dev/null +++ b/testcases/kernel/syscalls/clock_adjtime/clock_adjtime02.c @@ -0,0 +1,220 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) 2019 Linaro Limited. All rights reserved. + * Author: Rafael David Tinoco + */ + +/* + * clock_adjtime() syscall might have as execution path: + * + * 1) a regular POSIX clock (only REALTIME clock implements adjtime()) + * - will behave exactly like adjtimex() system call. + * - only one being tested here. + * + * 2) a dynamic POSIX clock (which ops are implemented by PTP clocks) + * - will trigger the PTP clock driver function "adjtime()" + * - different implementations from one PTP clock to another + * - might return EOPNOTSUPP (like ptp_kvm_caps, for example) + * - no entry point for clock_adjtime(), missing "CLOCK_PTP" model + * + * so it is sane to check for the following errors: + * + * EINVAL - clock id being used does not exist + * + * EFAULT - (struct timex *) does not point to valid memory + * + * EINVAL - ADJ_OFFSET + .offset outside range -512000 < x < 512000 + * (after 2.6.26, kernels normalize to the limit if outside range) + * + * EINVAL - ADJ_FREQUENCY + .freq outside range -32768000 < x < 3276800 + * (after 2.6.26, kernels normalize to the limit if outside range) + * + * EINVAL - .tick outside permitted range (900000/HZ < .tick < 1100000/HZ) + * + * EPERM - .modes is neither 0 nor ADJ_OFFSET_SS_READ (CAP_SYS_TIME required) + * + * EINVAL - .status other than those listed bellow + * + * For ADJ_STATUS, consider the following flags: + * + * rw STA_PLL - enable phase-locked loop updates (ADJ_OFFSET) + * rw STA_PPSFREQ - enable PPS (pulse-per-second) freq discipline + * rw STA_PPSTIME - enable PPS time discipline + * rw STA_FLL - select freq-locked loop mode. + * rw STA_INS - ins leap sec after the last sec of UTC day (all days) + * rw STA_DEL - del leap sec at last sec of UTC day (all days) + * rw STA_UNSYNC - clock unsynced + * rw STA_FREQHOLD - hold freq. ADJ_OFFSET made w/out auto small adjs + * ro STA_PPSSIGNAL - valid PPS (pulse-per-second) signal is present + * ro STA_PPSJITTER - PPS signal jitter exceeded. + * ro STA_PPSWANDER - PPS signal wander exceeded. + * ro STA_PPSERROR - PPS signal calibration error. + * ro STA_CLOKERR - clock HW fault. + * ro STA_NANO - 0 = us, 1 = ns (set = ADJ_NANO, cl = ADJ_MICRO) + * rw STA_MODE - mode: 0 = phased locked loop. 1 = freq locked loop + * ro STA_CLK - clock source. unused. + */ + +#include "clock_adjtime.h" + +static long hz; +static struct timex saved, ttxc; + +static void cleanup(void); + +struct test_case { + clockid_t clktype; + unsigned int modes; + long lowlimit; + long highlimit; + long *ptr; + long delta; + int exp_err; + int droproot; +}; + +struct test_case tc[] = { + { + .clktype = MAX_CLOCKS, + .exp_err = EINVAL, + }, + { + .clktype = MAX_CLOCKS + 1, + .exp_err = EINVAL, + }, + { + .clktype = CLOCK_REALTIME, + .modes = ADJ_ALL, + .exp_err = EFAULT, + }, + { + .clktype = CLOCK_REALTIME, + .modes = ADJ_TICK, + .lowlimit = 900000, + .ptr = &ttxc.tick, + .delta = 1, + .exp_err = EINVAL, + }, + { + .clktype = CLOCK_REALTIME, + .modes = ADJ_TICK, + .highlimit = 1100000, + .ptr = &ttxc.tick, + .delta = 1, + .exp_err = EINVAL, + }, + { + .clktype = CLOCK_REALTIME, + .modes = ADJ_ALL, + .exp_err = EPERM, + .droproot = 1, + }, +}; + +static void verify_clock_adjtime(unsigned int i) +{ + uid_t whoami = 0; + struct timex *txcptr; + struct passwd *nobody; + static const char name[] = "nobody"; + + txcptr = &ttxc; + + memset(txcptr, 0, sizeof(struct timex)); + + SAFE_CLOCK_ADJTIME(CLOCK_REALTIME, txcptr); + timex_show("GET", *txcptr); + + if (tc[i].droproot) { + nobody = SAFE_GETPWNAM(name); + whoami = nobody->pw_uid; + SAFE_SETEUID(whoami); + } + + txcptr->modes = tc[i].modes; + + if (tc[i].ptr) { + + if (tc[i].lowlimit) + *tc[i].ptr = tc[i].lowlimit - tc[i].delta; + + if (tc[i].highlimit) + *tc[i].ptr = tc[i].highlimit + tc[i].delta; + } + + /* special case: EFAULT for bad addresses */ + if (tc[i].exp_err == EFAULT) + txcptr = tst_get_bad_addr(cleanup); + + TEST(sys_clock_adjtime(tc[i].clktype, txcptr)); + if (txcptr && tc[i].exp_err != EFAULT) + timex_show("TEST", *txcptr); + + if (TST_RET >= 0) { + tst_res(TFAIL, "clock_adjtime(): passed unexpectedly (mode=%x, " + "uid=%d)", tc[i].modes, whoami); + return; + } + + if (tc[i].exp_err != TST_ERR) { + tst_res(TFAIL | TTERRNO, "clock_adjtime(): expected %d but " + "failed with %d (mode=%x, uid=%d)", + tc[i].exp_err, TST_ERR, tc[i].modes, whoami); + return; + } + + tst_res(TPASS, "clock_adjtime(): failed as expected (mode=0x%x, " + "uid=%d)", tc[i].modes, whoami); + + if (tc[i].droproot) + SAFE_SETEUID(0); +} + +static void setup(void) +{ + size_t i; + int rval; + + /* check if clock is TIME_OK and save original clock flags */ + + rval = SAFE_CLOCK_ADJTIME(CLOCK_REALTIME, &saved); + + if (rval != TIME_OK) + tst_brk(TBROK | TTERRNO, "unsynced clock or on-going leap"); + + hz = SAFE_SYSCONF(_SC_CLK_TCK); + + /* fix high and low limits by dividing it per HZ value */ + + for (i = 0; i < ARRAY_SIZE(tc); i++) { + if (tc[i].modes == ADJ_TICK) { + tc[i].highlimit /= hz; + tc[i].lowlimit /= hz; + } + } +} + +static void cleanup(void) +{ + saved.modes = ADJ_ALL; + + /* restore clock resolution based on original status flag */ + + if (saved.status & STA_NANO) + saved.modes |= ADJ_NANO; + else + saved.modes |= ADJ_MICRO; + + /* restore original clock flags */ + + SAFE_CLOCK_ADJTIME(CLOCK_REALTIME, &saved); +} + +static struct tst_test test = { + .test = verify_clock_adjtime, + .setup = setup, + .cleanup = cleanup, + .tcnt = ARRAY_SIZE(tc), + .needs_root = 1, + .restore_wallclock = 1, +};