aboutsummaryrefslogtreecommitdiffstats
path: root/tests/vpp/perf/vm_vhost/2n1l-10ge2p1x710-eth-l2xcbase-eth-2vhostvr1024-1vm-ndrpdr.robot
diff options
context:
space:
mode:
authorPeter Mikus <pmikus@cisco.com>2019-06-18 20:31:48 +0000
committerPeter Mikus <pmikus@cisco.com>2019-06-21 12:13:05 +0000
commit6871d4e7f6ed43ce0bb003cb08e88b2581a474eb (patch)
tree1ffdf006911d88de247d7dd0fc37818032c20461 /tests/vpp/perf/vm_vhost/2n1l-10ge2p1x710-eth-l2xcbase-eth-2vhostvr1024-1vm-ndrpdr.robot
parent8ded937abab242f2e096f83423e1dcecd1ecf722 (diff)
Align suite/test teardown/setup
+ Phase I - aligning FUNC/PERF Change-Id: I46b1e43687ddb29f5ed3c6335fe1baf21ec02822 Signed-off-by: Peter Mikus <pmikus@cisco.com>
Diffstat (limited to 'tests/vpp/perf/vm_vhost/2n1l-10ge2p1x710-eth-l2xcbase-eth-2vhostvr1024-1vm-ndrpdr.robot')
-rw-r--r--tests/vpp/perf/vm_vhost/2n1l-10ge2p1x710-eth-l2xcbase-eth-2vhostvr1024-1vm-ndrpdr.robot4
1 files changed, 2 insertions, 2 deletions
diff --git a/tests/vpp/perf/vm_vhost/2n1l-10ge2p1x710-eth-l2xcbase-eth-2vhostvr1024-1vm-ndrpdr.robot b/tests/vpp/perf/vm_vhost/2n1l-10ge2p1x710-eth-l2xcbase-eth-2vhostvr1024-1vm-ndrpdr.robot
index e855acad8c..1ac2fdf2a3 100644
--- a/tests/vpp/perf/vm_vhost/2n1l-10ge2p1x710-eth-l2xcbase-eth-2vhostvr1024-1vm-ndrpdr.robot
+++ b/tests/vpp/perf/vm_vhost/2n1l-10ge2p1x710-eth-l2xcbase-eth-2vhostvr1024-1vm-ndrpdr.robot
@@ -19,10 +19,10 @@
| ...
| Suite Setup | Set up 2-node performance topology with DUT's NIC model
| ... | L2 | ${nic_name}
-| Suite Teardown | Tear down 2-node performance topology
+| Suite Teardown | Tear down suite
| ...
| Test Setup | Set up performance test
-| Test Teardown | Tear down performance test with vhost
+| Test Teardown | Tear down test | performance | vhost
| ...
| Test Template | Local Template
| ...
02' href='#n402'>402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799
/*
 * Test suite for class VppOM
 *
 * Copyright (c) 2017 Cisco Systems, Inc. and others.  All rights reserved.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
 * and is available at http://www.eclipse.org/legal/epl-v10.html
 */
#define BOOST_TEST_MODULE "VPP OBJECT MODEL"
#define BOOST_TEST_DYN_LINK

#include <boost/test/unit_test.hpp>
#include <boost/assign/list_inserter.hpp>


#include <iostream>
#include <deque>

#include "vom/om.hpp"
#include "vom/interface.hpp"
#include "vom/interface_cmds.hpp"
#include "vom/bond_interface_cmds.hpp"
#include "vom/bond_group_binding.hpp"
#include "vom/bond_group_binding_cmds.hpp"
#include "vom/l2_binding.hpp"
#include "vom/l2_binding_cmds.hpp"
#include "vom/l3_binding.hpp"
#include "vom/l3_binding_cmds.hpp"
#include "vom/bridge_domain.hpp"
#include "vom/bridge_domain_entry.hpp"
#include "vom/bridge_domain_arp_entry.hpp"
#include "vom/bridge_domain_cmds.hpp"
#include "vom/bridge_domain_entry_cmds.hpp"
#include "vom/bridge_domain_arp_entry_cmds.hpp"
#include "vom/prefix.hpp"
#include "vom/route.hpp"
#include "vom/route_cmds.hpp"
#include "vom/route_domain.hpp"
#include "vom/route_domain_cmds.hpp"
#include "vom/vxlan_tunnel.hpp"
#include "vom/vxlan_tunnel_cmds.hpp"
#include "vom/sub_interface.hpp"
#include "vom/sub_interface_cmds.hpp"
#include "vom/acl_ethertype.hpp"
#include "vom/acl_ethertype_cmds.hpp"
#include "vom/acl_list.hpp"
#include "vom/acl_binding.hpp"
#include "vom/acl_list_cmds.hpp"
#include "vom/acl_binding_cmds.hpp"
#include "vom/acl_l3_rule.hpp"
#include "vom/acl_l2_rule.hpp"
#include "vom/arp_proxy_config.hpp"
#include "vom/arp_proxy_binding.hpp"
#include "vom/arp_proxy_config_cmds.hpp"
#include "vom/arp_proxy_binding_cmds.hpp"
#include "vom/ip_unnumbered.hpp"
#include "vom/ip_unnumbered_cmds.hpp"
#include "vom/interface_ip6_nd.hpp"
#include "vom/interface_span.hpp"
#include "vom/interface_span_cmds.hpp"
#include "vom/neighbour.hpp"
#include "vom/neighbour_cmds.hpp"
#include "vom/nat_static.hpp"
#include "vom/nat_static_cmds.hpp"
#include "vom/nat_binding.hpp"
#include "vom/nat_binding_cmds.hpp"

using namespace boost;
using namespace VOM;

/**
 * An expectation exception
 */
class ExpException
{
public:
    ExpException(unsigned int number)
    {
        // a neat place to add a break point
        std::cout << "  ExpException here: " << number << std::endl;
    }
};

class MockListener : public interface::event_listener,
                     public interface::stat_listener
{
    void handle_interface_stat(interface_cmds::stats_enable_cmd *cmd)
    {
    }
    void handle_interface_event(interface_cmds::events_cmd *cmd)
    {
    }
};

class MockCmdQ : public HW::cmd_q
{
public:
    MockCmdQ():
        m_strict_order(true)
    {
    }
    virtual ~MockCmdQ()
    {
    }
    void expect(cmd *f)
    {
        m_exp_queue.push_back(f);
    }
    void enqueue(cmd *f)
    {
        m_act_queue.push_back(f);
    }
    void enqueue(std::queue<cmd*> &cmds)
    {
        while (cmds.size())
        {
            m_act_queue.push_back(cmds.front());
            cmds.pop();
        }
    }
    void enqueue(std::shared_ptr<cmd> f)
    {
        m_act_queue.push_back(f.get());
    }

    void dequeue(cmd *f)
    {
    }

    void dequeue(std::shared_ptr<cmd> cmd)
    {
    }

    void strict_order(bool on)
    {
        m_strict_order = on;
    }

    bool is_empty()
    {
        return ((0 == m_exp_queue.size()) &&
                (0 == m_act_queue.size()));
    }

