aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/tests
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2010-04-01 03:55:27 +0200
committerHolger Hans Peter Freyther <zecke@selfish.org>2010-04-01 07:41:23 +0200
commit8cdfe9fc37819051187ad02dca20d8b75c701b0b (patch)
treefc88c8eaced4cc2abd2f04b6e098434d71f18376 /openbsc/tests
parent0959f8cbe6273b8580d6e0d46cefe1d8bfa019bd (diff)
nat: Add code to find a BSC connection by the given msc multiplex
Diffstat (limited to 'openbsc/tests')
-rw-r--r--openbsc/tests/bsc-nat/bsc_nat_test.c45
1 files changed, 43 insertions, 2 deletions
diff --git a/openbsc/tests/bsc-nat/bsc_nat_test.c b/openbsc/tests/bsc-nat/bsc_nat_test.c
index 70e98d721..30f1490f1 100644
--- a/openbsc/tests/bsc-nat/bsc_nat_test.c
+++ b/openbsc/tests/bsc-nat/bsc_nat_test.c
@@ -335,7 +335,7 @@ static void test_paging(void)
talloc_free(parsed);
}
-static void test_mgcp(void)
+static void test_mgcp_ass_tracking(void)
{
struct sccp_connections con;
struct bsc_nat_parsed *parsed;
@@ -370,6 +370,46 @@ static void test_mgcp(void)
}
}
+/* test the code to find a given connection */
+static void test_mgcp_find(void)
+{
+ struct bsc_nat *nat;
+ struct bsc_connection *con;
+ struct sccp_connections *sccp_con;
+
+ fprintf(stderr, "Testing finding of a BSC Connection\n");
+
+ nat = bsc_nat_alloc();
+ con = bsc_connection_alloc(nat);
+ llist_add(&con->list_entry, &nat->bsc_connections);
+
+ sccp_con = talloc_zero(con, struct sccp_connections);
+ sccp_con->msc_timeslot = 12;
+ sccp_con->bsc_timeslot = 12;
+ sccp_con->bsc = con;
+ llist_add(&sccp_con->list_entry, &nat->sccp_connections);
+
+ if (bsc_mgcp_find_con(nat, 11) != NULL) {
+ fprintf(stderr, "Found the wrong connection.\n");
+ abort();
+ }
+
+ if (bsc_mgcp_find_con(nat, 12) != con) {
+ fprintf(stderr, "Didn't find the connection\n");
+ abort();
+ }
+
+ sccp_con->msc_timeslot = 0;
+ sccp_con->bsc_timeslot = 0;
+ if (bsc_mgcp_find_con(nat, 1) != con) {
+ fprintf(stderr, "Didn't find the connection\n");
+ abort();
+ }
+
+ /* free everything */
+ talloc_free(nat);
+}
+
int main(int argc, char **argv)
{
struct debug_target *stderr_target;
@@ -381,7 +421,8 @@ int main(int argc, char **argv)
test_filter();
test_contrack();
test_paging();
- test_mgcp();
+ test_mgcp_ass_tracking();
+ test_mgcp_find();
return 0;
}