From cc0c8bc47ef7c82372c9d75865466ed00fc1a58d Mon Sep 17 00:00:00 2001 From: Christian Spielberger Date: Thu, 12 Oct 2023 16:17:15 +0200 Subject: [PATCH] test: call - add cancel_rules_debug() --- test/call.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/test/call.c b/test/call.c index 166895c837..11e2764aa3 100644 --- a/test/call.c +++ b/test/call.c @@ -222,6 +222,49 @@ static struct cancel_rule *cancel_rule_add_and(struct cancel_rule *cr, } +static int cancel_rule_debug(struct re_printf *pf, + const struct cancel_rule *cr) +{ + int err; + if (!cr) + return 0; + + err = re_hprintf(pf, "--- %s ---\n", uag_event_str(cr->ev)); + err |= re_hprintf(pf, " prm: %s\n", cr->prm); + err |= re_hprintf(pf, " ua: %s\n", account_aor(ua_account(cr->ua))); + err |= re_hprintf(pf, " n_incoming: %u\n", cr->n_incoming); + err |= re_hprintf(pf, " n_progress: %u\n", cr->n_progress); + err |= re_hprintf(pf, " n_established: %u\n", cr->n_established); + err |= re_hprintf(pf, " n_audio_estab: %u\n", cr->n_audio_estab); + err |= re_hprintf(pf, " n_video_estab: %u\n", cr->n_video_estab); + err |= re_hprintf(pf, " n_offer_cnt: %u\n", cr->n_offer_cnt); + err |= re_hprintf(pf, " n_answer_cnt: %u\n", cr->n_answer_cnt); + err |= re_hprintf(pf, " n_vidframe: %u\n", cr->n_vidframe); + err |= re_hprintf(pf, " met: %s\n", cr->met ? "yes": "no"); + if (err) + return err; + + if (cr->cr_and) { + err |= re_hprintf(pf, " AND -->\n"); + err |= cancel_rule_debug(pf, cr->cr_and); + } + + return err; +} + + +static void cancel_rules_debug(struct fixture *f) +{ + struct le *le; + + LIST_FOREACH(&f->rules, le) { + struct cancel_rule *cr = le->data; + + re_printf("%H", cancel_rule_debug, cr); + } +} + + static void cancel_rule_reset(struct cancel_rule *cr) { cr->met = false; @@ -350,6 +393,7 @@ static bool check_rule(struct cancel_rule *rule, int met_prev, out: if (met_prev && met_next) { + info("canceled by %H", cancel_rule_debug, rule); re_cancel(); cancel_rule_reset(rule); } @@ -1219,6 +1263,9 @@ int test_call_change_videodir(void) ASSERT_EQ(SDP_SENDRECV, sdp_media_rdir(vm)); out: + if (err) + cancel_rules_debug(f); + fixture_close(f); mem_deref(vidisp); module_unload("fakevideo");