diff options
| author | Manuel Bentele | 2020-10-23 15:18:01 +0200 |
|---|---|---|
| committer | Manuel Bentele | 2020-10-23 15:18:01 +0200 |
| commit | dbb41ce2b7f309d394054a6bd1e33afd578798a5 (patch) | |
| tree | 6a31092063d9f2fb5ac5720ec6759040e793c3d5 /kernel/tests/lib/tst_timer.c | |
| parent | Set Linux kernel version to unknown if it is not detectable (diff) | |
| download | xloop-dbb41ce2b7f309d394054a6bd1e33afd578798a5.tar.gz xloop-dbb41ce2b7f309d394054a6bd1e33afd578798a5.tar.xz xloop-dbb41ce2b7f309d394054a6bd1e33afd578798a5.zip | |
Move the source code of all xloop components to the common 'src' directory
Diffstat (limited to 'kernel/tests/lib/tst_timer.c')
| -rw-r--r-- | kernel/tests/lib/tst_timer.c | 59 |
1 files changed, 0 insertions, 59 deletions
diff --git a/kernel/tests/lib/tst_timer.c b/kernel/tests/lib/tst_timer.c deleted file mode 100644 index 62d8f90..0000000 --- a/kernel/tests/lib/tst_timer.c +++ /dev/null @@ -1,59 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* - * Copyright (C) 2015 Cyril Hrubis <chrubis@suse.cz> - */ - -#include <errno.h> - -#define TST_NO_DEFAULT_MAIN - -#include "tst_test.h" -#include "tst_timer.h" -#include "tst_clocks.h" -#include "lapi/posix_clocks.h" - -static struct timespec start_time, stop_time; -static clockid_t clock_id; - -void tst_timer_check(clockid_t clk_id) -{ - if (tst_clock_gettime(clk_id, &start_time)) { - if (errno == EINVAL) { - tst_brk(TCONF, - "Clock id %s(%u) not supported by kernel", - tst_clock_name(clk_id), clk_id); - return; - } - - tst_brk(TBROK | TERRNO, "tst_clock_gettime() failed"); - } -} - -void tst_timer_start(clockid_t clk_id) -{ - clock_id = clk_id; - - if (tst_clock_gettime(clock_id, &start_time)) - tst_res(TWARN | TERRNO, "tst_clock_gettime() failed"); -} - -int tst_timer_expired_ms(long long ms) -{ - struct timespec cur_time; - - if (tst_clock_gettime(clock_id, &cur_time)) - tst_res(TWARN | TERRNO, "tst_clock_gettime() failed"); - - return tst_timespec_diff_ms(cur_time, start_time) >= ms; -} - -void tst_timer_stop(void) -{ - if (tst_clock_gettime(clock_id, &stop_time)) - tst_res(TWARN | TERRNO, "tst_clock_gettime() failed"); -} - -struct timespec tst_timer_elapsed(void) -{ - return tst_timespec_diff(stop_time, start_time); -} |
