All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [RFC] [PATCH] lib/tst_test: Use CLOCK_MONOTONIC for -I option.
@ 2018-01-22 14:19 Cyril Hrubis
  2018-01-23  8:31 ` Jan Stancek
  2018-01-25  5:50 ` Li Wang
  0 siblings, 2 replies; 7+ messages in thread
From: Cyril Hrubis @ 2018-01-22 14:19 UTC (permalink / raw)
  To: ltp

CLOCK_MONOTONIC has been added to linux in the 2.5 development branch so
this syscall is available in all 2.6 kernels hence it's reasonable to be
used it in the test library at this point it has been 15 years after
all.

Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
---
 lib/tst_test.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/lib/tst_test.c b/lib/tst_test.c
index 1df4b72df..2cf35ed66 100644
--- a/lib/tst_test.c
+++ b/lib/tst_test.c
@@ -24,7 +24,6 @@
 #include <sys/mount.h>
 #include <sys/types.h>
 #include <sys/wait.h>
-#include <sys/time.h>
 
 #define TST_NO_DEFAULT_MAIN
 #include "tst_test.h"
@@ -34,6 +33,8 @@
 #include "tst_ansi_color.h"
 #include "tst_safe_stdio.h"
 #include "tst_timer_test.h"
+#include "tst_clocks.h"
+#include "tst_timer.h"
 
 #include "old_resource.h"
 #include "old_device.h"
@@ -853,11 +854,12 @@ static void run_tests(void)
 
 static unsigned long long get_time_ms(void)
 {
-	struct timeval tv;
+	struct timespec ts;
 
-	gettimeofday(&tv, NULL);
+	if (tst_clock_gettime(CLOCK_MONOTONIC, &ts))
+		tst_brk(TBROK | TERRNO, "tst_clock_gettime()");
 
-	return tv.tv_sec * 1000 + tv.tv_usec / 1000;
+	return tst_timespec_to_ms(ts);
 }
 
 static void add_paths(void)
-- 
2.13.6


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2018-02-07 15:15 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-22 14:19 [LTP] [RFC] [PATCH] lib/tst_test: Use CLOCK_MONOTONIC for -I option Cyril Hrubis
2018-01-23  8:31 ` Jan Stancek
2018-01-23  8:47   ` Cyril Hrubis
2018-02-07 15:15   ` Cyril Hrubis
2018-01-25  5:50 ` Li Wang
2018-01-25  6:59   ` Xiao Yang
2018-01-25  7:51     ` Li Wang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.