    rc_t write()
    {
        cmd *f_exp, *f_act;
        rc_t rc = rc_t::OK;

        while (m_act_queue.size())
        {
            bool matched = false;
            auto it_exp = m_exp_queue.begin();
            auto it_act = m_act_queue.begin();

            f_act = *it_act;

            std::cout << " Act: " << f_act->to_string() << std::endl;
            while (it_exp != m_exp_queue.end())
            {
                f_exp = *it_exp;
                try
                {
                    std::cout << "  Exp: " << f_exp->to_string() << std::endl;

                    if (typeid(*f_exp) != typeid(*f_act))
                    {
                        throw ExpException(1);
                    }

                    if (typeid(*f_exp) == typeid(interface_cmds::af_packet_create_cmd))
                    {
                        rc = handle_derived<interface_cmds::af_packet_create_cmd>(f_exp, f_act);
                    }
                    else if (typeid(*f_exp) == typeid(interface_cmds::loopback_create_cmd))
                    {
                        rc = handle_derived<interface_cmds::loopback_create_cmd>(f_exp, f_act);
                    }
                    else if (typeid(*f_exp) == typeid(interface_cmds::vhost_create_cmd))
                    {
                        rc = handle_derived<interface_cmds::vhost_create_cmd>(f_exp, f_act);
                    }
                    else if (typeid(*f_exp) == typeid(bond_interface_cmds::create_cmd))
                    {
                       rc = handle_derived<bond_interface_cmds::create_cmd>(f_exp, f_act);
                    }
                    else if (typeid(*f_exp) == typeid(interface_cmds::loopback_delete_cmd))
                    {
                        rc = handle_derived<interface_cmds::loopback_delete_cmd>(f_exp, f_act);
                    }
                    else if (typeid(*f_exp) == typeid(interface_cmds::af_packet_delete_cmd))
                    {
                        rc = handle_derived<interface_cmds::af_packet_delete_cmd>(f_exp, f_act);
                    }
                    else if (typeid(*f_exp) == typeid(interface_cmds::vhost_delete_cmd))
                    {
                       rc = handle_derived<interface_cmds::vhost_delete_cmd>(f_exp, f_act);
                    }
                    else if (typeid(*f_exp) == typeid(bond_interface_cmds::delete_cmd))
                    {
                       rc = handle_derived<bond_interface_cmds::delete_cmd>(f_exp, f_act);
                    }
                    else if (typeid(*f_exp) == typeid(interface_cmds::state_change_cmd))
                    {
                        rc = handle_derived<interface_cmds::state_change_cmd>(f_exp, f_act);
                    }
                    else if (typeid(*f_exp) == typeid(interface_cmds::set_table_cmd))
                    {
                        rc = handle_derived<interface_cmds::set_table_cmd>(f_exp, f_act);
                    }
                    else if (typeid(*f_exp) == typeid(interface_cmds::set_mac_cmd))
                    {
                        rc = handle_derived<interface_cmds::set_mac_cmd>(f_exp, f_act);
                    }
                    else if (typeid(*f_exp) == typeid(interface_cmds::set_tag))
                    {
                        rc = handle_derived<interface_cmds::set_tag>(f_exp, f_act);
                    }
                    else if (typeid(*f_exp) == typeid(bond_group_binding_cmds::bind_cmd))
                    {
                       rc = handle_derived<bond_group_binding_cmds::bind_cmd>(f_exp, f_act);
                    }
                    else if (typeid(*f_exp) == typeid(bond_group_binding_cmds::unbind_cmd))
                    {
                       rc = handle_derived<bond_group_binding_cmds::unbind_cmd>(f_exp, f_act);
                    }
                    else if (typeid(*f_exp) == typeid(route_domain_cmds::create_cmd))
                    {
			rc = handle_derived<route_domain_cmds::create_cmd>(f_exp, f_act);
                    }
                    else if (typeid(*f_exp) == typeid(route_domain_cmds::delete_cmd))
                    {
                        rc = handle_derived<route_domain_cmds::delete_cmd>(f_exp, f_act);
                    }
                    else if (typeid(*f_exp) == typeid(route::ip_route_cmds::update_cmd))
                    {
			rc = handle_derived<route::ip_route_cmds::update_cmd>(f_exp, f_act);
                    }
                    else if (typeid(*f_exp) == typeid(route::ip_route_cmds::delete_cmd))
                    {
                        rc = handle_derived<route::ip_route_cmds::delete_cmd>(f_exp, f_act);
                    }
                    else if (typeid(*f_exp) == typeid(neighbour_cmds::create_cmd))
                    {
			rc = handle_derived<neighbour_cmds::create_cmd>(f_exp, f_act);
                    }
                    else if (typeid(*f_exp) == typeid(neighbour_cmds::delete_cmd))
                    {
                        rc = handle_derived<neighbour_cmds::delete_cmd>(f_exp, f_act);
                    }
                    else if (typeid(*f_exp) == typeid(l3_binding_cmds::bind_cmd))
                    {
                        rc = handle_derived<l3_binding_cmds::bind_cmd>(f_exp, f_act);
                    }
                    else if (typeid(*f_exp) == typeid(l3_binding_cmds::unbind_cmd))
                    {
                        rc = handle_derived<l3_binding_cmds::unbind_cmd>(f_exp, f_act);
                    }
                    else if (typeid(*f_exp) == typeid(bridge_domain_cmds::create_cmd))
                    {
                        rc = handle_derived<bridge_domain_cmds::create_cmd>(f_exp, f_act);
                    }
                    else if (typeid(*f_exp) == typeid(bridge_domain_cmds::delete_cmd))
                    {
                        rc = handle_derived<bridge_domain_cmds::delete_cmd>(f_exp, f_act);
                    }
                    else if (typeid(*f_exp) == typeid(bridge_domain_entry_cmds::create_cmd))
                    {
                        rc = handle_derived<bridge_domain_entry_cmds::create_cmd>(f_exp, f_act);
                    }
                    else if (typeid(*f_exp) == typeid(bridge_domain_entry_cmds::delete_cmd))
                    {
                        rc = handle_derived<bridge_domain_entry_cmds::delete_cmd>(f_exp, f_act);
                    }
                    else if (typeid(*f_exp) == typeid(bridge_domain_arp_entry_cmds::create_cmd))
                    {
                        rc = handle_derived<bridge_domain_arp_entry_cmds::create_cmd>(f_exp, f_act);
                    }
                    else if (typeid(*f_exp) == typeid(bridge_domain_arp_entry_cmds::delete_cmd))
                    {
                        rc = handle_derived<bridge_domain_arp_entry_cmds::delete_cmd>(f_exp, f_act);
                    }
                    else if (typeid(*f_exp) == typeid(l2_binding_cmds::bind_cmd))
                    {
                        rc = handle_derived<l2_binding_cmds::bind_cmd>(f_exp, f_act);
                    }
                    else if (typeid(*f_exp) == typeid(l2_binding_cmds::unbind_cmd))
                    {
                        rc = handle_derived<l2_binding_cmds::unbind_cmd>(f_exp, f_act);
                    }
                    else if (typeid(*f_exp) == typeid(l2_binding_cmds::set_vtr_op_cmd))
                    {
                        rc = handle_derived<l2_binding_cmds::set_vtr_op_cmd>(f_exp, f_act);
                    }
                    else if (typeid(*f_exp) == typeid(vxlan_tunnel_cmds::create_cmd))
                    {
                        rc = handle_derived<vxlan_tunnel_cmds::create_cmd>(f_exp, f_act);
                    }
                    else if (typeid(*f_exp) == typeid(vxlan_tunnel_cmds::delete_cmd))
                    {
                        rc = handle_derived<vxlan_tunnel_cmds::delete_cmd>(f_exp, f_act);
                    }
                    else if (typeid(*f_exp) == typeid(sub_interface_cmds::create_cmd))
                    {
                        rc = handle_derived<sub_interface_cmds::create_cmd>(f_exp, f_act);
                    }
                    else if (typeid(*f_exp) == typeid(sub_interface_cmds::delete_cmd))
                    {
                        rc = handle_derived<sub_interface_cmds::delete_cmd>(f_exp, f_act);
                    }
                    else if (typeid(*f_exp) == typeid(ACL::acl_ethertype_cmds::bind_cmd))
                    {
                        rc = handle_derived<ACL::acl_ethertype_cmds::bind_cmd>(f_exp, f_act);
                    }
                    else if (typeid(*f_exp) == typeid(ACL::acl_ethertype_cmds::unbind_cmd))
                    {
                        rc = handle_derived<ACL::acl_ethertype_cmds::unbind_cmd>(f_exp, f_act);
                    }
                    else if (typeid(*f_exp) == typeid(ACL::list_cmds::l3_update_cmd))
                    {
                        rc = handle_derived<ACL::list_cmds::l3_update_cmd>(f_exp, f_act);
                    }
                    else if (typeid(*f_exp) == typeid(ACL::list_cmds::l3_delete_cmd))
                    {
                        rc = handle_derived<ACL::list_cmds::l3_delete_cmd>(f_exp, f_act);
                    }
                    else if (typeid(*f_exp) == typeid(ACL::binding_cmds::l3_bind_cmd))
                    {
                        rc = handle_derived<ACL::binding_cmds::l3_bind_cmd>(f_exp, f_act);
                    }
                    else if (typeid(*f_exp) == typeid(ACL::binding_cmds::l3_unbind_cmd))
                    {
                        rc = handle_derived<ACL::binding_cmds::l3_unbind_cmd>(f_exp, f_act);
                    }
                    else if (typeid(*f_exp) == typeid(ACL::list_cmds::l2_update_cmd))
                    {
                        rc = handle_derived<ACL::list_cmds::l2_update_cmd>(f_exp, f_act);
                    }
                    else if (typeid(*f_exp) == typeid(ACL::list_cmds::l2_delete_cmd))
                    {
                        rc = handle_derived<ACL::list_cmds::l2_delete_cmd>(f_exp, f_act);
                    }
                    else if (typeid(*f_exp) == typeid(ACL::binding_cmds::l2_bind_cmd))
                    {
                        rc = handle_derived<ACL::binding_cmds::l2_bind_cmd>(f_exp, f_act);
                    }
                    else if (typeid(*f_exp) == typeid(ACL::binding_cmds::l2_unbind_cmd))
                    {
                        rc = handle_derived<ACL::binding_cmds::l2_unbind_cmd>(f_exp, f_act);
                    }
                    else if (typeid(*f_exp) == typeid(arp_proxy_binding_cmds::bind_cmd))
                    {
                        rc = handle_derived<arp_proxy_binding_cmds::bind_cmd>(f_exp, f_act);
                    }
                    else if (typeid(*f_exp) == typeid(arp_proxy_binding_cmds::unbind_cmd))
                    {
                        rc = handle_derived<arp_proxy_binding_cmds::unbind_cmd>(f_exp, f_act);
                    }
                    else if (typeid(*f_exp) == typeid(arp_proxy_config_cmds::config_cmd))
                    {
                        rc = handle_derived<arp_proxy_config_cmds::config_cmd>(f_exp, f_act);
                    }
                    else if (typeid(*f_exp) == typeid(arp_proxy_config_cmds::unconfig_cmd))
                    {
                        rc = handle_derived<arp_proxy_config_cmds::unconfig_cmd>(f_exp, f_act);
                    }
                    else if (typeid(*f_exp) == typeid(ip_unnumbered_cmds::config_cmd))
                    {
                        rc = handle_derived<ip_unnumbered_cmds::config_cmd>(f_exp, f_act);
                    }
                    else if (typeid(*f_exp) == typeid(ip_unnumbered_cmds::unconfig_cmd))
                    {
                        rc = handle_derived<ip_unnumbered_cmds::unconfig_cmd>(f_exp, f_act);
                    }
                    else if (typeid(*f_exp) == typeid(ip6nd_ra_config::config_cmd))
                    {
                        rc = handle_derived<ip6nd_ra_config::config_cmd>(f_exp, f_act);
                    }
                    else if (typeid(*f_exp) == typeid(ip6nd_ra_config::unconfig_cmd))
                    {
                        rc = handle_derived<ip6nd_ra_config::unconfig_cmd>(f_exp, f_act);
                    }
                    else if (typeid(*f_exp) == typeid(ip6nd_ra_prefix::config_cmd))
                    {
                        rc = handle_derived<ip6nd_ra_prefix::config_cmd>(f_exp, f_act);
                    }
                    else if (typeid(*f_exp) == typeid(ip6nd_ra_prefix::unconfig_cmd))
                    {
                        rc = handle_derived<ip6nd_ra_prefix::unconfig_cmd>(f_exp, f_act);
                    }
                    else if (typeid(*f_exp) == typeid(interface_span_cmds::config_cmd))
                    {
                        rc = handle_derived<interface_span_cmds::config_cmd>(f_exp, f_act);
                    }
                    else if (typeid(*f_exp) == typeid(interface_span_cmds::unconfig_cmd))
                    {
                        rc = handle_derived<interface_span_cmds::unconfig_cmd>(f_exp, f_act);
                    }
                    else if (typeid(*f_exp) == typeid(nat_static_cmds::create_44_cmd))
                    {
                        rc = handle_derived<nat_static_cmds::create_44_cmd>(f_exp, f_act);
                    }
                    else if (typeid(*f_exp) == typeid(nat_static_cmds::delete_44_cmd))
                    {
                        rc = handle_derived<nat_static_cmds::delete_44_cmd>(f_exp, f_act);
                    }
                    else if (typeid(*f_exp) == typeid(nat_binding_cmds::bind_44_input_cmd))
                    {
                        rc = handle_derived<nat_binding_cmds::bind_44_input_cmd>(f_exp, f_act);
                    }
                    else if (typeid(*f_exp) == typeid(nat_binding_cmds::unbind_44_input_cmd))
                    {
                        rc = handle_derived<nat_binding_cmds::unbind_44_input_cmd>(f_exp, f_act);
                    }
                    else if (typeid(*f_exp) == typeid(interface_cmds::events_cmd))
                    {
                        rc = handle_derived<interface_cmds::events_cmd>(f_exp, f_act);
                    }
                    else
                    {
                        throw ExpException(2);
                    }

                    // if we get here then we found the match.
                    m_exp_queue.erase(it_exp);
                    m_act_queue.erase(it_act);
                    delete f_exp;
                    delete f_act;

                    // return any injected failures to the agent
                    if (rc_t::OK != rc && rc_t::NOOP != rc)
                    {
                        return (rc);
                    }

                    matched = true;
                    break;
                }
                catch (ExpException &e)
                {
                    // The expected and actual do not match
                    if (m_strict_order)
                    {
                        // in strict ordering mode this is fatal, so rethrow
                        throw e;
                    }
                    else
                    {
                        // move the iterator onto the next in the expected list and
                        // check for a match
                        ++it_exp;
                    }
                }
            }

            if (!matched)
                throw ExpException(3);
        }

        return (rc);
    }
private:

