From 92f398b258b795bddf604c241842603f804381e9 Mon Sep 17 00:00:00 2001 From: Numan Siddique Date: Mon, 8 Dec 2014 15:24:40 +0530 Subject: [PATCH] Fix the compiler warnings in the contrail agent test cases Change-Id: I0808192a0082d74b5800f8d4d9810197bb0730e0 Closes-bug: #1400267 --- src/vnsw/agent/diag/test/test_ping.cc | 4 +- src/vnsw/agent/init/test/test_vmware.cc | 6 +- src/vnsw/agent/kstate/test/test_kstate.cc | 38 +++---- .../agent/oper/test/test_inet_interface.cc | 8 +- .../agent/oper/test/test_instance_task.cc | 3 +- src/vnsw/agent/oper/test/test_intf.cc | 82 +++++++------- src/vnsw/agent/oper/test/test_ipv6.cc | 6 +- src/vnsw/agent/services/test/metadata_test.cc | 19 ++-- src/vnsw/agent/test-xml/test_xml.cc | 17 ++- src/vnsw/agent/test-xml/test_xml_oper.cc | 3 +- src/vnsw/agent/test/test_xmpp_discovery.cc | 106 +++++++++--------- 11 files changed, 144 insertions(+), 148 deletions(-) diff --git a/src/vnsw/agent/diag/test/test_ping.cc b/src/vnsw/agent/diag/test/test_ping.cc index 02c3807d3f2..410fe35ce7a 100644 --- a/src/vnsw/agent/diag/test/test_ping.cc +++ b/src/vnsw/agent/diag/test/test_ping.cc @@ -95,7 +95,7 @@ class DiagTest : public ::testing::Test { mac.ToArray(eth->ether_shost, sizeof(eth->ether_shost)); agent_hdr *agent = (agent_hdr *)(eth + 1); - int intf_id = ntohs(agent->hdr_ifindex); + uint16_t intf_id = ntohs(agent->hdr_ifindex); LOG(DEBUG, "Diag Callback; Agent index : " << ntohs(agent->hdr_ifindex) << " Interface index : " << GetItfId(0) << " " << GetItfId(1)); @@ -220,7 +220,7 @@ TEST_F(DiagTest, DiagReqTest) { EXPECT_TRUE(count() == 3); client->Reset(); - DeleteVmportEnv(input, 2, 1, 0); + DeleteVmportEnv(input, 2, 1, 0); client->WaitForIdle(); } diff --git a/src/vnsw/agent/init/test/test_vmware.cc b/src/vnsw/agent/init/test/test_vmware.cc index 54deae8633e..2a6ca624d77 100644 --- a/src/vnsw/agent/init/test/test_vmware.cc +++ b/src/vnsw/agent/init/test/test_vmware.cc @@ -38,9 +38,9 @@ class VmwareTest : public ::testing::Test { AgentParam *param; Agent *agent; - int intf_count_; - int nh_count_; - int vrf_count_; + unsigned int intf_count_; + unsigned int nh_count_; + unsigned int vrf_count_; opt::options_description desc; opt::variables_map var_map; diff --git a/src/vnsw/agent/kstate/test/test_kstate.cc b/src/vnsw/agent/kstate/test/test_kstate.cc index a8f018a1bb2..89c05f4fa9e 100644 --- a/src/vnsw/agent/kstate/test/test_kstate.cc +++ b/src/vnsw/agent/kstate/test/test_kstate.cc @@ -101,33 +101,33 @@ class KStateTest : public ::testing::Test { idx = i; WAIT_FOR(1000, 1000, (VmPortActive(input, idx) == true)); } - WAIT_FOR(1000, 1000, (num_ports == Agent::GetInstance()->vm_table()->Size())); + WAIT_FOR(1000, 1000, ((unsigned int)num_ports == Agent::GetInstance()->vm_table()->Size())); WAIT_FOR(1000, 1000, (1 == Agent::GetInstance()->vn_table()->Size())); WaitForVrf(input, 0, true); if (if_count) { unsigned int oper_if_count = num_ports + if_count; - WAIT_FOR(1000, 1000, ((oper_if_count) == + WAIT_FOR(1000, 1000, ((oper_if_count) == Agent::GetInstance()->interface_table()->Size())); } - WAIT_FOR(1000, 1000, ((num_ports * 2)== + WAIT_FOR(1000, 1000, ((unsigned int)(num_ports * 2)== Agent::GetInstance()->mpls_table()->Size())); if (!ksync_init_) { WAIT_FOR(1000, 1000, ((num_ports * 2) == KSyncSockTypeMap::MplsCount())); if (if_count) { - WAIT_FOR(1000, 1000, ((num_ports + if_count) == + WAIT_FOR(1000, 1000, ((num_ports + if_count) == KSyncSockTypeMap::IfCount())); } if (nh_count) { - //5 interface nexthops get created for each interface - //(l2 with policy, l2 without policy, l3 with policy, l3 + //5 interface nexthops get created for each interface + //(l2 with policy, l2 without policy, l3 with policy, l3 // without policy and 1 multicast - mac as all f's) //plus 4 Nexthops for each VRF (1 VRF NH and 2 Composite NHs) WAIT_FOR(1000, 1000, ((nh_count + (num_ports * 5) + 3) == KSyncSockTypeMap::NHCount())); } if (rt_count) { - WAIT_FOR(1000, 1000, ((rt_count + (num_ports * 2) + 1) == + WAIT_FOR(1000, 1000, ((rt_count + (num_ports * 2) + 1) == KSyncSockTypeMap::RouteCount())); } } @@ -216,7 +216,7 @@ TEST_F(KStateTest, IfDumpTest) { client->KStateResponseWait(1); if_count = TestKStateBase::fetched_count_; LOG(DEBUG, "if count " << if_count); - + CreatePorts(if_count, 0, 0); TestIfKState::Init(-1, true, if_count + MAX_TEST_FD); client->WaitForIdle(); @@ -231,7 +231,7 @@ TEST_F(KStateTest, IfGetTest) { client->KStateResponseWait(1); if_count = TestKStateBase::fetched_count_; LOG(DEBUG, "if count " << if_count); - + CreatePorts(if_count, 0, 0); for (int i = 0; i < MAX_TEST_FD; i++) { TestIfKState::Init(if_count + i); @@ -251,8 +251,8 @@ TEST_F(KStateTest, NHDumpTest) { int max_ports = 2; CreatePorts(0, nh_count, 0, max_ports); - //5 interface nexthops get created for each interface - //(l2 with policy, l2 without policy, l3 with policy, l3 without policy + //5 interface nexthops get created for each interface + //(l2 with policy, l2 without policy, l3 with policy, l3 without policy // and 1 multicast - mac as all f's ) //plus 4 Nexthops for each VRF (1 VRF NH and 2 Composite NHs) TestNHKState::Init(-1, true, nh_count + (max_ports * 5) + 3); @@ -294,7 +294,7 @@ TEST_F(KStateTest, MplsDumpTest) { client->WaitForIdle(); client->KStateResponseWait(1); mpls_count = TestKStateBase::fetched_count_; - + CreatePorts(0, 0, 0); TestMplsKState::Init(-1, true, mpls_count + MAX_TEST_MPLS); client->WaitForIdle(3); @@ -384,7 +384,7 @@ TEST_F(KStateTest, RouteDumpTest) { //Default //Addition of 2 vm ports in a new VN (VRF) will result in the following routes // 2 routes corresponding to the addresses of VM - // l2 broadcast + // l2 broadcast // 2 - v6 host route for new vrf addition TestRouteKState::Init(true, prev_rt_count + (MAX_TEST_FD * 2) + 3); client->WaitForIdle(); @@ -411,20 +411,20 @@ TEST_F(KStateTest, DISABLED_FlowDumpTest) { //Flow creation using IP packet TxIpPacketUtil(test0->id(), vm1_ip, vm2_ip, 0, hash_id); client->WaitForIdle(2); - EXPECT_TRUE(FlowGet("vrf3", vm1_ip, vm2_ip, 0, 0, 0, false, + EXPECT_TRUE(FlowGet("vrf3", vm1_ip, vm2_ip, 0, 0, 0, false, "vn3", "vn3", hash_id++, test0->flow_key_nh()->id())); //Create flow in reverse direction TxIpPacketUtil(test1->id(), vm2_ip, vm1_ip, 0, hash_id); client->WaitForIdle(2); - EXPECT_TRUE(FlowGet("vrf3", vm2_ip, vm1_ip, 0, 0, 0, true, + EXPECT_TRUE(FlowGet("vrf3", vm2_ip, vm1_ip, 0, 0, 0, true, "vn3", "vn3", hash_id++, test1->flow_key_nh()->id(), test0->flow_key_nh()->id())); //Flow creation using TCP packet - TxTcpPacketUtil(test0->id(), vm1_ip, vm2_ip, 1000, 200, + TxTcpPacketUtil(test0->id(), vm1_ip, vm2_ip, 1000, 200, hash_id); client->WaitForIdle(2); EXPECT_TRUE(FlowGet("vrf3", vm1_ip, vm2_ip, 6, 1000, 200, false, @@ -432,10 +432,10 @@ TEST_F(KStateTest, DISABLED_FlowDumpTest) { test0->flow_key_nh()->id())); //Create flow in reverse direction and make sure it is linked to previous flow - TxTcpPacketUtil(test1->id(), vm2_ip, vm1_ip, 200, 1000, + TxTcpPacketUtil(test1->id(), vm2_ip, vm1_ip, 200, 1000, hash_id); client->WaitForIdle(2); - EXPECT_TRUE(FlowGet("vrf3", vm2_ip, vm1_ip, 6, 200, 1000, true, + EXPECT_TRUE(FlowGet("vrf3", vm2_ip, vm1_ip, 6, 200, 1000, true, "vn3", "vn3", hash_id++, test1->flow_key_nh()->id(), test0->flow_key_nh()->id())); @@ -455,7 +455,7 @@ TEST_F(KStateTest, DISABLED_FlowDumpTest) { int main(int argc, char *argv[]) { int ret; GETUSERARGS(); - + /* Supported only with non-ksync mode for now */ ksync_init = false; diff --git a/src/vnsw/agent/oper/test/test_inet_interface.cc b/src/vnsw/agent/oper/test/test_inet_interface.cc index 1ab3311201a..7326b49b4dd 100644 --- a/src/vnsw/agent/oper/test/test_inet_interface.cc +++ b/src/vnsw/agent/oper/test/test_inet_interface.cc @@ -81,9 +81,9 @@ class InetInterfaceTest : public ::testing::Test { WAIT_FOR(100, 1000, (agent_->vn_table()->Size() == 0U)); } - int intf_count_; - int nh_count_; - int vrf_count_; + unsigned int intf_count_; + unsigned int nh_count_; + unsigned int vrf_count_; Agent *agent_; InterfaceTable *interface_table_; NextHopTable *nh_table_; @@ -156,7 +156,7 @@ TEST_F(InetInterfaceTest, vhost_key_manipulations) { "1.1.1.1", 24, "1.1.1.254"); client->WaitForIdle(); - ReceiveNH *nh = static_cast(ReceiveNHGet(nh_table_, "vhost1", + ReceiveNH *nh = static_cast(ReceiveNHGet(nh_table_, "vhost1", false)); EXPECT_TRUE(nh != NULL); DBEntryBase::KeyPtr key = nh->GetDBRequestKey(); diff --git a/src/vnsw/agent/oper/test/test_instance_task.cc b/src/vnsw/agent/oper/test/test_instance_task.cc index 55acd59419f..4eb56e88504 100644 --- a/src/vnsw/agent/oper/test/test_instance_task.cc +++ b/src/vnsw/agent/oper/test/test_instance_task.cc @@ -22,7 +22,8 @@ class InstanceTaskFdTest : public ::testing::Test { virtual void SetUp() { memset(tmpfilename, 0, sizeof(tmpfilename)); strcpy(tmpfilename, "task_fd_XXXXXX"); - mkstemp(tmpfilename); + if(mkstemp(tmpfilename) == -1) + return; std::fstream testfile(tmpfilename); testfile << "while true; do sleep 1; done"; testfile.close(); diff --git a/src/vnsw/agent/oper/test/test_intf.cc b/src/vnsw/agent/oper/test/test_intf.cc index b1faeb32f66..e478fc9c64a 100644 --- a/src/vnsw/agent/oper/test/test_intf.cc +++ b/src/vnsw/agent/oper/test/test_intf.cc @@ -168,7 +168,7 @@ class IntfTest : public ::testing::Test { } - int intf_count; + unsigned int intf_count; Agent *agent; }; @@ -187,7 +187,7 @@ static void NovaDel(int id) { MakeUuid(id)); } -static void FloatingIpAdd(VmInterface::FloatingIpList &list, const char *addr, +static void FloatingIpAdd(VmInterface::FloatingIpList &list, const char *addr, const char *vrf) { IpAddress ip = Ip4Address::from_string(addr); list.list_.insert(VmInterface::FloatingIp(ip.to_v4(), vrf, MakeUuid(1))); @@ -220,7 +220,7 @@ static void CreateMirror(AnalyzerInfo &analyzer_info) { analyzer_info.dport); } -static void CfgIntfSync(int id, const char *cfg_str, int vn, int vm, +static void CfgIntfSync(int id, const char *cfg_str, int vn, int vm, VmInterface::FloatingIpList list, string vrf_name, string ip, AnalyzerInfo &analyzer_info) { uuid intf_uuid = MakeUuid(id); @@ -265,7 +265,7 @@ static void CfgIntfSync(int id, const char *cfg_str, int vn, int vm, } -static void CfgIntfSync(int id, const char *cfg_str, int vn, int vm, +static void CfgIntfSync(int id, const char *cfg_str, int vn, int vm, VmInterface::FloatingIpList list, string vrf_name, string ip) { uuid intf_uuid = MakeUuid(id); @@ -296,7 +296,7 @@ static void CfgIntfSync(int id, const char *cfg_str, int vn, int vm, Agent::GetInstance()->interface_table()->Enqueue(&req); } -static void CfgIntfSync(int id, const char *cfg_str, int vn, int vm, +static void CfgIntfSync(int id, const char *cfg_str, int vn, int vm, string vrf, string ip) { VmInterface::FloatingIpList list; CfgIntfSync(id, cfg_str, vn, vm, list, vrf, ip); @@ -334,7 +334,6 @@ TEST_F(IntfTest, index_reuse) { struct PortInfo input2[] = { {"vnet9", 9, "9.1.1.1", "00:00:00:00:00:01", 1, 1} }; - KSyncSockTypeMap *sock = KSyncSockTypeMap::GetKSyncSockTypeMap(); client->Reset(); CreateVmportEnv(input1, 1); @@ -360,11 +359,11 @@ TEST_F(IntfTest, index_reuse) { usleep(2000); client->WaitForIdle(); VmInterfaceKey key1(AgentKey::ADD_DEL_CHANGE, MakeUuid(8), ""); - WAIT_FOR(100, 1000, - (Agent::GetInstance()->interface_table()->Find(&key1, true) + WAIT_FOR(100, 1000, + (Agent::GetInstance()->interface_table()->Find(&key1, true) == NULL)); VmInterfaceKey key2(AgentKey::ADD_DEL_CHANGE, MakeUuid(9), ""); - WAIT_FOR(100, 1000, + WAIT_FOR(100, 1000, (Agent::GetInstance()->interface_table()->Find(&key2, true) == NULL)); client->Reset(); @@ -376,7 +375,6 @@ TEST_F(IntfTest, entry_reuse) { struct PortInfo input1[] = { {"vnet8", 8, "8.1.1.1", "00:00:00:01:01:01", 1, 1} }; - KSyncSockTypeMap *sock = KSyncSockTypeMap::GetKSyncSockTypeMap(); client->Reset(); CreateVmportEnv(input1, 1); @@ -414,8 +412,8 @@ TEST_F(IntfTest, ActivateInactivate) { EXPECT_TRUE(VmPortFind(8)); client->Reset(); - //Delete VM, and delay deletion of nova - //message (BGP connection drop case) + //Delete VM, and delay deletion of nova + //message (BGP connection drop case) DelLink("virtual-machine", "vm1", "virtual-machine-interface", "vnet8"); DelVm("vm1"); client->WaitForIdle(); @@ -449,7 +447,7 @@ TEST_F(IntfTest, CfgSync_NoNova_1) { NovaDel(1); EXPECT_TRUE(client->NotifyWait(1, 0, 0)); EXPECT_FALSE(VmPortFind(1)); - WAIT_FOR(100, 1000, + WAIT_FOR(100, 1000, (Agent::GetInstance()->interface_table()->Size() == 3U)); client->Reset(); @@ -564,7 +562,7 @@ TEST_F(IntfTest, AddDelVmPortDepOnVmVn_2_Mirror) { client->Reset(); VrfAddReq("vrf2"); VnAddReq(1, "vn1", 0, "vrf2"); - + AnalyzerInfo analyzer_info; analyzer_info.analyzer_name = "Analyzer1"; analyzer_info.vrf_name = std::string(); @@ -587,7 +585,7 @@ TEST_F(IntfTest, AddDelVmPortDepOnVmVn_2_Mirror) { CfgIntfSync(1, "cfg-vnet1", 1, 1, list, "vrf2", "1.1.1.1", analyzer_info); client->WaitForIdle(); EXPECT_EQ(VmPortGetMirrorDirection(1), Interface::MIRROR_TX); - + client->Reset(); VmDelReq(1); CfgIntfSync(1, "cfg-vnet1", 1, 1, "vrf2", "1.1.1.1"); @@ -887,7 +885,7 @@ TEST_F(IntfTest, VmPortPolicy_2) { EXPECT_TRUE(client->PortNotifyWait(2)); EXPECT_FALSE(VmPortFind(1)); EXPECT_FALSE(VmPortFind(2)); - WAIT_FOR(100, 1000, + WAIT_FOR(100, 1000, (Agent::GetInstance()->interface_table()->Size() == 3U)); WAIT_FOR(100, 1000, (Agent::GetInstance()->vm_table()->Size() == 0U)); WAIT_FOR(100, 1000, (Agent::GetInstance()->vn_table()->Size() == 1U)); @@ -927,7 +925,7 @@ TEST_F(IntfTest, VmPortFloatingIp_1) { EXPECT_TRUE(client->PortNotifyWait(1)); EXPECT_TRUE(VmPortActive(1)); - // Ensure 2 FIP added to intf, policy enabled on interface and + // Ensure 2 FIP added to intf, policy enabled on interface and // FIP route exported to FIP VRF EXPECT_TRUE(VmPortFloatingIpCount(1, 1)); EXPECT_TRUE(VmPortPolicyEnable(1)); @@ -1157,7 +1155,7 @@ TEST_F(IntfTest, VmPortFloatingIpDelete_1) { CreateVmportEnv(input, 1); client->WaitForIdle(); EXPECT_TRUE(VmPortActive(input, 0)); - + AddVn("default-project:vn2", 2); AddVrf("default-project:vn2:vn2", 2); AddLink("virtual-network", "default-project:vn2", "routing-instance", @@ -1426,7 +1424,7 @@ TEST_F(IntfTest, IntfActivateDeactivate_2) { // and verify layer2 nexthops are absent //2> Activate layer2 forwarding of interface by changing forward mode in VN // verify layer 2 nexthop are added -//3> Activate both layer 2 and layer 3 forwarding, and verify both layer2 and +//3> Activate both layer 2 and layer 3 forwarding, and verify both layer2 and // layer3 nexthop are present //4> Delete the interface , and verify all nexthop are deleted TEST_F(IntfTest, IntfActivateDeactivate_3) { @@ -1492,7 +1490,7 @@ TEST_F(IntfTest, IntfActivateDeactivate_3) { //1> Deactivate layer3 forwarding of interface by changing forward mode in VN // verify layer 3 nexthop are deleted -//2> Activate both layer 2 and layer 3 forwarding, and verify both layer2 and +//2> Activate both layer 2 and layer 3 forwarding, and verify both layer2 and // layer3 nexthop are present //3> Delete the interface , and verify all nexthop are deleted TEST_F(IntfTest, IntfActivateDeactivate_4) { @@ -1621,7 +1619,7 @@ TEST_F(IntfTest, VmPortServiceVlanDelete_1) { CreateVmportEnv(input, 1); client->WaitForIdle(); EXPECT_TRUE(VmPortActive(input, 0)); - + AddVn("vn2", 2); AddVrf("vrf2", 2); AddLink("virtual-network", "vn2", "routing-instance", "vrf2"); @@ -1925,7 +1923,7 @@ TEST_F(IntfTest, VmPortServiceVlanAdd_3) { EXPECT_FALSE(VrfFind("vrf2")); } -//Add and delete static route +//Add and delete static route TEST_F(IntfTest, IntfStaticRoute) { struct PortInfo input[] = { {"vnet1", 1, "1.1.1.10", "00:00:00:01:01:01", 1, 1}, @@ -1946,7 +1944,7 @@ TEST_F(IntfTest, IntfStaticRoute) { AddLink("virtual-machine-interface", "vnet1", "interface-route-table", "static_route"); client->WaitForIdle(); - EXPECT_TRUE(RouteFind("vrf1", static_route[0].addr_, + EXPECT_TRUE(RouteFind("vrf1", static_route[0].addr_, static_route[0].plen_)); EXPECT_TRUE(RouteFind("vrf1", static_route[1].addr_, static_route[1].plen_)); @@ -1957,13 +1955,13 @@ TEST_F(IntfTest, IntfStaticRoute) { DelLink("virtual-machine-interface", "vnet1", "interface-route-table", "static_route"); client->WaitForIdle(); - EXPECT_FALSE(RouteFind("vrf1", static_route[0].addr_, + EXPECT_FALSE(RouteFind("vrf1", static_route[0].addr_, static_route[0].plen_)); - EXPECT_FALSE(RouteFind("vrf1", static_route[1].addr_, + EXPECT_FALSE(RouteFind("vrf1", static_route[1].addr_, static_route[1].plen_)); DoInterfaceSandesh("vnet1"); client->WaitForIdle(); - + DelLink("virtual-machine-interface", "vnet1", "interface-route-table", "static_route"); DeleteVmportEnv(input, 1, true); @@ -1971,7 +1969,7 @@ TEST_F(IntfTest, IntfStaticRoute) { EXPECT_FALSE(VmPortFind(1)); } -//Add static route, deactivate interface and make static routes are deleted +//Add static route, deactivate interface and make static routes are deleted TEST_F(IntfTest, IntfStaticRoute_1) { struct PortInfo input[] = { {"vnet1", 1, "1.1.1.10", "00:00:00:01:01:01", 1, 1}, @@ -1992,7 +1990,7 @@ TEST_F(IntfTest, IntfStaticRoute_1) { AddLink("virtual-machine-interface", "vnet1", "interface-route-table", "static_route"); client->WaitForIdle(); - EXPECT_TRUE(RouteFind("vrf1", static_route[0].addr_, + EXPECT_TRUE(RouteFind("vrf1", static_route[0].addr_, static_route[0].plen_)); EXPECT_TRUE(RouteFind("vrf1", static_route[1].addr_, static_route[1].plen_)); @@ -2001,20 +1999,20 @@ TEST_F(IntfTest, IntfStaticRoute_1) { DelLink("virtual-machine-interface", "vnet1", "virtual-network", "vn1"); client->WaitForIdle(); - EXPECT_FALSE(RouteFind("vrf1", static_route[0].addr_, + EXPECT_FALSE(RouteFind("vrf1", static_route[0].addr_, static_route[0].plen_)); - EXPECT_FALSE(RouteFind("vrf1", static_route[1].addr_, + EXPECT_FALSE(RouteFind("vrf1", static_route[1].addr_, static_route[1].plen_)); //Activate interface and make sure route are added again AddLink("virtual-machine-interface", "vnet1", "virtual-network", "vn1"); client->WaitForIdle(); - EXPECT_TRUE(RouteFind("vrf1", static_route[0].addr_, + EXPECT_TRUE(RouteFind("vrf1", static_route[0].addr_, static_route[0].plen_)); EXPECT_TRUE(RouteFind("vrf1", static_route[1].addr_, static_route[1].plen_)); - + DelLink("virtual-machine-interface", "vnet1", "interface-route-table", "static_route"); DeleteVmportEnv(input, 1, true); @@ -2044,7 +2042,7 @@ TEST_F(IntfTest, IntfStaticRoute_2) { AddLink("virtual-machine-interface", "vnet1", "interface-route-table", "static_route"); client->WaitForIdle(); - EXPECT_TRUE(RouteFind("vrf1", static_route[0].addr_, + EXPECT_TRUE(RouteFind("vrf1", static_route[0].addr_, static_route[0].plen_)); EXPECT_TRUE(RouteFind("vrf1", static_route[1].addr_, static_route[1].plen_)); @@ -2054,7 +2052,7 @@ TEST_F(IntfTest, IntfStaticRoute_2) { //Verify all 3 routes are present AddInterfaceRouteTable("static_route", 1, static_route, 3); client->WaitForIdle(); - EXPECT_TRUE(RouteFind("vrf1", static_route[0].addr_, + EXPECT_TRUE(RouteFind("vrf1", static_route[0].addr_, static_route[0].plen_)); EXPECT_TRUE(RouteFind("vrf1", static_route[1].addr_, static_route[1].plen_)); @@ -2092,7 +2090,7 @@ TEST_F(IntfTest, IntfStaticRoute_3) { AddLink("virtual-machine-interface", "vnet1", "interface-route-table", "static_route"); client->WaitForIdle(); - EXPECT_TRUE(RouteFind("vrf1", static_route[0].addr_, + EXPECT_TRUE(RouteFind("vrf1", static_route[0].addr_, static_route[0].plen_)); const NextHop *nh; nh = RouteGet("vrf1", static_route[0].addr_, @@ -2152,7 +2150,7 @@ TEST_F(IntfTest, IntfStaticRoute_4) { AddLink("virtual-machine-interface", "vnet1", "interface-route-table", "static_route"); client->WaitForIdle(); - EXPECT_FALSE(RouteFind("vrf1", static_route[0].addr_, + EXPECT_FALSE(RouteFind("vrf1", static_route[0].addr_, static_route[0].plen_)); EXPECT_FALSE(RouteFind("vrf1", static_route[1].addr_, static_route[1].plen_)); @@ -2165,7 +2163,7 @@ TEST_F(IntfTest, IntfStaticRoute_4) { AddPort("vnet1", 1); client->WaitForIdle(); EXPECT_TRUE(VmPortActive(input, 0)); - EXPECT_TRUE(RouteFind("vrf1", static_route[0].addr_, + EXPECT_TRUE(RouteFind("vrf1", static_route[0].addr_, static_route[0].plen_)); EXPECT_TRUE(RouteFind("vrf1", static_route[1].addr_, static_route[1].plen_)); @@ -2242,7 +2240,7 @@ TEST_F(IntfTest, vm_interface_key_verification) { TEST_F(IntfTest, packet_interface_get_key_verification) { PacketInterfaceKey key(nil_uuid(), "pkt0"); - Interface *intf = + Interface *intf = static_cast(agent->interface_table()->FindActiveEntry(&key)); DBEntryBase::KeyPtr entry_key = intf->GetDBRequestKey(); EXPECT_TRUE(entry_key.get() != NULL); @@ -2261,7 +2259,7 @@ TEST_F(IntfTest, sandesh_vm_interface_l2_only) { client->Reset(); AddL2Vn("vn1", 1); AddVrf("vrf1"); - AddLink("virtual-network", "vn1", "routing-instance", "vrf1"); + AddLink("virtual-network", "vn1", "routing-instance", "vrf1"); client->WaitForIdle(); CreateL2VmportEnv(input1, 1); client->WaitForIdle(); @@ -2274,7 +2272,7 @@ TEST_F(IntfTest, sandesh_vm_interface_l2_only) { client->WaitForIdle(); client->Reset(); - DeleteVmportEnv(input1, 1, true); + DeleteVmportEnv(input1, 1, true); client->WaitForIdle(); EXPECT_FALSE(VmPortFind(8)); } @@ -2296,7 +2294,7 @@ TEST_F(IntfTest, sandesh_vm_interface_without_ip) { client->WaitForIdle(); client->Reset(); - DeleteVmportEnv(input1, 1, true); + DeleteVmportEnv(input1, 1, true); client->WaitForIdle(); EXPECT_FALSE(VmPortFind(8)); } @@ -2477,7 +2475,7 @@ TEST_F(IntfTest, Intf_l2mode_deactivate_activat_via_os_state) { EXPECT_TRUE(VmPortFind(1)); VmInterface *vm_interface = static_cast(VmPortGet(1)); EXPECT_TRUE(vm_interface->vxlan_id() != 0); - uint32_t vxlan_id = vm_interface->vxlan_id(); + int32_t vxlan_id = vm_interface->vxlan_id(); //Deactivate OS state (IF down) DBRequest req(DBRequest::DB_ENTRY_ADD_CHANGE); diff --git a/src/vnsw/agent/oper/test/test_ipv6.cc b/src/vnsw/agent/oper/test/test_ipv6.cc index 662bf72baad..df0823a63d3 100644 --- a/src/vnsw/agent/oper/test/test_ipv6.cc +++ b/src/vnsw/agent/oper/test/test_ipv6.cc @@ -48,8 +48,8 @@ #include "test/test_init.h" #include "test_cmn_util.h" #include "vr_types.h" -#include -#include +#include +#include #include #include "oper/path_preference.h" #include "services/icmpv6_proto.h" @@ -73,7 +73,7 @@ class Ipv6Test : public ::testing::Test { WAIT_FOR(100, 1000, (agent_->vn_table()->Size() == 0U)); } - int intf_count_; + unsigned int intf_count_; Agent *agent_; }; diff --git a/src/vnsw/agent/services/test/metadata_test.cc b/src/vnsw/agent/services/test/metadata_test.cc index a4deddc8d01..ea86a636c5b 100644 --- a/src/vnsw/agent/services/test/metadata_test.cc +++ b/src/vnsw/agent/services/test/metadata_test.cc @@ -104,9 +104,9 @@ class MetadataTest : public ::testing::Test { } } - uint32_t GetItfCount() { + uint32_t GetItfCount() { tbb::mutex::scoped_lock lock(mutex_); - return itf_count_; + return itf_count_; } void WaitForItfUpdate(unsigned int expect_count) { @@ -123,9 +123,9 @@ class MetadataTest : public ::testing::Test { void SetupLinkLocalConfig() { std::stringstream global_config; - global_config << "\n" + global_config << "\n" << "\n" - << "metadata\n" + << "metadata\n" << "\n" << "0\n" << "\n" @@ -254,7 +254,7 @@ class MetadataTest : public ::testing::Test { } void StartNovaApiProxy() { - nova_api_proxy_ = + nova_api_proxy_ = new HttpServer(Agent::GetInstance()->event_manager()); nova_api_proxy_->RegisterHandler(HTTP_WILDCARD_ENTRY, boost::bind(&MetadataTest::HandleNovaApiRequest, this, _1, _2)); @@ -365,7 +365,7 @@ TEST_F(MetadataTest, MetadataReqTest) { client->Reset(); StopHttpClient(); - DeleteVmportEnv(input, 1, 1, 0); + DeleteVmportEnv(input, 1, 1, 0); client->WaitForIdle(); ClearLinkLocalConfig(); @@ -440,7 +440,7 @@ TEST_F(MetadataTest, MetadataOtherMethodsTest) { client->Reset(); StopHttpClient(); - DeleteVmportEnv(input, 1, 1, 0); + DeleteVmportEnv(input, 1, 1, 0); client->WaitForIdle(); ClearLinkLocalConfig(); @@ -481,7 +481,7 @@ TEST_F(MetadataTest, MetadataNoLinkLocalTest) { client->Reset(); StopHttpClient(); - DeleteVmportEnv(input, 1, 1, 0); + DeleteVmportEnv(input, 1, 1, 0); client->WaitForIdle(); StopNovaApiProxy(); @@ -492,7 +492,6 @@ TEST_F(MetadataTest, MetadataNoLinkLocalTest) { // Send message and close server connection while message is going TEST_F(MetadataTest, MetadataCloseServerTest) { - int count = 0; MetadataProxy::MetadataStats stats; struct PortInfo input[] = { {"vnet1", 1, vm1_ip, "00:00:00:01:01:01", 1, 1}, @@ -514,7 +513,7 @@ TEST_F(MetadataTest, MetadataCloseServerTest) { for (int i = 0; i < 200; i++) { large_data.append("add more data to be sent"); } - HttpConnection *conn = SendHttpClientRequest(POST_METHOD, large_data); + SendHttpClientRequest(POST_METHOD, large_data); // stop server StopNovaApiProxy(); client->WaitForIdle(); diff --git a/src/vnsw/agent/test-xml/test_xml.cc b/src/vnsw/agent/test-xml/test_xml.cc index 1de7e005e3e..36f31bf243f 100644 --- a/src/vnsw/agent/test-xml/test_xml.cc +++ b/src/vnsw/agent/test-xml/test_xml.cc @@ -76,13 +76,13 @@ void LinkXmlNode(xml_node *parent, const string <ype, const string lname, xml_node n1 = n.append_child("node"); n1.append_attribute("type") = ltype.c_str(); - + xml_node n2 = n1.append_child("name"); n2.append_child(pugi::node_pcdata).set_value(lname.c_str()); n1 = n.append_child("node"); n1.append_attribute("type") = rtype.c_str(); - + n2 = n1.append_child("name"); n2.append_child(pugi::node_pcdata).set_value(rname.c_str()); @@ -338,7 +338,7 @@ bool AgentUtXmlTestCase::ReadXml() { if (cfg) { cfg->set_op_delete(op_delete); } else { - cout << "Unknown node name <" << node.name() << ">. Ignoring" + cout << "Unknown node name <" << node.name() << ">. Ignoring" << endl; } if (cfg) { @@ -489,7 +489,7 @@ void AgentUtXmlLink::ToString(string *str) { stringstream s; s << "<" << l_node_ << " : " << l_name_ << "> <" << " right-node " - << r_node_ << " : " << r_name_ << ">" << endl; + << r_node_ << " : " << r_name_ << ">" << endl; *str += s.str(); return; @@ -545,9 +545,9 @@ static void AddUuid(xml_node *parent, const uuid &id) { std::vector v(id.size()); std::copy(id.begin(), id.end(), v.begin()); - uint64_t ms_val = v[7] + (v[6] << 8) + (v[5] << 16) + (v[4] << 24) + + uint64_t ms_val = v[7] + (v[6] << 8) + (v[5] << 16) + (v[4] << 24) + (v[3] << 32) + (v[2] << 40) + (v[1] << 48) + (v[0] << 56); - uint64_t ls_val = v[15] + (v[14] << 8) + (v[13] << 16) + (v[12] << 24) + + uint64_t ls_val = v[15] + (v[14] << 8) + (v[13] << 16) + (v[12] << 24) + (v[11] << 32) + (v[10] << 40) + (v[9] << 48) + (v[8] << 56); stringstream s; s << ms_val; @@ -585,7 +585,6 @@ bool AgentUtXmlPacket::ReadXml() { GetStringAttribute(node(), "tunnel_dip", &tunnel_dip_); GetUintAttribute(node(), "label", (uint16_t *)&label_); - uint16_t id = 0; if (GetUintAttribute(node(), "id", &intf_id_) == false) { cout << "Attribute \"id\" not specified for Packet. Skipping" << endl; @@ -610,7 +609,7 @@ bool AgentUtXmlPacket::ReadXml() { if (GetStringAttribute(node(), "proto", &proto_) == false && GetUintAttribute(node(), "proto", &proto_id_) == false) { - cout << "Attribute \"proto\" not specified for Packet. Skipping" + cout << "Attribute \"proto\" not specified for Packet. Skipping" << endl; return false; } @@ -684,7 +683,7 @@ bool AgentUtXmlPacket::Run() { TxIp6Packet(intf_id_, sip_.c_str(), dip_.c_str(), proto_id_); } } - + return true; } diff --git a/src/vnsw/agent/test-xml/test_xml_oper.cc b/src/vnsw/agent/test-xml/test_xml_oper.cc index f929f7151b2..89b9df194e2 100644 --- a/src/vnsw/agent/test-xml/test_xml_oper.cc +++ b/src/vnsw/agent/test-xml/test_xml_oper.cc @@ -773,7 +773,6 @@ AgentUtXmlFlowValidate::~AgentUtXmlFlowValidate() { } bool AgentUtXmlFlowValidate::ReadXml() { - uint16_t id = 0; if (GetUintAttribute(node(), "nh", &nh_id_) == false) { cout << "Attribute \"nh\" not specified for Flow. Skipping" << endl; return false; @@ -791,7 +790,7 @@ bool AgentUtXmlFlowValidate::ReadXml() { if (GetStringAttribute(node(), "proto", &proto_) == false && GetUintAttribute(node(), "proto", &proto_id_) == false) { - cout << "Attribute \"proto\" not specified for Flow. Skipping" + cout << "Attribute \"proto\" not specified for Flow. Skipping" << endl; return false; } diff --git a/src/vnsw/agent/test/test_xmpp_discovery.cc b/src/vnsw/agent/test/test_xmpp_discovery.cc index 6e8d1bcb446..4d00db22a38 100644 --- a/src/vnsw/agent/test/test_xmpp_discovery.cc +++ b/src/vnsw/agent/test/test_xmpp_discovery.cc @@ -73,7 +73,7 @@ class ControlNodeMockBgpXmppPeer { void ReceiveUpdate(const XmppStanza::XmppMessage *msg) { rx_count_++; - } + } void HandleXmppChannelEvent(XmppChannel *channel, xmps::PeerState state) { @@ -97,7 +97,7 @@ class ControlNodeMockBgpXmppPeer { } bool SendUpdate(uint8_t *msg, size_t size) { - if (channel_ && + if (channel_ && (channel_->GetPeerState() == xmps::READY)) { return channel_->Send(msg, size, xmps::BGP, boost::bind(&ControlNodeMockBgpXmppPeer::WriteReadyCb, this, _1)); @@ -117,17 +117,17 @@ class ControlNodeMockBgpXmppPeer { }; -class AgentXmppUnitTest : public ::testing::Test { +class AgentXmppUnitTest : public ::testing::Test { protected: AgentXmppUnitTest() : thread_(&evm_), agent_(Agent::GetInstance()) {} - + virtual void SetUp() { //TestInit initilaizes xmpp connection to 127.0.0.1, so disconnect that //and again spawn a new one. Its required since the receive path //is overridden by mock class. - //TODO later use the agent initializer - agent_->controller()->Cleanup(); + //TODO later use the agent initializer + agent_->controller()->Cleanup(); client->WaitForIdle(); agent_->controller()->DisConnect(); client->WaitForIdle(); @@ -145,7 +145,7 @@ class AgentXmppUnitTest : public ::testing::Test { xs4->Initialize(0, false); xs5->Initialize(0, false); xs6->Initialize(0, false); - + thread_.Start(); } @@ -177,40 +177,40 @@ class AgentXmppUnitTest : public ::testing::Test { //Init VNController for running tests agent_->controller()->Connect(); - //Create control-node bgp mock peer + //Create control-node bgp mock peer mock_peer1.reset(new ControlNodeMockBgpXmppPeer()); xs1->RegisterConnectionEvent(xmps::BGP, - boost::bind(&ControlNodeMockBgpXmppPeer::HandleXmppChannelEvent, + boost::bind(&ControlNodeMockBgpXmppPeer::HandleXmppChannelEvent, mock_peer1.get(), _1, _2)); - //Create control-node bgp mock peer + //Create control-node bgp mock peer mock_peer2.reset(new ControlNodeMockBgpXmppPeer()); xs2->RegisterConnectionEvent(xmps::BGP, - boost::bind(&ControlNodeMockBgpXmppPeer::HandleXmppChannelEvent, + boost::bind(&ControlNodeMockBgpXmppPeer::HandleXmppChannelEvent, mock_peer2.get(), _1, _2)); - //Create control-node bgp mock peer + //Create control-node bgp mock peer mock_peer3.reset(new ControlNodeMockBgpXmppPeer()); xs3->RegisterConnectionEvent(xmps::BGP, - boost::bind(&ControlNodeMockBgpXmppPeer::HandleXmppChannelEvent, + boost::bind(&ControlNodeMockBgpXmppPeer::HandleXmppChannelEvent, mock_peer3.get(), _1, _2)); - //Create control-node bgp mock peer + //Create control-node bgp mock peer mock_peer4.reset(new ControlNodeMockBgpXmppPeer()); xs4->RegisterConnectionEvent(xmps::BGP, - boost::bind(&ControlNodeMockBgpXmppPeer::HandleXmppChannelEvent, + boost::bind(&ControlNodeMockBgpXmppPeer::HandleXmppChannelEvent, mock_peer4.get(), _1, _2)); - //Create control-node bgp mock peer + //Create control-node bgp mock peer mock_peer5.reset(new ControlNodeMockBgpXmppPeer()); xs5->RegisterConnectionEvent(xmps::BGP, - boost::bind(&ControlNodeMockBgpXmppPeer::HandleXmppChannelEvent, + boost::bind(&ControlNodeMockBgpXmppPeer::HandleXmppChannelEvent, mock_peer5.get(), _1, _2)); - //Create control-node bgp mock peer + //Create control-node bgp mock peer mock_peer6.reset(new ControlNodeMockBgpXmppPeer()); xs6->RegisterConnectionEvent(xmps::BGP, - boost::bind(&ControlNodeMockBgpXmppPeer::HandleXmppChannelEvent, + boost::bind(&ControlNodeMockBgpXmppPeer::HandleXmppChannelEvent, mock_peer6.get(), _1, _2)); } @@ -254,19 +254,19 @@ TEST_F(AgentXmppUnitTest, XmppConnection_Discovery) { client->WaitForIdle(); //wait for connection establishment - EXPECT_TRUE(agent_->controller_ifmap_xmpp_port(0) == xs1->GetPort()); - WAIT_FOR(1000, 10000, + EXPECT_TRUE(agent_->controller_ifmap_xmpp_port(0) == (uint32_t)xs1->GetPort()); + WAIT_FOR(1000, 10000, agent_->controller_xmpp_channel(0)->GetXmppChannel()->GetPeerState() - == xmps::READY); + == xmps::READY); client->WaitForIdle(); - //Bring down Xmpp Server + //Bring down Xmpp Server xs1->Shutdown(); - WAIT_FOR(1000, 10000, + WAIT_FOR(1000, 10000, agent_->controller_xmpp_channel(0)->GetXmppChannel()->GetPeerState() == xmps::NOT_READY); - //Discovery indicating new Xmpp Server + //Discovery indicating new Xmpp Server ds_response.clear(); resp.ep.address(boost::asio::ip::address::from_string("127.0.0.2")); resp.ep.port(xs2->GetPort()); @@ -276,16 +276,16 @@ TEST_F(AgentXmppUnitTest, XmppConnection_Discovery) { client->WaitForIdle(); //wait for connection establishment - EXPECT_TRUE(agent_->controller_ifmap_xmpp_port(1) == xs2->GetPort()); - WAIT_FOR(1000, 10000, - agent_->controller_xmpp_channel(1)->GetXmppChannel()->GetPeerState() - == xmps::READY); + EXPECT_TRUE(agent_->controller_ifmap_xmpp_port(1) == (uint32_t)xs2->GetPort()); + WAIT_FOR(1000, 10000, + agent_->controller_xmpp_channel(1)->GetXmppChannel()->GetPeerState() + == xmps::READY); client->WaitForIdle(); //Bring down Xmpp Server xs2->Shutdown(); - WAIT_FOR(1000, 10000, - agent_->controller_xmpp_channel(1)->GetXmppChannel()->GetPeerState() + WAIT_FOR(1000, 10000, + agent_->controller_xmpp_channel(1)->GetXmppChannel()->GetPeerState() == xmps::NOT_READY); //Discovery indicating new Xmpp Server @@ -298,10 +298,10 @@ TEST_F(AgentXmppUnitTest, XmppConnection_Discovery) { client->WaitForIdle(); //wait for connection establishment - EXPECT_TRUE(agent_->controller_ifmap_xmpp_port(0) == xs3->GetPort()); - WAIT_FOR(1000, 10000, - agent_->controller_xmpp_channel(0)->GetXmppChannel()->GetPeerState() - == xmps::READY); + EXPECT_TRUE(agent_->controller_ifmap_xmpp_port(0) == (uint32_t)xs3->GetPort()); + WAIT_FOR(1000, 10000, + agent_->controller_xmpp_channel(0)->GetXmppChannel()->GetPeerState() + == xmps::READY); // Wait until older XmppClient, XmppChannel is cleaned client->WaitForIdle(); @@ -318,15 +318,15 @@ TEST_F(AgentXmppUnitTest, XmppConnection_Discovery) { client->WaitForIdle(); //wait for connection establishment - EXPECT_TRUE(agent_->controller_ifmap_xmpp_port(0) == xs3->GetPort()); - WAIT_FOR(1000, 10000, - agent_->controller_xmpp_channel(0)->GetXmppChannel()->GetPeerState() - == xmps::READY); - - EXPECT_TRUE(agent_->controller_ifmap_xmpp_port(1) == xs4->GetPort()); - WAIT_FOR(1000, 10000, - agent_->controller_xmpp_channel(1)->GetXmppChannel()->GetPeerState() - == xmps::READY); + EXPECT_TRUE(agent_->controller_ifmap_xmpp_port(0) == (uint32_t)xs3->GetPort()); + WAIT_FOR(1000, 10000, + agent_->controller_xmpp_channel(0)->GetXmppChannel()->GetPeerState() + == xmps::READY); + + EXPECT_TRUE(agent_->controller_ifmap_xmpp_port(1) == (uint32_t)xs4->GetPort()); + WAIT_FOR(1000, 10000, + agent_->controller_xmpp_channel(1)->GetXmppChannel()->GetPeerState() + == xmps::READY); // Wait until older XmppClient, XmppChannel is cleaned client->WaitForIdle(); @@ -349,15 +349,15 @@ TEST_F(AgentXmppUnitTest, XmppConnection_Discovery) { client->WaitForIdle(); //wait for connection establishment - EXPECT_TRUE(agent_->controller_ifmap_xmpp_port(0) == xs5->GetPort()); - WAIT_FOR(1000, 10000, - agent_->controller_xmpp_channel(0)->GetXmppChannel()->GetPeerState() - == xmps::READY); - - EXPECT_TRUE(agent_->controller_ifmap_xmpp_port(1) == xs6->GetPort()); - WAIT_FOR(1000, 10000, - agent_->controller_xmpp_channel(1)->GetXmppChannel()->GetPeerState() - == xmps::READY); + EXPECT_TRUE(agent_->controller_ifmap_xmpp_port(0) == (uint32_t)xs5->GetPort()); + WAIT_FOR(1000, 10000, + agent_->controller_xmpp_channel(0)->GetXmppChannel()->GetPeerState() + == xmps::READY); + + EXPECT_TRUE(agent_->controller_ifmap_xmpp_port(1) == (uint32_t)xs6->GetPort()); + WAIT_FOR(1000, 10000, + agent_->controller_xmpp_channel(1)->GetXmppChannel()->GetPeerState() + == xmps::READY); // Wait until older XmppClient, XmppChannel is cleaned client->WaitForIdle();