]>
Commit | Line | Data |
---|---|---|
8ef0791c | 1 | /* |
42ea6851 JB |
2 | * BGP Multipath Unit Test |
3 | * Copyright (C) 2010 Google Inc. | |
4 | * | |
5 | * This file is part of Quagga | |
6 | * | |
7 | * Quagga is free software; you can redistribute it and/or modify it | |
8 | * under the terms of the GNU General Public License as published by the | |
9 | * Free Software Foundation; either version 2, or (at your option) any | |
10 | * later version. | |
11 | * | |
12 | * Quagga is distributed in the hope that it will be useful, but | |
13 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 | * General Public License for more details. | |
16 | * | |
896014f4 DL |
17 | * You should have received a copy of the GNU General Public License along |
18 | * with this program; see the file COPYING; if not, write to the Free Software | |
19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
42ea6851 JB |
20 | */ |
21 | ||
22 | #include <zebra.h> | |
23 | ||
1bf9f027 | 24 | #include "qobj.h" |
42ea6851 JB |
25 | #include "vty.h" |
26 | #include "stream.h" | |
27 | #include "privs.h" | |
28 | #include "linklist.h" | |
29 | #include "memory.h" | |
30 | #include "zclient.h" | |
3f9c7369 | 31 | #include "queue.h" |
039f3a34 | 32 | #include "filter.h" |
42ea6851 JB |
33 | |
34 | #include "bgpd/bgpd.h" | |
42ea6851 JB |
35 | #include "bgpd/bgp_table.h" |
36 | #include "bgpd/bgp_route.h" | |
96450faf | 37 | #include "bgpd/bgp_attr.h" |
37d361e7 | 38 | #include "bgpd/bgp_nexthop.h" |
96450faf | 39 | #include "bgpd/bgp_mpath.h" |
1525e99f | 40 | #include "bgpd/bgp_evpn.h" |
c2d020ad | 41 | #include "bgpd/bgp_network.h" |
42ea6851 JB |
42 | |
43 | #define VT100_RESET "\x1b[0m" | |
44 | #define VT100_RED "\x1b[31m" | |
45 | #define VT100_GREEN "\x1b[32m" | |
46 | #define VT100_YELLOW "\x1b[33m" | |
47 | #define OK VT100_GREEN "OK" VT100_RESET | |
48 | #define FAILED VT100_RED "failed" VT100_RESET | |
49 | ||
50 | #define TEST_PASSED 0 | |
51 | #define TEST_FAILED -1 | |
52 | ||
d62a17ae | 53 | #define EXPECT_TRUE(expr, res) \ |
54 | if (!(expr)) { \ | |
15569c58 DA |
55 | printf("Test failure in %s line %u: %s\n", __func__, __LINE__, \ |
56 | #expr); \ | |
d62a17ae | 57 | (res) = TEST_FAILED; \ |
58 | } | |
42ea6851 JB |
59 | |
60 | typedef struct testcase_t__ testcase_t; | |
61 | ||
62 | typedef int (*test_setup_func)(testcase_t *); | |
63 | typedef int (*test_run_func)(testcase_t *); | |
64 | typedef int (*test_cleanup_func)(testcase_t *); | |
65 | ||
66 | struct testcase_t__ { | |
d62a17ae | 67 | const char *desc; |
68 | void *test_data; | |
69 | void *verify_data; | |
70 | void *tmp_data; | |
71 | test_setup_func setup; | |
72 | test_run_func run; | |
73 | test_cleanup_func cleanup; | |
42ea6851 JB |
74 | }; |
75 | ||
76 | /* need these to link in libbgp */ | |
77 | struct thread_master *master = NULL; | |
9635de6e | 78 | extern struct zclient *zclient; |
d62a17ae | 79 | struct zebra_privs_t bgpd_privs = { |
80 | .user = NULL, | |
81 | .group = NULL, | |
82 | .vty_group = NULL, | |
42ea6851 JB |
83 | }; |
84 | ||
85 | static int tty = 0; | |
86 | ||
87 | /* Create fake bgp instance */ | |
d62a17ae | 88 | static struct bgp *bgp_create_fake(as_t *as, const char *name) |
42ea6851 | 89 | { |
d62a17ae | 90 | struct bgp *bgp; |
91 | afi_t afi; | |
92 | safi_t safi; | |
93 | ||
94 | if ((bgp = XCALLOC(MTYPE_BGP, sizeof(struct bgp))) == NULL) | |
95 | return NULL; | |
96 | ||
97 | bgp_lock(bgp); | |
98 | // bgp->peer_self = peer_new (bgp); | |
99 | // bgp->peer_self->host = XSTRDUP (MTYPE_BGP_PEER_HOST, "Static | |
100 | // announcement"); | |
101 | ||
102 | bgp->peer = list_new(); | |
103 | // bgp->peer->cmp = (int (*)(void *, void *)) peer_cmp; | |
104 | ||
105 | bgp->group = list_new(); | |
106 | // bgp->group->cmp = (int (*)(void *, void *)) peer_group_cmp; | |
107 | ||
1525e99f | 108 | bgp_evpn_init(bgp); |
f18ba3cd DS |
109 | FOREACH_AFI_SAFI (afi, safi) { |
110 | bgp->route[afi][safi] = bgp_table_init(bgp, afi, safi); | |
111 | bgp->aggregate[afi][safi] = bgp_table_init(bgp, afi, safi); | |
112 | bgp->rib[afi][safi] = bgp_table_init(bgp, afi, safi); | |
113 | bgp->maxpaths[afi][safi].maxpaths_ebgp = MULTIPATH_NUM; | |
114 | bgp->maxpaths[afi][safi].maxpaths_ibgp = MULTIPATH_NUM; | |
115 | } | |
d62a17ae | 116 | |
117 | bgp_scan_init(bgp); | |
118 | bgp->default_local_pref = BGP_DEFAULT_LOCAL_PREF; | |
119 | bgp->default_holdtime = BGP_DEFAULT_HOLDTIME; | |
120 | bgp->default_keepalive = BGP_DEFAULT_KEEPALIVE; | |
121 | bgp->restart_time = BGP_DEFAULT_RESTART_TIME; | |
122 | bgp->stalepath_time = BGP_DEFAULT_STALEPATH_TIME; | |
123 | ||
124 | bgp->as = *as; | |
125 | ||
126 | if (name) | |
127 | bgp->name = strdup(name); | |
128 | ||
129 | return bgp; | |
42ea6851 JB |
130 | } |
131 | ||
132 | /*========================================================= | |
133 | * Testcase for maximum-paths configuration | |
134 | */ | |
d62a17ae | 135 | static int setup_bgp_cfg_maximum_paths(testcase_t *t) |
42ea6851 | 136 | { |
d62a17ae | 137 | as_t asn = 1; |
138 | t->tmp_data = bgp_create_fake(&asn, NULL); | |
139 | if (!t->tmp_data) | |
140 | return -1; | |
141 | return 0; | |
42ea6851 JB |
142 | } |
143 | ||
d62a17ae | 144 | static int run_bgp_cfg_maximum_paths(testcase_t *t) |
42ea6851 | 145 | { |
d62a17ae | 146 | afi_t afi; |
147 | safi_t safi; | |
148 | struct bgp *bgp; | |
149 | int api_result; | |
150 | int test_result = TEST_PASSED; | |
151 | ||
152 | bgp = t->tmp_data; | |
f18ba3cd DS |
153 | FOREACH_AFI_SAFI (afi, safi) { |
154 | /* test bgp_maximum_paths_set */ | |
155 | api_result = bgp_maximum_paths_set(bgp, afi, safi, | |
156 | BGP_PEER_EBGP, 10, 0); | |
157 | EXPECT_TRUE(api_result == 0, test_result); | |
158 | api_result = bgp_maximum_paths_set(bgp, afi, safi, | |
159 | BGP_PEER_IBGP, 10, 0); | |
160 | EXPECT_TRUE(api_result == 0, test_result); | |
161 | EXPECT_TRUE(bgp->maxpaths[afi][safi].maxpaths_ebgp == 10, | |
162 | test_result); | |
163 | EXPECT_TRUE(bgp->maxpaths[afi][safi].maxpaths_ibgp == 10, | |
164 | test_result); | |
165 | ||
166 | /* test bgp_maximum_paths_unset */ | |
167 | api_result = | |
168 | bgp_maximum_paths_unset(bgp, afi, safi, BGP_PEER_EBGP); | |
169 | EXPECT_TRUE(api_result == 0, test_result); | |
170 | api_result = | |
171 | bgp_maximum_paths_unset(bgp, afi, safi, BGP_PEER_IBGP); | |
172 | EXPECT_TRUE(api_result == 0, test_result); | |
173 | EXPECT_TRUE((bgp->maxpaths[afi][safi].maxpaths_ebgp | |
174 | == MULTIPATH_NUM), | |
175 | test_result); | |
176 | EXPECT_TRUE((bgp->maxpaths[afi][safi].maxpaths_ibgp | |
177 | == MULTIPATH_NUM), | |
178 | test_result); | |
179 | } | |
d62a17ae | 180 | |
181 | return test_result; | |
42ea6851 JB |
182 | } |
183 | ||
d62a17ae | 184 | static int cleanup_bgp_cfg_maximum_paths(testcase_t *t) |
42ea6851 | 185 | { |
d62a17ae | 186 | return bgp_delete((struct bgp *)t->tmp_data); |
42ea6851 JB |
187 | } |
188 | ||
189 | testcase_t test_bgp_cfg_maximum_paths = { | |
d62a17ae | 190 | .desc = "Test bgp maximum-paths config", |
191 | .setup = setup_bgp_cfg_maximum_paths, | |
192 | .run = run_bgp_cfg_maximum_paths, | |
193 | .cleanup = cleanup_bgp_cfg_maximum_paths, | |
42ea6851 JB |
194 | }; |
195 | ||
96450faf JB |
196 | /*========================================================= |
197 | * Testcase for bgp_mp_list | |
198 | */ | |
de8d5dff | 199 | struct peer test_mp_list_peer[] = { |
d62a17ae | 200 | {.local_as = 1, .as = 2}, {.local_as = 1, .as = 2}, |
201 | {.local_as = 1, .as = 2}, {.local_as = 1, .as = 2}, | |
202 | {.local_as = 1, .as = 2}, | |
de8d5dff | 203 | }; |
97b5d752 | 204 | int test_mp_list_peer_count = array_size(test_mp_list_peer); |
96450faf | 205 | struct attr test_mp_list_attr[4]; |
4b7e6066 | 206 | struct bgp_path_info test_mp_list_info[] = { |
d62a17ae | 207 | {.peer = &test_mp_list_peer[0], .attr = &test_mp_list_attr[0]}, |
208 | {.peer = &test_mp_list_peer[1], .attr = &test_mp_list_attr[1]}, | |
209 | {.peer = &test_mp_list_peer[2], .attr = &test_mp_list_attr[1]}, | |
210 | {.peer = &test_mp_list_peer[3], .attr = &test_mp_list_attr[2]}, | |
211 | {.peer = &test_mp_list_peer[4], .attr = &test_mp_list_attr[3]}, | |
96450faf | 212 | }; |
97b5d752 | 213 | int test_mp_list_info_count = array_size(test_mp_list_info); |
96450faf | 214 | |
d62a17ae | 215 | static int setup_bgp_mp_list(testcase_t *t) |
96450faf | 216 | { |
d62a17ae | 217 | test_mp_list_attr[0].nexthop.s_addr = 0x01010101; |
218 | test_mp_list_attr[1].nexthop.s_addr = 0x02020202; | |
219 | test_mp_list_attr[2].nexthop.s_addr = 0x03030303; | |
220 | test_mp_list_attr[3].nexthop.s_addr = 0x04040404; | |
221 | ||
222 | if ((test_mp_list_peer[0].su_remote = sockunion_str2su("1.1.1.1")) | |
223 | == NULL) | |
224 | return -1; | |
225 | if ((test_mp_list_peer[1].su_remote = sockunion_str2su("2.2.2.2")) | |
226 | == NULL) | |
227 | return -1; | |
228 | if ((test_mp_list_peer[2].su_remote = sockunion_str2su("3.3.3.3")) | |
229 | == NULL) | |
230 | return -1; | |
231 | if ((test_mp_list_peer[3].su_remote = sockunion_str2su("4.4.4.4")) | |
232 | == NULL) | |
233 | return -1; | |
234 | if ((test_mp_list_peer[4].su_remote = sockunion_str2su("5.5.5.5")) | |
235 | == NULL) | |
236 | return -1; | |
237 | ||
238 | return 0; | |
96450faf JB |
239 | } |
240 | ||
d62a17ae | 241 | static int run_bgp_mp_list(testcase_t *t) |
96450faf | 242 | { |
d62a17ae | 243 | struct list mp_list; |
244 | struct listnode *mp_node; | |
4b7e6066 | 245 | struct bgp_path_info *info; |
d62a17ae | 246 | int i; |
247 | int test_result = TEST_PASSED; | |
248 | bgp_mp_list_init(&mp_list); | |
249 | EXPECT_TRUE(listcount(&mp_list) == 0, test_result); | |
250 | ||
251 | bgp_mp_list_add(&mp_list, &test_mp_list_info[1]); | |
252 | bgp_mp_list_add(&mp_list, &test_mp_list_info[4]); | |
253 | bgp_mp_list_add(&mp_list, &test_mp_list_info[2]); | |
254 | bgp_mp_list_add(&mp_list, &test_mp_list_info[3]); | |
255 | bgp_mp_list_add(&mp_list, &test_mp_list_info[0]); | |
256 | ||
257 | for (i = 0, mp_node = mp_list.head; i < test_mp_list_info_count; | |
258 | i++, mp_node = listnextnode(mp_node)) { | |
259 | info = listgetdata(mp_node); | |
260 | EXPECT_TRUE(info == &test_mp_list_info[i], test_result); | |
261 | } | |
262 | ||
263 | bgp_mp_list_clear(&mp_list); | |
264 | EXPECT_TRUE(listcount(&mp_list) == 0, test_result); | |
265 | ||
266 | return test_result; | |
96450faf JB |
267 | } |
268 | ||
d62a17ae | 269 | static int cleanup_bgp_mp_list(testcase_t *t) |
96450faf | 270 | { |
d62a17ae | 271 | int i; |
96450faf | 272 | |
d62a17ae | 273 | for (i = 0; i < test_mp_list_peer_count; i++) |
274 | sockunion_free(test_mp_list_peer[i].su_remote); | |
96450faf | 275 | |
d62a17ae | 276 | return 0; |
96450faf JB |
277 | } |
278 | ||
279 | testcase_t test_bgp_mp_list = { | |
d62a17ae | 280 | .desc = "Test bgp_mp_list", |
281 | .setup = setup_bgp_mp_list, | |
282 | .run = run_bgp_mp_list, | |
283 | .cleanup = cleanup_bgp_mp_list, | |
96450faf JB |
284 | }; |
285 | ||
de8d5dff | 286 | /*========================================================= |
4b7e6066 | 287 | * Testcase for bgp_path_info_mpath_update |
de8d5dff JB |
288 | */ |
289 | ||
290 | struct bgp_node test_rn; | |
291 | ||
4b7e6066 | 292 | static int setup_bgp_path_info_mpath_update(testcase_t *t) |
de8d5dff | 293 | { |
d62a17ae | 294 | int i; |
f009ff26 | 295 | struct bgp *bgp; |
296 | struct bgp_table *rt; | |
297 | struct route_node *rt_node; | |
298 | as_t asn = 1; | |
299 | ||
300 | t->tmp_data = bgp_create_fake(&asn, NULL); | |
301 | if (!t->tmp_data) | |
302 | return -1; | |
303 | ||
304 | bgp = t->tmp_data; | |
305 | rt = bgp->rib[AFI_IP][SAFI_UNICAST]; | |
306 | ||
307 | if (!rt) | |
308 | return -1; | |
309 | ||
d62a17ae | 310 | str2prefix("42.1.1.0/24", &test_rn.p); |
9bcb3eef | 311 | rt_node = bgp_dest_to_rnode(&test_rn); |
f009ff26 | 312 | memcpy((struct route_table *)&rt_node->table, &rt->route_table, |
6aed8082 | 313 | sizeof(struct route_table)); |
d62a17ae | 314 | setup_bgp_mp_list(t); |
315 | for (i = 0; i < test_mp_list_info_count; i++) | |
4b7e6066 | 316 | bgp_path_info_add(&test_rn, &test_mp_list_info[i]); |
d62a17ae | 317 | return 0; |
de8d5dff JB |
318 | } |
319 | ||
4b7e6066 | 320 | static int run_bgp_path_info_mpath_update(testcase_t *t) |
de8d5dff | 321 | { |
4b7e6066 | 322 | struct bgp_path_info *new_best, *old_best, *mpath; |
d62a17ae | 323 | struct list mp_list; |
324 | struct bgp_maxpaths_cfg mp_cfg = {3, 3}; | |
325 | int test_result = TEST_PASSED; | |
326 | bgp_mp_list_init(&mp_list); | |
327 | bgp_mp_list_add(&mp_list, &test_mp_list_info[4]); | |
328 | bgp_mp_list_add(&mp_list, &test_mp_list_info[3]); | |
329 | bgp_mp_list_add(&mp_list, &test_mp_list_info[0]); | |
330 | bgp_mp_list_add(&mp_list, &test_mp_list_info[1]); | |
331 | new_best = &test_mp_list_info[3]; | |
332 | old_best = NULL; | |
4378495a | 333 | bgp_path_info_mpath_update(NULL, &test_rn, new_best, old_best, &mp_list, |
121e245d | 334 | &mp_cfg); |
d62a17ae | 335 | bgp_mp_list_clear(&mp_list); |
4b7e6066 DS |
336 | EXPECT_TRUE(bgp_path_info_mpath_count(new_best) == 2, test_result); |
337 | mpath = bgp_path_info_mpath_first(new_best); | |
d62a17ae | 338 | EXPECT_TRUE(mpath == &test_mp_list_info[0], test_result); |
1defdda8 | 339 | EXPECT_TRUE(CHECK_FLAG(mpath->flags, BGP_PATH_MULTIPATH), test_result); |
4b7e6066 | 340 | mpath = bgp_path_info_mpath_next(mpath); |
d62a17ae | 341 | EXPECT_TRUE(mpath == &test_mp_list_info[1], test_result); |
1defdda8 | 342 | EXPECT_TRUE(CHECK_FLAG(mpath->flags, BGP_PATH_MULTIPATH), test_result); |
d62a17ae | 343 | |
344 | bgp_mp_list_add(&mp_list, &test_mp_list_info[0]); | |
345 | bgp_mp_list_add(&mp_list, &test_mp_list_info[1]); | |
346 | new_best = &test_mp_list_info[0]; | |
347 | old_best = &test_mp_list_info[3]; | |
4378495a | 348 | bgp_path_info_mpath_update(NULL, &test_rn, new_best, old_best, &mp_list, |
121e245d | 349 | &mp_cfg); |
d62a17ae | 350 | bgp_mp_list_clear(&mp_list); |
4b7e6066 DS |
351 | EXPECT_TRUE(bgp_path_info_mpath_count(new_best) == 1, test_result); |
352 | mpath = bgp_path_info_mpath_first(new_best); | |
d62a17ae | 353 | EXPECT_TRUE(mpath == &test_mp_list_info[1], test_result); |
1defdda8 DS |
354 | EXPECT_TRUE(CHECK_FLAG(mpath->flags, BGP_PATH_MULTIPATH), test_result); |
355 | EXPECT_TRUE(!CHECK_FLAG(test_mp_list_info[0].flags, BGP_PATH_MULTIPATH), | |
d62a17ae | 356 | test_result); |
357 | ||
358 | return test_result; | |
de8d5dff JB |
359 | } |
360 | ||
4b7e6066 | 361 | static int cleanup_bgp_path_info_mpath_update(testcase_t *t) |
de8d5dff | 362 | { |
d62a17ae | 363 | int i; |
de8d5dff | 364 | |
d62a17ae | 365 | for (i = 0; i < test_mp_list_peer_count; i++) |
366 | sockunion_free(test_mp_list_peer[i].su_remote); | |
de8d5dff | 367 | |
f009ff26 | 368 | return bgp_delete((struct bgp *)t->tmp_data); |
de8d5dff JB |
369 | } |
370 | ||
4b7e6066 DS |
371 | testcase_t test_bgp_path_info_mpath_update = { |
372 | .desc = "Test bgp_path_info_mpath_update", | |
373 | .setup = setup_bgp_path_info_mpath_update, | |
374 | .run = run_bgp_path_info_mpath_update, | |
375 | .cleanup = cleanup_bgp_path_info_mpath_update, | |
de8d5dff JB |
376 | }; |
377 | ||
42ea6851 JB |
378 | /*========================================================= |
379 | * Set up testcase vector | |
380 | */ | |
381 | testcase_t *all_tests[] = { | |
9d303b37 | 382 | &test_bgp_cfg_maximum_paths, &test_bgp_mp_list, |
4b7e6066 | 383 | &test_bgp_path_info_mpath_update, |
42ea6851 JB |
384 | }; |
385 | ||
97b5d752 | 386 | int all_tests_count = array_size(all_tests); |
42ea6851 JB |
387 | |
388 | /*========================================================= | |
389 | * Test Driver Functions | |
390 | */ | |
d62a17ae | 391 | static int global_test_init(void) |
42ea6851 | 392 | { |
d62a17ae | 393 | qobj_init(); |
394 | master = thread_master_create(NULL); | |
a243d1db | 395 | zclient = zclient_new(master, &zclient_options_default, NULL, 0); |
733367c0 | 396 | bgp_master_init(master, BGP_SOCKET_SNDBUF_SIZE, list_new()); |
ecbc5a37 | 397 | vrf_init(NULL, NULL, NULL, NULL, NULL); |
d62a17ae | 398 | bgp_option_set(BGP_OPT_NO_LISTEN); |
399 | ||
400 | if (fileno(stdout) >= 0) | |
401 | tty = isatty(fileno(stdout)); | |
402 | return 0; | |
42ea6851 JB |
403 | } |
404 | ||
d62a17ae | 405 | static int global_test_cleanup(void) |
42ea6851 | 406 | { |
d62a17ae | 407 | if (zclient != NULL) |
408 | zclient_free(zclient); | |
409 | thread_master_free(master); | |
410 | return 0; | |
42ea6851 JB |
411 | } |
412 | ||
d62a17ae | 413 | static void display_result(testcase_t *test, int result) |
42ea6851 | 414 | { |
d62a17ae | 415 | if (tty) |
416 | printf("%s: %s\n", test->desc, | |
417 | result == TEST_PASSED ? OK : FAILED); | |
418 | else | |
419 | printf("%s: %s\n", test->desc, | |
420 | result == TEST_PASSED ? "OK" : "FAILED"); | |
42ea6851 JB |
421 | } |
422 | ||
d62a17ae | 423 | static int setup_test(testcase_t *t) |
42ea6851 | 424 | { |
d62a17ae | 425 | int res = 0; |
426 | if (t->setup) | |
427 | res = t->setup(t); | |
428 | return res; | |
42ea6851 JB |
429 | } |
430 | ||
d62a17ae | 431 | static int cleanup_test(testcase_t *t) |
42ea6851 | 432 | { |
d62a17ae | 433 | int res = 0; |
434 | if (t->cleanup) | |
435 | res = t->cleanup(t); | |
436 | return res; | |
42ea6851 JB |
437 | } |
438 | ||
d62a17ae | 439 | static void run_tests(testcase_t *tests[], int num_tests, int *pass_count, |
440 | int *fail_count) | |
42ea6851 | 441 | { |
d62a17ae | 442 | int test_index, result; |
443 | testcase_t *cur_test; | |
444 | ||
445 | *pass_count = *fail_count = 0; | |
446 | ||
447 | for (test_index = 0; test_index < num_tests; test_index++) { | |
448 | cur_test = tests[test_index]; | |
449 | if (!cur_test->desc) { | |
450 | printf("error: test %d has no description!\n", | |
451 | test_index); | |
452 | continue; | |
453 | } | |
454 | if (!cur_test->run) { | |
455 | printf("error: test %s has no run function!\n", | |
456 | cur_test->desc); | |
457 | continue; | |
458 | } | |
459 | if (setup_test(cur_test) != 0) { | |
460 | printf("error: setup failed for test %s\n", | |
461 | cur_test->desc); | |
462 | continue; | |
463 | } | |
464 | result = cur_test->run(cur_test); | |
465 | if (result == TEST_PASSED) | |
466 | *pass_count += 1; | |
467 | else | |
468 | *fail_count += 1; | |
469 | display_result(cur_test, result); | |
470 | if (cleanup_test(cur_test) != 0) { | |
471 | printf("error: cleanup failed for test %s\n", | |
472 | cur_test->desc); | |
473 | continue; | |
474 | } | |
475 | } | |
42ea6851 JB |
476 | } |
477 | ||
d62a17ae | 478 | int main(void) |
42ea6851 | 479 | { |
d62a17ae | 480 | int pass_count, fail_count; |
481 | time_t cur_time; | |
482 | ||
483 | time(&cur_time); | |
484 | printf("BGP Multipath Tests Run at %s", ctime(&cur_time)); | |
485 | if (global_test_init() != 0) { | |
486 | printf("Global init failed. Terminating.\n"); | |
487 | exit(1); | |
488 | } | |
489 | run_tests(all_tests, all_tests_count, &pass_count, &fail_count); | |
490 | global_test_cleanup(); | |
491 | printf("Total pass/fail: %d/%d\n", pass_count, fail_count); | |
492 | return fail_count; | |
42ea6851 | 493 | } |