    template <typename T>
    rc_t handle_derived(const cmd *f_exp, cmd *f_act)
    {
        const T *i_exp;
        T *i_act;

        i_exp = dynamic_cast<const T*>(f_exp);
        i_act = dynamic_cast<T*>(f_act);
        if (!(*i_exp == *i_act))
        {
            throw ExpException(4);
        }
        // pass the data and return code to the agent
        i_act->item() = i_exp->item();

        return (i_act->item().rc());
    }

    // The Q to push the expectations on
    std::deque<cmd*> m_exp_queue;

    // the queue to push the actual events on
    std::deque<cmd*> m_act_queue;

    // control whether the expected queue is strictly ordered.
    bool m_strict_order;
};

class VppInit {
public:
    std::string name;
    MockCmdQ *f;

    VppInit()
        : name("vpp-ut"),
          f(new MockCmdQ())
    {
        HW::init(f);
        OM::init();
        logger().set(log_level_t::DEBUG);
    }

    ~VppInit() {
        delete f;
    }
};

BOOST_AUTO_TEST_SUITE(vom)

#define TRY_CHECK_RC(stmt)                    \
{                                             \
    try {                                     \
        BOOST_CHECK(rc_t::OK == stmt);        \
    }                                         \
    catch (ExpException &e)                   \
    {                                         \
        BOOST_CHECK(false);                   \
    }                                         \
    BOOST_CHECK(vi.f->is_empty());            \
}

#define TRY_CHECK(stmt)                       \
{                                             \
    try {                                     \
        stmt;                                 \
    }                                         \
    catch (ExpException &e)                   \
    {                                         \
        BOOST_CHECK(false);                   \
    }                                         \
    BOOST_CHECK(vi.f->is_empty());            \
}

#define ADD_EXPECT(stmt)                      \
    vi.f->expect(new stmt)

#define STRICT_ORDER_OFF()                        \
    vi.f->strict_order(false)

BOOST_AUTO_TEST_CASE(test_interface) {
    VppInit vi;
    const std::string go = "GeorgeOrwell";
    const std::string js = "JohnSteinbeck";
    rc_t rc = rc_t::OK;

    /*
     * George creates and deletes the interface
     */
    std::string itf1_name = "afpacket1";
    interface itf1(itf1_name,
                   interface::type_t::AFPACKET,
                   interface::admin_state_t::UP);

    /*
     * set the expectation for a afpacket interface create.
     *  2 is the interface handle VPP [mock] assigns
     */
    HW::item<handle_t> hw_ifh(2, rc_t::OK);
    ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf1_name));

    HW::item<interface::admin_state_t> hw_as_up(interface::admin_state_t::UP, rc_t::OK);
    ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh));

    TRY_CHECK_RC(OM::write(go, itf1));

    HW::item<interface::admin_state_t> hw_as_down(interface::admin_state_t::DOWN, rc_t::OK);
    ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh));
    ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf1_name));

    TRY_CHECK(OM::remove(go));

    /*
     * George creates the interface, then John brings it down.
     * George's remove is a no-op, sice John also owns the interface
     */
    interface itf1b(itf1_name,
                    interface::type_t::AFPACKET,
                    interface::admin_state_t::DOWN);

    ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf1_name));
    ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh));
    TRY_CHECK_RC(OM::write(go, itf1));

    ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh));
    TRY_CHECK_RC(OM::write(js, itf1b));

    TRY_CHECK(OM::remove(go));

    ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf1_name));
    TRY_CHECK(OM::remove(js));

    /*
     * George adds an interface, then we flush all of Geroge's state
     */
    ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf1_name));
    ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh));
    TRY_CHECK_RC(OM::write(go, itf1));

    TRY_CHECK(OM::mark(go));

    ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh));
    ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf1_name));
    TRY_CHECK(OM::sweep(go));

    /*
     * George adds an interface. mark stale. update the same interface. sweep
     * and expect no delete
     */
    ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf1_name));
    ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh));
    TRY_CHECK_RC(OM::write(go, itf1b));

    TRY_CHECK(OM::mark(go));

    ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh));
    TRY_CHECK_RC(OM::write(go, itf1));

    TRY_CHECK(OM::sweep(go));

    ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh));
    ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf1_name));
    TRY_CHECK(OM::remove(go));

    /*
     * George adds an insterface, then we mark that state. Add a second interface
     * an flush the first that is now stale.
     */
    ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf1_name));
    ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh));
    TRY_CHECK_RC(OM::write(go, itf1));

    TRY_CHECK(OM::mark(go));

    std::string itf2_name = "afpacket2";
    std::string itf2_tag = "uuid-of-afpacket2-interface";
    interface itf2(itf2_name,
                   interface::type_t::AFPACKET,
                   interface::admin_state_t::UP,
                   itf2_tag);
    HW::item<handle_t> hw_ifh2(3, rc_t::OK);

    ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh2, itf2_name));
    ADD_EXPECT(interface_cmds::set_tag(hw_ifh2, itf2_tag));
    ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh2));
    TRY_CHECK_RC(OM::write(go, itf2));

    ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh));
    ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf1_name));
    TRY_CHECK(OM::sweep(go));

    TRY_CHECK(OM::mark(go));

    ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh2));
    ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh2, itf2_name));
    TRY_CHECK(OM::sweep(go));


    std::string itf3_name = "/PATH/TO/vhost_user1.sock";
    std::string itf3_tag = "uuid-of-vhost_user1-interface";
    interface itf3(itf3_name,
                   interface::type_t::VHOST,
                   interface::admin_state_t::UP,
                   itf3_tag);
    HW::item<handle_t> hw_ifh3(4, rc_t::OK);

    ADD_EXPECT(interface_cmds::vhost_create_cmd(hw_ifh3, itf3_name, itf3_tag));
    ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh3));
    TRY_CHECK_RC(OM::write(go, itf3));

    ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh3));
    ADD_EXPECT(interface_cmds::vhost_delete_cmd(hw_ifh3, itf3_name));
    TRY_CHECK(OM::remove(go));
}

BOOST_AUTO_TEST_CASE(test_bvi) {
    VppInit vi;
    const std::string ernest = "ErnestHemmingway";
    const std::string graham = "GrahamGreene";
    rc_t rc = rc_t::OK;
    l3_binding *l3;

    HW::item<interface::admin_state_t> hw_as_up(interface::admin_state_t::UP,
                                                rc_t::OK);
    HW::item<interface::admin_state_t> hw_as_down(interface::admin_state_t::DOWN,
                                                  rc_t::OK);

    /*
     * Enrest creates a BVI with address 10.10.10.10/24
     */
    route::prefix_t pfx_10("10.10.10.10", 24);

    const std::string bvi_name = "bvi1";
    interface itf(bvi_name,
                  interface::type_t::BVI,
                  interface::admin_state_t::UP);
    HW::item<handle_t> hw_ifh(4, rc_t::OK);
    HW::item<route::prefix_t> hw_pfx_10(pfx_10, rc_t::OK);

    ADD_EXPECT(interface_cmds::loopback_create_cmd(hw_ifh, bvi_name));
    ADD_EXPECT(interface_cmds::set_tag(hw_ifh, bvi_name));
    ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh));
    TRY_CHECK_RC(OM::write(ernest, itf));

    l3 = new l3_binding(itf, pfx_10);
    HW::item<bool> hw_l3_bind(true, rc_t::OK);
    HW::item<bool> hw_l3_unbind(false, rc_t::OK);
    ADD_EXPECT(l3_binding_cmds::bind_cmd(hw_l3_bind, hw_ifh.data(), pfx_10));
    TRY_CHECK_RC(OM::write(ernest, *l3));

    // change the MAC address on the BVI
    interface itf_new_mac(bvi_name,
                          interface::type_t::BVI,
                          interface::admin_state_t::UP);
    l2_address_t l2_addr({0,1,2,3,4,5});
    HW::item<l2_address_t> hw_mac(l2_addr, rc_t::OK);
    itf_new_mac.set(l2_addr);
    ADD_EXPECT(interface_cmds::set_mac_cmd(hw_mac, hw_ifh));
    TRY_CHECK_RC(OM::write(ernest, itf_new_mac));

    // create/write the interface to the OM again but with an unset MAC
    // this should not generate a MAC address update
    TRY_CHECK_RC(OM::write(ernest, itf));

    // change the MAC address on the BVI - again
    interface itf_new_mac2(bvi_name,
                           interface::type_t::BVI,
                           interface::admin_state_t::UP);
    l2_address_t l2_addr2({0,1,2,3,4,6});
    HW::item<l2_address_t> hw_mac2(l2_addr2, rc_t::OK);
    itf_new_mac2.set(l2_addr2);
    ADD_EXPECT(interface_cmds::set_mac_cmd(hw_mac2, hw_ifh));
    TRY_CHECK_RC(OM::write(ernest, itf_new_mac2));

    delete l3;
    ADD_EXPECT(l3_binding_cmds::unbind_cmd(hw_l3_unbind, hw_ifh.data(), pfx_10));
    ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh));
    ADD_EXPECT(interface_cmds::loopback_delete_cmd(hw_ifh));
    TRY_CHECK(OM::remove(ernest));

    /*
     * Graham creates a BVI with address 10.10.10.10/24 in Routing Domain
     */
    route_domain rd(1);
    HW::item<bool> hw_rd4_create(true, rc_t::OK);
    HW::item<bool> hw_rd4_delete(false, rc_t::OK);
    HW::item<bool> hw_rd6_create(true, rc_t::OK);
    HW::item<bool> hw_rd6_delete(false, rc_t::OK);
    HW::item<route::table_id_t> hw_rd4_bind(1, rc_t::OK);
    HW::item<route::table_id_t> hw_rd4_unbind(route::DEFAULT_TABLE, rc_t::OK);
    HW::item<route::table_id_t> hw_rd6_bind(1, rc_t::OK);
    HW::item<route::table_id_t> hw_rd6_unbind(route::DEFAULT_TABLE, rc_t::OK);
    ADD_EXPECT(route_domain_cmds::create_cmd(hw_rd4_create, l3_proto_t::IPV4, 1));
    ADD_EXPECT(route_domain_cmds::create_cmd(hw_rd6_create, l3_proto_t::IPV6, 1));
    TRY_CHECK_RC(OM::write(graham, rd));

    const std::string bvi2_name = "bvi2";
    interface *itf2 = new interface(bvi2_name,
                                    interface::type_t::BVI,
                                    interface::admin_state_t::UP,
                                    rd);
    HW::item<handle_t> hw_ifh2(5, rc_t::OK);

    ADD_EXPECT(interface_cmds::loopback_create_cmd(hw_ifh2, bvi2_name));
    ADD_EXPECT(interface_cmds::set_tag(hw_ifh2, bvi2_name));
    ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh2));
    ADD_EXPECT(interface_cmds::set_table_cmd(hw_rd4_bind, l3_proto_t::IPV4, hw_ifh2));
    ADD_EXPECT(interface_cmds::set_table_cmd(hw_rd6_bind, l3_proto_t::IPV6, hw_ifh2));

    TRY_CHECK_RC(OM::write(graham, *itf2));

    l3 = new l3_binding(*itf2, pfx_10);
    ADD_EXPECT(l3_binding_cmds::bind_cmd(hw_l3_bind, hw_ifh2.data(), pfx_10));
    TRY_CHECK_RC(OM::write(graham, *l3));

    delete l3;
    delete itf2;

    ADD_EXPECT(l3_binding_cmds::unbind_cmd(hw_l3_unbind, hw_ifh2.data(), pfx_10));
    ADD_EXPECT(interface_cmds::set_table_cmd(hw_rd4_unbind, l3_proto_t::IPV4, hw_ifh2));
    ADD_EXPECT(interface_cmds::set_table_cmd(hw_rd6_unbind, l3_proto_t::IPV6, hw_ifh2));
    ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh2));
    ADD_EXPECT(interface_cmds::loopback_delete_cmd(hw_ifh2));
    ADD_EXPECT(route_domain_cmds::delete_cmd(hw_rd4_delete, l3_proto_t::IPV4, 1));
    ADD_EXPECT(route_domain_cmds::delete_cmd(hw_rd6_delete, l3_proto_t::IPV6, 1));
    TRY_CHECK(OM::remove(graham));
}

