From 7b4de472d27e9fe5201a8e0b847e5b2281b71452 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Sat, 23 Jul 2016 17:07:25 +0200 Subject: added config 'call_max_calls' to limit maximum number of calls per ua --- test/call.c | 41 +++++++++++++++++++++++++++++++++++++++++ test/main.c | 1 + test/test.h | 1 + 3 files changed, 43 insertions(+) (limited to 'test') diff --git a/test/call.c b/test/call.c index 629b890..b1e6c33 100644 --- a/test/call.c +++ b/test/call.c @@ -198,6 +198,7 @@ static void event_handler(struct ua *ua, enum ua_event ev, } if (ag->failed && ag->peer->failed) { + info("test: re_cancel on call failed\n"); re_cancel(); return; } @@ -530,3 +531,43 @@ int test_call_multiple(void) return err; } + + +int test_call_max(void) +{ + struct fixture fix, *f = &fix; + unsigned i; + int err = 0; + + /* Set the max-calls limit */ + conf_config()->call.max_calls = 1; + + fixture_init(f); + + f->behaviour = BEHAVIOUR_ANSWER; + + /* Make 2 calls, one should work and one should fail */ + for (i=0; i<2; i++) { + err = ua_connect(f->a.ua, 0, NULL, f->buri, NULL, VIDMODE_OFF); + TEST_ERR(err); + } + + f->b.failed = true; /* tiny hack to stop the runloop */ + + err = re_main_timeout(5000); + TEST_ERR(err); + TEST_ERR(fix.err); + + ASSERT_EQ(0, fix.a.n_incoming); + ASSERT_EQ(1, fix.a.n_established); + ASSERT_EQ(1, fix.a.n_closed); + ASSERT_EQ(486, fix.a.close_scode); + + ASSERT_EQ(1, fix.b.n_incoming); + ASSERT_EQ(0, fix.b.n_closed); + + out: + fixture_close(f); + + return err; +} diff --git a/test/main.c b/test/main.c index 18442f8..c9f1964 100644 --- a/test/main.c +++ b/test/main.c @@ -26,6 +26,7 @@ static const struct test tests[] = { TEST(test_call_reject), TEST(test_call_rtp_timeout), TEST(test_call_multiple), + TEST(test_call_max), TEST(test_cmd), TEST(test_cplusplus), TEST(test_mos), diff --git a/test/test.h b/test/test.h index 30257cb..e8217c9 100644 --- a/test/test.h +++ b/test/test.h @@ -104,6 +104,7 @@ int test_call_answer_hangup_a(void); int test_call_answer_hangup_b(void); int test_call_rtp_timeout(void); int test_call_multiple(void); +int test_call_max(void); #ifdef __cplusplus -- cgit v1.2.3