Vince Lehman | 4387e78 | 2014-06-19 16:57:45 -0500 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
| 3 | * Copyright (c) 2014, Regents of the University of California, |
| 4 | * Arizona Board of Regents, |
| 5 | * Colorado State University, |
| 6 | * University Pierre & Marie Curie, Sorbonne University, |
| 7 | * Washington University in St. Louis, |
| 8 | * Beijing Institute of Technology, |
| 9 | * The University of Memphis |
| 10 | * |
| 11 | * This file is part of NFD (Named Data Networking Forwarding Daemon). |
| 12 | * See AUTHORS.md for complete list of NFD authors and contributors. |
| 13 | * |
| 14 | * NFD is free software: you can redistribute it and/or modify it under the terms |
| 15 | * of the GNU General Public License as published by the Free Software Foundation, |
| 16 | * either version 3 of the License, or (at your option) any later version. |
| 17 | * |
| 18 | * NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
| 19 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 20 | * PURPOSE. See the GNU General Public License for more details. |
| 21 | * |
| 22 | * You should have received a copy of the GNU General Public License along with |
| 23 | * NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>. |
| 24 | */ |
| 25 | |
| 26 | #include "rib/rib.hpp" |
| 27 | |
| 28 | #include "tests/test-common.hpp" |
| 29 | #include "fib-updates-common.hpp" |
| 30 | |
| 31 | namespace nfd { |
| 32 | namespace rib { |
| 33 | namespace tests { |
| 34 | |
| 35 | BOOST_FIXTURE_TEST_SUITE(FibUpdates, FibUpdatesFixture) |
| 36 | |
| 37 | BOOST_AUTO_TEST_SUITE(EraseFace) |
| 38 | |
| 39 | BOOST_AUTO_TEST_CASE(WithInheritedFace_Root) |
| 40 | { |
Vince Lehman | 218be0a | 2015-01-15 17:25:20 -0600 | [diff] [blame] | 41 | insertRoute("/", 1, 0, 10, ndn::nfd::ROUTE_FLAG_CHILD_INHERIT); |
| 42 | insertRoute("/a", 1, 0, 50, ndn::nfd::ROUTE_FLAG_CHILD_INHERIT); |
| 43 | insertRoute("/a/b", 2, 0, 75, 0); |
Vince Lehman | 4387e78 | 2014-06-19 16:57:45 -0500 | [diff] [blame] | 44 | |
| 45 | // Clear updates generated from previous insertions |
| 46 | rib.clearFibUpdates(); |
| 47 | |
| 48 | // Should generate 1 updates: 1 to remove face 1 from / |
Vince Lehman | 218be0a | 2015-01-15 17:25:20 -0600 | [diff] [blame] | 49 | eraseRoute("/", 1, 0); |
Vince Lehman | 4387e78 | 2014-06-19 16:57:45 -0500 | [diff] [blame] | 50 | |
| 51 | Rib::FibUpdateList updates = getSortedFibUpdates(); |
| 52 | BOOST_REQUIRE_EQUAL(updates.size(), 1); |
| 53 | |
| 54 | Rib::FibUpdateList::const_iterator update = updates.begin(); |
| 55 | BOOST_CHECK_EQUAL((*update)->name, "/"); |
| 56 | BOOST_CHECK_EQUAL((*update)->faceId, 1); |
| 57 | BOOST_CHECK_EQUAL((*update)->action, FibUpdate::REMOVE_NEXTHOP); |
| 58 | } |
| 59 | |
| 60 | BOOST_AUTO_TEST_CASE(WithInheritedFace) |
| 61 | { |
Vince Lehman | 218be0a | 2015-01-15 17:25:20 -0600 | [diff] [blame] | 62 | insertRoute("/a", 5, 0, 10, ndn::nfd::ROUTE_FLAG_CHILD_INHERIT); |
| 63 | insertRoute("/a", 5, 255, 5, ndn::nfd::ROUTE_FLAG_CHILD_INHERIT); |
| 64 | insertRoute("/a", 2, 0, 20, 0); |
| 65 | insertRoute("/a/b", 3, 0, 5, 0); |
Vince Lehman | 4387e78 | 2014-06-19 16:57:45 -0500 | [diff] [blame] | 66 | |
| 67 | // /a should have face 5 with cost 10; /a/b should have face 3 with cost 5 and |
| 68 | // face 5 with cost 10 |
Vince Lehman | 218be0a | 2015-01-15 17:25:20 -0600 | [diff] [blame] | 69 | eraseRoute("/a", 5, 255); |
Vince Lehman | 4387e78 | 2014-06-19 16:57:45 -0500 | [diff] [blame] | 70 | |
| 71 | // Clear updates generated from previous insertions |
| 72 | rib.clearFibUpdates(); |
| 73 | |
Vince Lehman | 218be0a | 2015-01-15 17:25:20 -0600 | [diff] [blame] | 74 | // Should generate 2 updates: 1 to remove face 3 from /a/b and one to remove inherited route |
| 75 | eraseRoute("/a/b", 3, 0); |
Vince Lehman | 4387e78 | 2014-06-19 16:57:45 -0500 | [diff] [blame] | 76 | |
| 77 | Rib::FibUpdateList updates = getSortedFibUpdates(); |
| 78 | BOOST_REQUIRE_EQUAL(updates.size(), 2); |
| 79 | |
| 80 | Rib::FibUpdateList::const_iterator update = updates.begin(); |
| 81 | BOOST_CHECK_EQUAL((*update)->name, "/a/b"); |
| 82 | BOOST_CHECK_EQUAL((*update)->faceId, 3); |
| 83 | BOOST_CHECK_EQUAL((*update)->action, FibUpdate::REMOVE_NEXTHOP); |
| 84 | |
| 85 | ++update; |
| 86 | BOOST_CHECK_EQUAL((*update)->name, "/a/b"); |
| 87 | BOOST_CHECK_EQUAL((*update)->faceId, 5); |
| 88 | BOOST_CHECK_EQUAL((*update)->action, FibUpdate::REMOVE_NEXTHOP); |
| 89 | } |
| 90 | |
| 91 | BOOST_AUTO_TEST_CASE(MultipleFaces) |
| 92 | { |
Vince Lehman | 218be0a | 2015-01-15 17:25:20 -0600 | [diff] [blame] | 93 | insertRoute("/a", 5, 0, 10, 0); |
| 94 | insertRoute("/a", 5, 255, 5, 0); |
Vince Lehman | 4387e78 | 2014-06-19 16:57:45 -0500 | [diff] [blame] | 95 | |
| 96 | // Clear updates generated from previous insertions |
| 97 | rib.clearFibUpdates(); |
| 98 | |
| 99 | // Should generate 1 updates: 1 to update cost to 10 for /a |
Vince Lehman | 218be0a | 2015-01-15 17:25:20 -0600 | [diff] [blame] | 100 | eraseRoute("/a", 5, 255); |
Vince Lehman | 4387e78 | 2014-06-19 16:57:45 -0500 | [diff] [blame] | 101 | |
| 102 | Rib::FibUpdateList updates = getSortedFibUpdates(); |
| 103 | BOOST_REQUIRE_EQUAL(updates.size(), 1); |
| 104 | |
| 105 | Rib::FibUpdateList::const_iterator update = updates.begin(); |
| 106 | BOOST_CHECK_EQUAL((*update)->name, "/a"); |
| 107 | BOOST_CHECK_EQUAL((*update)->faceId, 5); |
| 108 | BOOST_CHECK_EQUAL((*update)->cost, 10); |
| 109 | BOOST_CHECK_EQUAL((*update)->action, FibUpdate::ADD_NEXTHOP); |
| 110 | } |
| 111 | |
| 112 | BOOST_AUTO_TEST_CASE(NoFlags_NoCaptureChange_NoCaptureOnRoute) |
| 113 | { |
Vince Lehman | 218be0a | 2015-01-15 17:25:20 -0600 | [diff] [blame] | 114 | insertRoute("/", 1, 0, 5, ndn::nfd::ROUTE_FLAG_CHILD_INHERIT); |
| 115 | insertRoute("/a", 2, 0, 10, 0); |
| 116 | insertRoute("/a/b", 3, 0, 10, 0); |
| 117 | insertRoute("/a/c", 1, 0, 100, 0); |
| 118 | insertRoute("/a", 1, 128, 50, 0); |
Vince Lehman | 4387e78 | 2014-06-19 16:57:45 -0500 | [diff] [blame] | 119 | |
| 120 | // Clear updates generated from previous insertions |
| 121 | rib.clearFibUpdates(); |
| 122 | |
| 123 | // Should generate 1 updates: 1 to update cost for /a |
Vince Lehman | 218be0a | 2015-01-15 17:25:20 -0600 | [diff] [blame] | 124 | eraseRoute("/a", 1, 128); |
Vince Lehman | 4387e78 | 2014-06-19 16:57:45 -0500 | [diff] [blame] | 125 | |
| 126 | Rib::FibUpdateList updates = getSortedFibUpdates(); |
| 127 | BOOST_REQUIRE_EQUAL(updates.size(), 1); |
| 128 | |
| 129 | Rib::FibUpdateList::const_iterator update = updates.begin(); |
| 130 | BOOST_CHECK_EQUAL((*update)->name, "/a"); |
| 131 | BOOST_CHECK_EQUAL((*update)->faceId, 1); |
| 132 | BOOST_CHECK_EQUAL((*update)->cost, 5); |
| 133 | BOOST_CHECK_EQUAL((*update)->action, FibUpdate::ADD_NEXTHOP); |
| 134 | } |
| 135 | |
| 136 | BOOST_AUTO_TEST_CASE(MakeRibEmpty) |
| 137 | { |
Vince Lehman | 218be0a | 2015-01-15 17:25:20 -0600 | [diff] [blame] | 138 | insertRoute("/", 1, 0, 5, ndn::nfd::ROUTE_FLAG_CHILD_INHERIT); |
Vince Lehman | 4387e78 | 2014-06-19 16:57:45 -0500 | [diff] [blame] | 139 | |
| 140 | // Clear updates generated from previous insertions |
| 141 | rib.clearFibUpdates(); |
| 142 | |
Vince Lehman | 218be0a | 2015-01-15 17:25:20 -0600 | [diff] [blame] | 143 | // Should generate 1 updates: 1 to remove route from / |
| 144 | eraseRoute("/", 1, 0); |
Vince Lehman | 4387e78 | 2014-06-19 16:57:45 -0500 | [diff] [blame] | 145 | |
| 146 | Rib::FibUpdateList updates = getSortedFibUpdates(); |
| 147 | BOOST_REQUIRE_EQUAL(updates.size(), 1); |
| 148 | |
| 149 | Rib::FibUpdateList::const_iterator update = updates.begin(); |
| 150 | BOOST_CHECK_EQUAL((*update)->name, "/"); |
| 151 | BOOST_CHECK_EQUAL((*update)->faceId, 1); |
| 152 | BOOST_CHECK_EQUAL((*update)->action, FibUpdate::REMOVE_NEXTHOP); |
| 153 | } |
| 154 | |
| 155 | BOOST_AUTO_TEST_CASE(NoFlags_NoCaptureChange_CaptureOnRoute) |
| 156 | { |
Vince Lehman | 218be0a | 2015-01-15 17:25:20 -0600 | [diff] [blame] | 157 | insertRoute("/", 1, 0, 5, ndn::nfd::ROUTE_FLAG_CHILD_INHERIT); |
| 158 | insertRoute("/a", 2, 0, 10, ndn::nfd::ROUTE_FLAG_CAPTURE); |
| 159 | insertRoute("/a/b", 3, 0, 10, 0); |
| 160 | insertRoute("/a/c", 1, 0, 100, 0); |
| 161 | insertRoute("/a", 1, 128, 50, 0); |
Vince Lehman | 4387e78 | 2014-06-19 16:57:45 -0500 | [diff] [blame] | 162 | |
| 163 | // Clear updates generated from previous insertions |
| 164 | rib.clearFibUpdates(); |
| 165 | |
Vince Lehman | 218be0a | 2015-01-15 17:25:20 -0600 | [diff] [blame] | 166 | // Should generate 1 updates: 1 to remove route from /a |
| 167 | eraseRoute("/a", 1, 128); |
Vince Lehman | 4387e78 | 2014-06-19 16:57:45 -0500 | [diff] [blame] | 168 | |
| 169 | Rib::FibUpdateList updates = getSortedFibUpdates(); |
| 170 | BOOST_REQUIRE_EQUAL(updates.size(), 1); |
| 171 | |
| 172 | Rib::FibUpdateList::const_iterator update = updates.begin(); |
| 173 | BOOST_CHECK_EQUAL((*update)->name, "/a"); |
| 174 | BOOST_CHECK_EQUAL((*update)->faceId, 1); |
| 175 | BOOST_CHECK_EQUAL((*update)->action, FibUpdate::REMOVE_NEXTHOP); |
| 176 | } |
| 177 | |
| 178 | BOOST_AUTO_TEST_CASE(BothFlags_NoCaptureChange_CaptureOnRoute) |
| 179 | { |
Vince Lehman | 218be0a | 2015-01-15 17:25:20 -0600 | [diff] [blame] | 180 | insertRoute("/", 1, 0, 5, ndn::nfd::ROUTE_FLAG_CHILD_INHERIT); |
| 181 | insertRoute("/a", 2, 0, 10, ndn::nfd::ROUTE_FLAG_CAPTURE); |
| 182 | insertRoute("/a/b", 3, 0, 10, 0); |
| 183 | insertRoute("/a/c", 1, 0, 100, 0); |
| 184 | insertRoute("/a", 1, 128, 50, (ndn::nfd::ROUTE_FLAG_CHILD_INHERIT | |
Vince Lehman | 4387e78 | 2014-06-19 16:57:45 -0500 | [diff] [blame] | 185 | ndn::nfd::ROUTE_FLAG_CAPTURE)); |
| 186 | |
| 187 | // Clear updates generated from previous insertions |
| 188 | rib.clearFibUpdates(); |
| 189 | |
| 190 | // Should generate 2 updates: 1 to remove face1 from /a and |
Vince Lehman | 218be0a | 2015-01-15 17:25:20 -0600 | [diff] [blame] | 191 | // 1 to remove face1 from /a/b |
| 192 | eraseRoute("/a", 1, 128); |
Vince Lehman | 4387e78 | 2014-06-19 16:57:45 -0500 | [diff] [blame] | 193 | |
| 194 | Rib::FibUpdateList updates = getSortedFibUpdates(); |
| 195 | BOOST_REQUIRE_EQUAL(updates.size(), 2); |
| 196 | |
| 197 | Rib::FibUpdateList::const_iterator update = updates.begin(); |
| 198 | BOOST_CHECK_EQUAL((*update)->name, "/a"); |
| 199 | BOOST_CHECK_EQUAL((*update)->faceId, 1); |
| 200 | BOOST_CHECK_EQUAL((*update)->action, FibUpdate::REMOVE_NEXTHOP); |
| 201 | |
| 202 | ++update; |
| 203 | BOOST_CHECK_EQUAL((*update)->name, "/a/b"); |
| 204 | BOOST_CHECK_EQUAL((*update)->faceId, 1); |
| 205 | BOOST_CHECK_EQUAL((*update)->action, FibUpdate::REMOVE_NEXTHOP); |
| 206 | } |
| 207 | |
| 208 | BOOST_AUTO_TEST_CASE(BothFlags_CaptureChange_NoCaptureOnRoute) |
| 209 | { |
Vince Lehman | 218be0a | 2015-01-15 17:25:20 -0600 | [diff] [blame] | 210 | insertRoute("/", 1, 0, 5, ndn::nfd::ROUTE_FLAG_CHILD_INHERIT); |
| 211 | insertRoute("/a", 2, 0, 10, 0); |
| 212 | insertRoute("/a/b", 3, 0, 10, 0); |
| 213 | insertRoute("/a/c", 1, 0, 100, 0); |
| 214 | insertRoute("/a", 1, 128, 50, (ndn::nfd::ROUTE_FLAG_CHILD_INHERIT | |
Vince Lehman | 4387e78 | 2014-06-19 16:57:45 -0500 | [diff] [blame] | 215 | ndn::nfd::ROUTE_FLAG_CAPTURE)); |
| 216 | |
| 217 | // Clear updates generated from previous insertions |
| 218 | rib.clearFibUpdates(); |
| 219 | |
| 220 | // Should generate 2 updates: 1 to add face1 to /a and |
| 221 | // 1 to add face1 to /a/b |
Vince Lehman | 218be0a | 2015-01-15 17:25:20 -0600 | [diff] [blame] | 222 | eraseRoute("/a", 1, 128); |
Vince Lehman | 4387e78 | 2014-06-19 16:57:45 -0500 | [diff] [blame] | 223 | |
| 224 | Rib::FibUpdateList updates = getSortedFibUpdates(); |
| 225 | BOOST_REQUIRE_EQUAL(updates.size(), 2); |
| 226 | |
| 227 | Rib::FibUpdateList::const_iterator update = updates.begin(); |
| 228 | BOOST_CHECK_EQUAL((*update)->name, "/a"); |
| 229 | BOOST_CHECK_EQUAL((*update)->faceId, 1); |
| 230 | BOOST_CHECK_EQUAL((*update)->cost, 5); |
| 231 | BOOST_CHECK_EQUAL((*update)->action, FibUpdate::ADD_NEXTHOP); |
| 232 | |
| 233 | ++update; |
| 234 | BOOST_CHECK_EQUAL((*update)->name, "/a/b"); |
| 235 | BOOST_CHECK_EQUAL((*update)->faceId, 1); |
| 236 | BOOST_CHECK_EQUAL((*update)->cost, 5); |
| 237 | BOOST_CHECK_EQUAL((*update)->action, FibUpdate::ADD_NEXTHOP); |
| 238 | } |
| 239 | |
| 240 | BOOST_AUTO_TEST_CASE(ChildInherit_NoCaptureChange_NoCaptureOnRoute) |
| 241 | { |
Vince Lehman | 218be0a | 2015-01-15 17:25:20 -0600 | [diff] [blame] | 242 | insertRoute("/", 1, 0, 5, ndn::nfd::ROUTE_FLAG_CHILD_INHERIT); |
| 243 | insertRoute("/a", 2, 0, 10, 0); |
| 244 | insertRoute("/a/b", 3, 0, 10, 0); |
| 245 | insertRoute("/a/c", 1, 0, 100, 0); |
| 246 | insertRoute("/a", 1, 128, 50, ndn::nfd::ROUTE_FLAG_CHILD_INHERIT); |
Vince Lehman | 4387e78 | 2014-06-19 16:57:45 -0500 | [diff] [blame] | 247 | |
| 248 | // Clear updates generated from previous insertions |
| 249 | rib.clearFibUpdates(); |
| 250 | |
| 251 | // Should generate 2 updates: 2 to add face1 to /a and /a/b |
Vince Lehman | 218be0a | 2015-01-15 17:25:20 -0600 | [diff] [blame] | 252 | eraseRoute("/a", 1, 128); |
Vince Lehman | 4387e78 | 2014-06-19 16:57:45 -0500 | [diff] [blame] | 253 | |
| 254 | Rib::FibUpdateList updates = getSortedFibUpdates(); |
| 255 | BOOST_REQUIRE_EQUAL(updates.size(), 2); |
| 256 | |
| 257 | Rib::FibUpdateList::const_iterator update = updates.begin(); |
| 258 | BOOST_CHECK_EQUAL((*update)->name, "/a"); |
| 259 | BOOST_CHECK_EQUAL((*update)->faceId, 1); |
| 260 | BOOST_CHECK_EQUAL((*update)->cost, 5); |
| 261 | BOOST_CHECK_EQUAL((*update)->action, FibUpdate::ADD_NEXTHOP); |
| 262 | |
| 263 | ++update; |
| 264 | BOOST_CHECK_EQUAL((*update)->name, "/a/b"); |
| 265 | BOOST_CHECK_EQUAL((*update)->faceId, 1); |
| 266 | BOOST_CHECK_EQUAL((*update)->cost, 5); |
| 267 | BOOST_CHECK_EQUAL((*update)->action, FibUpdate::ADD_NEXTHOP); |
| 268 | } |
| 269 | |
| 270 | BOOST_AUTO_TEST_CASE(ChildInherit_NoCaptureChange_CaptureOnRoute) |
| 271 | { |
Vince Lehman | 218be0a | 2015-01-15 17:25:20 -0600 | [diff] [blame] | 272 | insertRoute("/", 1, 0, 5, ndn::nfd::ROUTE_FLAG_CHILD_INHERIT); |
| 273 | insertRoute("/a", 2, 0, 10, ndn::nfd::ROUTE_FLAG_CAPTURE); |
| 274 | insertRoute("/a/b", 3, 0, 10, 0); |
| 275 | insertRoute("/a/c", 1, 0, 100, 0); |
| 276 | insertRoute("/a", 1, 128, 50, ndn::nfd::ROUTE_FLAG_CHILD_INHERIT); |
Vince Lehman | 4387e78 | 2014-06-19 16:57:45 -0500 | [diff] [blame] | 277 | |
| 278 | // Clear updates generated from previous insertions |
| 279 | rib.clearFibUpdates(); |
| 280 | |
| 281 | // Should generate 2 updates: 2 to remove face 1 from /a and /a/b |
Vince Lehman | 218be0a | 2015-01-15 17:25:20 -0600 | [diff] [blame] | 282 | eraseRoute("/a", 1, 128); |
Vince Lehman | 4387e78 | 2014-06-19 16:57:45 -0500 | [diff] [blame] | 283 | |
| 284 | Rib::FibUpdateList updates = getSortedFibUpdates(); |
| 285 | BOOST_REQUIRE_EQUAL(updates.size(), 2); |
| 286 | |
| 287 | Rib::FibUpdateList::const_iterator update = updates.begin(); |
| 288 | BOOST_CHECK_EQUAL((*update)->name, "/a"); |
| 289 | BOOST_CHECK_EQUAL((*update)->faceId, 1); |
| 290 | BOOST_CHECK_EQUAL((*update)->action, FibUpdate::REMOVE_NEXTHOP); |
| 291 | |
| 292 | ++update; |
| 293 | BOOST_CHECK_EQUAL((*update)->name, "/a/b"); |
| 294 | BOOST_CHECK_EQUAL((*update)->faceId, 1); |
| 295 | BOOST_CHECK_EQUAL((*update)->action, FibUpdate::REMOVE_NEXTHOP); |
| 296 | } |
| 297 | |
| 298 | BOOST_AUTO_TEST_CASE(Capture_CaptureChange_NoCaptureOnRoute) |
| 299 | { |
Vince Lehman | 218be0a | 2015-01-15 17:25:20 -0600 | [diff] [blame] | 300 | insertRoute("/", 1, 0, 5, ndn::nfd::ROUTE_FLAG_CHILD_INHERIT); |
| 301 | insertRoute("/a", 2, 0, 10, 0); |
| 302 | insertRoute("/a/b", 3, 0, 10, 0); |
| 303 | insertRoute("/a/c", 1, 0, 100, 0); |
| 304 | insertRoute("/a", 1, 128, 50, ndn::nfd::ROUTE_FLAG_CAPTURE); |
Vince Lehman | 4387e78 | 2014-06-19 16:57:45 -0500 | [diff] [blame] | 305 | |
| 306 | // Clear updates generated from previous insertions |
| 307 | rib.clearFibUpdates(); |
| 308 | |
| 309 | // Should generate 2 updates: 1 to update cost on /a and |
| 310 | // 1 to add face1 to /a/b |
Vince Lehman | 218be0a | 2015-01-15 17:25:20 -0600 | [diff] [blame] | 311 | eraseRoute("/a", 1 ,128); |
Vince Lehman | 4387e78 | 2014-06-19 16:57:45 -0500 | [diff] [blame] | 312 | |
| 313 | Rib::FibUpdateList updates = getSortedFibUpdates(); |
| 314 | BOOST_REQUIRE_EQUAL(updates.size(), 2); |
| 315 | |
| 316 | Rib::FibUpdateList::const_iterator update = updates.begin(); |
| 317 | BOOST_CHECK_EQUAL((*update)->name, "/a"); |
| 318 | BOOST_CHECK_EQUAL((*update)->faceId, 1); |
| 319 | BOOST_CHECK_EQUAL((*update)->cost, 5); |
| 320 | BOOST_CHECK_EQUAL((*update)->action, FibUpdate::ADD_NEXTHOP); |
| 321 | |
| 322 | ++update; |
| 323 | BOOST_CHECK_EQUAL((*update)->name, "/a/b"); |
| 324 | BOOST_CHECK_EQUAL((*update)->faceId, 1); |
| 325 | BOOST_CHECK_EQUAL((*update)->cost, 5); |
| 326 | BOOST_CHECK_EQUAL((*update)->action, FibUpdate::ADD_NEXTHOP); |
| 327 | } |
| 328 | |
| 329 | BOOST_AUTO_TEST_CASE(Capture_NoCaptureChange_CaptureOnRoute) |
| 330 | { |
Vince Lehman | 218be0a | 2015-01-15 17:25:20 -0600 | [diff] [blame] | 331 | insertRoute("/", 1, 0, 5, ndn::nfd::ROUTE_FLAG_CHILD_INHERIT); |
| 332 | insertRoute("/a", 2, 0, 10, ndn::nfd::ROUTE_FLAG_CAPTURE); |
| 333 | insertRoute("/a/b", 3, 0, 10, 0); |
| 334 | insertRoute("/a/c", 1, 0, 100, 0); |
| 335 | insertRoute("/a", 1, 128, 50, ndn::nfd::ROUTE_FLAG_CAPTURE); |
Vince Lehman | 4387e78 | 2014-06-19 16:57:45 -0500 | [diff] [blame] | 336 | |
| 337 | // Clear updates generated from previous insertions |
| 338 | rib.clearFibUpdates(); |
| 339 | |
Vince Lehman | 218be0a | 2015-01-15 17:25:20 -0600 | [diff] [blame] | 340 | // Should generate 1 updates: 1 to remove route from /a |
| 341 | eraseRoute("/a", 1, 128); |
Vince Lehman | 4387e78 | 2014-06-19 16:57:45 -0500 | [diff] [blame] | 342 | |
| 343 | Rib::FibUpdateList updates = getSortedFibUpdates(); |
| 344 | BOOST_REQUIRE_EQUAL(updates.size(), 1); |
| 345 | |
| 346 | Rib::FibUpdateList::const_iterator update = updates.begin(); |
| 347 | BOOST_CHECK_EQUAL((*update)->name, "/a"); |
| 348 | BOOST_CHECK_EQUAL((*update)->faceId, 1); |
| 349 | BOOST_CHECK_EQUAL((*update)->action, FibUpdate::REMOVE_NEXTHOP); |
| 350 | } |
| 351 | |
| 352 | BOOST_AUTO_TEST_CASE(EraseFaceById) |
| 353 | { |
Vince Lehman | 218be0a | 2015-01-15 17:25:20 -0600 | [diff] [blame] | 354 | insertRoute("/", 1, 0, 5, ndn::nfd::ROUTE_FLAG_CHILD_INHERIT); |
| 355 | insertRoute("/a", 2, 0, 10, 0); |
| 356 | insertRoute("/a/b", 3, 0, 10, 0); |
| 357 | insertRoute("/a/c", 4, 0, 100, 0); |
| 358 | insertRoute("/a", 1, 128, 50, ndn::nfd::ROUTE_FLAG_CHILD_INHERIT); |
Vince Lehman | 4387e78 | 2014-06-19 16:57:45 -0500 | [diff] [blame] | 359 | |
| 360 | // Clear updates generated from previous insertions |
| 361 | rib.clearFibUpdates(); |
| 362 | |
| 363 | // Should generate 4 updates: 4 to remove face ID 1 from /, /a, /a/b, and /a/c |
| 364 | rib.erase(1); |
| 365 | |
| 366 | Rib::FibUpdateList updates = getSortedFibUpdates(); |
| 367 | BOOST_REQUIRE_EQUAL(updates.size(), 4); |
| 368 | |
| 369 | Rib::FibUpdateList::const_iterator update = updates.begin(); |
| 370 | BOOST_CHECK_EQUAL((*update)->name, "/"); |
| 371 | BOOST_CHECK_EQUAL((*update)->faceId, 1); |
| 372 | BOOST_CHECK_EQUAL((*update)->action, FibUpdate::REMOVE_NEXTHOP); |
| 373 | |
| 374 | ++update; |
| 375 | BOOST_CHECK_EQUAL((*update)->name, "/a"); |
| 376 | BOOST_CHECK_EQUAL((*update)->faceId, 1); |
| 377 | BOOST_CHECK_EQUAL((*update)->action, FibUpdate::REMOVE_NEXTHOP); |
| 378 | |
| 379 | ++update; |
| 380 | BOOST_CHECK_EQUAL((*update)->name, "/a/b"); |
| 381 | BOOST_CHECK_EQUAL((*update)->faceId, 1); |
| 382 | BOOST_CHECK_EQUAL((*update)->action, FibUpdate::REMOVE_NEXTHOP); |
| 383 | |
| 384 | ++update; |
| 385 | BOOST_CHECK_EQUAL((*update)->name, "/a/c"); |
| 386 | BOOST_CHECK_EQUAL((*update)->faceId, 1); |
| 387 | BOOST_CHECK_EQUAL((*update)->action, FibUpdate::REMOVE_NEXTHOP); |
| 388 | } |
| 389 | |
| 390 | BOOST_AUTO_TEST_SUITE_END() // EraseFace |
| 391 | |
| 392 | BOOST_AUTO_TEST_SUITE_END() // FibUpdates |
| 393 | |
| 394 | } // namespace tests |
| 395 | } // namespace rib |
| 396 | } // namespace nfd |