BOOST_AUTO_TEST_CASE(test_bond) {
    VppInit vi;
    const std::string cb = "CarolBerg";
    rc_t rc = rc_t::OK;

    /*
     * creates the interfaces
     */
    std::string itf1_name = "afpacket1";
    interface itf1(itf1_name,
                   interface::type_t::AFPACKET,
                   interface::admin_state_t::UP);

    HW::item<handle_t> hw_ifh(2, rc_t::OK);
    ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf1_name));

    HW::item<interface::admin_state_t> hw_as_up(interface::admin_state_t::UP, rc_t::OK);
    ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh));

    TRY_CHECK_RC(OM::write(cb, itf1));

    std::string itf2_name = "afpacket2";
    interface itf2(itf2_name,
                   interface::type_t::AFPACKET,
                   interface::admin_state_t::UP);


    HW::item<handle_t> hw_ifh2(4, rc_t::OK);
    ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh2, itf2_name));
    ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh2));

    TRY_CHECK_RC(OM::write(cb, itf2));

    std::string bond_name = "bond";
    bond_interface bond_itf(bond_name, interface::admin_state_t::UP,
                                 bond_interface::mode_t::LACP);

    HW::item<handle_t> hw_ifh3(6, rc_t::OK);
    ADD_EXPECT(bond_interface_cmds::create_cmd(hw_ifh3, bond_name,
      bond_interface::mode_t::LACP, bond_interface::lb_t::L2, l2_address_t::ZERO));
    ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh3));

    TRY_CHECK_RC(OM::write(cb, bond_itf));

    bond_member *bm1 = new bond_member(itf1, bond_member::mode_t::ACTIVE,
                                         bond_member::rate_t::SLOW);
    bond_member *bm2 = new bond_member(itf2, bond_member::mode_t::ACTIVE,
                                         bond_member::rate_t::SLOW);
    bond_group_binding *bgb = new bond_group_binding(bond_itf, {*bm1, *bm2});

    HW::item<bool> bond_hw_bind(true, rc_t::OK);
    ADD_EXPECT(bond_group_binding_cmds::bind_cmd(bond_hw_bind, hw_ifh3.data(), *bm1));
    ADD_EXPECT(bond_group_binding_cmds::bind_cmd(bond_hw_bind, hw_ifh3.data(), *bm2));

    TRY_CHECK_RC(OM::write(cb, *bgb));

    delete bgb;
    delete bm2;
    delete bm1;

    STRICT_ORDER_OFF();
    HW::item<interface::admin_state_t> hw_as_down(interface::admin_state_t::DOWN, rc_t::OK);
    ADD_EXPECT(bond_group_binding_cmds::unbind_cmd(bond_hw_bind, hw_ifh.data()));
    ADD_EXPECT(bond_group_binding_cmds::unbind_cmd(bond_hw_bind, hw_ifh2.data()));
    ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh2));
    ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh2, itf2_name));
    ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh3));
    ADD_EXPECT(bond_interface_cmds::delete_cmd(hw_ifh3));
    ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh));
    ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf1_name));

    TRY_CHECK(OM::remove(cb));
}

BOOST_AUTO_TEST_CASE(test_bridge) {
    VppInit vi;
    const std::string franz = "FranzKafka";
    const std::string dante = "Dante";
    const std::string jkr = "jkrowling";
    rc_t rc = rc_t::OK;

    /*
     * Franz creates an interface, Bridge-domain, then binds the two
     */

    // interface create
    std::string itf1_name = "afpacket1";
    interface itf1(itf1_name,
                   interface::type_t::AFPACKET,
                   interface::admin_state_t::UP);

    HW::item<handle_t> hw_ifh(3, rc_t::OK);
    HW::item<interface::admin_state_t> hw_as_up(interface::admin_state_t::UP,
                                                rc_t::OK);
    ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf1_name));
    ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh));

    TRY_CHECK_RC(OM::write(franz, itf1));

    // bridge-domain create
    bridge_domain bd1(33);

    HW::item<uint32_t> hw_bd(33, rc_t::OK);
    ADD_EXPECT(bridge_domain_cmds::create_cmd(hw_bd,
                                              bridge_domain::learning_mode_t::ON,
                                              bridge_domain::arp_term_mode_t::ON,
                                              bridge_domain::flood_mode_t::ON,
                                              bridge_domain::mac_age_mode_t::OFF));

    TRY_CHECK_RC(OM::write(franz, bd1));

    // L2-interface create and bind
    // this needs to be delete'd before the flush below, since it too maintains
    // references to the BD and Interface
    l2_binding *l2itf = new l2_binding(itf1, bd1);
    HW::item<bool> hw_l2_bind(true, rc_t::OK);

    ADD_EXPECT(l2_binding_cmds::bind_cmd(hw_l2_bind, hw_ifh.data(), hw_bd.data(), false));
    TRY_CHECK_RC(OM::write(franz, *l2itf));

    /*
     * Dante adds an interface to the same BD
     */
    std::string itf2_name = "afpacket2";
    interface itf2(itf2_name,
                   interface::type_t::AFPACKET,
                   interface::admin_state_t::UP);

    HW::item<handle_t> hw_ifh2(4, rc_t::OK);
    ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh2, itf2_name));
    ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh2));
    TRY_CHECK_RC(OM::write(dante, itf2));

    // BD add is a no-op since it exists
    TRY_CHECK_RC(OM::write(dante, bd1));

    l2_binding *l2itf2 = new l2_binding(itf2, bd1);
    HW::item<l2_binding::l2_vtr_op_t> hw_set_vtr(l2_binding::l2_vtr_op_t::L2_VTR_POP_1, rc_t::OK);
    l2itf2->set(l2_binding::l2_vtr_op_t::L2_VTR_POP_1, 68);

    ADD_EXPECT(l2_binding_cmds::bind_cmd(hw_l2_bind, hw_ifh2.data(), hw_bd.data(), false));
    ADD_EXPECT(l2_binding_cmds::set_vtr_op_cmd(hw_set_vtr, hw_ifh2.data(), 68));
    TRY_CHECK_RC(OM::write(dante, *l2itf2));

    // Add some static entries to the bridge-domain
    HW::item<bool> hw_be1(true, rc_t::OK);
    mac_address_t mac1({0,1,2,3,4,5});
    bridge_domain_entry *be1 = new bridge_domain_entry(bd1, mac1, itf2);
    ADD_EXPECT(bridge_domain_entry_cmds::create_cmd(hw_be1, mac1, bd1.id(), hw_ifh2.data(),
		                                    false));
    TRY_CHECK_RC(OM::write(dante, *be1));

    // Add some entries to the bridge-domain ARP termination table
    HW::item<bool> hw_bea1(true, rc_t::OK);
    boost::asio::ip::address ip1 = boost::asio::ip::address::from_string("10.10.10.10");

    bridge_domain_arp_entry *bea1 = new bridge_domain_arp_entry(bd1, ip1, mac1);
    ADD_EXPECT(bridge_domain_arp_entry_cmds::create_cmd(hw_be1, bd1.id(), mac1, ip1));
    TRY_CHECK_RC(OM::write(dante, *bea1));

    // flush Franz's state
    delete l2itf;
    HW::item<interface::admin_state_t> hw_as_down(interface::admin_state_t::DOWN,
                                                  rc_t::OK);
    ADD_EXPECT(l2_binding_cmds::unbind_cmd(hw_l2_bind, hw_ifh.data(), hw_bd.data(), false));
    ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh));
    ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf1_name));
    TRY_CHECK(OM::remove(franz));

    // flush Dante's state - the order the interface and BD are deleted
    // is an uncontrollable artifact of the C++ object destruction.
    delete l2itf2;
    delete be1;
    delete bea1;
    STRICT_ORDER_OFF();
    ADD_EXPECT(bridge_domain_arp_entry_cmds::delete_cmd(hw_be1, bd1.id(), mac1, ip1));
    ADD_EXPECT(bridge_domain_entry_cmds::delete_cmd(hw_be1, mac1, bd1.id(), false));
    ADD_EXPECT(l2_binding_cmds::unbind_cmd(hw_l2_bind, hw_ifh2.data(), hw_bd.data(), false));

    ADD_EXPECT(bridge_domain_cmds::delete_cmd(hw_bd));
    ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh2));
    ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh2, itf2_name));
    TRY_CHECK(OM::remove(dante));

    // test the BVI entry in l2fib
    bridge_domain bd2(99);

    HW::item<uint32_t> hw_bd2(99, rc_t::OK);
    ADD_EXPECT(bridge_domain_cmds::create_cmd(hw_bd2,
                                              bridge_domain::learning_mode_t::ON,
                                              bridge_domain::arp_term_mode_t::ON,
                                              bridge_domain::flood_mode_t::ON,
                                              bridge_domain::mac_age_mode_t::OFF));

    TRY_CHECK_RC(OM::write(jkr, bd2));

    std::string itf3_name = "bvi";
    interface itf3(itf3_name,
                   interface::type_t::BVI,
                   interface::admin_state_t::UP);

    HW::item<handle_t> hw_ifh3(5, rc_t::OK);
    ADD_EXPECT(interface_cmds::loopback_create_cmd(hw_ifh3, itf3_name));
    ADD_EXPECT(interface_cmds::set_tag(hw_ifh3, itf3_name));
    ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh3));
    TRY_CHECK_RC(OM::write(jkr, itf3));

    l2_binding *l2itf3 = new l2_binding(itf3, bd2);
    ADD_EXPECT(l2_binding_cmds::bind_cmd(hw_l2_bind, hw_ifh3.data(), hw_bd2.data(), true));
    TRY_CHECK_RC(OM::write(jkr, *l2itf3));

    HW::item<bool> hw_be2(true, rc_t::OK);
    mac_address_t mac2({0,1,2,3,4,5});
    bridge_domain_entry *be2 = new bridge_domain_entry(bd2, mac2, itf3);
    ADD_EXPECT(bridge_domain_entry_cmds::create_cmd(hw_be2, mac2, bd2.id(), hw_ifh3.data(), true));
    TRY_CHECK_RC(OM::write(jkr, *be2));

    delete l2itf3;
    delete be2;
    STRICT_ORDER_OFF();
    ADD_EXPECT(l2_binding_cmds::unbind_cmd(hw_l2_bind, hw_ifh3.data(), hw_bd2.data(), true));
    ADD_EXPECT(bridge_domain_entry_cmds::delete_cmd(hw_be2, mac2, bd2.id(), true));
    ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh3));
    ADD_EXPECT(interface_cmds::loopback_delete_cmd(hw_ifh3));
    ADD_EXPECT(bridge_domain_cmds::delete_cmd(hw_bd2));
    TRY_CHECK(OM::remove(jkr));
}

