aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/tests
diff options
context:
space:
mode:
authorJacob Erlbeck <jerlbeck@sysmocom.de>2014-01-16 16:50:40 +0100
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2014-01-20 08:27:03 +0100
commite35fd1369762b4b59e2673275836869df379f2b6 (patch)
treeaf0ebfdc914789c6024acf2defa1423d1b82badd /openbsc/tests
parent8857c90e3609c88a3d384e64633258d4d7463f93 (diff)
mgcp: Synchronize conn mode bits and output enabled flags
This patch changes implementation and the mgcp_connection_mode enum in a way that net_end.output_enabled (bts_end.output_enabled) flag always matches the MGCP_CONN_SEND_ONLY (MGCP_CONN_RECV_ONLY) bit of conn_mode. Based on this, the conn_mode bits are then used instead of the output_enabled fields within mgcp_protocol.c. Sponsored-by: On-Waves ehf
Diffstat (limited to 'openbsc/tests')
-rw-r--r--openbsc/tests/mgcp/mgcp_test.c33
1 files changed, 26 insertions, 7 deletions
diff --git a/openbsc/tests/mgcp/mgcp_test.c b/openbsc/tests/mgcp/mgcp_test.c
index 7eeef99af..1f11b1d52 100644
--- a/openbsc/tests/mgcp/mgcp_test.c
+++ b/openbsc/tests/mgcp/mgcp_test.c
@@ -321,6 +321,19 @@ ssize_t sendto(int sockfd, const void *buf, size_t len, int flags,
return real_sendto(sockfd, buf, len, flags, dest_addr, addrlen);
}
+#define CONN_UNMODIFIED (0x1000)
+
+static void test_values(void)
+{
+ /* Check that NONE disables all output */
+ OSMO_ASSERT((MGCP_CONN_NONE & MGCP_CONN_RECV_SEND) == 0)
+
+ /* Check that LOOPBACK enables all output */
+ OSMO_ASSERT((MGCP_CONN_LOOPBACK & MGCP_CONN_RECV_SEND) ==
+ MGCP_CONN_RECV_SEND)
+}
+
+
static void test_messages(void)
{
struct mgcp_config *cfg;
@@ -341,9 +354,9 @@ static void test_messages(void)
endp = &cfg->trunk.endpoints[i];
endp->net_end.payload_type = PTYPE_NONE;
endp->net_end.packet_duration_ms = -1;
- endp->bts_end.output_enabled = 0;
- endp->net_end.output_enabled = 0;
- endp->conn_mode = -1;
+
+ OSMO_ASSERT(endp->conn_mode == MGCP_CONN_NONE);
+ endp->conn_mode |= CONN_UNMODIFIED;
}
for (i = 0; i < ARRAY_SIZE(tests); i++) {
@@ -386,7 +399,7 @@ static void test_messages(void)
else
printf("Requested packetization period not set\n");
- if (endp->conn_mode != -1)
+ if ((endp->conn_mode & CONN_UNMODIFIED) == 0)
printf("Connection mode: %d, "
"BTS output %sabled, NET output %sabled\n",
endp->conn_mode,
@@ -395,12 +408,17 @@ static void test_messages(void)
else
printf("Connection mode not set\n");
+ OSMO_ASSERT(endp->net_end.output_enabled ==
+ (endp->conn_mode & MGCP_CONN_SEND_ONLY ? 1 : 0));
+ OSMO_ASSERT(endp->bts_end.output_enabled ==
+ (endp->conn_mode & MGCP_CONN_RECV_ONLY ? 1 : 0));
+
endp->net_end.packet_duration_ms = -1;
- endp->bts_end.output_enabled = 0;
- endp->net_end.output_enabled = 0;
endp->local_options.pkt_period_min = 0;
endp->local_options.pkt_period_max = 0;
- endp->conn_mode = -1;
+ endp->conn_mode = MGCP_CONN_NONE | CONN_UNMODIFIED;
+ endp->net_end.output_enabled = 0;
+ endp->bts_end.output_enabled = 0;
}
@@ -784,6 +802,7 @@ int main(int argc, char **argv)
osmo_init_logging(&log_info);
test_strline();
+ test_values();
test_messages();
test_retransmission();
test_packet_loss_calc();