asrt
Automated System Runtime Testing library
Loading...
Searching...
No Matches
reactor.h
1
12#ifndef ASRT_REACTOR_H
13#define ASRT_REACTOR_H
14
15#ifdef __cplusplus
16extern "C" {
17#endif
18
19#include "../asrtl/chann.h"
20#include "../asrtl/core_proto.h"
21#include "../asrtl/status.h"
22#include "record.h"
23
24#include <stdint.h>
25
35{
36 char const* desc;
37 void* ptr;
38 asrt_test_callback start_f;
39 struct asrt_test* next;
40};
41
43enum asrt_reactor_state
44{
45 ASRT_REAC_IDLE = 1,
46 ASRT_REAC_TEST_EXEC = 2,
47 ASRT_REAC_TEST_REPORT = 3,
48 ASRT_REAC_WAIT_SEND = 4,
49};
50
51enum asrt_reactor_flags
52{
53 ASRT_FLAG_DESC = 0x01,
54 ASRT_FLAG_PROTO_VER = 0x02,
55 ASRT_FLAG_TC = 0x04,
56 ASRT_FLAG_TI = 0x08,
57 ASRT_FLAG_TSTART = 0x10,
58 ASRT_FLAG_LOCKED = 0x20,
59};
60
61// Mask of flags that carry persistent state (not pending work).
62// Used to strip passive bits when checking for actionable flags.
63#define ASRT_PASSIVE_FLAGS ( ASRT_FLAG_LOCKED )
64
66{
67 struct asrt_node node;
68 char const* desc;
69
70 struct asrt_test* first_test;
71 struct asrt_test* last_test;
72
73 enum asrt_reactor_state state;
75 {
76 enum asrt_reactor_state next_state;
77 uint32_t err_run_id;
78 struct asrt_u8d8msg err_result_msg;
79 } wait_send;
80 struct asrt_test_input test_info;
81 struct asrt_record record;
82
83 uint32_t flags; // values of asrt_reactor_flags
84
85 uint16_t recv_test_info_id;
86 uint16_t recv_test_start_id;
87 uint32_t recv_test_run_id;
88
89 struct asrt_u8d8msg proto_ver_msg;
90 struct asrt_core_desc_msg desc_msg;
91 struct asrt_u8d4msg tc_msg;
92 struct asrt_core_test_info_msg ti_msg;
93 struct asrt_u8d8msg test_start_msg;
94 struct asrt_u8d8msg test_result_msg;
95};
96
99enum asrt_status asrt_reactor_init(
100 struct asrt_reactor* reac,
101 struct asrt_send_req_list* send_queue,
102 char const* desc );
103
105enum asrt_status asrt_test_init(
106 struct asrt_test* t,
107 char const* desc,
108 void* ptr,
109 asrt_test_callback start_f );
111enum asrt_status asrt_reactor_add_test( struct asrt_reactor* reac, struct asrt_test* test );
113void asrt_reactor_deinit( struct asrt_reactor* reac );
114
115#ifdef __cplusplus
116}
117#endif
118
119#endif
Definition: core_proto.h:74
Definition: core_proto.h:133
A node in a doubly-linked channel chain.
Definition: chann.h:122
Definition: reactor.h:75
Definition: reactor.h:66
Mutable test state passed to the test entry point on every tick.
Definition: record.h:46
Intrusive FIFO of outgoing send requests.
Definition: chann.h:76
Per-invocation context forwarded to the test entry point.
Definition: record.h:38
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee ...
Definition: reactor.h:35
asrt_test_callback start_f
Entry point; called each tick while the test is running.
Definition: reactor.h:38
struct asrt_test * next
Intrusive linked-list link.
Definition: reactor.h:39
void * ptr
Context pointer forwarded to start_f.
Definition: reactor.h:37
char const * desc
Human-readable test name.
Definition: reactor.h:36
Definition: chann.h:201
Definition: chann.h:216