BOOST_AUTO_TEST_CASE(test_vxlan) {
    VppInit vi;
    const std::string franz = "FranzKafka";
    rc_t rc = rc_t::OK;

    /*
     * Franz creates an interface, Bridge-domain, then binds the two
     */

    // VXLAN create
    vxlan_tunnel::endpoint_t ep(boost::asio::ip::address::from_string("10.10.10.10"),
                                boost::asio::ip::address::from_string("10.10.10.11"),
                                322);

    vxlan_tunnel vxt(ep.src, ep.dst, ep.vni);

    HW::item<handle_t> hw_vxt(3, rc_t::OK);
    ADD_EXPECT(vxlan_tunnel_cmds::create_cmd(hw_vxt, "don't-care", ep));

    TRY_CHECK_RC(OM::write(franz, vxt));

    // bridge-domain create
    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<uint32_t> 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(franz, bd1));

    // L2-interface create and bind
    // this needs to be delete'd before the flush below, since it too maintains
    // references to the BD and Interface
    l2_binding *l2itf = new l2_binding(vxt, bd1);
    HW::item<bool> hw_l2_bind(true, rc_t::OK);

    ADD_EXPECT(l2_binding_cmds::bind_cmd(hw_l2_bind, hw_vxt.data(), hw_bd.data(), false));
    TRY_CHECK_RC(OM::write(franz, *l2itf));

    // flush Franz's state
    delete l2itf;
    HW::item<handle_t> hw_vxtdel(3, rc_t::NOOP);
    STRICT_ORDER_OFF();
    ADD_EXPECT(l2_binding_cmds::unbind_cmd(hw_l2_bind, hw_vxt.data(), hw_bd.data(), false));
    ADD_EXPECT(bridge_domain_cmds::delete_cmd(hw_bd));
    ADD_EXPECT(vxlan_tunnel_cmds::delete_cmd(hw_vxtdel, ep));
    TRY_CHECK(OM::remove(franz));
}

BOOST_AUTO_TEST_CASE(test_vlan) {
    VppInit vi;
    const std::string noam = "NoamChomsky";
    rc_t rc = rc_t::OK;

    std::string itf1_name = "host1";
    interface itf1(itf1_name,
                   interface::type_t::AFPACKET,
                   interface::admin_state_t::UP);

    HW::item<handle_t> hw_ifh(2, rc_t::OK);
    ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf1_name));

    HW::item<interface::admin_state_t> hw_as_up(interface::admin_state_t::UP, rc_t::OK);
    ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh));

    TRY_CHECK_RC(OM::write(noam, itf1));

    sub_interface *vl33 = new sub_interface(itf1,
                                            interface::admin_state_t::UP,
                                            33);

    HW::item<handle_t> hw_vl33(3, rc_t::OK);
    ADD_EXPECT(sub_interface_cmds::create_cmd(hw_vl33, itf1_name+".33", hw_ifh.data(), 33));
    ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_vl33));

    TRY_CHECK_RC(OM::write(noam, *vl33));

    delete vl33;
    HW::item<interface::admin_state_t> hw_as_down(interface::admin_state_t::DOWN, rc_t::OK);
    HW::item<handle_t> hw_vl33_down(3, rc_t::NOOP);
    ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_vl33));
    ADD_EXPECT(sub_interface_cmds::delete_cmd(hw_vl33_down));
    ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh));
    ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf1_name));

    TRY_CHECK(OM::remove(noam));
}

BOOST_AUTO_TEST_CASE(test_acl) {
    VppInit vi;
    const std::string fyodor = "FyodorDostoyevsky";
    const std::string leo = "LeoTolstoy";
    rc_t rc = rc_t::OK;

    /*
     * Fyodor adds an ACL in the input direction
     */
    std::string itf1_name = "host1";
    interface itf1(itf1_name,
                   interface::type_t::AFPACKET,
                   interface::admin_state_t::UP);
    HW::item<handle_t> hw_ifh(2, rc_t::OK);
    HW::item<interface::admin_state_t> hw_as_up(interface::admin_state_t::UP, rc_t::OK);
    ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf1_name));
    ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh));
    TRY_CHECK_RC(OM::write(fyodor, itf1));

    ACL::ethertype_rule_t e1(ethertype_t::ARP, direction_t::INPUT);
    ACL::ethertype_rule_t e2(ethertype_t::ARP, direction_t::OUTPUT);
    ACL::ethertype_rule_t e3(ethertype_t::IPV4, direction_t::INPUT);
    ACL::acl_ethertype::ethertype_rules_t l_e = {e1, e2, e3};
    ACL::acl_ethertype *a_e = new ACL::acl_ethertype(itf1, l_e);
    HW::item<bool> ae_binding(true, rc_t::OK);
    ADD_EXPECT(ACL::acl_ethertype_cmds::bind_cmd(ae_binding, hw_ifh.data(), l_e));
    TRY_CHECK_RC(OM::write(fyodor, *a_e));

    route::prefix_t src("10.10.10.10", 32);
    ACL::l3_rule r1(10, ACL::action_t::PERMIT, src, route::prefix_t::ZERO);
    ACL::l3_rule r2(20, ACL::action_t::DENY, route::prefix_t::ZERO, route::prefix_t::ZERO);

    std::string acl_name = "acl1";
    ACL::l3_list acl1(acl_name);
    acl1.insert(r2);
    acl1.insert(r1);
    ACL::l3_list::rules_t rules = {r1, r2};

    HW::item<handle_t> hw_acl(2, rc_t::OK);
    ADD_EXPECT(ACL::list_cmds::l3_update_cmd(hw_acl, acl_name, rules));
    TRY_CHECK_RC(OM::write(fyodor, acl1));

    ACL::l3_rule r3(30, ACL::action_t::PERMIT, route::prefix_t::ZERO, route::prefix_t::ZERO);
    ACL::l3_list acl2(acl_name);
    acl2.insert(r3);
    ACL::l3_list::rules_t rules2 = {r3};
    ADD_EXPECT(ACL::list_cmds::l3_update_cmd(hw_acl, acl_name, rules2));
    TRY_CHECK_RC(OM::write(fyodor, acl2));

    ACL::l3_binding *l3b = new ACL::l3_binding(direction_t::INPUT, itf1, acl1);
    HW::item<bool> hw_binding(true, rc_t::OK);
    ADD_EXPECT(ACL::binding_cmds::l3_bind_cmd(hw_binding, direction_t::INPUT,
                                         hw_ifh.data(), hw_acl.data()));
    TRY_CHECK_RC(OM::write(fyodor, *l3b));

    /**
     * Leo adds an L2 ACL in the output direction
     */
    TRY_CHECK_RC(OM::write(leo, itf1));

    std::string l2_acl_name = "l2_acl1";
    mac_address_t mac({0x0, 0x0, 0x1, 0x2, 0x3, 0x4});
    mac_address_t mac_mask({0xff, 0xff, 0xff, 0x0, 0x0, 0x0});
    ACL::l2_rule l2_r1(10, ACL::action_t::PERMIT, src, mac, mac_mask);
    ACL::l2_rule l2_r2(20, ACL::action_t::DENY, src, {}, {});

    ACL::l2_list l2_acl(l2_acl_name);
    l2_acl.insert(l2_r2);
    l2_acl.insert(l2_r1);

    ACL::l2_list::rules_t l2_rules = {l2_r1, l2_r2};

    HW::item<handle_t> l2_hw_acl(3, rc_t::OK);
    ADD_EXPECT(ACL::list_cmds::l2_update_cmd(l2_hw_acl, l2_acl_name, l2_rules));
    TRY_CHECK_RC(OM::write(leo, l2_acl));

    ACL::l2_binding *l2b = new ACL::l2_binding(direction_t::OUTPUT, itf1, l2_acl);
    HW::item<bool> l2_hw_binding(true, rc_t::OK);
    ADD_EXPECT(ACL::binding_cmds::l2_bind_cmd(l2_hw_binding, direction_t::OUTPUT,
                                       hw_ifh.data(), l2_hw_acl.data()));
    TRY_CHECK_RC(OM::write(leo, *l2b));

    delete l2b;
    ADD_EXPECT(ACL::binding_cmds::l2_unbind_cmd(l2_hw_binding, direction_t::OUTPUT,
                                                hw_ifh.data(), l2_hw_acl.data()));
    ADD_EXPECT(ACL::list_cmds::l2_delete_cmd(l2_hw_acl));
    TRY_CHECK(OM::remove(leo));

    delete l3b;
    delete a_e;
    HW::item<interface::admin_state_t> hw_as_down(interface::admin_state_t::DOWN,
                                                  rc_t::OK);
    STRICT_ORDER_OFF();
    ADD_EXPECT(ACL::binding_cmds::l3_unbind_cmd(hw_binding, direction_t::INPUT,
                                         hw_ifh.data(), hw_acl.data()));
    ADD_EXPECT(ACL::list_cmds::l3_delete_cmd(hw_acl));
    ADD_EXPECT(ACL::acl_ethertype_cmds::unbind_cmd(ae_binding, hw_ifh.data()));
    ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh));
    ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf1_name));

    TRY_CHECK(OM::remove(fyodor));
}

