14#include "../asrtc/controller.h"
15#include "../asrtc/result.h"
16#include "../asrtlpp/callback.hpp"
17#include "../asrtlpp/task.hpp"
18#include "../asrtlpp/util.hpp"
25using status = asrt_status;
31 return asrt_cntr_init( c, s, a );
36ASRT_NODISCARD
inline status
start(
37 ref< asrt_controller > c,
41 return asrt_cntr_start( c, cb.fn, cb.ptr, timeout );
45ASRT_NODISCARD
inline bool is_idle( ref< asrt_controller > c )
47 return asrt_cntr_idle( c ) > 0;
52 ref< asrt_controller > c,
56 return asrt_cntr_desc( c, cb.fn, cb.ptr, timeout );
61 ref< asrt_controller > c,
65 return asrt_cntr_test_count( c, cb.fn, cb.ptr, timeout );
70 ref< asrt_controller > c,
75 return asrt_cntr_test_info( c,
id, cb.fn, cb.ptr, timeout );
80 ref< asrt_controller > c,
85 return asrt_cntr_test_exec( c,
id, cb.fn, cb.ptr, timeout );
89inline void deinit( ref< asrt_controller > c )
91 asrt_cntr_deinit( c );
100 using completion_signatures =
101 ecor::completion_signatures< ecor::set_value_t(), ecor::set_error_t( status ) >;
106 template <
typename OP >
109 auto s = asrt_cntr_start(
111 +[](
void* p, asrt_status s ) -> asrt_status {
112 auto& o = *
static_cast< OP*
>( p );
113 if ( s != ASRT_SUCCESS )
114 o.receiver.set_error( s );
116 o.receiver.set_value();
121 if ( s != ASRT_SUCCESS )
122 op.receiver.set_error( s );
131struct _cntr_query_desc_ctx
133 using completion_signatures = ecor::
134 completion_signatures< ecor::set_value_t( std::string ), ecor::set_error_t( status ) >;
139 template <
typename OP >
142 auto s = asrt_cntr_desc(
144 +[](
void* p, asrt_status s,
char const* desc ) -> asrt_status {
145 auto& o = *
static_cast< OP*
>( p );
146 if ( s != ASRT_SUCCESS )
147 o.receiver.set_error( s );
149 o.receiver.set_value( std::string{ desc } );
154 if ( s != ASRT_SUCCESS )
155 op.receiver.set_error( s );
164struct _cntr_query_test_count_ctx
166 using completion_signatures = ecor::
167 completion_signatures< ecor::set_value_t( uint16_t ), ecor::set_error_t( status ) >;
172 template <
typename OP >
175 auto s = asrt_cntr_test_count(
177 +[](
void* p, asrt_status s, uint16_t count ) -> asrt_status {
178 auto& o = *
static_cast< OP*
>( p );
179 if ( s != ASRT_SUCCESS )
180 o.receiver.set_error( s );
182 o.receiver.set_value( count );
187 if ( s != ASRT_SUCCESS )
188 op.receiver.set_error( s );
197struct _cntr_query_test_info_ctx
199 using completion_signatures = ecor::completion_signatures<
200 ecor::set_value_t( uint16_t, std::string ),
201 ecor::set_error_t( status ) >;
207 template <
typename OP >
210 auto s = asrt_cntr_test_info(
213 +[](
void* p, asrt_status s, uint16_t tid,
char const* desc ) -> asrt_status {
214 auto& o = *
static_cast< OP*
>( p );
215 if ( s != ASRT_SUCCESS )
216 o.receiver.set_error( s );
218 o.receiver.set_value( tid, std::string{ desc } );
223 if ( s != ASRT_SUCCESS )
224 op.receiver.set_error( s );
233struct _cntr_exec_test_ctx
235 using completion_signatures = ecor::
236 completion_signatures< ecor::set_value_t(
asrt_result ), ecor::set_error_t( status ) >;
242 template <
typename OP >
245 auto s = asrt_cntr_test_exec(
248 +[](
void* p, asrt_status s,
asrt_result* res ) -> asrt_status {
249 auto& o = *
static_cast< OP*
>( p );
250 if ( s != ASRT_SUCCESS )
251 o.receiver.set_error( s );
253 o.receiver.set_value( *res );
258 if ( s != ASRT_SUCCESS )
259 op.receiver.set_error( s );
268inline ecor::sender
auto start( ref< asrt_controller > c, uint32_t timeout )
274inline ecor::sender
auto query_desc( ref< asrt_controller > c, uint32_t timeout )
288inline ecor::sender
auto query_test_info( ref< asrt_controller > c, uint16_t
id, uint32_t timeout )
294inline ecor::sender
auto exec_test( ref< asrt_controller > c, uint16_t
id, uint32_t timeout )
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee ...
Definition: callback.hpp:17
ecor::sender_from< _cntr_start_ctx > cntr_start_sender
Sender backing co_await start(c, timeout).
Definition: controller.hpp:128
ecor::sender_from< _cntr_query_test_count_ctx > cntr_query_test_count_sender
Sender backing co_await query_test_count(c, timeout).
Definition: controller.hpp:194
ecor::sender_from< _cntr_query_desc_ctx > cntr_query_desc_sender
Sender backing co_await query_desc(c, timeout).
Definition: controller.hpp:161
ASRT_NODISCARD bool is_idle(ref< asrt_controller > c)
Returns true if the controller has no pending operation.
Definition: controller.hpp:45
ecor::sender_from< _cntr_exec_test_ctx > cntr_exec_test_sender
Sender backing co_await exec_test(c, id, timeout).
Definition: controller.hpp:265
ASRT_NODISCARD status query_test_count(ref< asrt_controller > c, callback< asrt_test_count_callback > cb, uint32_t timeout)
Request the number of tests registered on the target; cb receives the count.
Definition: controller.hpp:60
ASRT_NODISCARD status start(ref< asrt_controller > c, callback< asrt_init_callback > cb, uint32_t timeout)
Begin the protocol handshake; cb is invoked once the target responds or the operation times out.
Definition: controller.hpp:36
ecor::sender_from< _cntr_query_test_info_ctx > cntr_query_test_info_sender
Sender backing co_await query_test_info(c, id, timeout).
Definition: controller.hpp:230
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 status query_test_info(ref< asrt_controller > c, uint16_t id, callback< asrt_test_info_callback > cb, uint32_t timeout)
Request name and metadata for test id; cb receives the info.
Definition: controller.hpp:69
void deinit(ref< asrt_cntr_assm > assm)
Release all resources owned by the assembly.
Definition: cntr_assm.hpp:52
ASRT_NODISCARD enum asrt_status exec_test(ref< asrt_cntr_assm > assm, asrt_flat_tree const *tree, asrt_flat_id root_id, uint16_t tid, uint32_t timeout, callback< asrt_assembly_exec_cb > cb)
Execute test tid using the full assembly protocol sequence (param upload, collect ready,...
Definition: cntr_assm.hpp:40
ASRT_NODISCARD status query_desc(ref< asrt_controller > c, callback< asrt_desc_callback > cb, uint32_t timeout)
Request the target description string; cb receives it on success.
Definition: controller.hpp:51
A type-erasing wrapper for C-style callback + void* pairs.
Definition: callback.hpp:27
Controller module — CORE channel, host side.
Definition: controller.h:42
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee ...
Definition: result.h:25
Intrusive FIFO of outgoing send requests.
Definition: chann.h:76