asrt
Automated System Runtime Testing library
Loading...
Searching...
No Matches
reactor.hpp
1
11#pragma once
12
13#include "../asrtl/asrt_assert.h"
14#include "../asrtl/log.h"
15#include "../asrtl/status_to_str.h"
16#include "../asrtlpp/util.hpp"
17#include "../asrtr/reactor.h"
18
19#include <span>
20
21namespace asrt
22{
23
24using send_req_list = asrt_send_req_list;
25using record = asrt_record;
26
30template < typename T >
32{
33 template < typename... Args >
34 unit( Args&&... args )
35 : test( (Args&&) args... )
36 {
37 asrt_test_init( this, test.name(), static_cast< unit* >( this ), unit::cb );
38 }
39
40 unit( unit&& ) = delete;
41 unit( unit const& ) = delete;
42
43 static asrt_status cb( record* rec )
44 {
45 auto* self = static_cast< unit* >( rec->inpt->test_ptr );
46 asrt_status st = self->test( *rec );
47 if ( st != ASRT_SUCCESS )
48 rec->state = ASRT_TEST_FAIL;
49 return st;
50 }
51
52 T test;
53};
54
57ASRT_NODISCARD inline enum asrt_status init(
58 ref< asrt_reactor > reac,
59 send_req_list& req_l,
60 char const* desc )
61{
62 return asrt_reactor_init( reac, &req_l, desc );
63}
65ASRT_NODISCARD inline enum asrt_status add_test( ref< asrt_reactor > reac, asrt_test& test )
66{
67 return asrt_reactor_add_test( reac, &test );
68}
69
71inline void deinit( ref< asrt_reactor > reac )
72{
73 asrt_reactor_deinit( reac );
74}
75
76} // namespace asrt
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee ...
Definition: callback.hpp:17
ASRT_NODISCARD enum asrt_status init(ref< asrt_cntr_assm > assm, asrt_allocator alloc)
Initialise the controller assembly — wires controller, diag, param, collect and stream channels.
Definition: cntr_assm.hpp:25
ASRT_NODISCARD enum asrt_status add_test(ref< asrt_reac_assm > assm, asrt_test &test)
Append test to the assembly's reactor test list.
Definition: reac_assm.hpp:39
void deinit(ref< asrt_cntr_assm > assm)
Release all resources owned by the assembly.
Definition: cntr_assm.hpp:52
Test adaptor that wraps a synchronous callable T into an asrt_test.
Definition: reactor.hpp:32
Mutable test state passed to the test entry point on every tick.
Definition: record.h:46
struct asrt_test_input const * inpt
Immutable per-invocation context.
Definition: record.h:49
enum asrt_test_state state
Current state; updated by assertions and by the reactor.
Definition: record.h:47
Intrusive FIFO of outgoing send requests.
Definition: chann.h:76
void * test_ptr
Context pointer registered with asrt_test_init().
Definition: record.h:39
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee ...
Definition: reactor.h:35