BOOST_AUTO_TEST_CASE(test_arp_proxy) {
    VppInit vi;
    const std::string kurt = "KurtVonnegut";
    rc_t rc = rc_t::OK;

    asio::ip::address_v4 low  = asio::ip::address_v4::from_string("10.0.0.0");
    asio::ip::address_v4 high = asio::ip::address_v4::from_string("10.0.0.255");

    arp_proxy_config ap(low, high);
    HW::item<bool> hw_ap_cfg(true, rc_t::OK);
    ADD_EXPECT(arp_proxy_config_cmds::config_cmd(hw_ap_cfg, low, high));
    TRY_CHECK_RC(OM::write(kurt, ap));

    std::string itf3_name = "host3";
    interface itf3(itf3_name,
                   interface::type_t::AFPACKET,
                   interface::admin_state_t::UP);
    HW::item<handle_t> hw_ifh(2, rc_t::OK);
    HW::item<interface::admin_state_t> hw_as_up(interface::admin_state_t::UP, rc_t::OK);
    ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf3_name));
    ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh));
    TRY_CHECK_RC(OM::write(kurt, itf3));

    arp_proxy_binding *apb = new arp_proxy_binding(itf3);
    HW::item<bool> hw_binding(true, rc_t::OK);
    ADD_EXPECT(arp_proxy_binding_cmds::bind_cmd(hw_binding, hw_ifh.data()));
    TRY_CHECK_RC(OM::write(kurt, *apb));

    delete apb;

    HW::item<interface::admin_state_t> hw_as_down(interface::admin_state_t::DOWN,
                                                  rc_t::OK);
    STRICT_ORDER_OFF();
    ADD_EXPECT(arp_proxy_binding_cmds::unbind_cmd(hw_binding, hw_ifh.data()));
    ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh));
    ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf3_name));
    ADD_EXPECT(arp_proxy_config_cmds::unconfig_cmd(hw_ap_cfg, low, high));

    TRY_CHECK(OM::remove(kurt));
}

BOOST_AUTO_TEST_CASE(test_ip_unnumbered) {
    VppInit vi;
    const std::string eric = "EricAmbler";
    rc_t rc = rc_t::OK;

    /*
     * Interface 1 has the L3 address
     */
    std::string itf1_name = "host1";
    interface itf1(itf1_name,
                   interface::type_t::AFPACKET,
                   interface::admin_state_t::UP);
    HW::item<handle_t> hw_ifh(2, rc_t::OK);
    HW::item<interface::admin_state_t> hw_as_up(interface::admin_state_t::UP, rc_t::OK);
    ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf1_name));
    ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh));
    TRY_CHECK_RC(OM::write(eric, itf1));

    route::prefix_t pfx_10("10.10.10.10", 24);
    l3_binding *l3 = new l3_binding(itf1, pfx_10);
    HW::item<bool> hw_l3_bind(true, rc_t::OK);
    HW::item<bool> hw_l3_unbind(false, rc_t::OK);
    ADD_EXPECT(l3_binding_cmds::bind_cmd(hw_l3_bind, hw_ifh.data(), pfx_10));
    TRY_CHECK_RC(OM::write(eric, *l3));

    /*
     * Interface 2 is unnumbered
     */
    std::string itf2_name = "host2";
    interface itf2(itf2_name,
                   interface::type_t::AFPACKET,
                   interface::admin_state_t::UP);

    HW::item<handle_t> hw_ifh2(4, rc_t::OK);
    ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh2, itf2_name));
    ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh2));
    TRY_CHECK_RC(OM::write(eric, itf2));

    ip_unnumbered *ipun = new ip_unnumbered(itf2, itf1);
    HW::item<bool> hw_ip_cfg(true, rc_t::OK);
    HW::item<bool> hw_ip_uncfg(false, rc_t::OK);
    ADD_EXPECT(ip_unnumbered_cmds::config_cmd(hw_ip_cfg, hw_ifh2.data(), hw_ifh.data()));
    TRY_CHECK_RC(OM::write(eric, *ipun));

    delete l3;
    delete ipun;

    HW::item<interface::admin_state_t> hw_as_down(interface::admin_state_t::DOWN, rc_t::OK);
    STRICT_ORDER_OFF();
    ADD_EXPECT(ip_unnumbered_cmds::unconfig_cmd(hw_ip_uncfg, hw_ifh2.data(), hw_ifh.data()));
    ADD_EXPECT(l3_binding_cmds::unbind_cmd(hw_l3_unbind, hw_ifh.data(), pfx_10));
    ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh2));
    ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh2, itf2_name));
    ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh));
    ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf1_name));

    TRY_CHECK(OM::remove(eric));
}

BOOST_AUTO_TEST_CASE(test_ip6nd) {
    VppInit vi;
    const std::string paulo = "PauloCoelho";
    rc_t rc = rc_t::OK;

    /*
     * ra config
     */
    std::string itf_name = "host_ip6nd";
    interface itf(itf_name,
                   interface::type_t::AFPACKET,
                   interface::admin_state_t::UP);
    HW::item<handle_t> hw_ifh(3, rc_t::OK);
    HW::item<interface::admin_state_t> hw_as_up(interface::admin_state_t::UP, rc_t::OK);
    ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf_name));
    ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh));
    TRY_CHECK_RC(OM::write(paulo, itf));

    route::prefix_t pfx_10("fd8f:69d8:c12c:ca62::3", 128);
    l3_binding *l3 = new l3_binding(itf, pfx_10);
    HW::item<bool> hw_l3_bind(true, rc_t::OK);
    HW::item<bool> hw_l3_unbind(false, rc_t::OK);
    ADD_EXPECT(l3_binding_cmds::bind_cmd(hw_l3_bind, hw_ifh.data(), pfx_10));
    TRY_CHECK_RC(OM::write(paulo, *l3));

    ra_config ra(0, 1, 0, 4);
    ip6nd_ra_config *ip6ra = new ip6nd_ra_config(itf, ra);
    HW::item<bool> hw_ip6nd_ra_config_config(true, rc_t::OK);
    HW::item<bool> hw_ip6nd_ra_config_unconfig(false, rc_t::OK);
    ADD_EXPECT(ip6nd_ra_config::config_cmd(hw_ip6nd_ra_config_config, hw_ifh.data(), ra));
    TRY_CHECK_RC(OM::write(paulo, *ip6ra));

    /*
     * ra prefix
     */
    ra_prefix ra_pfx(pfx_10, 0, 0, 2592000, 604800);
    ip6nd_ra_prefix *ip6pfx = new ip6nd_ra_prefix(itf, ra_pfx);
    HW::item<bool> hw_ip6nd_ra_prefix_config(true, rc_t::OK);
    HW::item<bool> hw_ip6nd_ra_prefix_unconfig(false, rc_t::OK);
    ADD_EXPECT(ip6nd_ra_prefix::config_cmd(hw_ip6nd_ra_prefix_config, hw_ifh.data(), ra_pfx));
    TRY_CHECK_RC(OM::write(paulo, *ip6pfx));

    delete ip6pfx;

    ADD_EXPECT(ip6nd_ra_prefix::unconfig_cmd(hw_ip6nd_ra_prefix_unconfig, hw_ifh.data(), ra_pfx));

    delete ip6ra;
    delete l3;

    HW::item<interface::admin_state_t> hw_as_down(interface::admin_state_t::DOWN, rc_t::OK);

    STRICT_ORDER_OFF();
    ADD_EXPECT(ip6nd_ra_config::unconfig_cmd(hw_ip6nd_ra_config_unconfig, hw_ifh.data(), ra));
    ADD_EXPECT(l3_binding_cmds::unbind_cmd(hw_l3_unbind, hw_ifh.data(), pfx_10));
    ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh));
    ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf_name));

    TRY_CHECK(OM::remove(paulo));
}

BOOST_AUTO_TEST_CASE(test_interface_span) {
    VppInit vi;
    const std::string elif = "ElifShafak";
    rc_t rc = rc_t::OK;

    /*
     * Interface 1 to be mirrored
     */
    std::string itf1_name = "port-from";
    interface itf1(itf1_name,
                   interface::type_t::AFPACKET,
                   interface::admin_state_t::UP);
    HW::item<handle_t> hw_ifh(2, rc_t::OK);
    HW::item<interface::admin_state_t> hw_as_up(interface::admin_state_t::UP, rc_t::OK);
    ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf1_name));
    ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh));
    TRY_CHECK_RC(OM::write(elif, itf1));

    /*
     * Interface 2 where traffic is mirrored
     */
    std::string itf2_name = "port-to";
    interface itf2(itf2_name,
                   interface::type_t::AFPACKET,
                   interface::admin_state_t::UP);

    HW::item<handle_t> hw_ifh2(4, rc_t::OK);
    HW::item<interface::admin_state_t> hw_as_up2(interface::admin_state_t::UP, rc_t::OK);

    ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh2, itf2_name));
    ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up2, hw_ifh2));
    TRY_CHECK_RC(OM::write(elif, itf2));

    interface_span *itf_span = new interface_span(itf1, itf2, interface_span::state_t::TX_RX_ENABLED);
    HW::item<bool> hw_is_cfg(true, rc_t::OK);
    HW::item<bool> hw_is_uncfg(true, rc_t::OK);
    ADD_EXPECT(interface_span_cmds::config_cmd(hw_is_cfg, hw_ifh.data(), hw_ifh2.data(), interface_span::state_t::TX_RX_ENABLED));
    TRY_CHECK_RC(OM::write(elif, *itf_span));

    HW::item<interface::admin_state_t> hw_as_down(interface::admin_state_t::DOWN, rc_t::OK);
    HW::item<interface::admin_state_t> hw_as_down2(interface::admin_state_t::DOWN, rc_t::OK);

    delete itf_span;
    STRICT_ORDER_OFF();
    ADD_EXPECT(interface_span_cmds::unconfig_cmd(hw_is_uncfg, hw_ifh.data(), hw_ifh2.data()));
    ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh));
    ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf1_name));
    ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down2, hw_ifh2));
    ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh2, itf2_name));

    TRY_CHECK(OM::remove(elif));
}

