* [LTP] [PATCH v1 1/3] timers/timer_delete0{2, 3}: Ported to new library
@ 2019-07-23 7:08 Christian Amann
2019-07-23 7:08 ` [LTP] [PATCH v1 2/3] timers/timer_settime0{2, " Christian Amann
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Christian Amann @ 2019-07-23 7:08 UTC (permalink / raw)
To: ltp
Cleaned up and ported both timer_delete(2) tests to new library.
Signed-off-by: Christian Amann <camann@suse.com>
---
.../kernel/timers/timer_delete/timer_delete02.c | 188 +++++++--------------
.../kernel/timers/timer_delete/timer_delete03.c | 175 +++++--------------
2 files changed, 102 insertions(+), 261 deletions(-)
rewrite testcases/kernel/timers/timer_delete/timer_delete02.c (93%)
rewrite testcases/kernel/timers/timer_delete/timer_delete03.c (93%)
diff --git a/testcases/kernel/timers/timer_delete/timer_delete02.c b/testcases/kernel/timers/timer_delete/timer_delete02.c
dissimilarity index 93%
index b9b9c7ffc..6380a34cf 100644
--- a/testcases/kernel/timers/timer_delete/timer_delete02.c
+++ b/testcases/kernel/timers/timer_delete/timer_delete02.c
@@ -1,125 +1,63 @@
-/*
- * 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 : timer_delete02
- *
- * EXECUTED BY : anyone
- *
- * TEST TITLE : Basic test for timer_delete(2)
- *
- * TEST CASE TOTAL : 1
- *
- * AUTHOR : Aniruddha Marathe <aniruddha.marathe@wipro.com>
- *
- * 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 timer_delete(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.
- * Create a POSIX timer
- * 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: <for command-line>
- * timer_delete02 [-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 <stdlib.h>
-#include <errno.h>
-#include <time.h>
-#include <signal.h>
-
-#include "test.h"
-#include "common_timers.h"
-
-void setup(void);
-
-char *TCID = "timer_delete02"; /* Test program identifier. */
-int TST_TOTAL = 1; /* Total number of test cases. */
-
-int main(int ac, char **av)
-{
- int lc;
- kernel_timer_t timer_id;
-
- tst_parse_opts(ac, av, NULL, NULL);
-
- setup();
-
- for (lc = 0; TEST_LOOPING(lc); lc++) {
-
- tst_count = 0;
-
- /* Create a Posix timer */
- if (ltp_syscall(__NR_timer_create, CLOCK_REALTIME, NULL,
- &timer_id) < 0) {
- tst_count = TST_TOTAL;
- tst_brkm(TBROK | TERRNO, cleanup,
- "timer_delete can't be tested because "
- "timer_create failed");
- }
- TEST(ltp_syscall(__NR_timer_delete, timer_id));
- tst_resm((TEST_RETURN == 0 ? TPASS : TFAIL | TTERRNO),
- "%s", (TEST_RETURN == 0 ? "passed" : "failed"));
- }
-
- cleanup();
- tst_exit();
-}
-
-/* setup() - performs all ONE TIME setup for this test */
-void setup(void)
-{
-
- tst_sig(NOFORK, DEF_HANDLER, cleanup);
-
- TEST_PAUSE;
-}
-
-/*
- * cleanup() - Performs one time cleanup for this test at
- * completion or premature exit
- */
-void cleanup(void)
-{
-}
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) Wipro Technologies Ltd, 2003. All Rights Reserved.
+ *
+ * Author: Aniruddha Marathe <aniruddha.marathe@wipro.com>
+ *
+ * Ported to new library:
+ * 07/2019 Christian Amann <camann@suse.com>
+ */
+/*
+ * Basic test for timer_delete(2)
+ *
+ * Creates a timer for each available clock and then tries
+ * to delete them again.
+ */
+
+#include <errno.h>
+#include <time.h>
+#include "tst_test.h"
+#include "common_timers.h"
+
+static void run(void)
+{
+ unsigned int i;
+ kernel_timer_t timer_id;
+
+ for (i = 0; i < CLOCKS_DEFINED; ++i) {
+ clock_t clock = clock_list[i];
+
+ if (clock == CLOCK_PROCESS_CPUTIME_ID ||
+ clock == CLOCK_THREAD_CPUTIME_ID) {
+ if (!have_cputime_timers())
+ continue;
+ }
+
+ tst_res(TINFO, "Testing %s", get_clock_str(clock));
+
+ TEST(tst_syscall(__NR_timer_create, clock, NULL, &timer_id));
+ if (TST_RET != 0) {
+ if (possibly_unsupported(clock) && TST_ERR == EINVAL) {
+ tst_res(TPASS | TTERRNO,
+ "%s unsupported, failed as expected",
+ get_clock_str(clock));
+ } else {
+ tst_res(TBROK | TTERRNO,
+ "Aborting test - timer_create(%s) failed",
+ get_clock_str(clock));
+ }
+ continue;
+ }
+
+ TEST(tst_syscall(__NR_timer_delete, timer_id));
+ if (TST_RET == 0)
+ tst_res(TPASS, "Timer deleted successfully!");
+ else
+ tst_res(TFAIL | TTERRNO, "Timer deletion failed!");
+ }
+}
+
+static struct tst_test test = {
+ .test_all = run,
+ .needs_root = 1,
+};
diff --git a/testcases/kernel/timers/timer_delete/timer_delete03.c b/testcases/kernel/timers/timer_delete/timer_delete03.c
dissimilarity index 93%
index 02506fb90..748c23c0f 100644
--- a/testcases/kernel/timers/timer_delete/timer_delete03.c
+++ b/testcases/kernel/timers/timer_delete/timer_delete03.c
@@ -1,136 +1,39 @@
-/*
- * 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 : timer_delete03
- *
- * EXECUTED BY : anyone
- *
- * TEST TITLE : Test checking for basic error conditions for
- * timer_delete(2)
- *
- * TEST CASE TOTAL : 1
- *
- * AUTHOR : Aniruddha Marathe <aniruddha.marathe@wipro.com>
- *
- * SIGNALS
- * Uses SIGUSR1 to pause before test if option set.
- * (See the parse_opts(3) man page).
- *
- * DESCRIPTION
- * This test case check whether timer_delete(2) returns appropriate error
- * value for invalid parameter
- *
- * Setup:
- * Setup signal handling.
- * Pause for SIGUSR1 if option specified.
- *
- * Test:
- * Loop if the proper options are given.
- * Execute system call with invalid parameter.
- * Check return code, if system call fails with errno == expected errno
- * Issue syscall passed with expected errno
- * Otherwise, Issue syscall failed to produce expected errno
- *
- * Cleanup:
- * Print errno log and/or timing stats if options given
- *
- * USAGE: <for command-line>
- * timer_delete03 [-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 <stdlib.h>
-#include <errno.h>
-#include <time.h>
-#include <signal.h>
-
-#include "test.h"
-#include "common_timers.h"
-
-#define INVALID_ID ((kernel_timer_t)-1)
-
-void setup(void);
-
-int testcase[] = {
- EINVAL /* Invalid timer ID */
-};
-
-char *TCID = "timer_delete03";
-int TST_TOTAL = ARRAY_SIZE(testcase);
-
-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++) {
-
- TEST(ltp_syscall(__NR_timer_delete, INVALID_ID));
-
- /* check return code */
- if (TEST_RETURN == -1 && TEST_ERRNO == testcase[i]) {
- tst_resm(TPASS | TTERRNO,
- "failed as expected failure");
- } else {
- tst_resm(TFAIL | TTERRNO,
- "didn't fail as expected [expected "
- "errno = %d (%s)]",
- testcase[i], strerror(testcase[i]));
- } /* end of else */
-
- } /* End of TEST CASE LOOPING */
-
- } /* End for TEST_LOOPING */
-
- cleanup();
- tst_exit();
-}
-
-/* setup() - performs all ONE TIME setup for this test */
-void setup(void)
-{
-
- tst_sig(NOFORK, DEF_HANDLER, cleanup);
-
- TEST_PAUSE;
-}
-
-/*
- * cleanup() - Performs one time cleanup for this test at
- * completion or premature exit
- */
-void cleanup(void)
-{
-}
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) Wipro Technologies Ltd, 2003. All Rights Reserved.
+ *
+ * Author: Aniruddha Marathe <aniruddha.marathe@wipro.com>
+ *
+ * Ported to new library:
+ * 07/2019 Christian Amann <camann@suse.com>
+ */
+/*
+ * Basic error handling test for timer_delete(2):
+ *
+ * This test case checks whether timer_delete(2) returns an appropriate
+ * error (EINVAL) for an invalid timerid parameter
+ */
+
+#include <errno.h>
+#include <time.h>
+#include "tst_test.h"
+#include "common_timers.h"
+
+#define INVALID_ID ((kernel_timer_t)-1)
+
+static void run(void)
+{
+ TEST(tst_syscall(__NR_timer_delete, INVALID_ID));
+
+ if (TST_RET == -1 && TST_ERR == EINVAL) {
+ tst_res(TPASS | TTERRNO,
+ "Failed as expected");
+ } else {
+ tst_res(TFAIL | TTERRNO,
+ "Didn't fail with EINVAL as expected - got");
+ }
+}
+
+static struct tst_test test = {
+ .test_all = run,
+};
--
2.16.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [LTP] [PATCH v1 2/3] timers/timer_settime0{2, 3}: Ported to new library
2019-07-23 7:08 [LTP] [PATCH v1 1/3] timers/timer_delete0{2, 3}: Ported to new library Christian Amann
@ 2019-07-23 7:08 ` Christian Amann
2019-07-24 12:16 ` Cyril Hrubis
2019-07-23 7:08 ` [LTP] [PATCH v1 3/3] timers/leapsec_timer: " Christian Amann
2019-07-24 12:14 ` [LTP] [PATCH v1 1/3] timers/timer_delete0{2, 3}: " Cyril Hrubis
2 siblings, 1 reply; 6+ messages in thread
From: Christian Amann @ 2019-07-23 7:08 UTC (permalink / raw)
To: ltp
Cleaned up and ported both timer_settime(2) tests to new library.
Signed-off-by: Christian Amann <camann@suse.com>
---
.../kernel/timers/timer_settime/timer_settime02.c | 318 ++++++++-------------
.../kernel/timers/timer_settime/timer_settime03.c | 314 ++++++++------------
2 files changed, 249 insertions(+), 383 deletions(-)
rewrite testcases/kernel/timers/timer_settime/timer_settime02.c (92%)
rewrite testcases/kernel/timers/timer_settime/timer_settime03.c (95%)
diff --git a/testcases/kernel/timers/timer_settime/timer_settime02.c b/testcases/kernel/timers/timer_settime/timer_settime02.c
dissimilarity index 92%
index cfeb7b3d3..36d9a745f 100644
--- a/testcases/kernel/timers/timer_settime/timer_settime02.c
+++ b/testcases/kernel/timers/timer_settime/timer_settime02.c
@@ -1,193 +1,125 @@
-/*
- * 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 : timer_settime02
- *
- * EXECUTED BY : anyone
- *
- * TEST TITLE : Basic test for timer_settime(2)
- *
- * TEST CASE TOTAL : 4
- *
- * AUTHOR : Aniruddha Marathe <aniruddha.marathe@wipro.com>
- *
- * 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 timer_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.
- * setup individual test
- * 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: <for command-line>
- * timer_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 <stdlib.h>
-#include <errno.h>
-#include <time.h>
-#include <signal.h>
-
-#include "test.h"
-#include "common_timers.h"
-
-void setup(void);
-static int setup_test(int option);
-
-char *TCID = "timer_settime02"; /* Test program identifier. */
-int TST_TOTAL = 4; /* Total number of test cases. */
-
-static struct itimerspec new_set, old_set, *old_temp;
-static kernel_timer_t timer;
-static int flag;
-
-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++) {
-
- /* Set up individual test */
- if (setup_test(i) == 0) {
- TEST(ltp_syscall(__NR_timer_settime, timer,
- flag, &new_set, old_temp));
- tst_resm((TEST_RETURN == 0 ?
- TPASS :
- TFAIL | TTERRNO),
- "%s",
- (TEST_RETURN ==
- 0 ? "passed" : "failed")
- );
- }
-
- }
- }
-
- cleanup();
- tst_exit();
-}
-
-/* This function does set up for individual tests */
-static int setup_test(int option)
-{
- struct timespec timenow; /* Used to obtain current time */
- int rc = 0;
-
- switch (option) {
- case 0:
- /* This is general initialization.
- * make old_setting NULL
- * make flags equal to zero
- * use one-shot timer
- */
- old_temp = NULL;
- new_set.it_interval.tv_sec = 0;
- new_set.it_interval.tv_nsec = 0;
- new_set.it_value.tv_sec = 5;
- new_set.it_value.tv_nsec = 0;
- flag = 0;
- break;
- case 1:
- /* get the old_setting in old_set
- * This test case also takes care
- * of situation where the timerid is
- * already armed
- */
- old_temp = &old_set;
- break;
- case 2:
- /* Use the periodic timer */
- new_set.it_interval.tv_sec = 5;
- new_set.it_value.tv_sec = 0;
- break;
- case 3:
- /* Use TIMER_ABSTIME flag for setting
- * absolute time for timer
- */
- flag = TIMER_ABSTIME;
- /*
- * Let's not use the linux_syscall_number syscall(2)
- * wrapper here because our primary test focus is
- * timer_create, not clock_gettime. That's covered in
- * those respective tests.
- */
- if (clock_gettime(CLOCK_REALTIME, &timenow) < 0) {
- tst_resm(TWARN | TERRNO,
- "clock_gettime failed; skipping the test");
- rc = -1;
- } else {
- new_set.it_value.tv_sec = timenow.tv_sec + 25;
- }
- break;
- }
- return rc;
-}
-
-/* setup() - performs all ONE TIME setup for this test */
-void setup(void)
-{
-
- tst_sig(NOFORK, DEF_HANDLER, cleanup);
-
- TEST_PAUSE;
-
- if (ltp_syscall(__NR_timer_create, CLOCK_REALTIME, NULL, &timer) < 0)
- tst_brkm(TBROK, NULL, "timer_create failed");
-}
-
-/*
- * cleanup() - Performs one time cleanup for this test at
- * completion or premature exit
- */
-void cleanup(void)
-{
-}
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) Wipro Technologies Ltd, 2003. All Rights Reserved.
+ *
+ * Author: Aniruddha Marathe <aniruddha.marathe@wipro.com>
+ *
+ * Ported to new library:
+ * 07/2019 Christian Amann <camann@suse.com>
+ */
+/*
+ * This tests the timer_settime(2) syscall under various conditions:
+ *
+ * 1) General initialization: No old_value, no flags, 5-second-timer
+ * 2) Setting a pointer to a itimerspec struct as old_set parameter
+ * 3) Using a periodic timer
+ * 4) Using absolute time
+ *
+ * All of these tests are supposed to be successful.
+ */
+
+#include <stdlib.h>
+#include <errno.h>
+#include <time.h>
+#include <signal.h>
+#include "tst_test.h"
+#include "common_timers.h"
+
+static struct timespec timenow;
+static struct itimerspec new_set, old_set;
+static kernel_timer_t timer;
+
+static struct testcase {
+ struct itimerspec *old_ptr;
+ int it_value_tv_sec;
+ int it_internal_tv_sec;
+ int check_clock_gettime;
+ int flag;
+ char *description;
+} tcases[] = {
+ {NULL, 5, 0, 0, 0, "general initialization"},
+ {&old_set, 5, 0, 0, 0, "setting old_value"},
+ {&old_set, 0, 5, 0, 0, "using periodic timer"},
+ {&old_set, 5, 0, 1, TIMER_ABSTIME, "using absolute time"},
+};
+
+static void run(unsigned int n)
+{
+ unsigned int i;
+ struct testcase *tc = &tcases[n];
+
+ tst_res(TINFO, "Testing for %s:", tc->description);
+
+ for (i = 0; i < CLOCKS_DEFINED; ++i) {
+ clock_t clock = clock_list[i];
+
+ if (clock == CLOCK_PROCESS_CPUTIME_ID ||
+ clock == CLOCK_THREAD_CPUTIME_ID) {
+ if (!have_cputime_timers())
+ continue;
+ }
+
+ TEST(tst_syscall(__NR_timer_create, clock, NULL, &timer));
+ if (TST_RET != 0) {
+ if (possibly_unsupported(clock) && TST_ERR == EINVAL) {
+ tst_res(TPASS | TTERRNO,
+ "%s unsupported, failed as expected",
+ get_clock_str(clock));
+ } else {
+ tst_res(TBROK | TTERRNO,
+ "timer_create(%s) failed",
+ get_clock_str(clock));
+ }
+ continue;
+ }
+
+ memset(&new_set, 0, sizeof(new_set));
+ memset(&old_set, 0, sizeof(old_set));
+
+ new_set.it_value.tv_sec = tc->it_value_tv_sec;
+ new_set.it_interval.tv_sec = tc->it_internal_tv_sec;
+
+ if (tc->check_clock_gettime) {
+ if (clock_gettime(clock, &timenow) < 0) {
+ tst_res(TBROK,
+ "clock_gettime(%s) failed - skipping the test",
+ get_clock_str(clock));
+ continue;
+ }
+ new_set.it_value.tv_sec = timenow.tv_sec + 25;
+ }
+
+ TEST(tst_syscall(__NR_timer_settime, timer,
+ tc->flag, &new_set, tc->old_ptr));
+
+ if (TST_RET != 0) {
+ tst_res(TFAIL | TTERRNO, "%s failed",
+ get_clock_str(clock));
+ } else {
+ tst_res(TPASS, "%s was successful",
+ get_clock_str(clock));
+ }
+
+ TEST(tst_syscall(__NR_timer_delete, timer));
+ if (TST_RET != 0)
+ tst_res(TFAIL | TTERRNO, "timer_delete() failed!");
+ }
+}
+
+static void sighandler(int sig)
+{
+ /* sighandler for CLOCK_*_ALARM */
+ tst_res(TINFO, "Caught signal %s", tst_strsig(sig));
+}
+
+static void setup(void)
+{
+ SAFE_SIGNAL(SIGALRM, sighandler);
+}
+
+static struct tst_test test = {
+ .test = run,
+ .needs_root = 1,
+ .tcnt = ARRAY_SIZE(tcases),
+ .setup = setup,
+};
diff --git a/testcases/kernel/timers/timer_settime/timer_settime03.c b/testcases/kernel/timers/timer_settime/timer_settime03.c
dissimilarity index 95%
index 1216c117c..80861995f 100644
--- a/testcases/kernel/timers/timer_settime/timer_settime03.c
+++ b/testcases/kernel/timers/timer_settime/timer_settime03.c
@@ -1,190 +1,124 @@
-/*
- * 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 : timer_settime03
- *
- * EXECUTED BY : anyone
- *
- * TEST TITLE : Test checking for basic error conditions for
- * timer_settime(2)
- *
- * TEST CASE TOTAL : 6
- *
- * AUTHOR : Aniruddha Marathe <aniruddha.marathe@wipro.com>
- *
- * SIGNALS
- * Uses SIGUSR1 to pause before test if option set.
- * (See the parse_opts(3) man page).
- *
- * DESCRIPTION
- * This test case check whether timer_settime(2) returns appropriate error
- * value for invalid parameter
- *
- * Setup:
- * Setup signal handling.
- * Pause for SIGUSR1 if option specified.
- *
- * Test:
- * Loop if the proper options are given.
- * setup the individual test.
- * Execute system call with invalid parameters.
- * Check return code, if system call fails with errno == expected errno
- * Issue syscall passed with expected errno
- * Otherwise, Issue syscall failed to produce expected errno
- *
- * Cleanup:
- * Print errno log and/or timing stats if options given
- *
- * USAGE: <for command-line>
- * timer_settime03 [-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 <errno.h>
-#include <time.h>
-#include <unistd.h>
-
-#include "test.h"
-#include "common_timers.h"
-
-void setup(void);
-void setup_test(int option);
-
-int testcase[] = {
- EINVAL, /* New setting null */
- EINVAL, /* tv_nsec < 0 */
- EINVAL, /* nsec > NSEC/SEC */
- EINVAL, /* Invalid timerid */
- EFAULT, /* bad newsetting * */
- EFAULT /* bad oldsetting * */
-};
-
-char *TCID = "timer_settime03";
-int TST_TOTAL = ARRAY_SIZE(testcase);
-
-static struct itimerspec new_set, old_set, *old_temp, *new_temp;
-static kernel_timer_t timer, tim;
-
-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++) {
-
- /* Set up individual tests */
- setup_test(i);
- TEST(ltp_syscall(__NR_timer_settime, tim, 0, new_temp,
- old_temp));
-
- /* check return code */
- if (TEST_RETURN == -1 && TEST_ERRNO == testcase[i]) {
- tst_resm(TPASS | TTERRNO, "failed as expected");
- } else {
- tst_resm(TFAIL | TTERRNO,
- "didn't fail as expected [expected "
- "errno = %d (%s)]",
- testcase[i], strerror(testcase[i]));
- } /* end of else */
-
- }
-
- }
-
- cleanup();
- tst_exit();
-}
-
-/* This function sets up individual tests */
-void setup_test(int option)
-{
- switch (option) {
- case 0:
- /* Pass NULL structure as new setting */
- new_temp = NULL;
- tim = timer;
- old_temp = &old_set;
- break;
- case 1:
- /* Make tv_nsec value less than 0 */
- new_set.it_value.tv_nsec = -1;
- new_set.it_value.tv_sec = 5;
- new_set.it_interval.tv_sec = 0;
- new_set.it_interval.tv_nsec = 0;
- new_temp = &new_set;
- break;
- case 2:
- /* Make tv_nsec more than NSEC_PER_SEC */
- new_set.it_value.tv_nsec = NSEC_PER_SEC + 1;
- break;
- case 3:
- /* make timer_id invalid */
- tim = (kernel_timer_t) - 1;
- new_set.it_value.tv_nsec = 0;
- break;
- case 4:
- /* make new_setting a bad pointer */
- tim = timer;
- new_temp = (struct itimerspec *)-1;
- break;
- case 5:
- /* make old_setting a bad pointer */
- new_temp = &new_set;
- old_temp = (struct itimerspec *)-1;
- break;
- }
-}
-
-/* setup() - performs all ONE TIME setup for this test */
-void setup(void)
-{
-
- tst_sig(NOFORK, DEF_HANDLER, cleanup);
-
- if (ltp_syscall(__NR_timer_create, CLOCK_REALTIME, NULL, &timer) < 0) {
- tst_brkm(TBROK, NULL, "Timer create failed. Cannot"
- " setup test");
- }
-
- TEST_PAUSE;
-}
-
-/*
- * cleanup() - Performs one time cleanup for this test at
- * completion or premature exit
- */
-void cleanup(void)
-{
-}
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) Wipro Technologies Ltd, 2003. All Rights Reserved.
+ *
+ * Author: Aniruddha Marathe <aniruddha.marathe@wipro.com>
+ *
+ * Ported to new library:
+ * 07/2019 Christian Amann <camann@suse.com>
+ */
+/*
+ * This tests basic error handling of the timer_settime(2) syscall:
+ *
+ * 1) Setting pointer to new settings to NULL -> EINVAL
+ * 2) Setting tv_nsec of the itimerspec structure to a negative value
+ * -> EINVAL
+ * 3) Setting tv_nsec of the itimerspec structure to something larger
+ * than NSEC_PER_SEC -> EINVAL
+ * 4) Passing an invalid timer -> EINVAL
+ * 5) Passing an invalid address for new_value -> EFAULT
+ * 6) Passing an invalid address for old_value -> EFAULT
+ */
+
+#include <errno.h>
+#include <time.h>
+#include "tst_test.h"
+#include "common_timers.h"
+
+static struct itimerspec new_set, old_set;
+static kernel_timer_t timer, timer_inval;
+
+/* separate description-array to (hopefully) improve readability */
+static const char * const descriptions[] = {
+ "setting new_set pointer to NULL",
+ "setting tv_nsec to a negative value",
+ "setting tv_nsec value too high",
+ "passing pointer to invalid timer_id",
+ "passing invalid address for new_value",
+ "passing invalid address for old_value",
+};
+
+static struct testcase {
+ kernel_timer_t *timer_id;
+ struct itimerspec *new_ptr;
+ struct itimerspec *old_ptr;
+ int it_value_tv_nsec;
+ int error;
+} tcases[] = {
+ {&timer, NULL, &old_set, 0, EINVAL},
+ {&timer, &new_set, &old_set, -1, EINVAL},
+ {&timer, &new_set, &old_set, NSEC_PER_SEC + 1, EINVAL},
+ {&timer_inval, &new_set, &old_set, 0, EINVAL},
+ {&timer, (struct itimerspec *) -1, &old_set, 0, EFAULT},
+ {&timer, &new_set, (struct itimerspec *) -1, 0, EFAULT},
+};
+
+static void run(unsigned int n)
+{
+ unsigned int i;
+ struct testcase *tc = &tcases[n];
+
+ tst_res(TINFO, "Testing for %s:", descriptions[n]);
+
+ for (i = 0; i < CLOCKS_DEFINED; ++i) {
+ clock_t clock = clock_list[i];
+
+ if (clock == CLOCK_PROCESS_CPUTIME_ID ||
+ clock == CLOCK_THREAD_CPUTIME_ID) {
+ if (!have_cputime_timers())
+ continue;
+ }
+
+ /* Init temporary timer */
+ TEST(tst_syscall(__NR_timer_create, clock, NULL, &timer));
+ if (TST_RET != 0) {
+ if (possibly_unsupported(clock) && TST_ERR == EINVAL) {
+ tst_res(TPASS | TTERRNO,
+ "%s unsupported, failed as expected",
+ get_clock_str(clock));
+ } else {
+ tst_res(TBROK | TTERRNO,
+ "timer_create(%s) failed",
+ get_clock_str(clock));
+ }
+ continue;
+ }
+
+ memset(&new_set, 0, sizeof(new_set));
+ memset(&old_set, 0, sizeof(old_set));
+
+ new_set.it_value.tv_sec = 5;
+ new_set.it_value.tv_nsec = tc->it_value_tv_nsec;
+
+ TEST(tst_syscall(__NR_timer_settime, *tc->timer_id,
+ 0, tc->new_ptr, tc->old_ptr));
+
+ if (tc->error != TST_ERR) {
+ tst_res(TFAIL | TTERRNO,
+ "%s didn't fail as expected. Expected: %s - Got",
+ get_clock_str(clock),
+ tst_strerrno(tc->error));
+ } else {
+ tst_res(TPASS | TTERRNO,
+ "%s failed as expected",
+ get_clock_str(clock));
+ }
+
+ /* Delete temporary timer */
+ TEST(tst_syscall(__NR_timer_delete, timer));
+ if (TST_RET != 0)
+ tst_res(TFAIL | TTERRNO, "timer_delete() failed!");
+ }
+}
+
+static void setup(void)
+{
+ timer_inval = -1;
+}
+
+static struct tst_test test = {
+ .test = run,
+ .needs_root = 1,
+ .tcnt = ARRAY_SIZE(tcases),
+ .setup = setup,
+};
--
2.16.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [LTP] [PATCH v1 3/3] timers/leapsec_timer: Ported to new library
2019-07-23 7:08 [LTP] [PATCH v1 1/3] timers/timer_delete0{2, 3}: Ported to new library Christian Amann
2019-07-23 7:08 ` [LTP] [PATCH v1 2/3] timers/timer_settime0{2, " Christian Amann
@ 2019-07-23 7:08 ` Christian Amann
2019-07-29 12:09 ` Petr Vorel
2019-07-24 12:14 ` [LTP] [PATCH v1 1/3] timers/timer_delete0{2, 3}: " Cyril Hrubis
2 siblings, 1 reply; 6+ messages in thread
From: Christian Amann @ 2019-07-23 7:08 UTC (permalink / raw)
To: ltp
Ported the test to the new library
Signed-off-by: Christian Amann <camann@suse.com>
Notes:
The leapsec timer is still a mess, even after porting it.
Cleaning it up would probably be its own patch as the best
solution would be to rewrite it from scratch
---
testcases/kernel/timers/include/common_timers.h | 1 -
testcases/kernel/timers/leapsec/leapsec_timer.c | 174 +++++++++++-------------
2 files changed, 80 insertions(+), 95 deletions(-)
diff --git a/testcases/kernel/timers/include/common_timers.h b/testcases/kernel/timers/include/common_timers.h
index 154be670f..df4196eeb 100644
--- a/testcases/kernel/timers/include/common_timers.h
+++ b/testcases/kernel/timers/include/common_timers.h
@@ -7,7 +7,6 @@
#ifndef __COMMON_TIMERS_H__
#define __COMMON_TIMERS_H__
-#define CLEANUP cleanup
#include "config.h"
#include "lapi/syscalls.h"
#include "lapi/posix_clocks.h"
diff --git a/testcases/kernel/timers/leapsec/leapsec_timer.c b/testcases/kernel/timers/leapsec/leapsec_timer.c
index 1d18f6433..e087cc47a 100644
--- a/testcases/kernel/timers/leapsec/leapsec_timer.c
+++ b/testcases/kernel/timers/leapsec/leapsec_timer.c
@@ -1,3 +1,12 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) Red Hat, Inc., 2012.
+ *
+ * Author: Lingzhu Xiang <lxiang@redhat.com>
+ *
+ * Ported to new library:
+ * 07/2019 Christian Amann <camann@suse.com>
+ */
/*
* Regression test for hrtimer early expiration during and after leap seconds
*
@@ -7,60 +16,36 @@
*
* This is a regression test for the bug.
*
- * Lingzhu Xiang <lxiang@redhat.com> Copyright (c) Red Hat, Inc., 2012.
- *
- * 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.
- *
+ * Note: running this test simultaneously with a timesync daemon
+ * (e.g. systemd-timesyncd) can cause this test to fail.
*/
#include <sys/types.h>
-#include <sys/time.h>
-#include <sys/timex.h>
#include <errno.h>
-#include <stdlib.h>
+#include <stdio.h>
#include <time.h>
-#include "test.h"
+#include "tst_test.h"
+#include "tst_safe_clocks.h"
#include "common_timers.h"
#define SECONDS_BEFORE_LEAP 2
#define SECONDS_AFTER_LEAP 2
-char *TCID = "leapsec_timer";
-int TST_TOTAL = 1;
-
-static inline int in_order(struct timespec a, struct timespec b);
-static void adjtimex_status(struct timex *tx, int status);
-static const char *strtime(const struct timespec *now);
-static void test_hrtimer_early_expiration(void);
-static void run_leapsec(void);
-static void setup(void);
-static void cleanup(void);
+static int errors;
-int main(int argc, char **argv)
+static const char *strtime(const struct timespec *now)
{
- int lc;
-
- tst_parse_opts(argc, argv, NULL, NULL);
-
- setup();
+ static char fmt[256], buf[256];
- for (lc = 0; TEST_LOOPING(lc); lc++) {
- tst_count = 0;
- run_leapsec();
+ if (snprintf(fmt, sizeof(fmt), "%%T.%09ld", now->tv_nsec) < 0) {
+ buf[0] = '\0';
+ return buf;
}
-
- cleanup();
- tst_exit();
+ if (!strftime(buf, sizeof(buf), fmt, localtime(&now->tv_sec))) {
+ buf[0] = '\0';
+ return buf;
+ }
+ return buf;
}
static inline int in_order(struct timespec a, struct timespec b)
@@ -84,64 +69,53 @@ static void adjtimex_status(struct timex *tx, int status)
"leap second has occurred",
"clock not synchronized",
};
- int r;
+
+ int ret;
struct timespec now;
tx->modes = ADJ_STATUS;
tx->status = status;
- r = adjtimex(tx);
+ ret = adjtimex(tx);
now.tv_sec = tx->time.tv_sec;
now.tv_nsec = tx->time.tv_usec * 1000;
if ((tx->status & status) != status)
- tst_brkm(TBROK, cleanup, "adjtimex status %d not set", status);
- else if (r < 0)
- tst_brkm(TBROK | TERRNO, cleanup, "adjtimex");
- else if (r < 6)
- tst_resm(TINFO, "%s adjtimex: %s", strtime(&now), msgs[r]);
+ tst_brk(TBROK, "adjtimex status %d not set", status);
+ else if (ret < 0)
+ tst_brk(TBROK | TERRNO, "adjtimex");
+ else if (ret < 6)
+ tst_res(TINFO, "%s adjtimex: %s", strtime(&now), msgs[ret]);
else
- tst_resm(TINFO, "%s adjtimex: clock state %d",
- strtime(&now), r);
-}
-
-static const char *strtime(const struct timespec *now)
-{
- static char fmt[256], buf[256];
-
- if (snprintf(fmt, sizeof(fmt), "%%F %%T.%09ld %%z", now->tv_nsec) < 0) {
- buf[0] = '\0';
- return buf;
- }
- if (!strftime(buf, sizeof(buf), fmt, localtime(&now->tv_sec))) {
- buf[0] = '\0';
- return buf;
- }
- return buf;
+ tst_res(TINFO, "%s adjtimex: clock state %d",
+ strtime(&now), ret);
}
static void test_hrtimer_early_expiration(void)
{
struct timespec now, target;
- int r, fail;
+ int ret;
- clock_gettime(CLOCK_REALTIME, &now);
- tst_resm(TINFO, "now is %s", strtime(&now));
+ SAFE_CLOCK_GETTIME(CLOCK_REALTIME, &now);
+ tst_res(TINFO, "now is %s", strtime(&now));
target = now;
target.tv_sec++;
- tst_resm(TINFO, "sleep till %s", strtime(&target));
- r = clock_nanosleep(CLOCK_REALTIME, TIMER_ABSTIME, &target, NULL);
- if (r < 0) {
- tst_resm(TINFO | TERRNO, "clock_nanosleep");
+ tst_res(TINFO, "sleep until %s", strtime(&target));
+ ret = clock_nanosleep(CLOCK_REALTIME, TIMER_ABSTIME, &target, NULL);
+ if (ret < 0) {
+ tst_res(TINFO | TERRNO, "clock_nanosleep");
return;
}
- clock_gettime(CLOCK_REALTIME, &now);
- tst_resm(TINFO, "now is %s", strtime(&now));
+ SAFE_CLOCK_GETTIME(CLOCK_REALTIME, &now);
+ tst_res(TINFO, "now is %s", strtime(&now));
- fail = !in_order(target, now);
- tst_resm(fail ? TFAIL : TINFO, "hrtimer early expiration is %s.",
- fail ? "detected" : "not detected");
+ if (in_order(target, now)) {
+ tst_res(TINFO, "hrtimer early expiration is not detected.");
+ } else {
+ tst_res(TFAIL, "hrtimer early expiration is detected.");
+ errors++;
+ }
}
static void run_leapsec(void)
@@ -150,9 +124,9 @@ static void run_leapsec(void)
struct timespec now, leap, start;
struct timex tx;
- clock_gettime(CLOCK_REALTIME, &now);
+ SAFE_CLOCK_GETTIME(CLOCK_REALTIME, &now);
start = now;
- tst_resm(TINFO, "test start at %s", strtime(&now));
+ tst_res(TINFO, "test start@%s", strtime(&now));
test_hrtimer_early_expiration();
@@ -160,13 +134,13 @@ static void run_leapsec(void)
now.tv_sec += 86400 - now.tv_sec % 86400;
now.tv_nsec = 0;
leap = now;
- tst_resm(TINFO, "scheduling leap second %s", strtime(&leap));
+ tst_res(TINFO, "scheduling leap second %s", strtime(&leap));
/* start before the leap second */
now.tv_sec -= SECONDS_BEFORE_LEAP;
- if (clock_settime(CLOCK_REALTIME, &now) < 0)
- tst_brkm(TBROK | TERRNO, cleanup, "clock_settime");
- tst_resm(TINFO, "setting time to %s", strtime(&now));
+ SAFE_CLOCK_SETTIME(CLOCK_REALTIME, &now);
+
+ tst_res(TINFO, "setting time to %s", strtime(&now));
/* reset NTP time state */
adjtimex_status(&tx, STA_PLL);
@@ -175,7 +149,7 @@ static void run_leapsec(void)
/* set the leap second insert flag */
adjtimex_status(&tx, STA_INS);
- /* reliably sleep till after the leap second */
+ /* reliably sleep until after the leap second */
while (tx.time.tv_sec < leap.tv_sec + SECONDS_AFTER_LEAP) {
adjtimex_status(&tx, tx.status);
clock_nanosleep(CLOCK_MONOTONIC, 0, &sleeptime, NULL);
@@ -187,31 +161,43 @@ static void run_leapsec(void)
adjtimex_status(&tx, 0);
/* recover from timer expiring state and restore time */
- clock_gettime(CLOCK_REALTIME, &now);
+ SAFE_CLOCK_GETTIME(CLOCK_REALTIME, &now);
start.tv_sec += now.tv_sec - (leap.tv_sec - SECONDS_BEFORE_LEAP);
start.tv_nsec += now.tv_nsec;
start.tv_sec += start.tv_nsec / NSEC_PER_SEC;
start.tv_nsec = start.tv_nsec % NSEC_PER_SEC;
- tst_resm(TINFO, "restoring time to %s", strtime(&start));
+ tst_res(TINFO, "restoring time to %s", strtime(&start));
/* calls clock_was_set() in kernel to revert inconsistency */
- if (clock_settime(CLOCK_REALTIME, &start) < 0)
- tst_brkm(TBROK | TERRNO, cleanup, "clock_settime");
+ SAFE_CLOCK_SETTIME(CLOCK_REALTIME, &start);
test_hrtimer_early_expiration();
+
+ if (!errors)
+ tst_res(TPASS, "No errors were reported during this test!");
+ else
+ tst_res(TFAIL, "Got %d errors during this test!", errors);
+
}
static void setup(void)
{
- tst_require_root();
- tst_sig(NOFORK, DEF_HANDLER, CLEANUP);
- TEST_PAUSE;
+ errors = 0;
}
static void cleanup(void)
{
struct timespec now;
- clock_gettime(CLOCK_REALTIME, &now);
- /* Calls clock_was_set() in kernel to revert inconsistency.
- * The only possible EPERM doesn't matter here. */
- clock_settime(CLOCK_REALTIME, &now);
+
+ SAFE_CLOCK_GETTIME(CLOCK_REALTIME, &now);
+ /* Calls clock_was_set() in the kernel to revert inconsistencies.
+ * The only possible error EPERM doesn't matter here.
+ * */
+ SAFE_CLOCK_SETTIME(CLOCK_REALTIME, &now);
}
+
+static struct tst_test test = {
+ .test_all = run_leapsec,
+ .setup = setup,
+ .cleanup = cleanup,
+ .needs_root = 1,
+};
--
2.16.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [LTP] [PATCH v1 1/3] timers/timer_delete0{2, 3}: Ported to new library
2019-07-23 7:08 [LTP] [PATCH v1 1/3] timers/timer_delete0{2, 3}: Ported to new library Christian Amann
2019-07-23 7:08 ` [LTP] [PATCH v1 2/3] timers/timer_settime0{2, " Christian Amann
2019-07-23 7:08 ` [LTP] [PATCH v1 3/3] timers/leapsec_timer: " Christian Amann
@ 2019-07-24 12:14 ` Cyril Hrubis
2 siblings, 0 replies; 6+ messages in thread
From: Cyril Hrubis @ 2019-07-24 12:14 UTC (permalink / raw)
To: ltp
Hi!
Pushed, thanks.
--
Cyril Hrubis
chrubis@suse.cz
^ permalink raw reply [flat|nested] 6+ messages in thread
* [LTP] [PATCH v1 2/3] timers/timer_settime0{2, 3}: Ported to new library
2019-07-23 7:08 ` [LTP] [PATCH v1 2/3] timers/timer_settime0{2, " Christian Amann
@ 2019-07-24 12:16 ` Cyril Hrubis
0 siblings, 0 replies; 6+ messages in thread
From: Cyril Hrubis @ 2019-07-24 12:16 UTC (permalink / raw)
To: ltp
Hi!
Pushed with a minor enhancements, thanks.
diff --git a/testcases/kernel/timers/timer_settime/timer_settime02.c b/testcases/kernel/timers/timer_settime/timer_settime02.c
index 36d9a745f..6c431c53d 100644
--- a/testcases/kernel/timers/timer_settime/timer_settime02.c
+++ b/testcases/kernel/timers/timer_settime/timer_settime02.c
@@ -32,15 +32,14 @@ static kernel_timer_t timer;
static struct testcase {
struct itimerspec *old_ptr;
int it_value_tv_sec;
- int it_internal_tv_sec;
- int check_clock_gettime;
+ int it_interval_tv_sec;
int flag;
char *description;
} tcases[] = {
- {NULL, 5, 0, 0, 0, "general initialization"},
- {&old_set, 5, 0, 0, 0, "setting old_value"},
- {&old_set, 0, 5, 0, 0, "using periodic timer"},
- {&old_set, 5, 0, 1, TIMER_ABSTIME, "using absolute time"},
+ {NULL, 5, 0, 0, "general initialization"},
+ {&old_set, 5, 0, 0, "setting old_value"},
+ {&old_set, 0, 5, 0, "using periodic timer"},
+ {&old_set, 5, 0, TIMER_ABSTIME, "using absolute time"},
};
static void run(unsigned int n)
@@ -77,16 +76,16 @@ static void run(unsigned int n)
memset(&old_set, 0, sizeof(old_set));
new_set.it_value.tv_sec = tc->it_value_tv_sec;
- new_set.it_interval.tv_sec = tc->it_internal_tv_sec;
+ new_set.it_interval.tv_sec = tc->it_interval_tv_sec;
- if (tc->check_clock_gettime) {
+ if (tc->flag & TIMER_ABSTIME) {
if (clock_gettime(clock, &timenow) < 0) {
tst_res(TBROK,
"clock_gettime(%s) failed - skipping the test",
get_clock_str(clock));
continue;
}
- new_set.it_value.tv_sec = timenow.tv_sec + 25;
+ new_set.it_value.tv_sec += timenow.tv_sec;
}
TEST(tst_syscall(__NR_timer_settime, timer,
diff --git a/testcases/kernel/timers/timer_settime/timer_settime03.c b/testcases/kernel/timers/timer_settime/timer_settime03.c
index 80861995f..bc3a0f2c8 100644
--- a/testcases/kernel/timers/timer_settime/timer_settime03.c
+++ b/testcases/kernel/timers/timer_settime/timer_settime03.c
@@ -26,7 +26,8 @@
#include "common_timers.h"
static struct itimerspec new_set, old_set;
-static kernel_timer_t timer, timer_inval;
+static kernel_timer_t timer;
+static kernel_timer_t timer_inval = -1;
/* separate description-array to (hopefully) improve readability */
static const char * const descriptions[] = {
@@ -111,14 +112,8 @@ static void run(unsigned int n)
}
}
-static void setup(void)
-{
- timer_inval = -1;
-}
-
static struct tst_test test = {
.test = run,
.needs_root = 1,
.tcnt = ARRAY_SIZE(tcases),
- .setup = setup,
};
--
Cyril Hrubis
chrubis@suse.cz
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [LTP] [PATCH v1 3/3] timers/leapsec_timer: Ported to new library
2019-07-23 7:08 ` [LTP] [PATCH v1 3/3] timers/leapsec_timer: " Christian Amann
@ 2019-07-29 12:09 ` Petr Vorel
0 siblings, 0 replies; 6+ messages in thread
From: Petr Vorel @ 2019-07-29 12:09 UTC (permalink / raw)
To: ltp
Hi,
> Ported the test to the new library
> Signed-off-by: Christian Amann <camann@suse.com>
> Notes:
> The leapsec timer is still a mess, even after porting it.
> Cleaning it up would probably be its own patch as the best
> solution would be to rewrite it from scratch
Rebased and reposted
https://patchwork.ozlabs.org/patch/1138328/
Kind regards,
Petr
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2019-07-29 12:09 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-07-23 7:08 [LTP] [PATCH v1 1/3] timers/timer_delete0{2, 3}: Ported to new library Christian Amann
2019-07-23 7:08 ` [LTP] [PATCH v1 2/3] timers/timer_settime0{2, " Christian Amann
2019-07-24 12:16 ` Cyril Hrubis
2019-07-23 7:08 ` [LTP] [PATCH v1 3/3] timers/leapsec_timer: " Christian Amann
2019-07-29 12:09 ` Petr Vorel
2019-07-24 12:14 ` [LTP] [PATCH v1 1/3] timers/timer_delete0{2, 3}: " Cyril Hrubis
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox