aboutsummaryrefslogtreecommitdiffstats
path: root/src/vpp-api/vapi/vapi_cpp_test.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/vpp-api/vapi/vapi_cpp_test.cpp')
-rw-r--r--src/vpp-api/vapi/vapi_cpp_test.cpp85
1 files changed, 71 insertions, 14 deletions
diff --git a/src/vpp-api/vapi/vapi_cpp_test.cpp b/src/vpp-api/vapi/vapi_cpp_test.cpp
index 1dd58f85484..918c7590b60 100644
--- a/src/vpp-api/vapi/vapi_cpp_test.cpp
+++ b/src/vpp-api/vapi/vapi_cpp_test.cpp
@@ -21,17 +21,21 @@
#include <assert.h>
#include <setjmp.h>
#include <check.h>
+#include <vapi/memclnt.api.vapi.h>
#include <vapi/vapi.hpp>
#include <vapi/vpe.api.vapi.hpp>
#include <vapi/interface.api.vapi.hpp>
+#include <vapi/mss_clamp.api.vapi.hpp>
#include <fake.api.vapi.hpp>
DEFINE_VAPI_MSG_IDS_VPE_API_JSON;
DEFINE_VAPI_MSG_IDS_INTERFACE_API_JSON;
+DEFINE_VAPI_MSG_IDS_MSS_CLAMP_API_JSON;
DEFINE_VAPI_MSG_IDS_FAKE_API_JSON;
static char *app_name = nullptr;
static char *api_prefix = nullptr;
+static bool use_uds = false;
static const int max_outstanding_requests = 32;
static const int response_queue_size = 32;
@@ -57,8 +61,9 @@ Connection con;
void setup (void)
{
- vapi_error_e rv = con.connect (
- app_name, api_prefix, max_outstanding_requests, response_queue_size);
+ vapi_error_e rv =
+ con.connect (app_name, api_prefix, max_outstanding_requests,
+ response_queue_size, true, use_uds);
ck_assert_int_eq (VAPI_OK, rv);
}
@@ -144,9 +149,53 @@ START_TEST (test_loopbacks_1)
}
{ // new context
+ for (int i = 0; i < num_ifs; ++i)
+ {
+ Mss_clamp_enable_disable d (con);
+ auto &req = d.get_request ().get_payload ();
+ req.sw_if_index = sw_if_indexes[i];
+ req.ipv4_mss = 1420;
+ req.ipv4_direction = vapi_enum_mss_clamp_dir::MSS_CLAMP_DIR_RX;
+ auto rv = d.execute ();
+ ck_assert_int_eq (VAPI_OK, rv);
+ WAIT_FOR_RESPONSE (d, rv);
+ ck_assert_int_eq (VAPI_OK, rv);
+ }
+ }
+
+ { // new context
+ bool seen[num_ifs] = { 0 };
+ Mss_clamp_get d (con);
+ d.get_request ().get_payload ().sw_if_index = ~0;
+ auto rv = d.execute ();
+ ck_assert_int_eq (VAPI_OK, rv);
+ WAIT_FOR_RESPONSE (d, rv);
+ ck_assert_int_eq (VAPI_OK, rv);
+ auto &rs = d.get_result_set ();
+ for (auto &r : rs)
+ {
+ auto &p = r.get_payload ();
+ ck_assert_int_eq (p.ipv4_mss, 1420);
+ printf ("tcp-clamp: sw_if_idx %u ip4-mss %d dir %d\n", p.sw_if_index,
+ p.ipv4_mss, p.ipv4_direction);
+ for (int i = 0; i < num_ifs; ++i)
+ {
+ if (sw_if_indexes[i] == p.sw_if_index)
+ {
+ ck_assert_int_eq (0, seen[i]);
+ seen[i] = true;
+ }
+ }
+ }
+ for (int i = 0; i < num_ifs; ++i)
+ {
+ ck_assert_int_eq (1, seen[i]);
+ }
+ }
+
+ { // new context
bool seen[num_ifs] = {0};
- Sw_interface_dump d (con);
- d.get_request ().get_payload ();
+ Sw_interface_dump d (con, 0);
auto rv = d.execute ();
ck_assert_int_eq (VAPI_OK, rv);
WAIT_FOR_RESPONSE (d, rv);
@@ -185,8 +234,7 @@ START_TEST (test_loopbacks_1)
}
{ // new context
- Sw_interface_dump d (con);
- d.get_request ().get_payload ();
+ Sw_interface_dump d (con, 0);
auto rv = d.execute ();
ck_assert_int_eq (VAPI_OK, rv);
WAIT_FOR_RESPONSE (d, rv);
@@ -207,7 +255,7 @@ END_TEST;
struct Create_loopback_cb
{
- Create_loopback_cb () : called{0}, sw_if_index{0} {};
+ Create_loopback_cb () : called{ 0 }, sw_if_index{ 0 }, seen{ false } {};
int called;
u32 sw_if_index;
bool seen;
@@ -222,7 +270,7 @@ struct Create_loopback_cb
struct Delete_loopback_cb
{
- Delete_loopback_cb () : called{0}, sw_if_index{0} {};
+ Delete_loopback_cb () : called{ 0 }, sw_if_index{ 0 }, seen{ false } {};
int called;
u32 sw_if_index;
bool seen;
@@ -301,8 +349,7 @@ START_TEST (test_loopbacks_2)
}
Sw_interface_dump_cb<num_ifs> swdcb (ccbs);
- Sw_interface_dump d (con, std::ref (swdcb));
- d.get_request ().get_payload ();
+ Sw_interface_dump d (con, 0, std::ref (swdcb));
auto rv = d.execute ();
ck_assert_int_eq (VAPI_OK, rv);
WAIT_FOR_RESPONSE (d, rv);
@@ -328,8 +375,7 @@ START_TEST (test_loopbacks_2)
}
{ // new context
- Sw_interface_dump d (con);
- d.get_request ().get_payload ();
+ Sw_interface_dump d (con, 0);
auto rv = d.execute ();
ck_assert_int_eq (VAPI_OK, rv);
WAIT_FOR_RESPONSE (d, rv);
@@ -408,14 +454,25 @@ Suite *test_suite (void)
int main (int argc, char *argv[])
{
- if (3 != argc)
+ if (4 != argc)
{
printf ("Invalid argc==`%d'\n", argc);
return EXIT_FAILURE;
}
app_name = argv[1];
api_prefix = argv[2];
- printf ("App name: `%s', API prefix: `%s'\n", app_name, api_prefix);
+ if (!strcmp (argv[3], "shm"))
+ use_uds = 0;
+ else if (!strcmp (argv[3], "uds"))
+ use_uds = 1;
+ else
+ {
+ printf ("Unrecognised required argument '%s', expected 'uds' or 'shm'.",
+ argv[3]);
+ return EXIT_FAILURE;
+ }
+ printf ("App name: `%s', API prefix: `%s', use unix sockets %d\n", app_name,
+ api_prefix, use_uds);
int number_failed;
Suite *s;