From 208c29aac523231af2420a95ba7e5d361698780b Mon Sep 17 00:00:00 2001 From: Neale Ranns Date: Wed, 11 Apr 2018 08:08:30 -0700 Subject: VOM: support for pipes Change-Id: I5c381dfe2f926f94a34ee8ed8f1b9ec6038d5fe2 Signed-off-by: Neale Ranns --- test/ext/vom_test.cpp | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) (limited to 'test/ext') diff --git a/test/ext/vom_test.cpp b/test/ext/vom_test.cpp index 0213c42196e..5ccdf55f5da 100644 --- a/test/ext/vom_test.cpp +++ b/test/ext/vom_test.cpp @@ -67,6 +67,8 @@ #include "vom/nat_static_cmds.hpp" #include "vom/nat_binding.hpp" #include "vom/nat_binding_cmds.hpp" +#include "vom/pipe.hpp" +#include "vom/pipe_cmds.hpp" using namespace boost; using namespace VOM; @@ -427,6 +429,14 @@ public: { rc = handle_derived(f_exp, f_act); } + else if (typeid(*f_exp) == typeid(pipe_cmds::create_cmd)) + { + rc = handle_derived(f_exp, f_act); + } + else if (typeid(*f_exp) == typeid(pipe_cmds::delete_cmd)) + { + rc = handle_derived(f_exp, f_act); + } else { throw ExpException(2); @@ -1860,4 +1870,72 @@ BOOST_AUTO_TEST_CASE(test_prefixes) { } +BOOST_AUTO_TEST_CASE(test_pipes) { + VppInit vi; + const std::string gk = "GKChesterton"; + + const std::string pipe_name_1 = "pipe1"; + VOM::pipe pipe1(1, interface::admin_state_t::UP); + HW::item hw_hdl(4, rc_t::OK); + HW::item hw_hdl_pair(std::make_pair(5,6), rc_t::OK); + + HW::item hw_as_up(interface::admin_state_t::UP, + rc_t::OK); + HW::item hw_as_down(interface::admin_state_t::DOWN, + rc_t::OK); + ADD_EXPECT(pipe_cmds::create_cmd(hw_hdl, pipe_name_1, 1, hw_hdl_pair)); + ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_hdl)); + TRY_CHECK_RC(OM::write(gk, pipe1)); + + pipe1.set_ends(hw_hdl_pair.data()); + + // put each end of the pipe in a BD + bridge_domain bd1(33, bridge_domain::learning_mode_t::OFF, + bridge_domain::arp_term_mode_t::OFF, + bridge_domain::flood_mode_t::OFF, + bridge_domain::mac_age_mode_t::ON); + + HW::item hw_bd(33, rc_t::OK); + ADD_EXPECT(bridge_domain_cmds::create_cmd(hw_bd, + bridge_domain::learning_mode_t::OFF, + bridge_domain::arp_term_mode_t::OFF, + bridge_domain::flood_mode_t::OFF, + bridge_domain::mac_age_mode_t::ON)); + + TRY_CHECK_RC(OM::write(gk, bd1)); + + l2_binding *l2_1 = new l2_binding(*pipe1.east(), bd1); + HW::item hw_l2_1_bind(true, rc_t::OK); + + ADD_EXPECT(l2_binding_cmds::bind_cmd(hw_l2_1_bind, + pipe1.east()->handle(), + hw_bd.data(), false)); + TRY_CHECK_RC(OM::write(gk, *l2_1)); + + l2_binding *l2_2 = new l2_binding(*pipe1.west(), bd1); + HW::item hw_l2_2_bind(true, rc_t::OK); + + ADD_EXPECT(l2_binding_cmds::bind_cmd(hw_l2_2_bind, + pipe1.west()->handle(), + hw_bd.data(), false)); + TRY_CHECK_RC(OM::write(gk, *l2_2)); + + STRICT_ORDER_OFF(); + + delete l2_1; + delete l2_2; + ADD_EXPECT(l2_binding_cmds::unbind_cmd(hw_l2_1_bind, + pipe1.east()->handle(), + hw_bd.data(), + false)); + ADD_EXPECT(l2_binding_cmds::unbind_cmd(hw_l2_1_bind, + pipe1.west()->handle(), + hw_bd.data(), + false)); + ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_hdl)); + ADD_EXPECT(pipe_cmds::delete_cmd(hw_hdl, hw_hdl_pair)); + ADD_EXPECT(bridge_domain_cmds::delete_cmd(hw_bd)); + TRY_CHECK(OM::remove(gk)); +} + BOOST_AUTO_TEST_SUITE_END() -- cgit 1.2.3-korg