From patchwork Fri Mar 22 18:25:23 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: 160951 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp1113073jan; Fri, 22 Mar 2019 11:25:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqzK2G9TdNDWG/6N7J+6esePqMUZv7AdVA3LBPjgJZrvDB+NVkFTF+eqVE0f07YCt73NQm1u X-Received: by 2002:a1c:dfc5:: with SMTP id w188mr3827605wmg.79.1553279138454; Fri, 22 Mar 2019 11:25:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553279138; cv=none; d=google.com; s=arc-20160816; b=JXMzD5XNYoF988PtM6k2YJnmv9ckdZSPedkWP6NDfjWdCQ555gNnpYbB1YkWoSwHlf jCMbCYGSkClRagBgEt1neSk4NGJHfpkVJ/dtYPcBHwBXi4/6mfgscdAqIVKTwkPCa01w X9cnR8IWfl4Q1HIJ0Y09kERcvGxHVAyo/aBBdwexWhl2bHkqdIf0Vl78OrrL7y/Cup7b 6EcevXYPdACPA5FnXkHamMp/y+4DptQrpXY235CK8L2Uaa9ccSx7BO8IF7T/1QjkTEy3 wqFt9AO5UR0G9uGHf08mChIqMaqxQvpmTOnh/sML5zKCj54DKWjoL4JateIgNoVj5RHJ 3flg== 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=YHJq98Rf+U1KLcAeMHQ+rJP21wOb4yLIUwNgFnsYM2X5J9wKfSM92rR1WAibvrR8+K qGymv7oWicF/Yx1YCZJp1HgyUamFwu8g4h0JRtIa7GZYcWyevawwL+lQhZl3eYBH6Yc1 zhD1+E11P6/1YqijcgosXuT6sTM3D74RzBa/rASXvpBkRMxDKwwLR9eHOtfNa2UG/QUH 4hnSWWGkJswXuiLbeEdZ0hNTJxWdJfSMeKAnP43PjkZmzLJZ8H3X6HFkwMwUqLtTYQmC JwX7yIbp18UY/z/kTLhMVhDb1BVAu/xSGCjkkFGdJV/RPYJbRQv5lVGFsi6Xev088k4c jTBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=WJZJ0Vqz; 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 d3si2824516wrj.85.2019.03.22.11.25.38 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Mar 2019 11:25:38 -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=WJZJ0Vqz; 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 E7D2A3EB01D for ; Fri, 22 Mar 2019 19:25:37 +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 [217.194.8.4]) by picard.linux.it (Postfix) with ESMTP id F06453EA04F for ; Fri, 22 Mar 2019 19:25:33 +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-4.smtp.seeweb.it (Postfix) with ESMTPS id 883D51000C75 for ; Fri, 22 Mar 2019 19:25:31 +0100 (CET) Received: by mail-qt1-x841.google.com with SMTP id w5so3563476qtb.11 for ; Fri, 22 Mar 2019 11:25:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=TdXXiGaRpeHTu5okHncaoNQzoyb/0cRHr1KE56BSNJ4=; b=WJZJ0Vqz0mb5RpukHY9k617O4Z4aX3DZwpFh0x4HbkpPqStnZx5AAb2l7mGXbW2oFj iVVVcbAigqYIH/MXT7KyHe6BLuMJXCl0pImu6h3lJTGKZj2OdGL/GLBYzh0OnsLp+fT9 zHp5cCKwfvOo3u3LgjQVgfznOM41kXDXi5und1Ivydx3R7/1U2W+KNJhTF4eqzMhW7ym lb7l6eJEO7/dlLMAoHTar+BA78Nm3aLJ54DS+JD2Byk1wSeZamyDf0W+6xYGqbN3j0IR O4XbEvWkc7VCuXpKMV2STScpTt0BrOZrUMfTvT6ULZZ0wlu72KTCYoNian7LS1s7RHcU idzA== 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=ojfqfDT5EnvVqpJ9UzD4hLrDEYaM3E2TB5JmIIlSZ2YCcuflQemg/hO14BqtKWcUig W4Onynhg9hO7GI54w411a3tLGzESi+3zRvj8dIl+QUNjT9O1pgk9Vvft6EL8tsj3mrye AMl8zxlo1Dzuwo/Z1uPyyympzTM6lnZClpb1CPBXgkvr+JG8YmK0CSYU/WlTokcKsCc7 7oLy6JX3womk4jrsyNzgHP1hwECxX9asMoCXa6nMDJsBgl0YTtOmXZTuntaTd70U4TA/ z1CSDyntL1vG+sg0Vdzqr1EnmHQJTSph6XS8SKab1pfT8/eKg8DxNhpUzkJQRC5CR0Ae 39+A== X-Gm-Message-State: APjAAAXGUzV5vaDKrbp3WQFEFJ9m4jH4lF6d65xZ+Fejh6k9St/TJMTk rL/iurxU7r5bbz+QG5VDjap/89aB2p9eWfM1 X-Received: by 2002:a0c:88e9:: with SMTP id 38mr9323835qvo.241.1553279131714; Fri, 22 Mar 2019 11:25:31 -0700 (PDT) Received: from workstation.celeiro.br ([191.177.184.97]) by smtp.gmail.com with ESMTPSA id h24sm7056241qte.50.2019.03.22.11.25.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Mar 2019 11:25:30 -0700 (PDT) From: Rafael David Tinoco To: ltp@lists.linux.it Date: Fri, 22 Mar 2019 15:25:23 -0300 Message-Id: <20190322182526.10353-1-rafael.tinoco@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190322133425.GB20408@rei.lan> References: <20190322133425.GB20408@rei.lan> 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 v4 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 Fri Mar 22 18:25:24 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: 160952 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp1113145jan; Fri, 22 Mar 2019 11:25:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqwAoEEvPzRKSShSp2aebypaxoHezardC3e1q/nNCGRcjqlnNH3nFwrSRL8+m0y5lNI+Ci7p X-Received: by 2002:a50:b646:: with SMTP id c6mr7426723ede.149.1553279143627; Fri, 22 Mar 2019 11:25:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553279143; cv=none; d=google.com; s=arc-20160816; b=r9t9j7Tmk4WjA9sJTnlLHxa3oVLXU9A672xzWzhFLsYQc2+nvzC1fw6ntiwiEjwV8A 8ex/ZPiZn+Qow80ncW+xsdxNApZPa9DErBDUSMBmypQQPGDveRPIxKeG5eUBAJEjFpDM WPiTE9Wi0w8VDoAdQpZme/L9dzBxzCdORKV5KMxFZ8kFts2j40Vy3q+HxIVbE5DPv+LV 9/B/Yt3AL/Cj30zI9p6L1ZLxVmlKBgueMXtpMw1PTwOV2warxmbmtxwOh+tG17FNVD1n I7pTdoVdj+2vo1oaQzNN1qfBRSwK8v0LchORj2RjbrwpITjgmOnv54XaF5sH+flmgLNi B1Qw== 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=hmcievNCBl4jeIOK65rarAJRSySb4Yna2nUKtD4TX20Mpg3wrdICCnjzIBlPK66OCP TZIkjR6c+WHZoavfIZwgEykpD8NiZXwMpWKc9WEI2+aIvX2OJ/IBAA0qx4XTdJ1eVXPo otdm0QC5sUyHLdFBohGN85u0dVCMYWK2ZyPkala/oty9XxkW1d511pBYXSLnuaDIZQM3 ugrQvZoSnz6s1/+QsMSo7iTgRnn136WL5uFKbEVaDTW26FGqdn4WsuxudJeQy/OxmTZV 8eNTuULt7epIup1xP/IUtMuy0QHtbLTfc+v3zUd3SCH/Nn83Vfq4P9nbD8p9gfauRqPR mhsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=lERiw8QJ; 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 y13si1478278edp.88.2019.03.22.11.25.43 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Mar 2019 11:25:43 -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=lERiw8QJ; 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 2A6803EAEC0 for ; Fri, 22 Mar 2019 19:25:43 +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 [217.194.8.4]) by picard.linux.it (Postfix) with ESMTP id D5A8B3EAFF3 for ; Fri, 22 Mar 2019 19:25:35 +0100 (CET) Received: from mail-qt1-x82a.google.com (mail-qt1-x82a.google.com [IPv6:2607:f8b0:4864:20::82a]) (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 792F11000C77 for ; Fri, 22 Mar 2019 19:25:33 +0100 (CET) Received: by mail-qt1-x82a.google.com with SMTP id y36so3623587qtb.3 for ; Fri, 22 Mar 2019 11:25:35 -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=lERiw8QJX8yzs1w4I1UdOJg0pQuz14OYr6pgCKGUd0r/feY/XCiueTCftYUlArmVs+ L1rqoZgPPGX5qAyBFIV07IYs6J2dHzWFj4idI9tPwUtDfD2uF72S84jOJVpG/2MiXCF2 hhSM5/cEdqtg5uOwsLX5hcumYuoSF98qXCFPQCo/whSOrmJugMt6ydyonT36olxVLsGi Wm2o+rac7tHBNOhhZgapiRvbKt/FaurQiW6OGDZu+yCt06lUl+ns9b7yXxZvo//SyrZ1 b3fOQklEKDhWkPlAPb8wHzD6ZIbqS6nPEiXjCunJdXNekLTZahUry/efOW1I/XPNKY0K rQBA== 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=G8rnE1r+s9AkmXt70yi4wyO5JjHyw2GFMR/ZB/DPPR4Sa3CaubHlgqNR5fOJD2nOB7 YLR6MKdd6l7Ubz61GoRFV+zF/QB55bMvuHg2i33qXDYM0nvbzoXbsfUZHjTS19UicaFP flzaNDk+gJF7APiJAqpXpmJMzv0TVKClYzCHbE4bHvr2ccgTy4WozuOFkfyNpAhuNEH5 fkhlETpnW+8+twAOwjb7w7uCPyVY2PRgrvVsZ68ReBvhCyLBCnlpqre4U85QHjEpJrv7 s9/Jqyx/ll6swlGfpW65VKvzVUx9/hnQ9stRN57gtZu5Q3L5Ij+XQoFXHOd7TqV5vRzt X0Jg== X-Gm-Message-State: APjAAAV6Z4ZoxjQIr6BE5WzujFukN4CW4zXJjukFLPsHvu14pzIMqr/E Jttjo7XWc/QVoXRSMa7BbrgRsTTU3qyainTe X-Received: by 2002:ac8:3f62:: with SMTP id w31mr9753018qtk.342.1553279133849; Fri, 22 Mar 2019 11:25:33 -0700 (PDT) Received: from workstation.celeiro.br ([191.177.184.97]) by smtp.gmail.com with ESMTPSA id h24sm7056241qte.50.2019.03.22.11.25.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Mar 2019 11:25:33 -0700 (PDT) From: Rafael David Tinoco To: ltp@lists.linux.it Date: Fri, 22 Mar 2019 15:25:24 -0300 Message-Id: <20190322182526.10353-2-rafael.tinoco@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190322182526.10353-1-rafael.tinoco@linaro.org> References: <20190322133425.GB20408@rei.lan> <20190322182526.10353-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 v4 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 Fri Mar 22 18:25:25 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: 160953 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp1113212jan; Fri, 22 Mar 2019 11:25:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqyQ3oZw6ymjOu0H78oIojJER4hD+HXE29E3PBdRMonJAvlIA0015b28R81lRm5V+oRryT3C X-Received: by 2002:a5d:464e:: with SMTP id j14mr7903811wrs.109.1553279148581; Fri, 22 Mar 2019 11:25:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553279148; cv=none; d=google.com; s=arc-20160816; b=zJfW52asjVul28hV+oSXzF6hwRLHnzMKUpYdqohP9MSTpUX2SU1aiPZaBJ3lx+3Kn7 K/gsBxN5z8AwGpzl6vWWPyYVP1jvMX24R6AAPJb4fpp8qnFNBhSBSWZ6KdBn5nGnTREe a5qc2/l0NW+HCBoU1tuF0VkyRWetcMLb/gEYNFI+H6Gtu/zwuE/oFtD904mBFH/62Fxj yfjkS5y9hix7ZtrJcpRMXyYIDi5GFB7zEJj3wqxfbt4vonnW1tUCPwR/u3RelfzaV4Q6 dglIT7intqXGGT77rveqlnfYc4YOnQz/J09T4Mprrga6JfwBc8J73o36bjzYfc6SNOLp vAPQ== 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=RRA5snkRpBUUt4LrAK1TUd9/jYBC9vKRsMbd7jCWQvQ3kXMFAMikJWOwQp38uyadcb HMNKGyXg1N2C3nTAvlrKgfqBa6ulSzMke/zqjR80f191vMe4oAxBdGcN3DwZNjFC5x8A OBo2DRY1gXjmX23SHJP2fqYSY8KoMQgpWDtg+lTTZjFMCytJG+ujIM8eOakLc/GdQqvs WuVAikyPETxx/f8mjghF9rOqsB0ZZLTuYhTpe4VEiAXsjirhbFBzjE9hbw7/YGSt8a2k mG3qSAv8669QQJ5YHllW0z2sYIisqeLyn9vkwDC0id4kCX/Vn3XVVpinNXAGAUgWBOFH 2X5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=EgDlCZHV; 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 j20si5574339wre.388.2019.03.22.11.25.48 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Mar 2019 11:25:48 -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=EgDlCZHV; 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 20B4C3EB00C for ; Fri, 22 Mar 2019 19:25:48 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-3.smtp.seeweb.it (in-3.smtp.seeweb.it [217.194.8.3]) by picard.linux.it (Postfix) with ESMTP id D18F13EB019 for ; Fri, 22 Mar 2019 19:25:37 +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-3.smtp.seeweb.it (Postfix) with ESMTPS id 33BC01A0120C for ; Fri, 22 Mar 2019 19:25:37 +0100 (CET) Received: by mail-qk1-x741.google.com with SMTP id z76so1770788qkb.12 for ; Fri, 22 Mar 2019 11:25:37 -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=EgDlCZHVN8CjO0gJi91LN+1PuBwl9IhrSF10Cd+WJNy57kjPT2MivyFhOrkK7JnIJ4 58+lGl4T/O2ByZlI2CGN+F1L9/WZZLhPSDkEx31ORvMQX3+2acWJN3nr33HEnOMMoevq TPBrd3GNbMakYB0CkHk9mpTpb4JEJWWAjDlNZmHdO+6tlZicWKuqE6yvc+MqW/Sz1gjd fWd+xOQEa/PHWXOpLwMl/NlMnbXZnz/FroV1E8e7vgfVaEmHFUWH3SJ0WGgZYx63Ri6A qbarQmcOU/veYGKn3QW3wpJUgwdAhWMSztjW/jiiyFeYerLJVatgp44uv3QddHmU0zmL 9YvQ== 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=KV4DVRwoAWlKZqKB2lWZCHAxse5q0JGRkCv+0yvBDIOK8Mouo3inzwb54rBZhGlTeU 562u2+f7NDPw9l23Pqf3uABABwoJFl0JW/Lh4NcLDxEwjVG+2miIUmU9nmjtQWZXerzq k6TnQpaJhALyy8/Ed8t8Tm+3QSemEUdXpVmne4PjnN45R0mYxgNcahZICpjfNMd+M5RI av1TmFRJXJEhEJ6+LlMlk74hESn1mkWDuVB4ZYWnzWoGkq8qiMky0Q+x7oBc3/J/DxiD kaAQT0ItAfLCZUuLwZgqmwkUHDLTLGrkITyOpe1HwV02Gtv+n8/PBiAnR9VADXZjb5lq YS+w== X-Gm-Message-State: APjAAAUOaNLiJMgbO6bDYq3Erfb5IrkCIxI5J3cElA8H0R8R4bpaNgXY PzXY0N2TVd+dqgJcLBNgF8NmX/pUJjc87LWB X-Received: by 2002:a37:8c9:: with SMTP id 192mr8711394qki.203.1553279135847; Fri, 22 Mar 2019 11:25:35 -0700 (PDT) Received: from workstation.celeiro.br ([191.177.184.97]) by smtp.gmail.com with ESMTPSA id h24sm7056241qte.50.2019.03.22.11.25.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Mar 2019 11:25:35 -0700 (PDT) From: Rafael David Tinoco To: ltp@lists.linux.it Date: Fri, 22 Mar 2019 15:25:25 -0300 Message-Id: <20190322182526.10353-3-rafael.tinoco@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190322182526.10353-1-rafael.tinoco@linaro.org> References: <20190322133425.GB20408@rei.lan> <20190322182526.10353-1-rafael.tinoco@linaro.org> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.99.2 at in-3.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,SPF_PASS autolearn=disabled version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-3.smtp.seeweb.it Cc: rafael.tinoco@linaro.org Subject: [LTP] [PATCH v4 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 Fri Mar 22 18:25:26 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: 160954 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp1113265jan; Fri, 22 Mar 2019 11:25:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqwAZhay0xaNpNBOA6ZLCWzkz4DAItdhkKVpakm+nwCwTeaOqLynQe4Q49HxaBmR/k8dCjS+ X-Received: by 2002:a1c:9d8f:: with SMTP id g137mr4075162wme.26.1553279154271; Fri, 22 Mar 2019 11:25:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553279154; cv=none; d=google.com; s=arc-20160816; b=MG7VvqkXCiYXJQCjkSTCJjFa79jCQ0YcqgSOoj9pc3qDtARunFKPCuhiFLWo6YvdAR MQqJi8LkO+ATEwWifKwbaHlrjN3qjgsjnZmjpWyx9HZjJzeJpQfa4/8YxATBO6Np2PrH /Jk41NETM0WZxZREMrMOSBWRlKLyIj2P+oCfo5s+pHlmzflFirWmVIVOto3/6av8ExOr HA4KV6r04hCviTR0rFewug0939WoVVhy81yF6U0CytAddkZmjIAJZZnGRd4u1yb8Ky+s 3dR58Ax2B+lU72ohGCc756TLrfBMMi5lNAKvHaxSORZoBxlJpRKI7HEKgHJkA8HvrmVj JeCQ== 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=9AIQwrAsNhm2fWSNJxm54ZTOtkTJX3lzxr3dld20I+Y=; b=owRvz8ton5oDiAZuuCOt9kxLjoVulyENXt3+0V2ixxJaDpgSvkG2GHOaGBzi+n5BTJ OOVsNN6ELDxH063DXpRuq748QRz6dIFdFp2S6O44QT7PRZ1BziTvjhoCp9uwfEVWPmdM 4qYpZscZBJvjUV1AQcqKcPIWGFdl7TEa0V2QZItawXLS9NATtZkLWDuy9Z/vf9wzwh78 OAKidh6y7c5xuUUJa527cyoMG2/mMJm0exOcyFNul50M7bib8k88EYpsNo4IF93yH3zE YjFN6nCIfyDh3BhR29hKVgd/9a3XOe1QYVTEG3lae5++Vt43kbGYBmHykgNwkJCL5kQx nYgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=eEJz0WeR; 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 h125si5535289wmf.46.2019.03.22.11.25.53 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Mar 2019 11:25:54 -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=eEJz0WeR; 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 F124B3EB007 for ; Fri, 22 Mar 2019 19:25:52 +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 D7B2A3EB00F for ; Fri, 22 Mar 2019 19:25:40 +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-2.smtp.seeweb.it (Postfix) with ESMTPS id A51AC60198B for ; Fri, 22 Mar 2019 19:25:39 +0100 (CET) Received: by mail-qk1-x744.google.com with SMTP id b74so1779136qkg.9 for ; Fri, 22 Mar 2019 11:25:39 -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=LHrCZXnxZnO5W49tMBhy4Roa6RTVEyz4RRuO22L+55g=; b=eEJz0WeRTwvT6MwGRlrz0nXbg5q8A4/zyhjuu1A7UNTYwSUbBOf2m+IcumrspfmBSt NtMruUBb8jR6n7a4NXS/eCpa8aLwZz3bgKARc99FLbMQpUF3wkZ12re5UFfQz4oBplK/ whi0NNU9wZpiOmtevAKKhnStrHkIuNbAqYMIoB5eF7DtHqZjhuiinzrdCbk/Pve5liXf rt0bIVuxDOduqoVMAcy3uLDATdwmfrPh3g85JNfVxN2IgaHkhJ32jzhLkamLuVQvD5JZ ugyrn9D6RlWUO7Tc/oR5yYQkq1qhcTfUr3LkBuSZowkUf9t5DAgedw56qZ9ZEVb3fdoW ndSA== 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=LHrCZXnxZnO5W49tMBhy4Roa6RTVEyz4RRuO22L+55g=; b=dJRZf/dtE3oDoPmOJbqkKNjMKN4FSHfCslIECTaxfcWnsTcRUBXtwBo4aYugglGPDl /NmDmMVI9U4Lr45By3T7HTA3Go7zvvkmsdp8saqTVC4+xqxULmB+giMSLKO4J02y6Iu4 tNIeIEQ/Y7zY0UN+tHdJm5bqW2o2L3RCJzn2dghZwbT1mPhpgCPrOYVt276vO7UJ1JnI Z6XkgGHC/jvzy3qKD/zwUMWX3YmFdRGsQJtm639pgXwIJti9uBmKMI5/4Q+jfYCZtAmx gcWR64tyQvKwU2GLG7P9+3/VqcU54Gz0CEVDu7lkXFXGca+hkIp/7O1QOFvAb+haDX0Z UY8w== X-Gm-Message-State: APjAAAXeNuB2jWwP+2gZ3VJEzHHWJvFD1t+B8m3wQjyEuvy/UN2hyR8D ab0fUj2QlASHZB8dJWggJ7j41qYDUFnR7On7 X-Received: by 2002:a37:8345:: with SMTP id f66mr8297426qkd.154.1553279138008; Fri, 22 Mar 2019 11:25:38 -0700 (PDT) Received: from workstation.celeiro.br ([191.177.184.97]) by smtp.gmail.com with ESMTPSA id h24sm7056241qte.50.2019.03.22.11.25.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Mar 2019 11:25:37 -0700 (PDT) From: Rafael David Tinoco To: ltp@lists.linux.it Date: Fri, 22 Mar 2019 15:25:26 -0300 Message-Id: <20190322182526.10353-4-rafael.tinoco@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190322182526.10353-1-rafael.tinoco@linaro.org> References: <20190322133425.GB20408@rei.lan> <20190322182526.10353-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 Cc: rafael.tinoco@linaro.org Subject: [LTP] [PATCH v4 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 | 221 ++++++++++++++++++ .../syscalls/clock_adjtime/clock_adjtime02.c | 221 ++++++++++++++++++ 7 files changed, 518 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..6eac1f25c --- /dev/null +++ b/testcases/kernel/syscalls/clock_adjtime/clock_adjtime01.c @@ -0,0 +1,221 @@ +// 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; + + rval = SAFE_CLOCK_ADJTIME(CLOCK_REALTIME, &saved); + + if (rval != TIME_OK && rval != TIME_ERROR) { + timex_show("SAVE_STATUS", saved); + tst_brk(TBROK | TTERRNO, "clock has on-going leap changes, " + "returned: %i", rval); + } + + 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..1ce936f96 --- /dev/null +++ b/testcases/kernel/syscalls/clock_adjtime/clock_adjtime02.c @@ -0,0 +1,221 @@ +// 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; + + rval = SAFE_CLOCK_ADJTIME(CLOCK_REALTIME, &saved); + + if (rval != TIME_OK && rval != TIME_ERROR) { + timex_show("SAVE_STATUS", saved); + tst_brk(TBROK | TTERRNO, "clock has on-going leap changes, " + "returned: %i", rval); + } + + 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, +};