* [LTP] [PATCH 01/12] lib: Move tst_clock_name() to tst_clock.c
@ 2020-03-04 15:24 Cyril Hrubis
2020-03-04 15:24 ` [LTP] [PATCH 02/12] include/tst_safe_clocks.h: Make use of tst_clock_name() Cyril Hrubis
2020-03-04 18:46 ` [LTP] [PATCH 01/12] lib: Move tst_clock_name() to tst_clock.c Petr Vorel
0 siblings, 2 replies; 5+ messages in thread
From: Cyril Hrubis @ 2020-03-04 15:24 UTC (permalink / raw)
To: ltp
Move tst_clock_name() from tst_timer.c to tst_clock.c and add a few
missing clocks.
Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
---
include/tst_clocks.h | 5 +++++
include/tst_timer.h | 5 -----
lib/tst_clocks.c | 31 +++++++++++++++++++++++++++++++
lib/tst_timer.c | 24 ------------------------
4 files changed, 36 insertions(+), 29 deletions(-)
diff --git a/include/tst_clocks.h b/include/tst_clocks.h
index 90784a3fd..f4a2c3301 100644
--- a/include/tst_clocks.h
+++ b/include/tst_clocks.h
@@ -28,4 +28,9 @@ int tst_clock_gettime(clockid_t clk_id, struct timespec *ts);
int tst_clock_settime(clockid_t clk_id, struct timespec *ts);
+/*
+ * Converts clock id to a readable name.
+ */
+const char *tst_clock_name(clockid_t clk_id);
+
#endif /* TST_CLOCKS__ */
diff --git a/include/tst_timer.h b/include/tst_timer.h
index d361aa2ed..de60bc62a 100644
--- a/include/tst_timer.h
+++ b/include/tst_timer.h
@@ -332,9 +332,4 @@ static inline long long tst_timer_elapsed_us(void)
return tst_timespec_to_us(tst_timer_elapsed());
}
-/*
- * Returns a string containing given clock type name
- */
-const char *tst_clock_name(clockid_t);
-
#endif /* TST_TIMER */
diff --git a/lib/tst_clocks.c b/lib/tst_clocks.c
index fa2f1cb84..2eaa73b11 100644
--- a/lib/tst_clocks.c
+++ b/lib/tst_clocks.c
@@ -9,6 +9,7 @@
#include "tst_test.h"
#include "tst_clocks.h"
#include "lapi/syscalls.h"
+#include "lapi/posix_clocks.h"
int tst_clock_getres(clockid_t clk_id, struct timespec *res)
{
@@ -24,3 +25,33 @@ int tst_clock_settime(clockid_t clk_id, struct timespec *ts)
{
return tst_syscall(__NR_clock_settime, clk_id, ts);
}
+
+const char *tst_clock_name(clockid_t clk_id)
+{
+ switch (clk_id) {
+ case CLOCK_REALTIME:
+ return "CLOCK_REALTIME";
+ case CLOCK_MONOTONIC:
+ return "CLOCK_MONOTONIC";
+ case CLOCK_PROCESS_CPUTIME_ID:
+ return "CLOCK_PROCESS_CPUTIME_ID";
+ case CLOCK_THREAD_CPUTIME_ID:
+ return "CLOCK_THREAD_CPUTIME_ID";
+ case CLOCK_MONOTONIC_RAW:
+ return "CLOCK_MONOTONIC_RAW";
+ case CLOCK_REALTIME_COARSE:
+ return "CLOCK_REALTIME_COARSE";
+ case CLOCK_MONOTONIC_COARSE:
+ return "CLOCK_MONOTONIC_COARSE";
+ case CLOCK_BOOTTIME:
+ return "CLOCK_BOOTTIME";
+ case CLOCK_REALTIME_ALARM:
+ return "CLOCK_REALTIME_ALARM";
+ case CLOCK_BOOTTIME_ALARM:
+ return "CLOCK_BOOTTIME_ALARM";
+ case CLOCK_TAI:
+ return "CLOCK_TAI";
+ default:
+ return "INVALID/UNKNOWN CLOCK";
+ }
+}
diff --git a/lib/tst_timer.c b/lib/tst_timer.c
index f7f09f3d2..62d8f9080 100644
--- a/lib/tst_timer.c
+++ b/lib/tst_timer.c
@@ -15,30 +15,6 @@
static struct timespec start_time, stop_time;
static clockid_t clock_id;
-const char *tst_clock_name(clockid_t clk_id)
-{
- switch (clk_id) {
- case CLOCK_REALTIME:
- return "CLOCK_REALTIME";
- case CLOCK_REALTIME_COARSE:
- return "CLOCK_REALTIME_COARSE";
- case CLOCK_MONOTONIC:
- return "CLOCK_MONOTONIC";
- case CLOCK_MONOTONIC_COARSE:
- return "CLOCK_MONOTONIC_COARSE";
- case CLOCK_MONOTONIC_RAW:
- return "CLOCK_MONOTONIC_RAW";
- case CLOCK_BOOTTIME:
- return "CLOCK_BOOTTIME";
- case CLOCK_PROCESS_CPUTIME_ID:
- return "CLOCK_PROCESS_CPUTIME_ID";
- case CLOCK_THREAD_CPUTIME_ID:
- return "CLOCK_THREAD_CPUTIME_ID";
- default:
- return "UNKNOWN/INVALID";
- }
-}
-
void tst_timer_check(clockid_t clk_id)
{
if (tst_clock_gettime(clk_id, &start_time)) {
--
2.24.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [LTP] [PATCH 02/12] include/tst_safe_clocks.h: Make use of tst_clock_name()
2020-03-04 15:24 [LTP] [PATCH 01/12] lib: Move tst_clock_name() to tst_clock.c Cyril Hrubis
@ 2020-03-04 15:24 ` Cyril Hrubis
2020-03-04 18:47 ` Petr Vorel
2020-03-04 18:46 ` [LTP] [PATCH 01/12] lib: Move tst_clock_name() to tst_clock.c Petr Vorel
1 sibling, 1 reply; 5+ messages in thread
From: Cyril Hrubis @ 2020-03-04 15:24 UTC (permalink / raw)
To: ltp
Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
---
include/tst_safe_clocks.h | 26 +++++++++++++++++---------
1 file changed, 17 insertions(+), 9 deletions(-)
diff --git a/include/tst_safe_clocks.h b/include/tst_safe_clocks.h
index 34ed953b4..27e8bda45 100644
--- a/include/tst_safe_clocks.h
+++ b/include/tst_safe_clocks.h
@@ -11,6 +11,7 @@
#include <time.h>
#include <sys/timex.h>
#include "tst_test.h"
+#include "tst_clocks.h"
#include "lapi/syscalls.h"
#include "lapi/posix_clocks.h"
@@ -20,10 +21,11 @@ static inline void safe_clock_getres(const char *file, const int lineno,
int rval;
rval = clock_getres(clk_id, res);
- if (rval != 0)
+ if (rval != 0) {
tst_brk(TBROK | TERRNO,
- "%s:%d clock_getres() failed", file, lineno);
-
+ "%s:%d clock_getres(%s) failed",
+ file, lineno, tst_clock_name(clk_id));
+ }
}
static inline void safe_clock_gettime(const char *file, const int lineno,
@@ -32,9 +34,11 @@ static inline void safe_clock_gettime(const char *file, const int lineno,
int rval;
rval = clock_gettime(clk_id, tp);
- if (rval != 0)
+ if (rval != 0) {
tst_brk(TBROK | TERRNO,
- "%s:%d clock_gettime() failed", file, lineno);
+ "%s:%d clock_gettime(%s) failed",
+ file, lineno, tst_clock_name(clk_id));
+ }
}
@@ -44,9 +48,11 @@ static inline void safe_clock_settime(const char *file, const int lineno,
int rval;
rval = clock_settime(clk_id, tp);
- if (rval != 0)
+ if (rval != 0) {
tst_brk(TBROK | TERRNO,
- "%s:%d clock_gettime() failed", file, lineno);
+ "%s:%d clock_gettime(%s) failed",
+ file, lineno, tst_clock_name(clk_id));
+ }
}
static inline int safe_clock_adjtime(const char *file, const int lineno,
@@ -55,9 +61,11 @@ static inline int safe_clock_adjtime(const char *file, const int lineno,
int rval;
rval = tst_syscall(__NR_clock_adjtime, clk_id, txc);
- if (rval < 0)
+ if (rval < 0) {
tst_brk(TBROK | TERRNO,
- "%s:%d clock_adjtime() failed %i", file, lineno, rval);
+ "%s:%d clock_adjtime(%s) failed %i",
+ file, lineno, tst_clock_name(clk_id), rval);
+ }
return rval;
}
--
2.24.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [LTP] [PATCH 01/12] lib: Move tst_clock_name() to tst_clock.c
2020-03-04 15:24 [LTP] [PATCH 01/12] lib: Move tst_clock_name() to tst_clock.c Cyril Hrubis
2020-03-04 15:24 ` [LTP] [PATCH 02/12] include/tst_safe_clocks.h: Make use of tst_clock_name() Cyril Hrubis
@ 2020-03-04 18:46 ` Petr Vorel
1 sibling, 0 replies; 5+ messages in thread
From: Petr Vorel @ 2020-03-04 18:46 UTC (permalink / raw)
To: ltp
Hi Cyril,
> Move tst_clock_name() from tst_timer.c to tst_clock.c and add a few
> missing clocks.
Reviewed-by: Petr Vorel <pvorel@suse.cz>
Kind regards,
Petr
^ permalink raw reply [flat|nested] 5+ messages in thread
* [LTP] [PATCH 02/12] include/tst_safe_clocks.h: Make use of tst_clock_name()
2020-03-04 15:24 ` [LTP] [PATCH 02/12] include/tst_safe_clocks.h: Make use of tst_clock_name() Cyril Hrubis
@ 2020-03-04 18:47 ` Petr Vorel
2020-03-05 10:23 ` Cyril Hrubis
0 siblings, 1 reply; 5+ messages in thread
From: Petr Vorel @ 2020-03-04 18:47 UTC (permalink / raw)
To: ltp
Hi Cyril,
Reviewed-by: Petr Vorel <pvorel@suse.cz>
Kind regards,
Petr
^ permalink raw reply [flat|nested] 5+ messages in thread
* [LTP] [PATCH 02/12] include/tst_safe_clocks.h: Make use of tst_clock_name()
2020-03-04 18:47 ` Petr Vorel
@ 2020-03-05 10:23 ` Cyril Hrubis
0 siblings, 0 replies; 5+ messages in thread
From: Cyril Hrubis @ 2020-03-05 10:23 UTC (permalink / raw)
To: ltp
Hi!
Both pushed, thanks.
--
Cyril Hrubis
chrubis@suse.cz
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-03-05 10:23 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-03-04 15:24 [LTP] [PATCH 01/12] lib: Move tst_clock_name() to tst_clock.c Cyril Hrubis
2020-03-04 15:24 ` [LTP] [PATCH 02/12] include/tst_safe_clocks.h: Make use of tst_clock_name() Cyril Hrubis
2020-03-04 18:47 ` Petr Vorel
2020-03-05 10:23 ` Cyril Hrubis
2020-03-04 18:46 ` [LTP] [PATCH 01/12] lib: Move tst_clock_name() to tst_clock.c Petr Vorel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox