@@ -2064,6 +2064,8 @@ void test_full_zwave_tx_queue()
2064
2064
& test_tx_session_id_2 ));
2065
2065
contiki_test_helper_run (0 );
2066
2066
2067
+
2068
+
2067
2069
for (int i = 1 ; i < ZWAVE_TX_QUEUE_BUFFER_SIZE ; ++ i ) {
2068
2070
TEST_ASSERT_EQUAL (SL_STATUS_OK ,
2069
2071
zwave_tx_send_data (& test_connection_1 ,
@@ -2074,9 +2076,14 @@ void test_full_zwave_tx_queue()
2074
2076
(void * )& my_user_pointer ,
2075
2077
& test_tx_session_id ));
2076
2078
}
2079
+ zwave_tx_session_id_t second_message_id = test_tx_session_id ;
2077
2080
2078
2081
TEST_ASSERT_EQUAL (ZWAVE_TX_QUEUE_BUFFER_SIZE , zwave_tx_get_queue_size ());
2079
2082
2083
+ zwave_controller_transport_abort_send_data_ExpectAndReturn (
2084
+ test_tx_session_id_2 ,
2085
+ SL_STATUS_FAIL );
2086
+
2080
2087
// Now there is no more queue space:
2081
2088
TEST_ASSERT_EQUAL (SL_STATUS_FAIL ,
2082
2089
zwave_tx_send_data (& test_connection_1 ,
@@ -2087,14 +2094,11 @@ void test_full_zwave_tx_queue()
2087
2094
(void * )& my_user_pointer ,
2088
2095
& test_tx_session_id ));
2089
2096
2090
- // Get one free slot
2091
- on_zwave_transport_send_data_complete (TRANSMIT_COMPLETE_OK ,
2092
- NULL ,
2093
- test_tx_session_id_2 );
2094
-
2097
+ // Process events
2095
2098
contiki_test_helper_run (0 );
2096
2099
TEST_ASSERT_EQUAL (1 , send_done_count );
2097
- TEST_ASSERT_EQUAL (TRANSMIT_COMPLETE_OK , send_done_status );
2100
+ TEST_ASSERT_EQUAL (TRANSMIT_COMPLETE_FAIL , send_done_status );
2101
+
2098
2102
2099
2103
// Now queueing should work again:
2100
2104
TEST_ASSERT_EQUAL (SL_STATUS_OK ,
@@ -2106,6 +2110,9 @@ void test_full_zwave_tx_queue()
2106
2110
(void * )& my_user_pointer ,
2107
2111
& test_tx_session_id ));
2108
2112
2113
+ zwave_controller_transport_abort_send_data_ExpectAndReturn (
2114
+ second_message_id ,
2115
+ SL_STATUS_FAIL );
2109
2116
// And now we are full again:
2110
2117
TEST_ASSERT_EQUAL (SL_STATUS_FAIL ,
2111
2118
zwave_tx_send_data (& test_connection_1 ,
@@ -2117,6 +2124,72 @@ void test_full_zwave_tx_queue()
2117
2124
& test_tx_session_id ));
2118
2125
}
2119
2126
2127
+ void test_full_zwave_tx_queue_with_timeouts ()
2128
+ {
2129
+ // We do not care about interactions with the transports for this test.
2130
+ zwave_controller_transport_send_data_IgnoreAndReturn (SL_STATUS_OK );
2131
+
2132
+ // Queue a first element:
2133
+ TEST_ASSERT_EQUAL (SL_STATUS_OK ,
2134
+ zwave_tx_send_data (& test_connection_2 ,
2135
+ sizeof (test_expected_frame_data_2 ),
2136
+ test_expected_frame_data_2 ,
2137
+ & test_tx_options_2 ,
2138
+ send_data_callback ,
2139
+ (void * )& my_user_pointer ,
2140
+ & test_tx_session_id_2 ));
2141
+ contiki_test_helper_run (0 );
2142
+
2143
+
2144
+
2145
+ for (int i = 1 ; i < ZWAVE_TX_QUEUE_BUFFER_SIZE ; ++ i ) {
2146
+ TEST_ASSERT_EQUAL (SL_STATUS_OK ,
2147
+ zwave_tx_send_data (& test_connection_2 ,
2148
+ sizeof (test_expected_frame_data_2 ),
2149
+ test_expected_frame_data_2 ,
2150
+ & test_tx_options_2 ,
2151
+ send_data_callback ,
2152
+ (void * )& my_user_pointer ,
2153
+ & test_tx_session_id ));
2154
+ }
2155
+ //zwave_tx_session_id_t second_message_id = test_tx_session_id;
2156
+
2157
+ TEST_ASSERT_EQUAL (ZWAVE_TX_QUEUE_BUFFER_SIZE , zwave_tx_get_queue_size ());
2158
+
2159
+ zwave_controller_transport_abort_send_data_ExpectAndReturn (
2160
+ test_tx_session_id_2 ,
2161
+ SL_STATUS_FAIL );
2162
+
2163
+ // Now there is no more queue space:
2164
+ TEST_ASSERT_EQUAL (SL_STATUS_FAIL ,
2165
+ zwave_tx_send_data (& test_connection_1 ,
2166
+ sizeof (test_expected_frame_data_1 ),
2167
+ test_expected_frame_data_1 ,
2168
+ & test_tx_options_1 ,
2169
+ send_data_callback ,
2170
+ (void * )& my_user_pointer ,
2171
+ & test_tx_session_id ));
2172
+
2173
+ // Process events
2174
+ contiki_test_helper_run (1000 );
2175
+ TEST_ASSERT_EQUAL (ZWAVE_TX_QUEUE_BUFFER_SIZE , send_done_count );
2176
+ TEST_ASSERT_EQUAL (TRANSMIT_COMPLETE_FAIL , send_done_status );
2177
+
2178
+
2179
+ // Now queueing should work again:
2180
+ for (int i = 1 ; i < ZWAVE_TX_QUEUE_BUFFER_SIZE ; ++ i ) {
2181
+ TEST_ASSERT_EQUAL (SL_STATUS_OK ,
2182
+ zwave_tx_send_data (& test_connection_2 ,
2183
+ sizeof (test_expected_frame_data_2 ),
2184
+ test_expected_frame_data_2 ,
2185
+ & test_tx_options_2 ,
2186
+ send_data_callback ,
2187
+ (void * )& my_user_pointer ,
2188
+ & test_tx_session_id ));
2189
+ }
2190
+ }
2191
+
2192
+
2120
2193
void test_additional_back_off ()
2121
2194
{
2122
2195
zwave_node_id_t chatty_node_id = 23 ;
0 commit comments