@@ -149,6 +149,38 @@ void greentea_teardown(const size_t passed, const size_t failed, const failure_t
149149 return greentea_test_teardown_handler (passed, failed, failure);
150150}
151151
152+ utest::v1::status_t greentea_case_setup_handler_tcp (const Case *const source, const size_t index_of_case)
153+ {
154+ #if MBED_CONF_NSAPI_SOCKET_STATS_ENABLED
155+ int count = fetch_stats ();
156+ for (int j = 0 ; j < count; j++) {
157+ TEST_ASSERT_EQUAL (SOCK_CLOSED, tcp_stats[j].state );
158+ }
159+ #endif
160+ return greentea_case_setup_handler (source, index_of_case);
161+ }
162+
163+ utest::v1::status_t greentea_case_teardown_handler_tcp (const Case *const source, const size_t passed, const size_t failed, const failure_t failure)
164+ {
165+ #if MBED_CONF_NSAPI_SOCKET_STATS_ENABLED
166+ int count = fetch_stats ();
167+ for (int j = 0 ; j < count; j++) {
168+ TEST_ASSERT_EQUAL (SOCK_CLOSED, tcp_stats[j].state );
169+ }
170+ #endif
171+ return greentea_case_teardown_handler (source, passed, failed, failure);
172+ }
173+
174+ static void test_failure_handler (const failure_t failure)
175+ {
176+ UTEST_LOG_FUNCTION ();
177+ if (failure.location == LOCATION_TEST_SETUP || failure.location == LOCATION_TEST_TEARDOWN) {
178+ verbose_test_failure_handler (failure);
179+ GREENTEA_TESTSUITE_RESULT (false );
180+ while (1 ) ;
181+ }
182+ }
183+
152184
153185Case cases[] = {
154186 Case (" TCPSOCKET_ECHOTEST" , TCPSOCKET_ECHOTEST),
@@ -178,7 +210,16 @@ Case cases[] = {
178210 Case (" TCPSOCKET_ENDPOINT_CLOSE" , TCPSOCKET_ENDPOINT_CLOSE),
179211};
180212
181- Specification specification (greentea_setup, cases, greentea_teardown, greentea_continue_handlers);
213+ handlers_t tcp_test_case_handlers = {
214+ default_greentea_test_setup_handler,
215+ greentea_test_teardown_handler,
216+ test_failure_handler,
217+ greentea_case_setup_handler_tcp,
218+ greentea_case_teardown_handler_tcp,
219+ greentea_case_failure_continue_handler
220+ };
221+
222+ Specification specification (greentea_setup, cases, greentea_teardown, tcp_test_case_handlers);
182223
183224int main ()
184225{
0 commit comments