aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDave Wallace <dwallacelf@gmail.com>2019-09-19 20:38:44 +0000
committerDave Barach <openvpp@barachs.net>2019-09-20 13:49:44 +0000
commit0e402a98b20fbb7c5b715abd038c244c539bad36 (patch)
treebbf21f8c1f7bae497fb7e2aabaa77224a4fdff44 /src
parent4e323cbdbd57fcd77db68e295f639288441ef3e3 (diff)
hsa: refactor vpp_echo failure handling
- Return unique value for each failure condition - Last failure value returned - All failures included in description - Output failure value and description Type: test Signed-off-by: Dave Wallace <dwallacelf@gmail.com> Change-Id: I72d5e7f660ad4765c468874421622607af6ae3d1 Signed-off-by: Dave Wallace <dwallacelf@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/hs_apps/sapi/vpp_echo.c135
-rw-r--r--src/plugins/hs_apps/sapi/vpp_echo_bapi.c51
-rw-r--r--src/plugins/hs_apps/sapi/vpp_echo_common.c9
-rw-r--r--src/plugins/hs_apps/sapi/vpp_echo_common.h104
-rw-r--r--src/plugins/hs_apps/sapi/vpp_echo_proto_quic.c6
-rw-r--r--src/plugins/hs_apps/sapi/vpp_echo_proto_tcp.c3
-rw-r--r--src/plugins/hs_apps/sapi/vpp_echo_proto_udp.c3
7 files changed, 214 insertions, 97 deletions
diff --git a/src/plugins/hs_apps/sapi/vpp_echo.c b/src/plugins/hs_apps/sapi/vpp_echo.c
index 99a443a35b3..93495587423 100644
--- a/src/plugins/hs_apps/sapi/vpp_echo.c
+++ b/src/plugins/hs_apps/sapi/vpp_echo.c
@@ -42,12 +42,15 @@ echo_session_prealloc (echo_main_t * em)
static void
echo_assert_test_suceeded (echo_main_t * em)
{
- CHECK (em->n_clients * em->bytes_to_receive,
- em->stats.rx_total, "Not enough data received");
- CHECK (em->n_clients * em->bytes_to_send,
- em->stats.tx_total, "Not enough data sent");
+ CHECK (ECHO_FAIL_TEST_ASSERT_RX_TOTAL,
+ em->n_clients * em->bytes_to_receive, em->stats.rx_total,
+ "Invalid amount of data received");
+ CHECK (ECHO_FAIL_TEST_ASSERT_TX_TOTAL,
+ em->n_clients * em->bytes_to_send, em->stats.tx_total,
+ "Invalid amount of data sent");
clib_spinlock_lock (&em->sid_vpp_handles_lock);
- CHECK (0, hash_elts (em->session_index_by_vpp_handles),
+ CHECK (ECHO_FAIL_TEST_ASSERT_ALL_SESSIONS_CLOSED,
+ 0, hash_elts (em->session_index_by_vpp_handles),
"Some sessions are still open");
clib_spinlock_unlock (&em->sid_vpp_handles_lock);
}
@@ -61,7 +64,8 @@ echo_session_dequeue_notify (echo_session_t * s)
if ((rv =
app_send_io_evt_to_vpp (s->vpp_evt_q, s->rx_fifo->master_session_index,
SESSION_IO_EVT_RX, SVM_Q_WAIT)))
- ECHO_FAIL ("app_send_io_evt_to_vpp errored %d", rv);
+ ECHO_FAIL (ECHO_FAIL_SEND_IO_EVT, "app_send_io_evt_to_vpp errored %d",
+ rv);
svm_fifo_clear_deq_ntf (s->rx_fifo);
}
@@ -83,13 +87,13 @@ connect_to_vpp (char *name)
if (vl_socket_client_connect ((char *) em->socket_name, name,
0 /* default rx, tx buffer */ ))
{
- ECHO_FAIL ("socket connect failed");
+ ECHO_FAIL (ECHO_FAIL_SOCKET_CONNECT, "socket connect failed");
return -1;
}
if (vl_socket_client_init_shm (0, 1 /* want_pthread */ ))
{
- ECHO_FAIL ("init shm api failed");
+ ECHO_FAIL (ECHO_FAIL_INIT_SHM_API, "init shm api failed");
return -1;
}
}
@@ -97,7 +101,7 @@ connect_to_vpp (char *name)
{
if (vl_client_connect_to_vlib ("/vpe-api", name, 32) < 0)
{
- ECHO_FAIL ("shmem connect failed");
+ ECHO_FAIL (ECHO_FAIL_SHMEM_CONNECT, "shmem connect failed");
return -1;
}
}
@@ -107,15 +111,6 @@ connect_to_vpp (char *name)
}
static void
-echo_event_didnt_happen (u8 e)
-{
- echo_main_t *em = &echo_main;
- u8 *s = format (0, "%U", echo_format_timing_event, e);
- ECHO_LOG (0, "Expected event %s to happen, but it did not!", s);
- em->has_failed = 1;
-}
-
-static void
print_global_json_stats (echo_main_t * em)
{
u8 *start_evt =
@@ -128,9 +123,13 @@ print_global_json_stats (echo_main_t * em)
em->timing.end_time - em->timing.start_time;
if (start_evt_missing)
- echo_event_didnt_happen (em->timing.start_event);
+ ECHO_FAIL (ECHO_FAIL_MISSING_START_EVENT,
+ "Expected event %s to happen, but it did not!", start_evt);
+
if (end_evt_missing)
- echo_event_didnt_happen (em->timing.end_event);
+ ECHO_FAIL (ECHO_FAIL_MISSING_END_EVENT,
+ "Expected event %s to happen, but it did not!", end_evt);
+
fformat (stdout, "vpp_echo JSON stats:\n{\n");
fformat (stdout, " \"role\": \"%s\",\n",
em->i_am_master ? "server" : "client");
@@ -153,33 +152,41 @@ print_global_json_stats (echo_main_t * em)
fformat (stdout, " \"clean\": { \"q\": %d, \"s\": %d }\n",
em->stats.clean_count.q, em->stats.clean_count.s);
fformat (stdout, " }\n");
+ fformat (stdout, " \"results\": {\n");
+ fformat (stdout, " \"has_failed\": \"%d\"\n", em->has_failed);
+ fformat (stdout, " \"fail_descr\": \"%v\"\n", em->fail_descr);
+ fformat (stdout, " }\n");
fformat (stdout, "}\n");
fflush (stdout);
+ vec_free (start_evt);
+ vec_free (end_evt);
}
static void
print_global_stats (echo_main_t * em)
{
- u8 *s;
+ u8 *start_evt =
+ format (0, "%U", echo_format_timing_event, em->timing.start_event);
+ u8 *end_evt =
+ format (0, "%U", echo_format_timing_event, em->timing.end_event);
u8 start_evt_missing = !(em->timing.events_sent & em->timing.start_event);
u8 end_evt_missing = !(em->timing.events_sent & em->timing.end_event);
f64 deltat = start_evt_missing || end_evt_missing ? 0 :
em->timing.end_time - em->timing.start_time;
if (start_evt_missing)
- echo_event_didnt_happen (em->timing.start_event);
+ ECHO_FAIL (ECHO_FAIL_MISSING_START_EVENT,
+ "Expected event %s to happen, but it did not!", start_evt);
+
if (end_evt_missing)
- echo_event_didnt_happen (em->timing.end_event);
- s = format (0, "%U:%U",
- echo_format_timing_event, em->timing.start_event,
- echo_format_timing_event, em->timing.end_event);
- fformat (stdout, "Timing %v\n", s);
+ ECHO_FAIL (ECHO_FAIL_MISSING_END_EVENT,
+ "Expected event %s to happen, but it did not!", end_evt);
+
+ fformat (stdout, "Timing %s:%s\n", start_evt, end_evt);
if (start_evt_missing)
- fformat (stdout, "Missing Start Timing Event (%U)!\n",
- echo_format_timing_event, em->timing.start_event);
+ fformat (stdout, "Missing Start Timing Event (%s)!\n", start_evt);
if (end_evt_missing)
- fformat (stdout, "Missing End Timing Event (%U)!\n",
- echo_format_timing_event, em->timing.end_event);
+ fformat (stdout, "Missing End Timing Event (%s)!\n", end_evt);
fformat (stdout, "-------- TX --------\n");
fformat (stdout, "%lld bytes (%lld mbytes, %lld gbytes) in %.6f seconds\n",
em->stats.tx_total, em->stats.tx_total / (1ULL << 20),
@@ -203,6 +210,11 @@ print_global_stats (echo_main_t * em)
em->stats.active_count.s, em->stats.active_count.q);
fformat (stdout, "Discarded %d streams (and %d Quic conn)\n",
em->stats.clean_count.s, em->stats.clean_count.q);
+ if (em->has_failed)
+ fformat (stdout, "\nFailure Return Status: %d\n%v", em->has_failed,
+ em->fail_descr);
+ vec_free (start_evt);
+ vec_free (end_evt);
}
void
@@ -264,7 +276,7 @@ test_recv_bytes (echo_main_t * em, echo_session_t * s, u8 * rx_buf,
if (em->max_test_msg == 0)
ECHO_LOG (0, "Too many errors, hiding next ones");
if (em->test_return_packets == RETURN_PACKETS_ASSERT)
- ECHO_FAIL ("test-bytes errored");
+ ECHO_FAIL (ECHO_FAIL_TEST_BYTES_ERR, "test-bytes errored");
}
}
@@ -444,7 +456,7 @@ session_bound_handler (session_bound_msg_t * mp)
echo_session_t *listen_session;
if (mp->retval)
{
- ECHO_FAIL ("bind failed: %U", format_api_error,
+ ECHO_FAIL (ECHO_FAIL_BIND, "bind failed: %U", format_api_error,
clib_net_to_host_u32 (mp->retval));
return;
}
@@ -476,7 +488,8 @@ session_accepted_handler (session_accepted_msg_t * mp)
if (wait_for_segment_allocation (mp->segment_handle))
{
- ECHO_FAIL ("wait_for_segment_allocation errored");
+ ECHO_FAIL (ECHO_FAIL_ACCEPTED_WAIT_FOR_SEG_ALLOC,
+ "accepted wait_for_segment_allocation errored");
return;
}
@@ -529,7 +542,8 @@ session_connected_handler (session_connected_msg_t * mp)
if (mp->retval)
{
- ECHO_FAIL ("connection failed with code: %U", format_api_error,
+ ECHO_FAIL (ECHO_FAIL_SESSION_CONNECT,
+ "connection failed with code: %U", format_api_error,
clib_net_to_host_u32 (mp->retval));
return;
}
@@ -537,7 +551,8 @@ session_connected_handler (session_connected_msg_t * mp)
session = echo_session_new (em);
if (wait_for_segment_allocation (mp->segment_handle))
{
- ECHO_FAIL ("wait_for_segment_allocation errored");
+ ECHO_FAIL (ECHO_FAIL_CONNECTED_WAIT_FOR_SEG_ALLOC,
+ "connected wait_for_segment_allocation errored");
return;
}
@@ -667,7 +682,7 @@ echo_mq_thread_fn (void *arg)
wait_for_state_change (em, STATE_ATTACHED, 0);
if (em->state < STATE_ATTACHED || !em->our_event_queue)
{
- ECHO_FAIL ("Application failed to attach");
+ ECHO_FAIL (ECHO_FAIL_APP_ATTACH, "Application failed to attach");
pthread_exit (0);
}
@@ -710,7 +725,8 @@ server_run (echo_main_t * em)
echo_send_unbind (em);
if (wait_for_state_change (em, STATE_DISCONNECTED, TIMEOUT))
{
- ECHO_FAIL ("Timeout waiting for state disconnected");
+ ECHO_FAIL (ECHO_FAIL_SERVER_DISCONNECT_TIMEOUT,
+ "Timeout waiting for state disconnected");
return;
}
}
@@ -915,7 +931,7 @@ echo_process_uri (echo_main_t * em)
&em->uri_elts.ip.ip6, &port))
em->uri_elts.is_ip4 = 0;
else
- ECHO_FAIL ("Unable to process uri");
+ ECHO_FAIL (ECHO_FAIL_INVALID_URI, "Unable to process uri");
em->uri_elts.port = clib_host_to_net_u16 (port);
unformat_free (input);
}
@@ -968,9 +984,10 @@ main (int argc, char **argv)
em->proto_cb_vft = em->available_proto_cb_vft[em->uri_elts.transport_proto];
if (!em->proto_cb_vft)
{
- ECHO_FAIL ("Protocol %U is not supported",
+ ECHO_FAIL (ECHO_FAIL_PROTOCOL_NOT_SUPPORTED,
+ "Protocol %U is not supported",
format_transport_proto, em->uri_elts.transport_proto);
- exit (1);
+ goto exit_on_error;
}
if (em->proto_cb_vft->set_defaults_after_opts_cb)
em->proto_cb_vft->set_defaults_after_opts_cb ();
@@ -1006,8 +1023,8 @@ main (int argc, char **argv)
if (connect_to_vpp (app_name))
{
svm_region_exit ();
- ECHO_FAIL ("Couldn't connect to vpe, exiting...\n");
- exit (1);
+ ECHO_FAIL (ECHO_FAIL_CONNECT_TO_VPP, "Couldn't connect to vpp");
+ goto exit_on_error;
}
echo_session_prealloc (em);
@@ -1016,51 +1033,55 @@ main (int argc, char **argv)
echo_send_attach (em);
if (wait_for_state_change (em, STATE_ATTACHED, TIMEOUT))
{
- ECHO_FAIL ("Couldn't attach to vpp, did you run <session enable> ?\n");
- exit (1);
+ ECHO_FAIL (ECHO_FAIL_ATTACH_TO_VPP,
+ "Couldn't attach to vpp, did you run <session enable> ?");
+ goto exit_on_error;
}
if (pthread_create (&em->mq_thread_handle,
NULL /*attr */ , echo_mq_thread_fn, 0))
{
- ECHO_FAIL ("pthread create errored\n");
- exit (1);
+ ECHO_FAIL (ECHO_FAIL_PTHREAD_CREATE, "pthread create errored");
+ goto exit_on_error;
}
for (i = 0; i < em->n_rx_threads; i++)
if (pthread_create (&em->data_thread_handles[i],
NULL /*attr */ , echo_data_thread_fn, (void *) i))
{
- ECHO_FAIL ("pthread create errored\n");
- exit (1);
+ ECHO_FAIL (ECHO_FAIL_PTHREAD_CREATE,
+ "pthread create errored (index %d)", i);
+ goto exit_on_error;
}
if (em->i_am_master)
server_run (em);
else
clients_run (em);
echo_notify_event (em, ECHO_EVT_EXIT);
- if (em->output_json)
- print_global_json_stats (em);
- else
- print_global_stats (em);
echo_free_sessions (em);
echo_assert_test_suceeded (em);
echo_send_detach (em);
if (wait_for_state_change (em, STATE_DETACHED, TIMEOUT))
{
- ECHO_FAIL ("ECHO-ERROR: Couldn't detach from vpp, exiting...\n");
- exit (1);
+ ECHO_FAIL (ECHO_FAIL_DETACH, "Couldn't detach from vpp");
+ goto exit_on_error;
}
int *rv;
pthread_join (em->mq_thread_handle, (void **) &rv);
if (rv)
{
- ECHO_FAIL ("mq pthread errored %d", rv);
- exit (1);
+ ECHO_FAIL (ECHO_FAIL_MQ_PTHREAD, "mq pthread errored %d", rv);
+ goto exit_on_error;
}
if (em->use_sock_api)
vl_socket_client_disconnect ();
else
vl_client_disconnect_from_vlib ();
+exit_on_error:
ECHO_LOG (0, "Test complete !\n");
+ if (em->output_json)
+ print_global_json_stats (em);
+ else
+ print_global_stats (em);
+ vec_free (em->fail_descr);
exit (em->has_failed);
}
diff --git a/src/plugins/hs_apps/sapi/vpp_echo_bapi.c b/src/plugins/hs_apps/sapi/vpp_echo_bapi.c
index dafcd8a42b6..6a958cb59d6 100644
--- a/src/plugins/hs_apps/sapi/vpp_echo_bapi.c
+++ b/src/plugins/hs_apps/sapi/vpp_echo_bapi.c
@@ -199,14 +199,15 @@ vl_api_application_attach_reply_t_handler (vl_api_application_attach_reply_t *
if (mp->retval)
{
- ECHO_FAIL ("attach failed: %U", format_api_error,
- clib_net_to_host_u32 (mp->retval));
+ ECHO_FAIL (ECHO_FAIL_VL_API_APP_ATTACH, "attach failed: %U",
+ format_api_error, clib_net_to_host_u32 (mp->retval));
return;
}
if (mp->segment_name_length == 0)
{
- ECHO_FAIL ("segment_name_length zero");
+ ECHO_FAIL (ECHO_FAIL_VL_API_MISSING_SEGMENT_NAME,
+ "segment_name_length zero");
return;
}
@@ -219,14 +220,16 @@ vl_api_application_attach_reply_t_handler (vl_api_application_attach_reply_t *
vec_validate (fds, mp->n_fds);
if (vl_socket_client_recv_fd_msg (fds, mp->n_fds, 5))
{
- ECHO_FAIL ("vl_socket_client_recv_fd_msg failed");
+ ECHO_FAIL (ECHO_FAIL_VL_API_RECV_FD_MSG,
+ "vl_socket_client_recv_fd_msg failed");
goto failed;
}
if (mp->fd_flags & SESSION_FD_F_VPP_MQ_SEGMENT)
if (ssvm_segment_attach (0, SSVM_SEGMENT_MEMFD, fds[n_fds++]))
{
- ECHO_FAIL ("svm_fifo_segment_attach failed");
+ ECHO_FAIL (ECHO_FAIL_VL_API_SVM_FIFO_SEG_ATTACH,
+ "svm_fifo_segment_attach failed on SSVM_SEGMENT_MEMFD");
goto failed;
}
@@ -234,8 +237,9 @@ vl_api_application_attach_reply_t_handler (vl_api_application_attach_reply_t *
if (ssvm_segment_attach ((char *) mp->segment_name,
SSVM_SEGMENT_MEMFD, fds[n_fds++]))
{
- ECHO_FAIL ("svm_fifo_segment_attach ('%s') failed",
- mp->segment_name);
+ ECHO_FAIL (ECHO_FAIL_VL_API_SVM_FIFO_SEG_ATTACH,
+ "svm_fifo_segment_attach ('%s') "
+ "failed on SSVM_SEGMENT_MEMFD", mp->segment_name);
goto failed;
}
if (mp->fd_flags & SESSION_FD_F_MQ_EVENTFD)
@@ -248,8 +252,9 @@ vl_api_application_attach_reply_t_handler (vl_api_application_attach_reply_t *
if (ssvm_segment_attach ((char *) mp->segment_name, SSVM_SEGMENT_SHM,
-1))
{
- ECHO_FAIL ("svm_fifo_segment_attach ('%s') failed",
- mp->segment_name);
+ ECHO_FAIL (ECHO_FAIL_VL_API_SVM_FIFO_SEG_ATTACH,
+ "svm_fifo_segment_attach ('%s') "
+ "failed on SSVM_SEGMENT_SHM", mp->segment_name);
return;
}
}
@@ -270,7 +275,8 @@ vl_api_application_detach_reply_t_handler (vl_api_application_detach_reply_t *
{
if (mp->retval)
{
- ECHO_FAIL ("detach returned with err: %d", mp->retval);
+ ECHO_FAIL (ECHO_FAIL_VL_API_DETACH_REPLY,
+ "app detach returned with err: %d", mp->retval);
return;
}
echo_main.state = STATE_DETACHED;
@@ -301,13 +307,15 @@ vl_api_map_another_segment_t_handler (vl_api_map_another_segment_t * mp)
vec_validate (fds, 1);
if (vl_socket_client_recv_fd_msg (fds, 1, 5))
{
- ECHO_FAIL ("vl_socket_client_recv_fd_msg failed");
+ ECHO_FAIL (ECHO_FAIL_VL_API_RECV_FD_MSG,
+ "vl_socket_client_recv_fd_msg failed");
goto failed;
}
if (ssvm_segment_attach (seg_name, SSVM_SEGMENT_MEMFD, fds[0]))
{
- ECHO_FAIL ("svm_fifo_segment_attach ('%s')"
+ ECHO_FAIL (ECHO_FAIL_VL_API_SVM_FIFO_SEG_ATTACH,
+ "svm_fifo_segment_attach ('%s') "
"failed on SSVM_SEGMENT_MEMFD", seg_name);
goto failed;
}
@@ -321,7 +329,8 @@ vl_api_map_another_segment_t_handler (vl_api_map_another_segment_t * mp)
/* Attach to the segment vpp created */
if (fifo_segment_attach (sm, a))
{
- ECHO_FAIL ("svm_fifo_segment_attach ('%s') failed", seg_name);
+ ECHO_FAIL (ECHO_FAIL_VL_API_FIFO_SEG_ATTACH,
+ "fifo_segment_attach ('%s') failed", seg_name);
goto failed;
}
}
@@ -340,8 +349,8 @@ vl_api_bind_uri_reply_t_handler (vl_api_bind_uri_reply_t * mp)
{
if (mp->retval)
{
- ECHO_FAIL ("bind failed: %U", format_api_error,
- clib_net_to_host_u32 (mp->retval));
+ ECHO_FAIL (ECHO_FAIL_VL_API_BIND_URI_REPLY, "bind failed: %U",
+ format_api_error, clib_net_to_host_u32 (mp->retval));
}
}
@@ -352,7 +361,8 @@ vl_api_unbind_uri_reply_t_handler (vl_api_unbind_uri_reply_t * mp)
echo_main_t *em = &echo_main;
if (mp->retval != 0)
{
- ECHO_FAIL ("returned %d", ntohl (mp->retval));
+ ECHO_FAIL (ECHO_FAIL_VL_API_UNBIND_REPLY, "unbind_uri returned %d",
+ ntohl (mp->retval));
return;
}
listen_session = pool_elt_at_index (em->sessions, em->listen_session_index);
@@ -369,7 +379,8 @@ vl_api_disconnect_session_reply_t_handler (vl_api_disconnect_session_reply_t *
if (mp->retval)
{
- ECHO_FAIL ("vpp complained about disconnect: %d", ntohl (mp->retval));
+ ECHO_FAIL (ECHO_FAIL_VL_API_DISCONNECT_SESSION_REPLY,
+ "vpp complained about disconnect: %d", ntohl (mp->retval));
return;
}
@@ -384,7 +395,8 @@ static void
(vl_api_application_tls_cert_add_reply_t * mp)
{
if (mp->retval)
- ECHO_FAIL ("failed to add tls cert");
+ ECHO_FAIL (ECHO_FAIL_VL_API_TLS_CERT_ADD_REPLY,
+ "failed to add application tls cert");
}
static void
@@ -392,7 +404,8 @@ static void
(vl_api_application_tls_key_add_reply_t * mp)
{
if (mp->retval)
- ECHO_FAIL ("failed to add tls key");
+ ECHO_FAIL (ECHO_FAIL_VL_API_TLS_KEY_ADD_REPLY,
+ "failed to add application tls key");
}
static void
diff --git a/src/plugins/hs_apps/sapi/vpp_echo_common.c b/src/plugins/hs_apps/sapi/vpp_echo_common.c
index 013affd0420..03ed278d497 100644
--- a/src/plugins/hs_apps/sapi/vpp_echo_common.c
+++ b/src/plugins/hs_apps/sapi/vpp_echo_common.c
@@ -18,6 +18,12 @@
#include <hs_apps/sapi/vpp_echo_common.h>
+char *echo_fail_code_str[] = {
+#define _(sym, str) str,
+ foreach_echo_fail_code
+#undef _
+};
+
/*
*
* Format functions
@@ -487,7 +493,8 @@ echo_get_session_from_handle (echo_main_t * em, u64 handle)
clib_spinlock_unlock (&em->sid_vpp_handles_lock);
if (!p)
{
- ECHO_FAIL ("unknown handle 0x%lx", handle);
+ ECHO_FAIL (ECHO_FAIL_GET_SESSION_FROM_HANDLE,
+ "unknown handle 0x%lx", handle);
return 0;
}
return pool_elt_at_index (em->sessions, p[0]);
diff --git a/src/plugins/hs_apps/sapi/vpp_echo_common.h b/src/plugins/hs_apps/sapi/vpp_echo_common.h
index 2f9d3912bb7..17a39732a2d 100644
--- a/src/plugins/hs_apps/sapi/vpp_echo_common.h
+++ b/src/plugins/hs_apps/sapi/vpp_echo_common.h
@@ -37,17 +37,88 @@
#define TIMEOUT 10.0
-#define CHECK(expected, result, _fmt, _args...) \
- if (expected != result) \
- ECHO_FAIL ("expected %d, got %d : " _fmt, expected, result, ##_args);
+#define foreach_echo_fail_code \
+ _(ECHO_FAIL_NONE, "ECHO_FAIL_NONE") \
+ _(ECHO_FAIL_SEND_IO_EVT, "ECHO_FAIL_SEND_IO_EVT") \
+ _(ECHO_FAIL_SOCKET_CONNECT, "ECHO_FAIL_SOCKET_CONNECT") \
+ _(ECHO_FAIL_INIT_SHM_API, "ECHO_FAIL_INIT_SHM_API") \
+ _(ECHO_FAIL_SHMEM_CONNECT, "ECHO_FAIL_SHMEM_CONNECT") \
+ _(ECHO_FAIL_TEST_BYTES_ERR, "ECHO_FAIL_TEST_BYTES_ERR") \
+ _(ECHO_FAIL_BIND, "ECHO_FAIL_BIND") \
+ _(ECHO_FAIL_ACCEPTED_WAIT_FOR_SEG_ALLOC, \
+ "ECHO_FAIL_ACCEPTED_WAIT_FOR_SEG_ALLOC") \
+ _(ECHO_FAIL_SESSION_CONNECT, "ECHO_FAIL_SESSION_CONNECT") \
+ _(ECHO_FAIL_CONNECTED_WAIT_FOR_SEG_ALLOC, \
+ "ECHO_FAIL_CONNECTED_WAIT_FOR_SEG_ALLOC") \
+ _(ECHO_FAIL_APP_ATTACH, "ECHO_FAIL_APP_ATTACH") \
+ _(ECHO_FAIL_SERVER_DISCONNECT_TIMEOUT, \
+ "ECHO_FAIL_SERVER_DISCONNECT_TIMEOUT") \
+ _(ECHO_FAIL_INVALID_URI, "ECHO_FAIL_INVALID_URI") \
+ _(ECHO_FAIL_PROTOCOL_NOT_SUPPORTED, \
+ "ECHO_FAIL_PROTOCOL_NOT_SUPPORTED") \
+ _(ECHO_FAIL_CONNECT_TO_VPP, "ECHO_FAIL_CONNECT_TO_VPP") \
+ _(ECHO_FAIL_ATTACH_TO_VPP, "ECHO_FAIL_ATTACH_TO_VPP") \
+ _(ECHO_FAIL_1ST_PTHREAD_CREATE, "ECHO_FAIL_1ST_PTHREAD_CREATE") \
+ _(ECHO_FAIL_PTHREAD_CREATE, "ECHO_FAIL_PTHREAD_CREATE") \
+ _(ECHO_FAIL_DETACH, "ECHO_FAIL_DETACH") \
+ _(ECHO_FAIL_MQ_PTHREAD, "ECHO_FAIL_MQ_PTHREAD") \
+ _(ECHO_FAIL_VL_API_APP_ATTACH, "ECHO_FAIL_VL_API_APP_ATTACH") \
+ _(ECHO_FAIL_VL_API_MISSING_SEGMENT_NAME, \
+ "ECHO_FAIL_VL_API_MISSING_SEGMENT_NAME") \
+ _(ECHO_FAIL_VL_API_RECV_FD_MSG, "ECHO_FAIL_VL_API_RECV_FD_MSG") \
+ _(ECHO_FAIL_VL_API_SVM_FIFO_SEG_ATTACH, \
+ "ECHO_FAIL_VL_API_SVM_FIFO_SEG_ATTACH") \
+ _(ECHO_FAIL_VL_API_FIFO_SEG_ATTACH, \
+ "ECHO_FAIL_VL_API_FIFO_SEG_ATTACH") \
+ _(ECHO_FAIL_VL_API_DETACH_REPLY, "ECHO_FAIL_VL_API_DETACH_REPLY") \
+ _(ECHO_FAIL_VL_API_BIND_URI_REPLY, "ECHO_FAIL_VL_API_BIND_URI_REPLY") \
+ _(ECHO_FAIL_VL_API_UNBIND_REPLY, "ECHO_FAIL_VL_API_UNBIND_REPLY") \
+ _(ECHO_FAIL_VL_API_DISCONNECT_SESSION_REPLY, \
+ "ECHO_FAIL_VL_API_DISCONNECT_SESSION_REPLY") \
+ _(ECHO_FAIL_VL_API_TLS_CERT_ADD_REPLY, \
+ "ECHO_FAIL_VL_API_TLS_CERT_ADD_REPLY") \
+ _(ECHO_FAIL_VL_API_TLS_KEY_ADD_REPLY, \
+ "ECHO_FAIL_VL_API_TLS_KEY_ADD_REPLY") \
+ _(ECHO_FAIL_GET_SESSION_FROM_HANDLE, \
+ "ECHO_FAIL_GET_SESSION_FROM_HANDLE") \
+ _(ECHO_FAIL_QUIC_WRONG_CONNECT, "ECHO_FAIL_QUIC_WRONG_CONNECT") \
+ _(ECHO_FAIL_QUIC_WRONG_ACCEPT, "ECHO_FAIL_QUIC_WRONG_ACCEPT") \
+ _(ECHO_FAIL_TCP_BAPI_CONNECT, "ECHO_FAIL_TCP_BAPI_CONNECT") \
+ _(ECHO_FAIL_UDP_BAPI_CONNECT, "ECHO_FAIL_UDP_BAPI_CONNECT") \
+ _(ECHO_FAIL_MISSING_START_EVENT, "ECHO_FAIL_MISSING_START_EVENT") \
+ _(ECHO_FAIL_MISSING_END_EVENT, "ECHO_FAIL_MISSING_END_EVENT") \
+ _(ECHO_FAIL_TEST_ASSERT_RX_TOTAL, "ECHO_FAIL_TEST_ASSERT_RX_TOTAL") \
+ _(ECHO_FAIL_TEST_ASSERT_TX_TOTAL, "ECHO_FAIL_TEST_ASSERT_TX_TOTAL") \
+ _(ECHO_FAIL_TEST_ASSERT_ALL_SESSIONS_CLOSED, \
+ "ECHO_FAIL_TEST_ASSERT_ALL_SESSIONS_CLOSED")
-#define ECHO_FAIL(_fmt,_args...) \
- { \
- echo_main_t *em = &echo_main; \
- em->has_failed = 1; \
- em->time_to_stop = 1; \
- if (em->log_lvl > 0) \
- clib_warning ("ECHO-ERROR: "_fmt, ##_args); \
+typedef enum
+{
+#define _(sym, str) sym,
+ foreach_echo_fail_code
+#undef _
+} echo_fail_t;
+
+extern char *echo_fail_code_str[];
+
+#define CHECK(fail, expected, result, _fmt, _args...) \
+ if (expected != result) \
+ ECHO_FAIL (fail, "expected %d, got %d : " _fmt, expected, \
+ result, ##_args); \
+
+#define ECHO_FAIL(fail, _fmt, _args...) \
+ { \
+ echo_main_t *em = &echo_main; \
+ em->has_failed = fail; \
+ if (vec_len(em->fail_descr)) \
+ em->fail_descr = format(em->fail_descr, " | %s (%d): "_fmt, \
+ echo_fail_code_str[fail], fail, ##_args); \
+ else \
+ em->fail_descr = format(0, "%s (%d): "_fmt, \
+ echo_fail_code_str[fail], fail, ##_args); \
+ em->time_to_stop = 1; \
+ if (em->log_lvl > 0) \
+ clib_warning ("%v", em->fail_descr); \
}
#define ECHO_LOG(lvl, _fmt,_args...) \
@@ -57,12 +128,12 @@
clib_warning (_fmt, ##_args); \
}
-#define ECHO_REGISTER_PROTO(proto, vft) \
- static void __clib_constructor \
- vpp_echo_init_##proto () \
- { \
- echo_main_t *em = &echo_main; \
- em->available_proto_cb_vft[proto] = &vft; \
+#define ECHO_REGISTER_PROTO(proto, vft) \
+ static void __clib_constructor \
+ vpp_echo_init_##proto () \
+ { \
+ echo_main_t *em = &echo_main; \
+ em->available_proto_cb_vft[proto] = &vft; \
}
typedef struct
@@ -197,6 +268,7 @@ typedef struct
volatile connection_state_t state;
volatile u8 time_to_stop; /* Signal variables */
u8 has_failed; /* stores the exit code */
+ u8 *fail_descr; /* vector containing fail description */
/** Flag that decides if socket, instead of svm, api is used to connect to
* vpp. If sock api is used, shm binary api is subsequently bootstrapped
diff --git a/src/plugins/hs_apps/sapi/vpp_echo_proto_quic.c b/src/plugins/hs_apps/sapi/vpp_echo_proto_quic.c
index 01812bdf7cb..5ffa7a7c70e 100644
--- a/src/plugins/hs_apps/sapi/vpp_echo_proto_quic.c
+++ b/src/plugins/hs_apps/sapi/vpp_echo_proto_quic.c
@@ -83,7 +83,8 @@ quic_echo_on_connected_send (session_connected_msg_t * mp, u32 session_index)
static void
quic_echo_on_connected_error (session_connected_msg_t * mp, u32 session_index)
{
- ECHO_FAIL ("Got a wrong connected on session %u [%lx]", session_index,
+ ECHO_FAIL (ECHO_FAIL_QUIC_WRONG_CONNECT,
+ "Got a wrong connected on session %u [%lx]", session_index,
mp->handle);
}
@@ -118,7 +119,8 @@ quic_echo_on_accept_connect (session_accepted_msg_t * mp, u32 session_index)
static void
quic_echo_on_accept_error (session_accepted_msg_t * mp, u32 session_index)
{
- ECHO_FAIL ("Got a wrong accept on session %u [%lx]", session_index,
+ ECHO_FAIL (ECHO_FAIL_QUIC_WRONG_ACCEPT,
+ "Got a wrong accept on session %u [%lx]", session_index,
mp->handle);
}
diff --git a/src/plugins/hs_apps/sapi/vpp_echo_proto_tcp.c b/src/plugins/hs_apps/sapi/vpp_echo_proto_tcp.c
index 51144d34889..c68ffafbac6 100644
--- a/src/plugins/hs_apps/sapi/vpp_echo_proto_tcp.c
+++ b/src/plugins/hs_apps/sapi/vpp_echo_proto_tcp.c
@@ -48,7 +48,8 @@ tcp_echo_connected_cb (session_connected_bundled_msg_t * mp,
echo_session_t *session = pool_elt_at_index (em->sessions, session_index);
if (is_failed)
{
- ECHO_FAIL ("Bapi connect errored");
+ ECHO_FAIL (ECHO_FAIL_TCP_BAPI_CONNECT,
+ "Bapi connect errored on session %u", session_index);
return; /* Dont handle bapi connect errors for now */
}
diff --git a/src/plugins/hs_apps/sapi/vpp_echo_proto_udp.c b/src/plugins/hs_apps/sapi/vpp_echo_proto_udp.c
index fd07597e0a5..357d3e08022 100644
--- a/src/plugins/hs_apps/sapi/vpp_echo_proto_udp.c
+++ b/src/plugins/hs_apps/sapi/vpp_echo_proto_udp.c
@@ -47,7 +47,8 @@ udp_echo_connected_cb (session_connected_bundled_msg_t * mp,
echo_session_t *session = pool_elt_at_index (em->sessions, session_index);
if (is_failed)
{
- ECHO_FAIL ("Bapi connect errored");
+ ECHO_FAIL (ECHO_FAIL_UDP_BAPI_CONNECT,
+ "Bapi connect errored on session %u", session_index);
return; /* Dont handle bapi connect errors for now */
}