From patchwork Thu Dec 6 19:07:09 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: 153059 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp10906455ljp; Thu, 6 Dec 2018 11:07:38 -0800 (PST) X-Google-Smtp-Source: AFSGD/XvTD3k2L/jjURMB4VL/yXPh5gsDOKL8NaOMLdVK6SOEH0Q5iQRuuzrE0l7xcIIGRov0rMQ X-Received: by 2002:a1c:b456:: with SMTP id d83mr21904027wmf.115.1544123258143; Thu, 06 Dec 2018 11:07:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544123258; cv=none; d=google.com; s=arc-20160816; b=pFYG2jdO/GEA4JhtLsm9cHTveR4l+rETHB+/fG2Z7P03bUF4RDyxI13XC8g8rx4Cke 6LrXVkd/z6EOoTVJf+Jr13L1mvD/LzwRa1rBl2dcGMEC9tp0c8IRk0SaK1+Er7gS673m 14yQi4ZTcCsGOfNVagdvMG9Ky1F4qb/PJspZpNXEP5VUzf4NMY2igRbHKWKzjDRhlbM6 wTDogKnPBvfiBD7zzjbElRURW3n/pBBpU43MTvMK3yQOakDKp40qXhDsU1W+/SlHp819 Ljtz1oDbA8xDen/HsvSJOqRdziAGMj9ze2DGKRQ08V+pk3kE5Nkc1If8B4R1ySKrQdtU Glcg== 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=AW9xR7UWZtyDHASsMG4SHg+VapnggA0R2Fb8zIrM6Uw=; b=MRJKEtmQdpd9BKL4G4I8ID6/6DRfHE+5hbPeszSuvSdzK1VYYkpLtKFAHxLHoouFCZ JpnJUv4CcISuHruLZo53BNBXiDknNCBWf4Q4yu75hAo3gR7IbZ53n0U4ZdMr5/rzxWeg iFnPdebQlT44f89T5YvlIeQXD1s2j7Nu6D0hdGQfDXgvjGyLXsPppeYHvjJJ4dprmv+x ZXKQ1SybQs6vkA6J1WY0BUL0a765r2P14IMGgSgyCRLDoWM5NwCUJLVmOupkqmhXQ0+8 K6usCXJ3LL1hJSOAK5GxTE3aSMKaFitFPEnTMuKoHXbJSct+UA30O3HnZQxjHTcfMyFc mf1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=B1Om2O1E; 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 62si1120761wmp.92.2018.12.06.11.07.37 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 06 Dec 2018 11:07:38 -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=B1Om2O1E; 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 A058A3E7091 for ; Thu, 6 Dec 2018 20:07:37 +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 [IPv6:2001:4b78:1:20::5]) by picard.linux.it (Postfix) with ESMTP id CBB7F3E702A for ; Thu, 6 Dec 2018 20:07:33 +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-5.smtp.seeweb.it (Postfix) with ESMTPS id D5037600C8C for ; Thu, 6 Dec 2018 20:07:29 +0100 (CET) Received: by mail-qt1-x842.google.com with SMTP id v11so1793684qtc.2 for ; Thu, 06 Dec 2018 11:07:29 -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=dXawWjLS8e6ndy1JJWsUlm3Gdgoro0A1XGLeb7w/R9A=; b=B1Om2O1EQTb4iW1vq2A+kCo88Fk7/tS8FWznjGfEjamYGK8WQ1DZ7G3mSkb4mg3bvK +WpmtlVurQ+5BT1rPeaKxjwECxR63ShX9XyOKAthl+WMGmTXZst8Z1zcAGO8Nf/aYnMM LhlEM28vboLGOuwx2cYBbk7b6XybsLU8StYD4= 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=dXawWjLS8e6ndy1JJWsUlm3Gdgoro0A1XGLeb7w/R9A=; b=jnXacBJ33J9DOYY2F6puZm5y+IGReyu3nq3zI/5HJFeUO+hswo+leu7xBYkTI85moH di9SD/lX8PIKyjxSbSyRK6EOiu9DRygqP4geq6TJsf5s3TZkU+9ulMq4Af47zO2EjRcy ggOwnDlJRyF28OvZWlHwOnrg4EOUXDxwKfqoCeHMbK9x4ZcqjcR+DQQhAgdNPgl1TJSR gjDQvTXyzSgOj2EjS6RqoDgtMiYzHCnjNMaCFM31apOl6noq9w14ie3VBRmn2Pc54ikx MkM1EGqvq0y7Bl099pLivIkkc2VuApZw/BRmloYpqU5uoNPBP+jPZvFrTtNxkDSQ+JWT Ephw== X-Gm-Message-State: AA+aEWaqKkFTLziG9ttnVOKJhdWgHqTLf/RX466O8VM7pNvyrB8qXKqC PCfJVfhWBvzO3jXczKuJvyDqly4OwVRxfQ== X-Received: by 2002:a0c:ba24:: with SMTP id w36mr28217257qvf.60.1544123248200; Thu, 06 Dec 2018 11:07:28 -0800 (PST) Received: from workstation.celeiro.br ([168.181.50.200]) by smtp.gmail.com with ESMTPSA id h41sm815166qte.83.2018.12.06.11.07.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 06 Dec 2018 11:07:27 -0800 (PST) From: Rafael David Tinoco To: ltp@lists.linux.it Date: Thu, 6 Dec 2018 17:07:09 -0200 Message-Id: <20181206190710.22471-1-rafael.tinoco@linaro.org> X-Mailer: git-send-email 2.20.0.rc1 In-Reply-To: <20181206130309.GA22250@rei> References: <20181206130309.GA22250@rei> 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 v2 1/2] syscalls/clock_settime01.c: create syscall clock_settime 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, which will be deleted in next commits. Signed-off-by: Rafael David Tinoco 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 | 122 +++++++++++++ .../syscalls/clock_settime/clock_settime02.c | 171 ++++++++++++++++++ 5 files changed, 306 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 ac1d2d2cd..2e38ab37e 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..97d720fa2 --- /dev/null +++ b/testcases/kernel/syscalls/clock_settime/clock_settime01.c @@ -0,0 +1,122 @@ +// 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 + * + * Accept DELTA_PER deviation on both (specially going backwards). + */ + +#include "config.h" +#include "tst_test.h" +#include "lapi/syscalls.h" + +#define DELTA_SEC 10 /* 10 seconds delta */ +#define DELTA_PER 0.1 /* 1 percent deviation */ + +static struct timespec real_begin, mono_begin, mono_end; + +static void clock_elapsed(struct timespec *begin, struct timespec *end, + struct timespec *elapsed) +{ + elapsed->tv_sec = end->tv_sec - begin->tv_sec; + elapsed->tv_nsec = end->tv_nsec - begin->tv_nsec; +} + +static void clock_return(void) +{ + static struct timespec elapsed, adjust; + + clock_elapsed(&mono_begin, &mono_end, &elapsed); + + adjust.tv_sec = real_begin.tv_sec + elapsed.tv_sec; + adjust.tv_nsec = real_begin.tv_nsec + elapsed.tv_nsec; + + if (clock_settime(CLOCK_REALTIME, &adjust) != 0) + tst_res(TBROK | TTERRNO, "could restore realtime clock"); +} + +static void clock_fixnow(void) +{ + if (clock_gettime(CLOCK_MONOTONIC_RAW, &mono_end) != 0) + tst_res(TBROK | TTERRNO, "could not get elapsed time"); + + clock_return(); +} + +static void setup(void) +{ + /* save initial monotonic time to restore it when needed */ + + if (clock_gettime(CLOCK_REALTIME, &real_begin) != 0) + tst_res(TBROK | TTERRNO, "could not get initial real time"); + + if (clock_gettime(CLOCK_MONOTONIC_RAW, &mono_begin) != 0) + tst_res(TBROK | TTERRNO, "couldn't get initial monotonic time"); +} + +static void cleanup(void) +{ + clock_fixnow(); +} + +static void verify_clock_settime(void) +{ + static struct timespec begin, change, end, elapsed; + + /* test 01: move forward */ + + if (clock_gettime(CLOCK_REALTIME, &begin) != 0) + tst_res(TBROK | TTERRNO, "could not get realtime at the begin"); + + change.tv_sec = begin.tv_sec + DELTA_SEC; + + if (clock_settime(CLOCK_REALTIME, &change) != 0) + tst_res(TBROK | TTERRNO, "could not set realtime change"); + + if (clock_gettime(CLOCK_REALTIME, &end) != 0) + tst_res(TBROK | TTERRNO, "could not get realtime after change"); + + clock_elapsed(&begin, &end, &elapsed); + + if (elapsed.tv_sec < (float) (DELTA_SEC - (DELTA_SEC * DELTA_PER))) + tst_res(TFAIL, "clock_settime(2): could not advance time"); + else + tst_res(TPASS, "clock_settime(2): was able to advance time"); + + /* test 02: move backward */ + + if (clock_gettime(CLOCK_REALTIME, &begin) != 0) + tst_res(TBROK | TTERRNO, "could not get realtime at the begin"); + + change.tv_sec = begin.tv_sec - DELTA_SEC; + + if (clock_settime(CLOCK_REALTIME, &change) != 0) + tst_res(TBROK | TTERRNO, "could not set realtime change"); + + if (clock_gettime(CLOCK_REALTIME, &end) != 0) + tst_res(TBROK | TTERRNO, "could not get realtime after change"); + + clock_elapsed(&begin, &end, &elapsed); + + elapsed.tv_sec = ~elapsed.tv_sec; + elapsed.tv_nsec = ~elapsed.tv_nsec; + + if (elapsed.tv_sec < (float) (DELTA_SEC - (DELTA_SEC * DELTA_PER))) + tst_res(TFAIL, "clock_settime(2): could not recede time"); + else + tst_res(TPASS, "clock_settime(2): was able to recede time"); +} + +static struct tst_test test = { + .setup = setup, + .test_all = verify_clock_settime, + .cleanup = cleanup, + .needs_root = 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..710f37219 --- /dev/null +++ b/testcases/kernel/syscalls/clock_settime/clock_settime02.c @@ -0,0 +1,171 @@ +// 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" + +#define DELTA_SEC 10 +#define NSEC_PER_SEC (1000000000L) +#define MAX_CLOCKS 16 + +static struct timespec clock_realtime_saved; + +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 int sys_clock_gettime(clockid_t clk_id, struct timespec *tp) +{ + return tst_syscall(__NR_clock_gettime, clk_id, tp); +} + +static void cleanup(void) +{ + /* restore realtime clock */ + + if (sys_clock_settime(CLOCK_REALTIME, &clock_realtime_saved) < 0) + tst_res(TBROK | TTERRNO, "clock_settime(2): could not set " + "current time back"); +} + +static void setup(void) +{ + if (sys_clock_gettime(CLOCK_REALTIME, &clock_realtime_saved) < 0) + tst_res(TBROK | TTERRNO, "clock_gettime(2): could not get " + "current time"); +} + +static void verify_clock_settime(unsigned int i) +{ + struct timespec spec, *specptr; + + if (tc[i].replace == 0) { + + /* add 1 sec to test clock */ + + specptr = &spec; + specptr->tv_sec = clock_realtime_saved.tv_sec + 1; + specptr->tv_nsec = clock_realtime_saved.tv_nsec; + + } else { + + /* bad pointer case */ + + if (tc[i].newtime.tv_sec == -2) + specptr = tst_get_bad_addr(cleanup); + + /* use given values */ + + else { + 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 = { + .setup = setup, + .test = verify_clock_settime, + .cleanup = cleanup, + .tcnt = ARRAY_SIZE(tc), + .needs_root = 1, +}; From patchwork Thu Dec 6 19:07:10 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: 153060 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp10906574ljp; Thu, 6 Dec 2018 11:07:42 -0800 (PST) X-Google-Smtp-Source: AFSGD/UIs/Q9lgh1ngb9x8mme5h7gU/5KZfGLS869Bd0Gld4CCxiQS8AIyR0QMaZhPCQQH3Q93WF X-Received: by 2002:adf:f848:: with SMTP id d8mr9922602wrq.178.1544123262830; Thu, 06 Dec 2018 11:07:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544123262; cv=none; d=google.com; s=arc-20160816; b=AeKeD+HxNX6Rb5Z5reKiJsZoZIBqcuv9iOP86xkQEDUSdlxO7Vy7kYcI5lAvqnKIV5 5UsoIzwiqbwsAwI8JWpm+YmCZdyXQ5UwGYOXkG5IDBW8xubOGbqFptH5Fcq8gTnqgiDr 6uQhpYrANFWVHerBIMMHLrPIZFDUNL9IaXeiQpgv2Dic+8Pj8nCcErYlud3/xdJQ9SDF y1X9Lle+QOxFKtD1y4SlXq84lrVulcqI41zHEecX8TtXFS3J4+Fyo6Mg/NMiJiLWI5Ci mmKjPRjVsp9AfqZuXsT8CaNLH4aT2427msSxgttjezm4X7X6Y3eE6rvFi8pHWNAACrkE OMPQ== 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=cHOCCYw2BfzNE12ldW1k+VxZi8uy88ntE7n8m3lLqwaBycnBuygRY5C3AH9kNnZExK HyZ2u8ScXML4WMN3jHxm2OwHHrtKxaY4NpUOfaSfh77GYmScFj/LmvPEglgIXVU4WBiZ uZIBf65E3KTG2kSzo/5d52ylgQzM1bYF1ar/AERibbgvdHrfzuKq3ZISSpiaDCojFmSe mH6eUYuJpzweECiC4+FtyzRbn/znSfqN7ML/p8ZQcjj+fEf2glVjCKtFK+zHnToS8kwI RHM8Zg8/6qwJH7svJ1K419So+plUdBjXzvF4LyRBWPi3t4aWGbsBSQap1Q2w9zqKKvrX eZ6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=CChoDAT1; 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 m135-v6si1146622wmb.23.2018.12.06.11.07.42 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 06 Dec 2018 11:07:42 -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=CChoDAT1; 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 61BC83E7099 for ; Thu, 6 Dec 2018 20:07:42 +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 88EF93E7047 for ; Thu, 6 Dec 2018 20:07:36 +0100 (CET) Received: from mail-qk1-x741.google.com (mail-qk1-x741.google.com [IPv6:2607:f8b0:4864:20::741]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by in-2.smtp.seeweb.it (Postfix) with ESMTPS id 332DF60066E for ; Thu, 6 Dec 2018 20:07:32 +0100 (CET) Received: by mail-qk1-x741.google.com with SMTP id q1so975448qkf.13 for ; Thu, 06 Dec 2018 11:07:32 -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=CChoDAT1d5UhlcrjTxFbG+g0Mh8UAFSPCSL/ou162UyR4XnWnH5xM5AKlj9yqNVHAm Uu0c7x2MHtI+hIokNjuxoNILdjOR0WvZEwWVeWg0MPYEx+n2+uxkaYWbvbH3fBs/9oK+ OUZ/425c6tcyraEev10EY2fJyfBR2yt9jIO34= 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=PqcduZPdPWxP9OeHr1oKVGb+ogsTnWl/+Lorn8SRRJOYZn1UIyyvVF+QtLKzAiFQNG s3UBLIC+pcmw3ccBxds2Whs/kSO/u6cBVMVLaUu8FYXke++V6S4HongVlZj+8m/DW7OB V5QQYZTaT3sE0CcUhETKS+vjuBdFsIvu1eW/4zck8EPgwvZL3qaAAKIseNwp1Di4qOyT JgFZKdPwxbumSMKfUn2g4Shoj1TC/hH53d2s7t/0FjmiXHRiyr7YQ+HA2/ojksCP/ZNa 7WgwrpEODuUgyntPFNFdOXtdNT1QlQSTEm11R9BaJ0czCWqdrbZBQjOvqJE0lWd9fUmj MTrw== X-Gm-Message-State: AA+aEWZouWWqh8ieHgMAEAg0ykwOCWeH3gZcmdEOzYzet1zac/U1hbEH aqm0VAoJEZGYnJGgIUI9c0EWIpkhIAKfrw== X-Received: by 2002:a37:24c9:: with SMTP id k70mr27309415qkk.281.1544123250573; Thu, 06 Dec 2018 11:07:30 -0800 (PST) Received: from workstation.celeiro.br ([168.181.50.200]) by smtp.gmail.com with ESMTPSA id h41sm815166qte.83.2018.12.06.11.07.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 06 Dec 2018 11:07:29 -0800 (PST) From: Rafael David Tinoco To: ltp@lists.linux.it Date: Thu, 6 Dec 2018 17:07:10 -0200 Message-Id: <20181206190710.22471-2-rafael.tinoco@linaro.org> X-Mailer: git-send-email 2.20.0.rc1 In-Reply-To: <20181206190710.22471-1-rafael.tinoco@linaro.org> References: <20181206130309.GA22250@rei> <20181206190710.22471-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 v2 2/2] 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) -{ -}