BOOST_AUTO_TEST_CASE(test_routing) {
    VppInit vi;
    const std::string ian = "IanFleming";
    rc_t rc = rc_t::OK;

    /*
     * non-default route domain
     */
    route_domain rd4(1);
    HW::item<bool> hw_rd4_create(true, rc_t::OK);
    HW::item<bool> hw_rd4_delete(false, rc_t::OK);
    HW::item<bool> hw_rd6_create(true, rc_t::OK);
    HW::item<bool> hw_rd6_delete(false, rc_t::OK);
    HW::item<route::table_id_t> hw_rd4_bind(1, rc_t::OK);
    HW::item<route::table_id_t> hw_rd4_unbind(route::DEFAULT_TABLE, rc_t::OK);
    HW::item<route::table_id_t> hw_rd6_bind(1, rc_t::OK);
    HW::item<route::table_id_t> hw_rd7_unbind(route::DEFAULT_TABLE, rc_t::OK);
    ADD_EXPECT(route_domain_cmds::create_cmd(hw_rd4_create, l3_proto_t::IPV4, 1));
    ADD_EXPECT(route_domain_cmds::create_cmd(hw_rd6_create, l3_proto_t::IPV6, 1));
    TRY_CHECK_RC(OM::write(ian, rd4));

    /*
     * a couple of interfaces
     */
    std::string itf1_name = "af1";
    interface itf1(itf1_name,
                   interface::type_t::AFPACKET,
                   interface::admin_state_t::UP);
    HW::item<handle_t> hw_ifh(2, rc_t::OK);
    HW::item<interface::admin_state_t> hw_as_up(interface::admin_state_t::UP, rc_t::OK);
    HW::item<interface::admin_state_t> hw_as_down(interface::admin_state_t::DOWN, rc_t::OK);
    ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf1_name));
    ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh));
    TRY_CHECK_RC(OM::write(ian, itf1));

    std::string itf2_name = "af2";
    interface *itf2 = new interface(itf2_name,
                                    interface::type_t::AFPACKET,
                                    interface::admin_state_t::UP,
                                    rd4);

    HW::item<handle_t> hw_ifh2(4, rc_t::OK);
    HW::item<interface::admin_state_t> hw_as_up2(interface::admin_state_t::UP, rc_t::OK);
    HW::item<interface::admin_state_t> hw_as_down2(interface::admin_state_t::DOWN, rc_t::OK);
    ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh2, itf2_name));
    ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up2, hw_ifh2));
    ADD_EXPECT(interface_cmds::set_table_cmd(hw_rd4_bind, l3_proto_t::IPV4, hw_ifh2));
    ADD_EXPECT(interface_cmds::set_table_cmd(hw_rd6_bind, l3_proto_t::IPV6, hw_ifh2));
    TRY_CHECK_RC(OM::write(ian, *itf2));

    /*
     * prefix on each interface
     */
    route::prefix_t pfx_10("10.10.10.10", 24);
    l3_binding *l3_10 = new l3_binding(itf1, pfx_10);
    HW::item<bool> hw_l3_10_bind(true, rc_t::OK);
    HW::item<bool> hw_l3_10_unbind(false, rc_t::OK);
    ADD_EXPECT(l3_binding_cmds::bind_cmd(hw_l3_10_bind, hw_ifh.data(), pfx_10));
    TRY_CHECK_RC(OM::write(ian, *l3_10));
    route::prefix_t pfx_11("11.11.11.11", 24);
    l3_binding *l3_11 = new l3_binding(*itf2, pfx_11);
    HW::item<bool> hw_l3_11_bind(true, rc_t::OK);
    HW::item<bool> hw_l3_11_unbind(false, rc_t::OK);
    ADD_EXPECT(l3_binding_cmds::bind_cmd(hw_l3_11_bind, hw_ifh2.data(), pfx_11));
    TRY_CHECK_RC(OM::write(ian, *l3_11));

    /*
     * A route via interface 1 in the default table
     */
    route::prefix_t pfx_5("5.5.5.5", 32);
    boost::asio::ip::address nh_10 = boost::asio::ip::address::from_string("10.10.10.11");
    route::path *path_10 = new route::path(nh_10, itf1);
    route::ip_route *route_5 = new route::ip_route(pfx_5);
    route_5->add(*path_10);
    HW::item<bool> hw_route_5(true, rc_t::OK);
    ADD_EXPECT(route::ip_route_cmds::update_cmd(hw_route_5, 0, pfx_5, {*path_10}));
    TRY_CHECK_RC(OM::write(ian, *route_5));

    /*
     * A route via interface 2 in the non-default table
     */
    boost::asio::ip::address nh_11 = boost::asio::ip::address::from_string("11.11.11.10");
    route::path *path_11 = new route::path(nh_11, *itf2);
    route::ip_route *route_5_2 = new route::ip_route(rd4, pfx_5);
    route_5_2->add(*path_11);
    HW::item<bool> hw_route_5_2(true, rc_t::OK);
    ADD_EXPECT(route::ip_route_cmds::update_cmd(hw_route_5_2, 1, pfx_5, {*path_11}));
    TRY_CHECK_RC(OM::write(ian, *route_5_2));

    /*
     * An ARP entry for the neighbour on itf1
     */
    HW::item<bool> hw_neighbour(true, rc_t::OK);
    mac_address_t mac_n({0,1,2,4,5,6});
    neighbour *ne = new neighbour(itf1, nh_10, mac_n);
    ADD_EXPECT(neighbour_cmds::create_cmd(hw_neighbour, hw_ifh.data(), mac_n, nh_10));
    TRY_CHECK_RC(OM::write(ian, *ne));

    /*
     * A DVR route
     */
    route::prefix_t pfx_6("6.6.6.6", 32);
    route::path *path_l2 = new route::path(*itf2, nh_proto_t::ETHERNET);
    route::ip_route *route_dvr = new route::ip_route(pfx_6);
    route_dvr->add(*path_l2);
    HW::item<bool> hw_route_dvr(true, rc_t::OK);
    ADD_EXPECT(route::ip_route_cmds::update_cmd(hw_route_dvr, 0, pfx_6, {*path_l2}));
    TRY_CHECK_RC(OM::write(ian, *route_dvr));

    STRICT_ORDER_OFF();
    // delete the stack objects that hold references to others
    // so the OM::remove is the call that removes the last reference
    delete l3_11;
    delete l3_10;
    delete itf2;
    delete route_5;
    delete path_10;
    delete route_5_2;
    delete path_11;
    delete route_dvr;
    delete path_l2;
    delete ne;
    ADD_EXPECT(neighbour_cmds::delete_cmd(hw_neighbour, hw_ifh.data(), mac_n, nh_10));
    ADD_EXPECT(route::ip_route_cmds::delete_cmd(hw_route_dvr, 0, pfx_6));
    ADD_EXPECT(route::ip_route_cmds::delete_cmd(hw_route_5_2, 1, pfx_5));
    ADD_EXPECT(route::ip_route_cmds::delete_cmd(hw_route_5, 0, pfx_5));
    ADD_EXPECT(l3_binding_cmds::unbind_cmd(hw_l3_10_unbind, hw_ifh.data(), pfx_10));
    ADD_EXPECT(l3_binding_cmds::unbind_cmd(hw_l3_11_unbind, hw_ifh2.data(), pfx_11));
    ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh));
    ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf1_name));
    ADD_EXPECT(interface_cmds::set_table_cmd(hw_rd4_unbind, l3_proto_t::IPV4, hw_ifh2));
    ADD_EXPECT(interface_cmds::set_table_cmd(hw_rd4_unbind, l3_proto_t::IPV6, hw_ifh2));
    ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down2, hw_ifh2));
    ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh2, itf2_name));
    ADD_EXPECT(route_domain_cmds::delete_cmd(hw_rd4_delete, l3_proto_t::IPV4, 1));
    ADD_EXPECT(route_domain_cmds::delete_cmd(hw_rd6_delete, l3_proto_t::IPV6, 1));

    TRY_CHECK(OM::remove(ian));
}

