Module: xenomai-3 Branch: next Commit: 8d5ae69e6b93cb4960a7cd9b271ef7047cbb2a9f URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=8d5ae69e6b93cb4960a7cd9b271ef7047cbb2a9f
Author: Philippe Gerum <r...@xenomai.org> Date: Fri Jun 19 14:37:46 2015 +0200 testsuite/smokey: add POSIX clock testing code --- configure.ac | 1 + testsuite/regression/posix/Makefile.am | 1 - testsuite/regression/posix/clock_settime.c | 224 -------------- testsuite/smokey/Makefile.am | 2 + testsuite/smokey/posix-clock/Makefile.am | 9 + testsuite/smokey/posix-clock/posix-clock.c | 458 ++++++++++++++++++++++++++++ 6 files changed, 470 insertions(+), 225 deletions(-) diff --git a/configure.ac b/configure.ac index 118d668..14a3354 100644 --- a/configure.ac +++ b/configure.ac @@ -934,6 +934,7 @@ AC_CONFIG_FILES([ \ testsuite/smokey/bufp/Makefile \ testsuite/smokey/fork-exec/Makefile \ testsuite/smokey/sigdebug/Makefile \ + testsuite/smokey/posix-clock/Makefile \ testsuite/clocktest/Makefile \ testsuite/xeno-test/Makefile \ testsuite/regression/Makefile \ diff --git a/testsuite/regression/posix/Makefile.am b/testsuite/regression/posix/Makefile.am index 01aab8e..f78c244 100644 --- a/testsuite/regression/posix/Makefile.am +++ b/testsuite/regression/posix/Makefile.am @@ -5,7 +5,6 @@ CCLD = $(top_srcdir)/scripts/wrap-link.sh $(CC) noinst_HEADERS = check.h test_PROGRAMS = \ - clock_settime \ leaks \ mq_select \ timerfd diff --git a/testsuite/regression/posix/clock_settime.c b/testsuite/regression/posix/clock_settime.c deleted file mode 100644 index 236cc93..0000000 --- a/testsuite/regression/posix/clock_settime.c +++ /dev/null @@ -1,224 +0,0 @@ -/* - * Copyright (C) 2014 Gilles Chanteperdrix <g...@xenomai.org> - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#undef NDEBUG -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <errno.h> -#include <assert.h> - -#include <unistd.h> -#include <time.h> -#include <sys/timerfd.h> -#include "check.h" - -static void clock_increase_before_oneshot_timer_first_tick(void) -{ - unsigned long long ticks; - struct itimerspec timer; - struct timespec now; - int t; - - check_unix(t = timerfd_create(CLOCK_REALTIME, 0)); - check_unix(clock_gettime(CLOCK_REALTIME, &now)); - timer.it_value = now; - timer.it_value.tv_sec++; - timer.it_interval.tv_sec = 0; - timer.it_interval.tv_nsec = 0; - check_unix(timerfd_settime(t, TFD_TIMER_ABSTIME, &timer, NULL)); - now.tv_sec += 5; - check_unix(clock_settime(CLOCK_REALTIME, &now)); - check_unix(clock_gettime(CLOCK_MONOTONIC, &now)); - check_unix(read(t, &ticks, sizeof(ticks))); - assert(ticks == 1); - timer.it_value = now; - check_unix(clock_gettime(CLOCK_MONOTONIC, &now)); - assert(now.tv_sec * 1000000000ULL + now.tv_nsec - - (timer.it_value.tv_sec * 1000000000ULL + timer.it_value.tv_nsec) - < 1000000000); - check_unix(close(t)); -} - -static void clock_increase_before_periodic_timer_first_tick(void) -{ - unsigned long long ticks; - struct itimerspec timer; - struct timespec now; - int t; - - check_unix(t = timerfd_create(CLOCK_REALTIME, 0)); - check_unix(clock_gettime(CLOCK_REALTIME, &now)); - timer.it_value = now; - timer.it_value.tv_sec++; - timer.it_interval.tv_sec = 1; - timer.it_interval.tv_nsec = 0; - check_unix(timerfd_settime(t, TFD_TIMER_ABSTIME, &timer, NULL)); - now.tv_sec += 5; - check_unix(clock_settime(CLOCK_REALTIME, &now)); - check_unix(clock_gettime(CLOCK_MONOTONIC, &now)); - check_unix(read(t, &ticks, sizeof(ticks))); - assert(ticks == 5); - timer.it_value = now; - check_unix(clock_gettime(CLOCK_MONOTONIC, &now)); - assert(now.tv_sec * 1000000000ULL + now.tv_nsec - - (timer.it_value.tv_sec * 1000000000ULL + timer.it_value.tv_nsec) - < 1000000000); - check_unix(read(t, &ticks, sizeof(ticks))); - assert(ticks == 1); - check_unix(close(t)); -} - -static void clock_increase_after_periodic_timer_first_tick(void) -{ - unsigned long long ticks; - struct itimerspec timer; - struct timespec now; - int t; - - check_unix(t = timerfd_create(CLOCK_REALTIME, 0)); - check_unix(clock_gettime(CLOCK_REALTIME, &now)); - timer.it_value = now; - timer.it_value.tv_sec++; - timer.it_interval.tv_sec = 1; - timer.it_interval.tv_nsec = 0; - check_unix(timerfd_settime(t, TFD_TIMER_ABSTIME, &timer, NULL)); - check_unix(read(t, &ticks, sizeof(ticks))); - assert(ticks == 1); - check_unix(clock_gettime(CLOCK_REALTIME, &now)); - now.tv_sec += 5; - check_unix(clock_settime(CLOCK_REALTIME, &now)); - check_unix(clock_gettime(CLOCK_MONOTONIC, &now)); - check_unix(read(t, &ticks, sizeof(ticks))); - assert(ticks == 5); - timer.it_value = now; - check_unix(clock_gettime(CLOCK_MONOTONIC, &now)); - assert(now.tv_sec * 1000000000ULL + now.tv_nsec - - (timer.it_value.tv_sec * 1000000000ULL + timer.it_value.tv_nsec) - < 1000000000); - check_unix(read(t, &ticks, sizeof(ticks))); - assert(ticks == 1); - check_unix(close(t)); -} - -static void clock_decrease_before_oneshot_timer_first_tick(void) -{ - unsigned long long ticks; - struct itimerspec timer; - struct timespec now; - long long diff; - int t; - - check_unix(t = timerfd_create(CLOCK_REALTIME, 0)); - check_unix(clock_gettime(CLOCK_REALTIME, &now)); - timer.it_value = now; - timer.it_value.tv_sec++; - timer.it_interval.tv_sec = 0; - timer.it_interval.tv_nsec = 0; - check_unix(timerfd_settime(t, TFD_TIMER_ABSTIME, &timer, NULL)); - now.tv_sec -= 5; - check_unix(clock_settime(CLOCK_REALTIME, &now)); - check_unix(clock_gettime(CLOCK_MONOTONIC, &now)); - check_unix(read(t, &ticks, sizeof(ticks))); - assert(ticks == 1); - timer.it_value = now; - check_unix(clock_gettime(CLOCK_MONOTONIC, &now)); - diff = now.tv_sec * 1000000000ULL + now.tv_nsec - - (timer.it_value.tv_sec * 1000000000ULL + timer.it_value.tv_nsec); - assert(diff >= 5500000000LL && diff <= 6500000000LL); - check_unix(close(t)); -} - -static void clock_decrease_before_periodic_timer_first_tick(void) -{ - unsigned long long ticks; - struct itimerspec timer; - struct timespec now; - long long diff; - int t; - - check_unix(t = timerfd_create(CLOCK_REALTIME, 0)); - check_unix(clock_gettime(CLOCK_REALTIME, &now)); - timer.it_value = now; - timer.it_value.tv_sec++; - timer.it_interval.tv_sec = 1; - timer.it_interval.tv_nsec = 0; - check_unix(timerfd_settime(t, TFD_TIMER_ABSTIME, &timer, NULL)); - now.tv_sec -= 5; - check_unix(clock_settime(CLOCK_REALTIME, &now)); - check_unix(clock_gettime(CLOCK_MONOTONIC, &now)); - check_unix(read(t, &ticks, sizeof(ticks))); - assert(ticks == 1); - timer.it_value = now; - check_unix(clock_gettime(CLOCK_MONOTONIC, &now)); - diff = now.tv_sec * 1000000000ULL + now.tv_nsec - - (timer.it_value.tv_sec * 1000000000ULL + timer.it_value.tv_nsec); - assert(diff >= 5500000000LL && diff <= 6500000000LL); - check_unix(read(t, &ticks, sizeof(ticks))); - assert(ticks == 1); - check_unix(close(t)); -} - -static void clock_decrease_after_periodic_timer_first_tick(void) -{ - unsigned long long ticks; - struct itimerspec timer; - struct timespec now; - long long diff; - int t; - - check_unix(t = timerfd_create(CLOCK_REALTIME, 0)); - check_unix(clock_gettime(CLOCK_REALTIME, &now)); - timer.it_value = now; - timer.it_value.tv_sec++; - timer.it_interval.tv_sec = 1; - timer.it_interval.tv_nsec = 0; - check_unix(timerfd_settime(t, TFD_TIMER_ABSTIME, &timer, NULL)); - check_unix(read(t, &ticks, sizeof(ticks))); - assert(ticks == 1); - check_unix(clock_gettime(CLOCK_REALTIME, &now)); - now.tv_sec -= 5; - check_unix(clock_settime(CLOCK_REALTIME, &now)); - check_unix(clock_gettime(CLOCK_MONOTONIC, &now)); - check_unix(read(t, &ticks, sizeof(ticks))); - assert(ticks == 1); - timer.it_value = now; - check_unix(clock_gettime(CLOCK_MONOTONIC, &now)); - diff = now.tv_sec * 1000000000ULL + now.tv_nsec - - (timer.it_value.tv_sec * 1000000000ULL + timer.it_value.tv_nsec); - assert(diff < 1000000000); - check_unix(read(t, &ticks, sizeof(ticks))); - assert(ticks == 1); - check_unix(close(t)); -} - -int main(void) -{ - clock_increase_before_oneshot_timer_first_tick(); - clock_increase_before_periodic_timer_first_tick(); - clock_increase_after_periodic_timer_first_tick(); - clock_decrease_before_oneshot_timer_first_tick(); - clock_decrease_before_periodic_timer_first_tick(); - clock_decrease_after_periodic_timer_first_tick(); - return EXIT_SUCCESS; -} diff --git a/testsuite/smokey/Makefile.am b/testsuite/smokey/Makefile.am index 70192a9..f5a866c 100644 --- a/testsuite/smokey/Makefile.am +++ b/testsuite/smokey/Makefile.am @@ -10,6 +10,7 @@ wrappers = $(XENO_POSIX_WRAPPERS) SUBDIRS = \ arith \ bufp \ + clock \ cond-torture \ fork-exec \ iddp \ @@ -49,6 +50,7 @@ smokey_LDADD = \ DIST_SUBDIRS = \ arith \ bufp \ + clock \ cond-torture \ fork-exec \ iddp \ diff --git a/testsuite/smokey/posix-clock/Makefile.am b/testsuite/smokey/posix-clock/Makefile.am new file mode 100644 index 0000000..e5dd207 --- /dev/null +++ b/testsuite/smokey/posix-clock/Makefile.am @@ -0,0 +1,9 @@ + +noinst_LIBRARIES = libposix-clock.a + +libposix_clock_a_SOURCES = posix-clock.c + +libposix_clock_a_CPPFLAGS = \ + @XENO_USER_CFLAGS@ \ + -I$(top_srcdir) \ + -I$(top_srcdir)/include diff --git a/testsuite/smokey/posix-clock/posix-clock.c b/testsuite/smokey/posix-clock/posix-clock.c new file mode 100644 index 0000000..9781565 --- /dev/null +++ b/testsuite/smokey/posix-clock/posix-clock.c @@ -0,0 +1,458 @@ +/* + * Copyright (C) 2014 Gilles Chanteperdrix <g...@xenomai.org> + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <errno.h> +#include <assert.h> +#include <unistd.h> +#include <time.h> +#include <smokey/smokey.h> +#include <sys/timerfd.h> + +smokey_test_plugin(posix_clock, + SMOKEY_NOARGS, + "Check POSIX clock services." +); + +static int clock_increase_before_oneshot_timer_first_tick(void) +{ + unsigned long long ticks; + struct itimerspec timer; + struct timespec now; + int t, ret; + + smokey_note(__func__); + + t = smokey_check_errno(timerfd_create(CLOCK_REALTIME, 0)); + if (t < 0) + return t; + + ret = smokey_check_errno(clock_gettime(CLOCK_REALTIME, &now)); + if (ret) + return ret; + + timer.it_value = now; + timer.it_value.tv_sec++; + timer.it_interval.tv_sec = 0; + timer.it_interval.tv_nsec = 0; + + ret = smokey_check_errno(timerfd_settime(t, TFD_TIMER_ABSTIME, &timer, NULL)); + if (ret) + return ret; + + now.tv_sec += 5; + + ret = smokey_check_errno(clock_settime(CLOCK_REALTIME, &now)); + if (ret) + return ret; + + ret = smokey_check_errno(clock_gettime(CLOCK_MONOTONIC, &now)); + if (ret) + return ret; + + ret = smokey_check_errno(read(t, &ticks, sizeof(ticks))); + if (ret < 0) + return ret; + + if (!smokey_assert(ticks == 1)) + return -EINVAL; + + timer.it_value = now; + + ret = smokey_check_errno(clock_gettime(CLOCK_MONOTONIC, &now)); + if (ret) + return ret; + + if (!smokey_assert(now.tv_sec * 1000000000ULL + now.tv_nsec - + (timer.it_value.tv_sec * 1000000000ULL + timer.it_value.tv_nsec) + < 1000000000)) + return -EINVAL; + + return smokey_check_errno(close(t)); +} + +static int clock_increase_before_periodic_timer_first_tick(void) +{ + unsigned long long ticks; + struct itimerspec timer; + struct timespec now; + int t, ret; + + smokey_note(__func__); + + t = smokey_check_errno(timerfd_create(CLOCK_REALTIME, 0)); + if (t < 0) + return t; + + ret = smokey_check_errno(clock_gettime(CLOCK_REALTIME, &now)); + if (ret) + return ret; + + timer.it_value = now; + timer.it_value.tv_sec++; + timer.it_interval.tv_sec = 1; + timer.it_interval.tv_nsec = 0; + ret = smokey_check_errno(timerfd_settime(t, TFD_TIMER_ABSTIME, &timer, NULL)); + if (ret) + return ret; + + now.tv_sec += 5; + + ret = smokey_check_errno(clock_settime(CLOCK_REALTIME, &now)); + if (ret) + return ret; + + ret = smokey_check_errno(clock_gettime(CLOCK_MONOTONIC, &now)); + if (ret) + return ret; + + ret = smokey_check_errno(read(t, &ticks, sizeof(ticks))); + if (ret < 0) + return ret; + + if (!smokey_assert(ticks == 5)) + return -EINVAL; + + timer.it_value = now; + ret = smokey_check_errno(clock_gettime(CLOCK_MONOTONIC, &now)); + if (ret) + return ret; + + if (!smokey_assert(now.tv_sec * 1000000000ULL + now.tv_nsec - + (timer.it_value.tv_sec * 1000000000ULL + timer.it_value.tv_nsec) + < 1000000000)) + return -EINVAL; + + ret = smokey_check_errno(read(t, &ticks, sizeof(ticks))); + if (ret < 0) + return ret; + + if (!smokey_assert(ticks == 1)) + return -EINVAL; + + return smokey_check_errno(close(t)); +} + +static int clock_increase_after_periodic_timer_first_tick(void) +{ + unsigned long long ticks; + struct itimerspec timer; + struct timespec now; + int t, ret; + + smokey_note(__func__); + + t = smokey_check_errno(timerfd_create(CLOCK_REALTIME, 0)); + if (t < 0) + return t; + + ret = smokey_check_errno(clock_gettime(CLOCK_REALTIME, &now)); + if (ret) + return ret; + + timer.it_value = now; + timer.it_value.tv_sec++; + timer.it_interval.tv_sec = 1; + timer.it_interval.tv_nsec = 0; + + ret = smokey_check_errno(timerfd_settime(t, TFD_TIMER_ABSTIME, &timer, NULL)); + if (ret) + return ret; + + ret = smokey_check_errno(read(t, &ticks, sizeof(ticks))); + if (ret < 0) + return ret; + + if (!smokey_assert(ticks == 1)) + return -EINVAL; + + ret = smokey_check_errno(clock_gettime(CLOCK_REALTIME, &now)); + if (ret) + return ret; + + now.tv_sec += 5; + + ret = smokey_check_errno(clock_settime(CLOCK_REALTIME, &now)); + if (ret) + return ret; + + ret = smokey_check_errno(clock_gettime(CLOCK_MONOTONIC, &now)); + if (ret) + return ret; + + ret = smokey_check_errno(read(t, &ticks, sizeof(ticks))); + if (ret < 0) + return ret; + + if (!smokey_assert(ticks == 5)) + return -EINVAL; + + timer.it_value = now; + + ret = smokey_check_errno(clock_gettime(CLOCK_MONOTONIC, &now)); + if (ret) + return ret; + + if (!smokey_assert(now.tv_sec * 1000000000ULL + now.tv_nsec - + (timer.it_value.tv_sec * 1000000000ULL + timer.it_value.tv_nsec) + < 1000000000)) + return -EINVAL; + + ret = smokey_check_errno(read(t, &ticks, sizeof(ticks))); + if (ret < 0) + return ret; + + if (!smokey_assert(ticks == 1)) + return -EINVAL; + + return smokey_check_errno(close(t)); +} + +static int clock_decrease_before_oneshot_timer_first_tick(void) +{ + unsigned long long ticks; + struct itimerspec timer; + struct timespec now; + long long diff; + int t, ret; + + smokey_note(__func__); + + t = smokey_check_errno(timerfd_create(CLOCK_REALTIME, 0)); + if (t < 0) + return t; + + ret = smokey_check_errno(clock_gettime(CLOCK_REALTIME, &now)); + if (ret) + return ret; + + timer.it_value = now; + timer.it_value.tv_sec++; + timer.it_interval.tv_sec = 0; + timer.it_interval.tv_nsec = 0; + + ret = smokey_check_errno(timerfd_settime(t, TFD_TIMER_ABSTIME, &timer, NULL)); + if (ret) + return ret; + + now.tv_sec -= 5; + + ret = smokey_check_errno(clock_settime(CLOCK_REALTIME, &now)); + if (ret) + return ret; + + ret = smokey_check_errno(clock_gettime(CLOCK_MONOTONIC, &now)); + if (ret) + return ret; + + ret = smokey_check_errno(read(t, &ticks, sizeof(ticks))); + if (ret < 0) + return ret; + + if (!smokey_assert(ticks == 1)) + return -EINVAL; + + timer.it_value = now; + + ret = smokey_check_errno(clock_gettime(CLOCK_MONOTONIC, &now)); + if (ret) + return ret; + + diff = now.tv_sec * 1000000000ULL + now.tv_nsec - + (timer.it_value.tv_sec * 1000000000ULL + timer.it_value.tv_nsec); + + if (!smokey_assert(diff >= 5500000000LL && diff <= 6500000000LL)) + return -EINVAL; + + return smokey_check_errno(close(t)); +} + +static int clock_decrease_before_periodic_timer_first_tick(void) +{ + unsigned long long ticks; + struct itimerspec timer; + struct timespec now; + long long diff; + int t, ret; + + smokey_note(__func__); + + t = smokey_check_errno(timerfd_create(CLOCK_REALTIME, 0)); + if (t < 0) + return t; + + ret = smokey_check_errno(clock_gettime(CLOCK_REALTIME, &now)); + if (ret) + return ret; + + timer.it_value = now; + timer.it_value.tv_sec++; + timer.it_interval.tv_sec = 1; + timer.it_interval.tv_nsec = 0; + + ret = smokey_check_errno(timerfd_settime(t, TFD_TIMER_ABSTIME, &timer, NULL)); + if (ret) + return ret; + + now.tv_sec -= 5; + + ret = smokey_check_errno(clock_settime(CLOCK_REALTIME, &now)); + if (ret) + return ret; + + ret = smokey_check_errno(clock_gettime(CLOCK_MONOTONIC, &now)); + if (ret) + return ret; + + ret = smokey_check_errno(read(t, &ticks, sizeof(ticks))); + if (ret < 0) + return ret; + + if (!smokey_assert(ticks == 1)) + return -EINVAL; + + timer.it_value = now; + + ret = smokey_check_errno(clock_gettime(CLOCK_MONOTONIC, &now)); + if (ret) + return ret; + + diff = now.tv_sec * 1000000000ULL + now.tv_nsec - + (timer.it_value.tv_sec * 1000000000ULL + timer.it_value.tv_nsec); + + if (!smokey_assert(diff >= 5500000000LL && diff <= 6500000000LL)) + return -EINVAL; + + ret = smokey_check_errno(read(t, &ticks, sizeof(ticks))); + if (ret < 0) + return ret; + + if (!smokey_assert(ticks == 1)) + return -EINVAL; + + return smokey_check_errno(close(t)); +} + +static int clock_decrease_after_periodic_timer_first_tick(void) +{ + unsigned long long ticks; + struct itimerspec timer; + struct timespec now; + long long diff; + int t, ret; + + smokey_note(__func__); + + t = smokey_check_errno(timerfd_create(CLOCK_REALTIME, 0)); + if (t < 0) + return t; + + ret = smokey_check_errno(clock_gettime(CLOCK_REALTIME, &now)); + if (ret) + return ret; + + timer.it_value = now; + timer.it_value.tv_sec++; + timer.it_interval.tv_sec = 1; + timer.it_interval.tv_nsec = 0; + + ret = smokey_check_errno(timerfd_settime(t, TFD_TIMER_ABSTIME, &timer, NULL)); + if (ret) + return ret; + + ret = smokey_check_errno(read(t, &ticks, sizeof(ticks))); + if (ret < 0) + return ret; + + if (!smokey_assert(ticks == 1)) + return -EINVAL; + + ret = smokey_check_errno(clock_gettime(CLOCK_REALTIME, &now)); + if (ret) + return ret; + + now.tv_sec -= 5; + + ret = smokey_check_errno(clock_settime(CLOCK_REALTIME, &now)); + if (ret) + return ret; + + ret = smokey_check_errno(clock_gettime(CLOCK_MONOTONIC, &now)); + if (ret) + return ret; + + ret = smokey_check_errno(read(t, &ticks, sizeof(ticks))); + if (ret < 0) + return ret; + + if (!smokey_assert(ticks == 1)) + return -EINVAL; + + timer.it_value = now; + + ret = smokey_check_errno(clock_gettime(CLOCK_MONOTONIC, &now)); + if (ret) + return ret; + + diff = now.tv_sec * 1000000000ULL + now.tv_nsec - + (timer.it_value.tv_sec * 1000000000ULL + timer.it_value.tv_nsec); + if (!smokey_assert(diff < 1000000000)) + return -EINVAL; + + ret = smokey_check_errno(read(t, &ticks, sizeof(ticks))); + if (ret < 0) + return ret; + + if (!smokey_assert(ticks == 1)) + return -EINVAL; + + return smokey_check_errno(close(t)); +} + +static int run_posix_clock(struct smokey_test *t, int argc, char *const argv[]) +{ + int ret; + + ret = clock_increase_before_oneshot_timer_first_tick(); + if (ret) + return ret; + + ret = clock_increase_before_periodic_timer_first_tick(); + if (ret) + return ret; + + ret = clock_increase_after_periodic_timer_first_tick(); + if (ret) + return ret; + + ret = clock_decrease_before_oneshot_timer_first_tick(); + if (ret) + return ret; + + ret = clock_decrease_before_periodic_timer_first_tick(); + if (ret) + return ret; + + return clock_decrease_after_periodic_timer_first_tick(); +} _______________________________________________ Xenomai-git mailing list Xenomai-git@xenomai.org http://xenomai.org/mailman/listinfo/xenomai-git