summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Elder <aelder@audioscience.com>2016-01-08 11:02:54 -0500
committerAndrew Elder <aelder@audioscience.com>2016-01-08 11:02:54 -0500
commitfc551719037504203070cedf08986b59c39ffa24 (patch)
treea24adbb46d5da03a2a0cacac92e24fdbd88caa8b
parent98169389c5163adc868affb2e56b6d29ff92ad52 (diff)
downloadOpen-AVB-fc551719037504203070cedf08986b59c39ffa24.tar.gz
MRP: tests, add failing test example for issue #338
-rw-r--r--daemons/mrpd/tests/simple/msrp_tests.cpp55
1 files changed, 55 insertions, 0 deletions
diff --git a/daemons/mrpd/tests/simple/msrp_tests.cpp b/daemons/mrpd/tests/simple/msrp_tests.cpp
index 84004260..d6ffee9a 100644
--- a/daemons/mrpd/tests/simple/msrp_tests.cpp
+++ b/daemons/mrpd/tests/simple/msrp_tests.cpp
@@ -537,3 +537,58 @@ TEST(MsrpTestGroup, Pruning_Commands_Fail)
LONGS_EQUAL(0, msrp_interesting_id_count());
}
+/*
+ * Listener Asking Failed to Listener Ready transition in the presence of
+ * a rIn! from switch while waiting for a transmit opportunity.
+ */
+TEST(MsrpTestGroup, Listener_State_Transition_With_Rx_rIn)
+{
+ char cmd_string1[] = "S+L:L=" STREAM_ID ",D=1"; /* 1 is Asking Failed */
+ char cmd_string2[] = "S+L:L=" STREAM_ID ",D=2"; /* 2 is Ready */
+ char cmd_string3[] = "S++:S=" STREAM_ID ",A=" STREAM_DA ",V=" VLAN_ID
+ ",Z=" TSPEC_MAX_FRAME_SIZE ",I=" TSPEC_MAX_FRAME_INTERVAL
+ ",P=" PRIORITY_AND_RANK ",L=" ACCUMULATED_LATENCY;
+
+ uint8_t thisStreamID[8] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xBA, 0xDF, 0xCA, 0x11 };
+ struct msrp_attribute *attrib;
+ int rv;
+
+ /* declare Listener Asking Failed */
+ msrp_recv_cmd(cmd_string1, sizeof(cmd_string1), &client);
+ CHECK(msrp_tests_cmd_ok(test_state.ctl_msg_data));
+
+ attrib = msrp_lookup_stream_declaration(MSRP_LISTENER_TYPE, thisStreamID);
+ CHECK(NULL != attrib);
+ CHECK(MSRP_LISTENER_ASKFAILED == attrib->substate);
+
+ /* cause Listener Asking Failed to be sent */
+ msrp_event(MRP_EVENT_TX, NULL);
+ CHECK(1 == test_state.sent_count);
+
+ /* declare Talker stream because this is required before Listener Ready declaration will succeed */
+ msrp_recv_cmd(cmd_string3, sizeof(cmd_string3), &client);
+ CHECK(msrp_tests_cmd_ok(test_state.ctl_msg_data));
+
+ /* declare Listener Ready */
+ msrp_recv_cmd(cmd_string2, sizeof(cmd_string2), &client);
+ CHECK(msrp_tests_cmd_ok(test_state.ctl_msg_data));
+
+ attrib = msrp_lookup_stream_declaration(MSRP_LISTENER_TYPE, thisStreamID);
+ CHECK(NULL != attrib);
+ CHECK(MSRP_LISTENER_READY == attrib->substate);
+
+ /* Rx pdu with Listener Asking Failed in it.
+ * Loop the Tx PDU back into the the Rx PDU path. This won't actually send a rIn!
+ * event, but the effect should be the same.
+ */
+ memcpy(test_state.rx_PDU, test_state.tx_PDU, test_state.tx_PDU_len);
+ test_state.rx_PDU_len = test_state.tx_PDU_len;
+ rv = msrp_recv_msg();
+ LONGS_EQUAL(0, rv);
+
+ /* Check Listener declaration type */
+ attrib = msrp_lookup_stream_declaration(MSRP_LISTENER_TYPE, thisStreamID);
+ CHECK(NULL != attrib);
+ CHECK(MSRP_LISTENER_READY == attrib->substate);
+
+}