@@ -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__ */
@@ -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 */
@@ -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";
+ }
+}
@@ -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)) {
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(-)