Merge pull request #16133 from miri64/congure_mock/enh/real-methods
congure_mock: add capability to provide actual methods
This commit is contained in:
commit
3cb3b5ab85
@ -37,9 +37,11 @@ static const congure_snd_driver_t _driver = {
|
|||||||
.report_ecn_ce = _snd_report_ecn_ce,
|
.report_ecn_ce = _snd_report_ecn_ce,
|
||||||
};
|
};
|
||||||
|
|
||||||
void congure_mock_snd_setup(congure_mock_snd_t *c)
|
void congure_mock_snd_setup(congure_mock_snd_t *c,
|
||||||
|
const congure_snd_driver_t *methods)
|
||||||
{
|
{
|
||||||
c->super.driver = &_driver;
|
c->super.driver = &_driver;
|
||||||
|
c->methods = methods;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _snd_init(congure_snd_t *cong, void *ctx)
|
static void _snd_init(congure_snd_t *cong, void *ctx)
|
||||||
@ -49,6 +51,9 @@ static void _snd_init(congure_snd_t *cong, void *ctx)
|
|||||||
c->init_calls++;
|
c->init_calls++;
|
||||||
c->init_args.c = &c->super;
|
c->init_args.c = &c->super;
|
||||||
c->init_args.ctx = ctx;
|
c->init_args.ctx = ctx;
|
||||||
|
if (c->methods && c->methods->init) {
|
||||||
|
c->methods->init(cong, ctx);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t _snd_inter_msg_interval(congure_snd_t *cong, unsigned msg_size)
|
static int32_t _snd_inter_msg_interval(congure_snd_t *cong, unsigned msg_size)
|
||||||
@ -58,6 +63,9 @@ static int32_t _snd_inter_msg_interval(congure_snd_t *cong, unsigned msg_size)
|
|||||||
c->inter_msg_interval_calls++;
|
c->inter_msg_interval_calls++;
|
||||||
c->inter_msg_interval_args.c = &c->super;
|
c->inter_msg_interval_args.c = &c->super;
|
||||||
c->inter_msg_interval_args.msg_size = msg_size;
|
c->inter_msg_interval_args.msg_size = msg_size;
|
||||||
|
if (c->methods && c->methods->inter_msg_interval) {
|
||||||
|
return c->methods->inter_msg_interval(cong, msg_size);
|
||||||
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,6 +76,9 @@ static void _snd_report_msg_sent(congure_snd_t *cong, unsigned msg_size)
|
|||||||
c->report_msg_sent_calls++;
|
c->report_msg_sent_calls++;
|
||||||
c->report_msg_sent_args.c = &c->super;
|
c->report_msg_sent_args.c = &c->super;
|
||||||
c->report_msg_sent_args.msg_size = msg_size;
|
c->report_msg_sent_args.msg_size = msg_size;
|
||||||
|
if (c->methods && c->methods->report_msg_sent) {
|
||||||
|
c->methods->report_msg_sent(cong, msg_size);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _snd_report_msg_discarded(congure_snd_t *cong, unsigned msg_size)
|
static void _snd_report_msg_discarded(congure_snd_t *cong, unsigned msg_size)
|
||||||
@ -77,6 +88,9 @@ static void _snd_report_msg_discarded(congure_snd_t *cong, unsigned msg_size)
|
|||||||
c->report_msg_discarded_calls++;
|
c->report_msg_discarded_calls++;
|
||||||
c->report_msg_discarded_args.c = &c->super;
|
c->report_msg_discarded_args.c = &c->super;
|
||||||
c->report_msg_discarded_args.msg_size = msg_size;
|
c->report_msg_discarded_args.msg_size = msg_size;
|
||||||
|
if (c->methods && c->methods->report_msg_discarded) {
|
||||||
|
c->methods->report_msg_discarded(cong, msg_size);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _snd_report_msgs_lost(congure_snd_t *cong, congure_snd_msg_t *msgs)
|
static void _snd_report_msgs_lost(congure_snd_t *cong, congure_snd_msg_t *msgs)
|
||||||
@ -86,6 +100,9 @@ static void _snd_report_msgs_lost(congure_snd_t *cong, congure_snd_msg_t *msgs)
|
|||||||
c->report_msgs_lost_calls++;
|
c->report_msgs_lost_calls++;
|
||||||
c->report_msgs_lost_args.c = &c->super;
|
c->report_msgs_lost_args.c = &c->super;
|
||||||
c->report_msgs_lost_args.msgs = msgs;
|
c->report_msgs_lost_args.msgs = msgs;
|
||||||
|
if (c->methods && c->methods->report_msgs_lost) {
|
||||||
|
c->methods->report_msgs_lost(cong, msgs);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _snd_report_msgs_timeout(congure_snd_t *cong,
|
static void _snd_report_msgs_timeout(congure_snd_t *cong,
|
||||||
@ -96,6 +113,9 @@ static void _snd_report_msgs_timeout(congure_snd_t *cong,
|
|||||||
c->report_msgs_timeout_calls++;
|
c->report_msgs_timeout_calls++;
|
||||||
c->report_msgs_timeout_args.c = &c->super;
|
c->report_msgs_timeout_args.c = &c->super;
|
||||||
c->report_msgs_timeout_args.msgs = msgs;
|
c->report_msgs_timeout_args.msgs = msgs;
|
||||||
|
if (c->methods && c->methods->report_msgs_timeout) {
|
||||||
|
c->methods->report_msgs_timeout(cong, msgs);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _snd_report_msg_acked(congure_snd_t *cong, congure_snd_msg_t *msg,
|
static void _snd_report_msg_acked(congure_snd_t *cong, congure_snd_msg_t *msg,
|
||||||
@ -107,6 +127,9 @@ static void _snd_report_msg_acked(congure_snd_t *cong, congure_snd_msg_t *msg,
|
|||||||
c->report_msg_acked_args.c = &c->super;
|
c->report_msg_acked_args.c = &c->super;
|
||||||
c->report_msg_acked_args.msg = msg;
|
c->report_msg_acked_args.msg = msg;
|
||||||
c->report_msg_acked_args.ack = ack;
|
c->report_msg_acked_args.ack = ack;
|
||||||
|
if (c->methods && c->methods->report_msg_acked) {
|
||||||
|
c->methods->report_msg_acked(cong, msg, ack);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _snd_report_ecn_ce(congure_snd_t *cong, ztimer_now_t time)
|
static void _snd_report_ecn_ce(congure_snd_t *cong, ztimer_now_t time)
|
||||||
@ -116,6 +139,9 @@ static void _snd_report_ecn_ce(congure_snd_t *cong, ztimer_now_t time)
|
|||||||
c->report_ecn_ce_calls++;
|
c->report_ecn_ce_calls++;
|
||||||
c->report_ecn_ce_args.c = &c->super;
|
c->report_ecn_ce_args.c = &c->super;
|
||||||
c->report_ecn_ce_args.time = time;
|
c->report_ecn_ce_args.time = time;
|
||||||
|
if (c->methods && c->methods->report_ecn_ce) {
|
||||||
|
c->methods->report_ecn_ce(cong, time);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|||||||
@ -33,7 +33,12 @@ extern "C" {
|
|||||||
* @extends congure_snd_t
|
* @extends congure_snd_t
|
||||||
*/
|
*/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
congure_snd_t super; /**< see @ref congure_snd_t */
|
congure_snd_t super; /**< see @ref congure_snd_t */
|
||||||
|
/**
|
||||||
|
* @brief Optional methods called in addition to the tracking functions
|
||||||
|
* of the mock driver
|
||||||
|
*/
|
||||||
|
const congure_snd_driver_t *methods;
|
||||||
/**
|
/**
|
||||||
* @brief How often was the congure_snd_driver_t::init() method called?
|
* @brief How often was the congure_snd_driver_t::init() method called?
|
||||||
*/
|
*/
|
||||||
@ -152,9 +157,12 @@ typedef struct {
|
|||||||
/**
|
/**
|
||||||
* @brief Sets up the driver for CongURE mock object
|
* @brief Sets up the driver for CongURE mock object
|
||||||
*
|
*
|
||||||
* @param[in] c A CongURE mock object
|
* @param[in] c A CongURE mock object
|
||||||
|
* @param[in] methods Methods to call in addition to the tracking of the mock
|
||||||
|
* driver. May be NULL.
|
||||||
*/
|
*/
|
||||||
void congure_mock_snd_setup(congure_mock_snd_t *c);
|
void congure_mock_snd_setup(congure_mock_snd_t *c,
|
||||||
|
const congure_snd_driver_t *methods);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
@ -22,7 +22,7 @@ int congure_test_snd_setup(congure_test_snd_t *c, unsigned id)
|
|||||||
if (id > 0) {
|
if (id > 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
congure_mock_snd_setup(c);
|
congure_mock_snd_setup(c, NULL);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user