From patchwork Wed Dec 12 20:37:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rafael David Tinoco X-Patchwork-Id: 153591 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp26331ljp; Wed, 12 Dec 2018 12:37:35 -0800 (PST) X-Google-Smtp-Source: AFSGD/UNkpk58JmSr4lTwwE4jGyQ6GkI7wCkVsthlhA+czm5ntX8+ghMMsZwY4/OsLXQjqJGC2uE X-Received: by 2002:a17:906:6dcb:: with SMTP id j11-v6mr16440165ejt.162.1544647055771; Wed, 12 Dec 2018 12:37:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544647055; cv=none; d=google.com; s=arc-20160816; b=X728lm/6OBOSd1nzGKl/q1lfOx75eXplQ3QtshGO3NdfkEQ9m9Tr2cFPg7WAG9zxuB Sl6d4ix7VSe0vwjyq4q35qhWxr82wa7kS7mHN5H0BcXwYs/OADOd/L7ZI7X0PlvqUudG fU4KeeP97xRSHaiCtDgXhwfJMAydkDE68WxRTMtNC4y12hWqoF3XM0phylBsbkX4RFIZ IgGd8U4xU4yRKKcqDOh+NQC9qYRBWnfBe/Gwtcu7iHyOb68+lEjbHwnpqPIID2ldVqEB iD5YSNyXakvB7w4DTEwNchhJapIb0Xpto4QrnP/Ga7qebjhl16uLvwYusgm+8ICvXeIh O29A== 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=l8rhq4pzUxyzh/gKiMmibOoJ9LSgPRzKHbsl3JvpXDw=; b=EyAV25mhEwPXKJF6o5a4VuV3COG2k98KHRkmsOVH3T86GXF0jJSYksF5IdN23VY4z5 5xbew/LFFUyljlm5vgYyI3ke4gjW9t9kPd2h2XLb5OMyMjNiEt8HSW716HnofZDYaTwW EN7gV8scqaWmwxM+wNtDhIRL4rQTul1ItDLL8Rx7IPQYgEGonhSk8LTususpkXn8I22G UVFgN3s9TVRU750le03TlWJAtMYV1C4/SbTctykeyiP/l54gd3K8nhtjBzijRFt0ZlcU vuP0gf/GiaQ2aifp2eIIgjuJUgvgmrIIisiYh92EQ8DS9oNCgxlXVWSV+hbuyOkuoY2O JPMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=FmIca58r; 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 i18-v6si38257ejp.287.2018.12.12.12.37.35 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Dec 2018 12: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=FmIca58r; 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 355933E6FD4 for ; Wed, 12 Dec 2018 21:37:35 +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 46CF63E6F10 for ; Wed, 12 Dec 2018 21:37:30 +0100 (CET) Received: from mail-qk1-x742.google.com (mail-qk1-x742.google.com [IPv6:2607:f8b0:4864:20::742]) (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 46C5F201008 for ; Wed, 12 Dec 2018 21:37:28 +0100 (CET) Received: by mail-qk1-x742.google.com with SMTP id y78so11599490qka.12 for ; Wed, 12 Dec 2018 12:37:28 -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=JDlkqHawYJKTG0rd13zivqSEohUZOvSs1ARu/qU6UhY=; b=FmIca58rgNjSiV0bzZOD+8jR1zkRrzC0ECIzH6LAWcW44S8eELqE/+pfyusIs+iEAb NGo+xa5aEP5KnEii6DtM0vBqTxFY0kdalOPIbTlkCRPfIEN6ZyhvT4vU3arOdyXNBdrZ JDiaUzBZ3CTSHpNKFovK5c10tkS/Boe3RltoQ= 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=JDlkqHawYJKTG0rd13zivqSEohUZOvSs1ARu/qU6UhY=; b=OA81Pcyc/7soLUjpkofawLRvwx6dVg+tkHUBoyvpr3lIfLzV2GKlFtlQazum0T5ZkJ le0gy2CcJKWLS8OGaIOYzIQ4sfo8HzbolhOfj1qqrZTgNNzlwuRW2EAbp2KYnus8PWXZ kmdAvGF3bnzlTYqI34A3bGhuw2+H3XeylbGvME5oMGSGzn2hPqgzswpGYDDydTyOZDLA iwYlYv3bET0I0Qm2UG0oQlcoUcvHPHQLqSlOZ7jlPJfX/5GtlIP28w/OrtVxqbRO5+Kw wIBNdg2MvJN+mdr6yav6+ktJUt+en8SE8aBTFdmTwzzbJt5l2Nx1AnF7gC5nwIFUTYmE hd5A== X-Gm-Message-State: AA+aEWaVAVuBmWaLLPlBLFkUtCGbHHkt6coXmj0FIBJxkqx8AJrXMLf0 eCWYtca9aFJGnbW4SE45NYiDmGsuPH8cyw== X-Received: by 2002:ae9:ed51:: with SMTP id c78mr19232523qkg.85.1544647047665; Wed, 12 Dec 2018 12:37:27 -0800 (PST) Received: from workstation.celeiro.br ([138.204.25.7]) by smtp.gmail.com with ESMTPSA id n3sm11846872qtc.81.2018.12.12.12.37.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Dec 2018 12:37:26 -0800 (PST) From: Rafael David Tinoco To: ltp@lists.linux.it Date: Wed, 12 Dec 2018 18:37:18 -0200 Message-Id: <20181212203723.18810-1-rafael.tinoco@linaro.org> X-Mailer: git-send-email 2.20.0.rc1 In-Reply-To: <20181211142750.GA27159@rei> References: <20181211142750.GA27159@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 Subject: [LTP] [PATCH v3 1/6] tst_timer.h: add tst_timespect_rem_us() function 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" Expand tst_timer.h functionality by having a function to also remove given microseconds from a given timespec. 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 577bc88ef..b1c9ceeba 100644 --- a/include/tst_timer.h +++ b/include/tst_timer.h @@ -151,6 +151,23 @@ static inline struct timespec tst_timespec_add_us(struct timespec t, return t; } +/* + * Removes us microseconds to t. + */ +static inline struct timespec tst_timespec_rem_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 Wed Dec 12 20:37:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rafael David Tinoco X-Patchwork-Id: 153592 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp26436ljp; Wed, 12 Dec 2018 12:37:43 -0800 (PST) X-Google-Smtp-Source: AFSGD/XEZONK4zyO6fZvswZCnoPYxBe4iFpjSOmtlFDt540oLiLes/qHjfuDBkAgC5qJ2YCSWsMh X-Received: by 2002:aa7:d749:: with SMTP id a9mr19555519eds.223.1544647063230; Wed, 12 Dec 2018 12:37:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544647063; cv=none; d=google.com; s=arc-20160816; b=FfAckwrrauSu1vsO/jGaNPY0+tfLAyw0WHl33u3OY3d+f3HPjR7krdrWpppxMbnHo+ D21gCFLk9AsxhYjGPE5UKwSfuF5+0zt/WnYB5PNBFvkM/WEEn4CygpAzpDcnQ2euQ11v 25HJ73DM9KJVWMg+iv5VyZNqkEq4eI9p3seZs+NQX/JFo0G0tpUm74JuG44EwhySdjrp +078KdBaPnaBqPjngUw5OEW7TJHCcH3jKvJ1d9hozDi5l+0UAJxinwRiIXJ6rvWbqy1V VVPXXIsoDu7zFMTINoKAf8aYKe+3FwHok9jT603urd1JnaWONOIlIH5xUD8jfgjdrQsP wp9g== 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=xltuR8puqscTG4AIdW5ISqgfTISOsLcgT7dI4tGps84=; b=IxrwjCFOeVjXyf2ePx7Aqxfxm3R6e5WgWcqtTwxMvevyJ3Gdss4X5itpn6CZGjvoZv TR+HcoMuemxNqKASJgqaudgzgDkkV6HzABqF9H68D2pn5ws2Nh2H4cmdK1G/Dx9/Po+e ZjkRo9aBFriuJp2ZqKCq4el04xKVr4Y3wjNTpDZ8ILW2A+VLv1DQLX7213J+ymKK0xAR ca5Ty9YxMgLEVNPiyqb6nlaLZWonLTmgP2WIiCzfboUA5cf69AS7Eb9dctnY9yYd5LpP d8u3bd4MCbgWzyX6MAOwEZLXmdJkd6hTi0oFU3NacT0fH4/1o01jOf/yBnklDwzgVfoa w9yA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=ga2vZ71i; 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 i55si66552eda.23.2018.12.12.12.37.43 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Dec 2018 12:37:43 -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=ga2vZ71i; 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 D7F533E6FC0 for ; Wed, 12 Dec 2018 21:37:42 +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 380403E6F4E for ; Wed, 12 Dec 2018 21:37:31 +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-4.smtp.seeweb.it (Postfix) with ESMTPS id 45C171000B0C for ; Wed, 12 Dec 2018 21:37:31 +0100 (CET) Received: by mail-qk1-x741.google.com with SMTP id w204so11636691qka.2 for ; Wed, 12 Dec 2018 12:37:31 -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=1A6j/gZ1FjXSqF0s2MJ3kl/zk8KC6YigsZgnDt+zkvY=; b=ga2vZ71iRUFcKOtMu8/P+V3lrgzOEQUX1/7CGPSlHnc46ZeSitR7m3/LAjiyt40GqD CrvEutgfq2QztE/UxQCZQiwBwWh9tL5OvLWvKtiC7/dJS+CqRS14QNH/SysfzLLfzFMf 6QRykdAGxpjLldnKUHQNl5ovNBMv4bVOur9xY= 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=1A6j/gZ1FjXSqF0s2MJ3kl/zk8KC6YigsZgnDt+zkvY=; b=tHvP9p6Xj9o3EcQVlEc4X4FYKDRpLNhfsDJYeCPviPXkf9Ox7aX3oQGabK1IL6boGF jYrmWhAIN90pd3sHUbnAVv80uLDb8VPTnlDSQAyXlywA7kXpehdbM+HXWpADd4v+pwwd qRpqI/DO0E1s+PDPaK8YRkNsBRfokRaYBE2hEYsDlMQ5GFSZ2Ii+58VxZ6tpJbPElfJE bPaGUGyIHetCu1BIftKt8p7YhaA6iMwSMSdXmT4N5pz0xOJ6eM9ZpWPSi9XEx2WR+3ua 456/NyegK2vYmc5ayb8BD1dV//EvCocuo1WjUW6oRQTudCjdsQZMBXekvsXqJG/H9PoL xgPg== X-Gm-Message-State: AA+aEWZdN3CYbt/GUvY2NnbNk9bpuwsb56byriHYHhRzYXrdbYiqmwwM 3nxn3QiVLcrHq10sBT5W4ODSgo3SxFsh7g== X-Received: by 2002:a37:59c4:: with SMTP id n187mr20390873qkb.156.1544647049980; Wed, 12 Dec 2018 12:37:29 -0800 (PST) Received: from workstation.celeiro.br ([138.204.25.7]) by smtp.gmail.com with ESMTPSA id n3sm11846872qtc.81.2018.12.12.12.37.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Dec 2018 12:37:29 -0800 (PST) From: Rafael David Tinoco To: ltp@lists.linux.it Date: Wed, 12 Dec 2018 18:37:19 -0200 Message-Id: <20181212203723.18810-2-rafael.tinoco@linaro.org> X-Mailer: git-send-email 2.20.0.rc1 In-Reply-To: <20181212203723.18810-1-rafael.tinoco@linaro.org> References: <20181211142750.GA27159@rei> <20181212203723.18810-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 v3 2/6] 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 Wed Dec 12 20:37:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rafael David Tinoco X-Patchwork-Id: 153593 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp26522ljp; Wed, 12 Dec 2018 12:37:48 -0800 (PST) X-Google-Smtp-Source: AFSGD/U4svxmXGb3pLs5i3HFh20jE/j3Nx1V0zrrAG6+atBVsItzxt8PJW+rx53WCJPwOMzoHubh X-Received: by 2002:a50:ab82:: with SMTP id u2mr20384762edc.111.1544647068857; Wed, 12 Dec 2018 12:37:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544647068; cv=none; d=google.com; s=arc-20160816; b=CXddT7bcBri2Lcs6Ye1DaQ+DPvW5pgjqhwRQTTX7YURmvR6HjBT+4XvvQRRmbevKkl NntnP5pJgVwEa2ByGdQ7HuktMFSYLD6NUQVkVRLqpNYFZCH+CzMOUsJ9i0TAFLKUxqNk SOqqykyEOCGFK6E0zJfA55VPydWEbwMKtU1Wljk8zVrHy9WTE5Xjn0VzX4WdMIp4llDR dLO73ChW+XYUFfcjjrbQYgXXGmKskz1XFLw51dDJRZjmfB5KbFv5l6o2r5mmwuCgS1+S 1gm86rC8sTOueKWkcbu35peYVGNcU+dulYRDXRfvD9vMERndY8o3rBDFUr/uIfGfF9AG HWiA== 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=p5iF/3YYqlJa7D1b78SYlKGLaaUghUYtMgASo8uVEz8=; b=Zjkyjuf0CPULKEuyHjdrx6q3zca/ubZt8gQ3opl0nKcoEKEI1xwOYEqWmFC9me23pT lnQ+2oR+PGmxjsmm5wJnaCZRctP6CzHB7sUHgyluc3X5aXmM5K1xvKptnL0mebScWGhC nAHbRjFjpT02ljK7wqWSH4l8/rcRXAhrmKhskpOSxjdBQJNFBFLL2YkBseiq5CgAadHi QuRNSQj9/q/FssHkwyqXf/N44jP8T8DdQPXpWAOkagzgBIKlefDW7Q0CyuYGGZm0ANsC O77A64pp9jsgglJrTPMhz1rwHdwUmdsTYMl4eoVfQwi+gMtp+1k/6yIKL895DwpIO31U VVUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b="Wpa/gbwF"; 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 l16-v6si41981ejq.174.2018.12.12.12.37.48 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Dec 2018 12:37:48 -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="Wpa/gbwF"; 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 7A2533E7000 for ; Wed, 12 Dec 2018 21:37:48 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-5.smtp.seeweb.it (in-5.smtp.seeweb.it [217.194.8.5]) by picard.linux.it (Postfix) with ESMTP id 442C63E6FC0 for ; Wed, 12 Dec 2018 21:37:34 +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-5.smtp.seeweb.it (Postfix) with ESMTPS id A1979600C2D for ; Wed, 12 Dec 2018 21:37:33 +0100 (CET) Received: by mail-qk1-x743.google.com with SMTP id a132so11648081qkg.1 for ; Wed, 12 Dec 2018 12:37:33 -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=QmOwmPfwYhp1VQZnUjmetdUEO/kYDndpH+IGSJ8Uu+8=; b=Wpa/gbwFDtxt3GkKk5cb3UCvD5xsKYTT21dy6LmxshKlqZcUluqi10xZYDNKGoYUTK HFRgdmX7ij4KjBJNl9z4S+/eMrovWF45E2b678GfYKbDEK1lyW3jzAJq2WevFwEHWQ2Z uVx+YIxE39F76xsxGXZCXbdrnnaDc2GZ5acfU= 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=QmOwmPfwYhp1VQZnUjmetdUEO/kYDndpH+IGSJ8Uu+8=; b=m2tEtNB043xehyQvcumh8pPJ0tVRr3DpCzti0/Je9f5kmn9mPeOG71VUZQWG3hCQrP BazSZDGD83njqRFDwRgEH7o5Lwg6mS6wCLUHo5g4eeWObpySmte9KhmVXlxc3+CKPyRI ED2oKV0hy+FnMwItxqI82sLtcCexltX86fFwsNdJH1oT64WxwdyZzLIpWNI18U6Ps0jp H36Y4YFwTBvvmR88+6Ll5fb0Pnc4EwTFvskcTrqMoSKHNwSiwMPTM0JwWBSXw+F1AlPs eTTKozd+Egz/eJVPjgLR7hABDpA4vJTgW1BnDW+BSJiOSjYT65cMkrFg28XvCETDHfgp FjkQ== X-Gm-Message-State: AA+aEWZj1cHl+EFT7uXaoMKrAhdpsTu2HpMNT/42i3cso9cFvu+mBVV8 r4rReAJdVyAGz9ho6bhZyV+bNAShFjfWHw== X-Received: by 2002:a37:be02:: with SMTP id o2mr19808441qkf.133.1544647052309; Wed, 12 Dec 2018 12:37:32 -0800 (PST) Received: from workstation.celeiro.br ([138.204.25.7]) by smtp.gmail.com with ESMTPSA id n3sm11846872qtc.81.2018.12.12.12.37.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Dec 2018 12:37:31 -0800 (PST) From: Rafael David Tinoco To: ltp@lists.linux.it Date: Wed, 12 Dec 2018 18:37:20 -0200 Message-Id: <20181212203723.18810-3-rafael.tinoco@linaro.org> X-Mailer: git-send-email 2.20.0.rc1 In-Reply-To: <20181212203723.18810-1-rafael.tinoco@linaro.org> References: <20181211142750.GA27159@rei> <20181212203723.18810-1-rafael.tinoco@linaro.org> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.99.2 at in-5.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-5.smtp.seeweb.it Subject: [LTP] [PATCH v3 3/6] 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 Wed Dec 12 20:37:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rafael David Tinoco X-Patchwork-Id: 153594 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp26616ljp; Wed, 12 Dec 2018 12:37:54 -0800 (PST) X-Google-Smtp-Source: AFSGD/XifR2vnpI0zauvn0rxCTYqqjgnPhug+HfGiif7dooxAJ+Fe/KeLDofX8VyDU2gjEsTtCvb X-Received: by 2002:a17:906:6b43:: with SMTP id o3-v6mr16349135ejs.31.1544647074304; Wed, 12 Dec 2018 12:37:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544647074; cv=none; d=google.com; s=arc-20160816; b=jVJbUXgM1aI2KulY901UJxT/UJdxtdM9vND9/hWtTvqucbCiEeO9XzDBEmJP8cocWu DaiDWyGgLtiPddAkbgKYBRcXv3gx74/9VMgYbiKIo2COBiudys74MyLdutlid1oGcivW ESQgzO04/0ygYIB6l4qwrf/uVv7aI5f/11gtaj0HrsmKRSsFNoHB0FzHYZ0vTDqG7H2w 9uDkUPzla8+wBQBr910/4p5HVHbUi2Nj6VpG1QmZ2vlkMbl822hZEKqQuf/rEeGiqtBG 5SjeymHMLR//g889K/hp9NbO3RWNNV22KuOa7UIWYCk8ZcUYH0FB2hpf4lRBPYO9tskH Lwhw== 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=cMBFNO9hC/ffsXlmVS7P+8ZDdQo7aFSHDjXSme+ZYRY=; b=sgygtjPaEU2pGpuLOsyBGvPDR+RcBAmWSxBlpegiKUv6sBDdKXX9fqX6SLUZtR0a/F VIwoKsRers/DhEbMCS/Tos0FDRJtVQfgw0LOFn2TH85OoIfW96vAdPw4yCUMJmpI1axE ppdwRFvh6KcrAZg1iwLm43yge/uVTEqPBnXYuvmZbC9Rvru/wKNkcjrvi/b135rYmk4Q QGvvzwGwdJLMWx0c+467Bw0GRwpXV9JV2Ds/2v1zIkOK+kQxNCdYdsCSxxcbHWMPGZis M9k96L2L+R+QRFyULAMmg5besyGL6lz1jC9ozyfhTXBIL5e27k1RNERFSLxVDOwzPlGg Y3ew== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=HaDkETPx; 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 g17-v6si40396ejc.222.2018.12.12.12.37.54 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Dec 2018 12:37:54 -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=HaDkETPx; 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 EA0783E6FF5 for ; Wed, 12 Dec 2018 21:37:53 +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 412C83E6F94 for ; Wed, 12 Dec 2018 21:37:36 +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-2.smtp.seeweb.it (Postfix) with ESMTPS id 92019601C64 for ; Wed, 12 Dec 2018 21:37:35 +0100 (CET) Received: by mail-qk1-x743.google.com with SMTP id o125so11626286qkf.3 for ; Wed, 12 Dec 2018 12:37:35 -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=SC8/tFdtnpu12EZuucE2jE2icThtUYh/4MUtk5kxKQE=; b=HaDkETPxBqbd0+QTTq0A22XFNbCSohyyOcAptrtxFmGEJPtqkCf/uGFEjMn1BVykQJ MYk7A3mQRLrX9zEUX45eFXlc2cWXWzeeCd6lrlqYxXE3uS51i6CXL2sshSbBRVt9wD1h hceTVU4QdcPzZtgTs2s0HcMMwuhrTZEYORH54= 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=SC8/tFdtnpu12EZuucE2jE2icThtUYh/4MUtk5kxKQE=; b=SsQIYLXOxJ/LMyEqD30Zow9F5uWjpnkNNjOH/ngmD+CZ/RfUMBJQqbQlKbxUpTYb/y mE8wZGbd9rlCXh0WqIgtoftEpIwpnaqArVp+5yzp0oyUvwX8fXy4gZ7dZ4PIGABHLGFa xYZHW8xJDLA9H2uYmkSTgQCaJqpcMIf12LEQbhS15OqQXvISzQ8i/9/+Oq0pYyqAb+td VoGLrTtrPryss2Y96mN06TGKw+w5D1yi+mI9Mu7yIvF5Invitju2mmblBih7Hxcgmrtl lLtkPkhYL9G/4yDrirhA+VtLnXcgl9BLArAVwdmv/jc07KgAXu0YCfsGqHvsBaQ9QndL DOTQ== X-Gm-Message-State: AA+aEWao/RQSaCBGjZPQAQjZH7jQ2IPMhpslIAOySI6cFtLK9a63AeNG OHgNjmAoBW041yeRCVyEINTxxfIX6YEBhw== X-Received: by 2002:a37:2bcf:: with SMTP id r76mr19007464qkr.218.1544647054229; Wed, 12 Dec 2018 12:37:34 -0800 (PST) Received: from workstation.celeiro.br ([138.204.25.7]) by smtp.gmail.com with ESMTPSA id n3sm11846872qtc.81.2018.12.12.12.37.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Dec 2018 12:37:33 -0800 (PST) From: Rafael David Tinoco To: ltp@lists.linux.it Date: Wed, 12 Dec 2018 18:37:21 -0200 Message-Id: <20181212203723.18810-4-rafael.tinoco@linaro.org> X-Mailer: git-send-email 2.20.0.rc1 In-Reply-To: <20181212203723.18810-1-rafael.tinoco@linaro.org> References: <20181211142750.GA27159@rei> <20181212203723.18810-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 v3 4/6] 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 around clocks need to restore the correct date and time after the tests, including possible iterations, run. This commit introduces a new field to tst_test called "restore_wallclock", which 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 --- include/tst_test.h | 1 + lib/tst_test.c | 6 ++++++ lib/tst_wallclock.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+) create mode 100644 lib/tst_wallclock.c diff --git a/include/tst_test.h b/include/tst_test.h index 2ebf746eb..170bddc21 100644 --- a/include/tst_test.h +++ b/include/tst_test.h @@ -131,6 +131,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/lib/tst_test.c b/lib/tst_test.c index 661fbbfce..aa3d674f0 100644 --- a/lib/tst_test.c +++ b/lib/tst_test.c @@ -868,6 +868,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) @@ -899,6 +902,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..ef08e1dba --- /dev/null +++ b/lib/tst_wallclock.c @@ -0,0 +1,44 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) 2018 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 "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_us(real_begin, tst_timespec_to_us(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 Wed Dec 12 20:37:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rafael David Tinoco X-Patchwork-Id: 153595 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp26689ljp; Wed, 12 Dec 2018 12:37:58 -0800 (PST) X-Google-Smtp-Source: AFSGD/WVtUJaDTY1sQipBvdM1qZaBVOXTFEohYD9t+JP8PDt2AufQm03fxKKbgNQ8e4YolCMZQ5M X-Received: by 2002:a50:9624:: with SMTP id y33mr19582960eda.206.1544647078922; Wed, 12 Dec 2018 12:37:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544647078; cv=none; d=google.com; s=arc-20160816; b=J5Tp6GJBjTyTRpEFIgFgmunJoXbFZQ/jS8mrXHpqvNf8sbSlboMWcCDJ8yQuwMwCr2 6L5rP4FxHophldRqzlX3w4urps/ZcaqqyXB+StjJtTB/tzcU6MOX0UEe/u5tbd/Bq5ei X9JAXoHMSOiV4mPts9uv+SOa2BlyshZmYWqhRKfmHIoDufYR+Nh93zshmgyyk9G7JJaI BOhpZQ0vM/w++zGwv+6FfDc/1lamiy5YYH9FaR52wRu8iAwu+GLj72ORUWGnECiW6chK KhFYecD+ifV4bhcktX+NhLqRW6HeepKSK/iWsP5/g1qnfq8mUVDqAcgophAWJuosd2wX a5Mg== 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=S96aqvx1wEamgaIcC8R6ChTuBYK9oPEXzJ6j6g7safE=; b=qj3+fuzVNQdk1oCUHPIySUdDk/VWE4/NNLOlEq+7TrU1HbV5wkJgoE4KMj0c8XV4Y5 uzh642C50HUs1joveUOiinnozTwFeD3BIm0jXe2jHLmGbFdgtRRzYTurkeZNQIgewifX RmqmJdml20I2C753fpmmylpOGnUg6LWAqGWTQKBIzryFt2UZX+Z24LmTwSZbkujoLXDG R1EJRzfuh9zY+poBcwdOmAHyEhdzA0oG8uoEL90asldiF2BfT9KvOAomTDXBib9ocfVd o8U5Vj8QtgnLB5k7mmyoEdaoJLhdzIOaqnIxfSE2e5qxjoq1T34FNbp9jsyyDSDjH3Hc FaXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=g9XDpDkv; 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 e15-v6si44327ejr.99.2018.12.12.12.37.58 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Dec 2018 12:37:58 -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=g9XDpDkv; 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 803AC3E6F1C for ; Wed, 12 Dec 2018 21:37:58 +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 C1FC23E6F14 for ; Wed, 12 Dec 2018 21:37:38 +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-4.smtp.seeweb.it (Postfix) with ESMTPS id B92C91000B0C for ; Wed, 12 Dec 2018 21:37:37 +0100 (CET) Received: by mail-qt1-x843.google.com with SMTP id z16so22092630qtq.4 for ; Wed, 12 Dec 2018 12:37:37 -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=pQAi+9y2rcHflONOJzgbdWg6UJAdBJLNhFLdG1c0X9M=; b=g9XDpDkv6h754t0kgcppVUjfVgkcWk0ng4ilwugIFAvUjxMtbjzo7/ficbf50NFpqs 5ZzdMjXsQgl2Xv385mSZcK2aicq4d+C3GjsNycFGtr4pCDHYwghJLmeYhpzmpwTIX8Tu LlIOeAMrA/EMYjjNHSLhTKe/Q9uc8IctRE7sk= 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=pQAi+9y2rcHflONOJzgbdWg6UJAdBJLNhFLdG1c0X9M=; b=AYpaujC9Hk/bucalpmrPMB5dmNvai7cQjUeqchEf6ZVKYjlJge6rpcoYaNZlej1iib +fe4IgedLLM9S/3eDwdwPBQtHkzkxvkXLpUTXUDrTIW+ykOZgGnCqu3sWAV0Hwfm9zP9 XY8MjMxkFfs4ajZL26D6nHtODSmKxodsGOk66LLIPeeyrqNOLMgqFTXHflt9lFGZV/Uk 5QbtG9YA+5PDh5QiZyjwofLwrJDiBcuJB6hCUw0lmB5TbcwsevYRi9hv+NPBjYLyprxZ TclrnUhsUn6IniD0AbbSCf+i0Q/sq29WK+rMoKgPY1AlGFxFR4wur4+U7ZcqZDqzsmU8 z/UQ== X-Gm-Message-State: AA+aEWajC1Hyq19RFEgQ6+G9E7olSM++efDjNZhvaeK5YmtlNFGZRj6u vxjYgO01zeYlxuOeclvvuGUUeHcNwDMWPQ== X-Received: by 2002:aed:3e22:: with SMTP id l31mr21734369qtf.342.1544647056193; Wed, 12 Dec 2018 12:37:36 -0800 (PST) Received: from workstation.celeiro.br ([138.204.25.7]) by smtp.gmail.com with ESMTPSA id n3sm11846872qtc.81.2018.12.12.12.37.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Dec 2018 12:37:35 -0800 (PST) From: Rafael David Tinoco To: ltp@lists.linux.it Date: Wed, 12 Dec 2018 18:37:22 -0200 Message-Id: <20181212203723.18810-5-rafael.tinoco@linaro.org> X-Mailer: git-send-email 2.20.0.rc1 In-Reply-To: <20181212203723.18810-1-rafael.tinoco@linaro.org> References: <20181211142750.GA27159@rei> <20181212203723.18810-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,T_MIXED_ES 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 v3 5/6] 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 | 75 +++++++++ .../syscalls/clock_settime/clock_settime02.c | 150 ++++++++++++++++++ 5 files changed, 238 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 34b47f36b..dd03ad31a 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..6e0ee47c4 --- /dev/null +++ b/testcases/kernel/syscalls/clock_settime/clock_settime01.c @@ -0,0 +1,75 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) 2018 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_SEC_US (long long) (DELTA_SEC * 1000000) +#define DELTA_SEC_VAR_POS (long long) (DELTA_SEC_US * 1.10) +#define DELTA_SEC_VAR_NEG (long long) (DELTA_SEC_US * 0.90) + +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_SEC_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_SEC_US && elapsed < DELTA_SEC_VAR_POS) { + 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_rem_us(begin, DELTA_SEC_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_SEC_VAR_NEG) { + 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..25fcbfe09 --- /dev/null +++ b/testcases/kernel/syscalls/clock_settime/clock_settime02.c @@ -0,0 +1,150 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) 2018 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, + .newtime.tv_sec = -2, + .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 saved, spec, *specptr; + + if (tc[i].replace == 0) { + + SAFE_CLOCK_GETTIME(CLOCK_REALTIME, &saved); + + /* add 1 sec to test clock */ + specptr = &spec; + specptr->tv_sec = saved.tv_sec + 1; + specptr->tv_nsec = saved.tv_nsec; + + } else { + + + if (tc[i].newtime.tv_sec == -2) { + + /* bad pointer case */ + specptr = tst_get_bad_addr(NULL); + } else { + + /* use given values */ + specptr = &spec; + specptr->tv_sec = tc[i].newtime.tv_sec; + specptr->tv_nsec = tc[i].newtime.tv_nsec; + } + } + + 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): " + "failed with different error"); + } + + return; + } + + tst_res(TFAIL | TTERRNO, "clock_settime(2): clock type %d failed", + tc[i].type); +} + +static struct tst_test test = { + .test = verify_clock_settime, + .tcnt = ARRAY_SIZE(tc), + .needs_root = 1, + .restore_wallclock = 1, +}; From patchwork Wed Dec 12 20:37:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rafael David Tinoco X-Patchwork-Id: 153596 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp26776ljp; Wed, 12 Dec 2018 12:38:03 -0800 (PST) X-Google-Smtp-Source: AFSGD/WtQ9Crc+kp8EbyjAcx24vKD5Zs591DV4V1M4egAWsQCYo26Pxl1R/95l4UzIouEvIPsBMw X-Received: by 2002:a17:906:6690:: with SMTP id z16-v6mr16259333ejo.142.1544647083920; Wed, 12 Dec 2018 12:38:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544647083; cv=none; d=google.com; s=arc-20160816; b=R9I0l0XWvSDh0St7vskk/YT8Uzi0sN91aPk9KF1YPLmJ9wRkQzkkF7/NLBwVjIT61/ oE6OH2nx6PMFzmuF9yjMhIYiQdDP15rFUY0G3s01smlr5zxe4eTHHyTv/0OTypjXo8pe Ejr4SvsuW1hH8Tdpqa1MvTF4LfG//PU63cnhZaDM3GM9JJdIMvp04aRwSZw+C3D5DhbK Mvz9jgkkwLRWD3SKjSqXXGwLmPc8MuXGLRBs/ZILC9Qwpdz+msTycG0MDdzcd28uam8Q g3jHXF94toUdj4TJytc69sQinnKAOafzKdp7p0ztpg+xxe4+p+mQIv8gev/tdEudMjgB F0oA== 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=oQ9d9/uYvXlv1Bf4ns/Xd9JnE8fcKaBUtbl6verLvSc=; b=uaR0WFMdmdFiXSYfueAJVgFfpyniMroA2tQhGqa/07QWsraTw6sZIuIbfR8+WwkLYk MdUrZvNn6KR/UIaf3mBB7KSzP0BwY3yFaNPs7nBrmk09L3ww+FZ4eu0zycMkcp43KVZ0 z6L35NY86GgIPjTwo3U2/1lxddh7qYKeA6bUKy8QxEvMukcHGpAT3lBceg+TcMs0IGBX MyIHT1AGOBS+BwpY5ce/VxJK1Q2dm4MGfKC2BbGNQVwF8sKksLqsbE6/JElql2K8+kun eIMg5OLNhT+OWwm1xNjnYCkKDnMyO9IX3ZUqhMvblLrVHyHF2fSSbtLxOlQKnz9tUxai rECA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=KWeAzQsS; 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 m4si53897edi.384.2018.12.12.12.38.03 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Dec 2018 12:38:03 -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=KWeAzQsS; 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 85F213E7050 for ; Wed, 12 Dec 2018 21:38:03 +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 0CA7A3E6F5C for ; Wed, 12 Dec 2018 21:37:41 +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-7.smtp.seeweb.it (Postfix) with ESMTPS id A9772201008 for ; Wed, 12 Dec 2018 21:37:39 +0100 (CET) Received: by mail-qt1-x842.google.com with SMTP id d18so22061416qto.8 for ; Wed, 12 Dec 2018 12:37:39 -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=9UFcr5y8HWlmHu1Ul605LFMEpLFfrzGkRzdalCiiaEc=; b=KWeAzQsSPaRflRYKod1Rb7y+hdZd27Lg9a9fdQHyK+hr4HgNkEiStipsm5tIGgbIk8 4DelXE1/7d0s7JVaGbvaSf1Z+xZKO7fGYIveZoWrgPXaj2uBn9r1PRZuoTdSA6n6sAUr aqakGEjmQ0OMtVAzTKBlqdsEhovon7PfWoI6Y= 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=9UFcr5y8HWlmHu1Ul605LFMEpLFfrzGkRzdalCiiaEc=; b=QmlATZsRrVTHRbVMXFQ0AtSmIDFdkG+UMZzALGdowH09ZeJ0XPZdns4UKRuwNmCbOg rr29kkLbCZrkre0cIuLVbwJWq1MXs/vOF+KurcNTuIgLBhlNoF8SOHhateNXwZz1TnQg SdAqVkYq29R7knPC5WVYjdDKXg2QRPUDeOomHuBFPeg4ksJUCLkU17sBtfB2SKmrqA0l PAxEUDaE3lKpNjWWACv9Lhpgy1G9Ml7V6E2pbaVteydfjm8qbTw9xXRl5MWjFi+Y5/fW xkGjpiR8UV5p2bX/uug5FPzh1mCZAnFdqvYsd87SeEKE9BuRP8Ak81RTnNiCqvFIGgnU csZA== X-Gm-Message-State: AA+aEWY94kJmNatQfAqbTV1gxtgAE3RKJ6dvGkSKGorGZEy/7lMj4Bkh 2DiapIwV+q8jnJGrmeJln1BsWOysQGHLMg== X-Received: by 2002:a0c:c60b:: with SMTP id v11mr20402049qvi.198.1544647058190; Wed, 12 Dec 2018 12:37:38 -0800 (PST) Received: from workstation.celeiro.br ([138.204.25.7]) by smtp.gmail.com with ESMTPSA id n3sm11846872qtc.81.2018.12.12.12.37.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Dec 2018 12:37:37 -0800 (PST) From: Rafael David Tinoco To: ltp@lists.linux.it Date: Wed, 12 Dec 2018 18:37:23 -0200 Message-Id: <20181212203723.18810-6-rafael.tinoco@linaro.org> X-Mailer: git-send-email 2.20.0.rc1 In-Reply-To: <20181212203723.18810-1-rafael.tinoco@linaro.org> References: <20181211142750.GA27159@rei> <20181212203723.18810-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,T_MIXED_ES autolearn=disabled version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-7.smtp.seeweb.it Subject: [LTP] [PATCH v3 6/6] 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" Fixes: 343 clock_settime01 creates a new test, using new API, based on existing and older kernel/timers/clock_settime tests. It includes tests from files clock_settime02 and clock_settime03. This commit deletes 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) -{ -}