summaryrefslogtreecommitdiffstats
path: root/cpukit/include/rtems/test.h
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2020-08-07 20:30:39 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2020-08-11 08:03:47 +0200
commitc1354f05149a9290d61ff9acf39129df46d5eac5 (patch)
tree9d39aa0f455d86f5aa1b2b2f66f616f08c3038d7 /cpukit/include/rtems/test.h
parentlibtest: Constify (diff)
downloadrtems-c1354f05149a9290d61ff9acf39129df46d5eac5.tar.bz2
libtest: Add T_thread_switch_record()
Add support to record thread switch events. This can be used to check that a blocking operation results in the expected sequence of thread switches. Update #3199.
Diffstat (limited to 'cpukit/include/rtems/test.h')
-rw-r--r--cpukit/include/rtems/test.h45
1 files changed, 45 insertions, 0 deletions
diff --git a/cpukit/include/rtems/test.h b/cpukit/include/rtems/test.h
index a7955c735a..18aafbcf7c 100644
--- a/cpukit/include/rtems/test.h
+++ b/cpukit/include/rtems/test.h
@@ -83,6 +83,14 @@ typedef struct T_fixture_node {
#define T_FILE_NAME __FILE__
#endif
+#if defined(__GNUC__) || __STDC_VERSION__ >= 199409L
+#define T_ZERO_LENGTH_ARRAY
+#define T_ZERO_LENGTH_ARRAY_EXTENSION(n) (n)
+#else
+#define T_ZERO_LENGTH_ARRAY 1
+#define T_ZERO_LENGTH_ARRAY_EXTENSION(n) ((n) - 1)
+#endif
+
/** @} */
/**
@@ -2390,6 +2398,43 @@ void T_interrupt_test_busy_wait_for_interrupt(void);
T_interrupt_test_state T_interrupt_test(const T_interrupt_test_config *config,
void *arg);
+typedef struct {
+ uint32_t executing;
+ uint32_t heir;
+ uint32_t cpu;
+ T_time instant;
+} T_thread_switch_event;
+
+typedef struct {
+ size_t recorded;
+ size_t capacity;
+ uint64_t switches;
+ T_thread_switch_event events[T_ZERO_LENGTH_ARRAY];
+} T_thread_switch_log;
+
+typedef struct {
+ T_thread_switch_log log;
+ T_thread_switch_event events[T_ZERO_LENGTH_ARRAY_EXTENSION(2)];
+} T_thread_switch_log_2;
+
+typedef struct {
+ T_thread_switch_log log;
+ T_thread_switch_event events[T_ZERO_LENGTH_ARRAY_EXTENSION(4)];
+} T_thread_switch_log_4;
+
+typedef struct {
+ T_thread_switch_log log;
+ T_thread_switch_event events[T_ZERO_LENGTH_ARRAY_EXTENSION(10)];
+} T_thread_switch_log_10;
+
+T_thread_switch_log *T_thread_switch_record(T_thread_switch_log *);
+
+T_thread_switch_log *T_thread_switch_record_2(T_thread_switch_log_2 *);
+
+T_thread_switch_log *T_thread_switch_record_4(T_thread_switch_log_4 *);
+
+T_thread_switch_log *T_thread_switch_record_10(T_thread_switch_log_10 *);
+
void T_report_hash_sha256(T_event, const char *);
void T_check_heap(T_event, const char *);