Module: xenomai-3 Branch: arm64 Commit: 6a0c700645457dfec1111a4904e16aaa82457ed4 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=6a0c700645457dfec1111a4904e16aaa82457ed4
Author: Philippe Gerum <r...@xenomai.org> Date: Sat Oct 24 15:52:48 2015 +0200 testsuite/smokey: add basic FPU stress test --- configure.ac | 1 + testsuite/smokey/Makefile.am | 1 + testsuite/smokey/fpu-stress/Makefile.am | 8 +++ testsuite/smokey/fpu-stress/fpu-stress.c | 84 ++++++++++++++++++++++++++++++ 4 files changed, 94 insertions(+) diff --git a/configure.ac b/configure.ac index c805186..89c2911 100644 --- a/configure.ac +++ b/configure.ac @@ -899,6 +899,7 @@ AC_CONFIG_FILES([ \ testsuite/smokey/timerfd/Makefile \ testsuite/smokey/tsc/Makefile \ testsuite/smokey/leaks/Makefile \ + testsuite/smokey/fpu-stress/Makefile \ testsuite/clocktest/Makefile \ testsuite/xeno-test/Makefile \ utils/Makefile \ diff --git a/testsuite/smokey/Makefile.am b/testsuite/smokey/Makefile.am index 87e0555..e0361df 100644 --- a/testsuite/smokey/Makefile.am +++ b/testsuite/smokey/Makefile.am @@ -10,6 +10,7 @@ wrappers = $(XENO_POSIX_WRAPPERS) SUBDIRS = \ arith \ bufp \ + fpu-stress \ iddp \ leaks \ posix-clock \ diff --git a/testsuite/smokey/fpu-stress/Makefile.am b/testsuite/smokey/fpu-stress/Makefile.am new file mode 100644 index 0000000..c90d0dd --- /dev/null +++ b/testsuite/smokey/fpu-stress/Makefile.am @@ -0,0 +1,8 @@ + +noinst_LIBRARIES = libfpu-stress.a + +libfpu_stress_a_SOURCES = fpu-stress.c + +libfpu_stress_a_CPPFLAGS = \ + @XENO_USER_CFLAGS@ \ + -I$(top_srcdir)/include diff --git a/testsuite/smokey/fpu-stress/fpu-stress.c b/testsuite/smokey/fpu-stress/fpu-stress.c new file mode 100644 index 0000000..1846bf6 --- /dev/null +++ b/testsuite/smokey/fpu-stress/fpu-stress.c @@ -0,0 +1,84 @@ +#include <stdio.h> +#include <pthread.h> +#include <smokey/smokey.h> +#include <asm/xenomai/features.h> +#include <asm/xenomai/uapi/fptest.h> + +smokey_test_plugin(fpu_stress, + SMOKEY_ARGLIST( + SMOKEY_INT(duration), + ), + "Check FPU context sanity during real-time stress\n" + "\tduration=<seconds>\thow long to run the stress loop (0=indefinitely)" +); + +static int fp_features; + +static void *stress_loop(void *arg) +{ + struct timespec rqt = { + .tv_sec = 0, + .tv_nsec = CONFIG_XENO_DEFAULT_PERIOD + }; + + for (;;) { + fp_regs_set(fp_features, 0xf1f5f1f5); + clock_nanosleep(CLOCK_MONOTONIC, 0, &rqt, NULL); + } + + return NULL; +} + +static int run_fpu_stress(struct smokey_test *t, + int argc, char *const argv[]) +{ + unsigned sleep_ms, n, rounds, duration = 3; + struct sched_param param; + pthread_attr_t attr; + struct timespec rqt; + pthread_t tid; + int ret; + + fp_features = cobalt_fp_detect(); + if (fp_features == 0) + return -ENOSYS; + + smokey_parse_args(t, argc, argv); + + if (SMOKEY_ARG_ISSET(fpu_stress, duration)) + duration = SMOKEY_ARG_INT(fpu_stress, duration); + + rqt.tv_sec = 0; + rqt.tv_nsec = CONFIG_XENO_DEFAULT_PERIOD; + sleep_ms = 1000000UL / rqt.tv_nsec; /* wake up each ms */ + rounds = duration * 1000UL / sleep_ms; + + pthread_attr_init(&attr); + pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE); + pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED); + pthread_attr_setschedpolicy(&attr, SCHED_FIFO); + param.sched_priority = 10; + pthread_attr_setschedparam(&attr, ¶m); + ret = pthread_create(&tid, &attr, stress_loop, NULL); + if (ret) + return -ret; + + if (rounds) + smokey_trace("running for %d seconds", duration); + else + smokey_trace("running indefinitely..."); + + for (n = 0; rounds == 0 || n < rounds; n++) { + fp_regs_set(fp_features, n); + __STD(clock_nanosleep(CLOCK_MONOTONIC, 0, &rqt, NULL)); + if (fp_regs_check(fp_features, n, smokey_trace) != n) { + ret = -EINVAL; + break; + } + } + + pthread_cancel(tid); + pthread_join(tid, NULL); + + return ret; +} _______________________________________________ Xenomai-git mailing list Xenomai-git@xenomai.org http://xenomai.org/mailman/listinfo/xenomai-git