diff --git a/tests/posix_semaphore/main.c b/tests/posix_semaphore/main.c index 2ae718419a7e4e0989ff9f76f9d8f3aa12a64325..155696fbf26ca9c03ddd92bd5e296298353b10c4 100644 --- a/tests/posix_semaphore/main.c +++ b/tests/posix_semaphore/main.c @@ -22,13 +22,14 @@ * @} */ +#include <errno.h> #include <stdio.h> #include <semaphore.h> #include "msg.h" #include "timex.h" #include "thread.h" -#include "vtimer.h" +#include "xtimer.h" #define SEMAPHORE_MSG_QUEUE_SIZE (8) #define SEMAPHORE_TEST_THREADS (5) @@ -236,16 +237,16 @@ void test3(void) void test4(void) { struct timespec abs; - char timestamp[TIMEX_MAX_STR_LEN]; - timex_t now, start, stop, exp = { 1, 0 }; - vtimer_now(&now); - abs.tv_sec = now.seconds + 1; - abs.tv_nsec = now.microseconds * 1000; + uint64_t now, start, stop; + const uint64_t exp = 1000000; + now = xtimer_now64(); + abs.tv_sec = (time_t)((now / SEC_IN_USEC) + 1); + abs.tv_nsec = (long)((now % SEC_IN_USEC) * 1000); puts("first: sem_init s1"); if (sem_init(&s1, 0, 0) < 0) { puts("first: sem_init FAILED"); } - vtimer_now(&start); + start = xtimer_now64(); puts("first: wait 1 sec for s1"); if (sem_timedwait(&s1, &abs) != 0) { if (errno != ETIMEDOUT) { @@ -256,18 +257,17 @@ void test4(void) puts("first: timed out"); } } - vtimer_now(&stop); - stop = timex_sub(stop, start); - if (timex_cmp(stop, exp) < 0) { - printf("first: waited only %s => FAILED\n", - timex_to_str(stop, timestamp)); + stop = xtimer_now64() - start; + if (stop < exp) { + printf("first: waited only %" PRIu64 " usec => FAILED\n", stop); } - printf("first: waited %s\n", timex_to_str(stop, timestamp)); + printf("first: waited %" PRIu64 " usec\n", stop); } int main(void) { msg_init_queue(main_msg_queue, SEMAPHORE_MSG_QUEUE_SIZE); + xtimer_init(); puts("######################### TEST1:"); test1(); puts("######################### TEST2:"); diff --git a/tests/posix_semaphore/tests/01-run.py b/tests/posix_semaphore/tests/01-run.py index 091741f6f6c738c118084cb230a12d5e97a77898..056098804ffce6150c4a09aab4efa32fc0bd86d4 100755 --- a/tests/posix_semaphore/tests/01-run.py +++ b/tests/posix_semaphore/tests/01-run.py @@ -32,7 +32,6 @@ def test1(term): term.expect_exact("first: sem_trywait FAILED") term.expect_exact("first: sem_trywait done") term.expect_exact("first: sem_post") - term.expect_exact("second: sem_wait failed") term.expect_exact("second: sem was posted") term.expect_exact("second: end") term.expect_exact("first: sem_post done") @@ -90,7 +89,7 @@ def test4(term): term.expect_exact("first: sem_init s1") term.expect_exact("first: wait 1 sec for s1") term.expect_exact("first: timed out") - term.expect(r"first: waited 1\.\d{6} s") + term.expect(r"first: waited 1\d{6} usec") if __name__ == "__main__": TERM = init()