BOOST_AUTO_TEST_CASE(test_nat) {
    VppInit vi;
    const std::string gs = "GeorgeSimenon";
    rc_t rc = rc_t::OK;

    /*
     * Inside Interface
     */
    std::string itf_in_name = "inside";
    interface itf_in(itf_in_name,
                     interface::type_t::AFPACKET,
                     interface::admin_state_t::UP);
    HW::item<handle_t> hw_ifh(2, rc_t::OK);
    HW::item<interface::admin_state_t> hw_as_up(interface::admin_state_t::UP, rc_t::OK);
    HW::item<interface::admin_state_t> hw_as_down(interface::admin_state_t::DOWN, rc_t::OK);
    ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf_in_name));
    ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh));
    TRY_CHECK_RC(OM::write(gs, itf_in));

    /*
     * outside
     */
    std::string itf_out_name = "port-to";
    interface itf_out(itf_out_name,
                   interface::type_t::AFPACKET,
                   interface::admin_state_t::UP);

    HW::item<handle_t> hw_ifh2(4, rc_t::OK);
    HW::item<interface::admin_state_t> hw_as_up2(interface::admin_state_t::UP, rc_t::OK);
    HW::item<interface::admin_state_t> hw_as_down2(interface::admin_state_t::DOWN, rc_t::OK);

    ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh2, itf_out_name));
    ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up2, hw_ifh2));
    TRY_CHECK_RC(OM::write(gs, itf_out));

    /*
     * A NAT static mapping
     */
    boost::asio::ip::address in_addr = boost::asio::ip::address::from_string("10.0.0.1");
    boost::asio::ip::address_v4 out_addr = boost::asio::ip::address_v4::from_string("1.1.1.1");

    nat_static ns(in_addr, out_addr);
    HW::item<bool> hw_ns(true, rc_t::OK);

    ADD_EXPECT(nat_static_cmds::create_44_cmd(hw_ns, 0, in_addr.to_v4(), out_addr));
    TRY_CHECK_RC(OM::write(gs, ns));

    /*
     * bind nat inside and out
     */
    nat_binding *nb_in = new nat_binding(itf_in,
                                         direction_t::INPUT,
                                         l3_proto_t::IPV4,
                                         nat_binding::zone_t::INSIDE);
    HW::item<bool> hw_nb_in(true, rc_t::OK);

    ADD_EXPECT(nat_binding_cmds::bind_44_input_cmd(hw_nb_in,
                                                   hw_ifh.data().value(),
                                                   nat_binding::zone_t::INSIDE));
    TRY_CHECK_RC(OM::write(gs, *nb_in));

    nat_binding *nb_out = new nat_binding(itf_out,
                                          direction_t::INPUT,
                                          l3_proto_t::IPV4,
                                          nat_binding::zone_t::OUTSIDE);
    HW::item<bool> hw_nb_out(true, rc_t::OK);

    ADD_EXPECT(nat_binding_cmds::bind_44_input_cmd(hw_nb_out,
                                                   hw_ifh2.data().value(),
                                                   nat_binding::zone_t::OUTSIDE));
    TRY_CHECK_RC(OM::write(gs, *nb_out));


    STRICT_ORDER_OFF();
    delete nb_in;
    delete nb_out;
    ADD_EXPECT(nat_binding_cmds::unbind_44_input_cmd(hw_nb_in,
                                                     hw_ifh.data().value(),
                                                     nat_binding::zone_t::INSIDE));
    ADD_EXPECT(nat_binding_cmds::unbind_44_input_cmd(hw_nb_out,
                                                     hw_ifh2.data().value(),
                                                     nat_binding::zone_t::OUTSIDE));
    ADD_EXPECT(nat_static_cmds::delete_44_cmd(hw_ns, 0, in_addr.to_v4(), out_addr));
    ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh));
    ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf_in_name));
    ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down2, hw_ifh2));
    ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh2, itf_out_name));

    TRY_CHECK(OM::remove(gs));
}

BOOST_AUTO_TEST_CASE(test_interface_events) {
    VppInit vi;
    MockListener ml;

    HW::item<bool> hw_want(true, rc_t::OK);

    ADD_EXPECT(interface_cmds::events_cmd(ml));
    cmd* itf = new interface_cmds::events_cmd(ml);

    HW::enqueue(itf);
    HW::write();
}

BOOST_AUTO_TEST_CASE(test_interface_route_domain_change) {
    VppInit vi;
    const std::string rene = "ReneGoscinny";
    rc_t rc = rc_t::OK;

    /*
     * Create an interface with two IP addresses
     */
    std::string itf1_name = "host1";
    interface itf1(itf1_name,
                   interface::type_t::AFPACKET,
                   interface::admin_state_t::UP);
    HW::item<handle_t> hw_ifh1(2, rc_t::OK);
    HW::item<interface::admin_state_t> hw_as_up(interface::admin_state_t::UP, rc_t::OK);
    HW::item<interface::admin_state_t> hw_as_down(interface::admin_state_t::DOWN, rc_t::OK);
    ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh1, itf1_name));
    ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh1));
    TRY_CHECK_RC(OM::write(rene, itf1));

    route::prefix_t pfx_10("10.10.10.10", 24);
    l3_binding *l3_1 = new l3_binding(itf1, pfx_10);
    HW::item<bool> hw_l3_bind1(true, rc_t::OK);
    HW::item<bool> hw_l3_unbind1(false, rc_t::OK);
    ADD_EXPECT(l3_binding_cmds::bind_cmd(hw_l3_bind1, hw_ifh1.data(), pfx_10));
    TRY_CHECK_RC(OM::write(rene, *l3_1));

    route::prefix_t pfx_11("10.10.11.11", 24);
    l3_binding *l3_2 = new l3_binding(itf1, pfx_11);
    HW::item<bool> hw_l3_bind2(true, rc_t::OK);
    HW::item<bool> hw_l3_unbind2(false, rc_t::OK);
    ADD_EXPECT(l3_binding_cmds::bind_cmd(hw_l3_bind2, hw_ifh1.data(), pfx_11));
    TRY_CHECK_RC(OM::write(rene, *l3_2));

    route_domain rd(1);
    HW::item<bool> hw_rd_create(true, rc_t::OK);
    HW::item<bool> hw_rd_delete(false, rc_t::OK);
    HW::item<route::table_id_t> hw_rd_bind(1, rc_t::OK);
    HW::item<route::table_id_t> hw_rd_unbind(route::DEFAULT_TABLE, rc_t::OK);
    ADD_EXPECT(route_domain_cmds::create_cmd(hw_rd_create, l3_proto_t::IPV4, 1));
    ADD_EXPECT(route_domain_cmds::create_cmd(hw_rd_create, l3_proto_t::IPV6, 1));
    TRY_CHECK_RC(OM::write(rene, rd));

    /*
     * update the interface to change to a new route-domain
     * expect that the l3-bindings are removed and readded.
     */
    interface *itf2 = new interface(itf1_name,
                                    interface::type_t::AFPACKET,
                                    interface::admin_state_t::UP,
                                    rd);
    ADD_EXPECT(l3_binding_cmds::unbind_cmd(hw_l3_unbind1, hw_ifh1.data(), pfx_10));
    ADD_EXPECT(l3_binding_cmds::unbind_cmd(hw_l3_unbind2, hw_ifh1.data(), pfx_11));
    ADD_EXPECT(interface_cmds::set_table_cmd(hw_rd_bind, l3_proto_t::IPV4, hw_ifh1));
    ADD_EXPECT(interface_cmds::set_table_cmd(hw_rd_bind, l3_proto_t::IPV6, hw_ifh1));
    ADD_EXPECT(l3_binding_cmds::bind_cmd(hw_l3_bind1, hw_ifh1.data(), pfx_10));
    ADD_EXPECT(l3_binding_cmds::bind_cmd(hw_l3_bind2, hw_ifh1.data(), pfx_11));
    TRY_CHECK_RC(OM::write(rene, *itf2));

    /*
     * mve the interface back to the default route-domain
     */
    interface itf3(itf1_name,
                   interface::type_t::AFPACKET,
                   interface::admin_state_t::UP);
    ADD_EXPECT(l3_binding_cmds::unbind_cmd(hw_l3_unbind1, hw_ifh1.data(), pfx_10));
    ADD_EXPECT(l3_binding_cmds::unbind_cmd(hw_l3_unbind2, hw_ifh1.data(), pfx_11));
    ADD_EXPECT(interface_cmds::set_table_cmd(hw_rd_unbind, l3_proto_t::IPV4, hw_ifh1));
    ADD_EXPECT(interface_cmds::set_table_cmd(hw_rd_unbind, l3_proto_t::IPV6, hw_ifh1));
    ADD_EXPECT(l3_binding_cmds::bind_cmd(hw_l3_bind1, hw_ifh1.data(), pfx_10));
    ADD_EXPECT(l3_binding_cmds::bind_cmd(hw_l3_bind2, hw_ifh1.data(), pfx_11));
    TRY_CHECK_RC(OM::write(rene, itf3));

    delete l3_1;
    delete l3_2;
    delete itf2;

    STRICT_ORDER_OFF();
    ADD_EXPECT(l3_binding_cmds::unbind_cmd(hw_l3_unbind1, hw_ifh1.data(), pfx_10));
    ADD_EXPECT(l3_binding_cmds::unbind_cmd(hw_l3_unbind2, hw_ifh1.data(), pfx_11));
    ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh1));
    ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh1, itf1_name));
    ADD_EXPECT(route_domain_cmds::delete_cmd(hw_rd_delete, l3_proto_t::IPV4, 1));
    ADD_EXPECT(route_domain_cmds::delete_cmd(hw_rd_delete, l3_proto_t::IPV6, 1));

    TRY_CHECK(OM::remove(rene));
}

BOOST_AUTO_TEST_CASE(test_prefixes) {
    route::prefix_t p6_s_16(boost::asio::ip::address::from_string("2001::"), 16);

    BOOST_CHECK(p6_s_16.mask() == boost::asio::ip::address::from_string("ffff::"));

    route::prefix_t p6_s_17(boost::asio::ip::address::from_string("2001:ff00::"), 17);

    BOOST_CHECK(p6_s_17.mask() == boost::asio::ip::address::from_string("ffff:8000::"));
    BOOST_CHECK(p6_s_17.low().address() == boost::asio::ip::address::from_string("2001:8000::"));

    route::prefix_t p6_s_15(boost::asio::ip::address::from_string("2001:ff00::"), 15);
    BOOST_CHECK(p6_s_15.mask() == boost::asio::ip::address::from_string("fffe::"));
    BOOST_CHECK(p6_s_15.low().address() == boost::asio::ip::address::from_string("2000::"));

    route::prefix_t p4_s_16(boost::asio::ip::address::from_string("192.168.0.0"), 16);

    BOOST_CHECK(p4_s_16.mask() == boost::asio::ip::address::from_string("255.255.0.0"));

    route::prefix_t p4_s_17(boost::asio::ip::address::from_string("192.168.127.0"), 17);

    BOOST_CHECK(p4_s_17.mask() == boost::asio::ip::address::from_string("255.255.128.0"));
    BOOST_CHECK(p4_s_17.low().address() == boost::asio::ip::address::from_string("192.168.0.0"));
    BOOST_CHECK(p4_s_17.high().address() == boost::asio::ip::address::from_string("192.168.127.255"));

    route::prefix_t p4_s_15(boost::asio::ip::address::from_string("192.168.255.255"), 15);

    BOOST_CHECK(p4_s_15.mask() == boost::asio::ip::address::from_string("255.254.0.0"));
    BOOST_CHECK(p4_s_15.low().address() == boost::asio::ip::address::from_string("192.168.0.0"));
    BOOST_CHECK(p4_s_15.high().address() == boost::asio::ip::address::from_string("192.169.255.255"));

    route::prefix_t p4_s_32(boost::asio::ip::address::from_string("192.168.1.1"), 32);

    BOOST_CHECK(p4_s_32.mask() == boost::asio::ip::address::from_string("255.255.255.255"));
    BOOST_CHECK(p4_s_32.low().address() == boost::asio::ip::address::from_string("192.168.1.1"));
    BOOST_CHECK(p4_s_32.high().address() == boost::asio::ip::address::from_string("192.168.1.1"));

}

BOOST_AUTO_TEST_SUITE_END()