Reorganize source tree to use single autotools instance
[vpp.git] / src / tests / vnet / lisp-cp / test_cp_serdes.c
1 /*
2  * Copyright (c) 2016 Cisco and/or its affiliates.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at:
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15
16 #include <vnet/vnet.h>
17 #include <vppinfra/error.h>
18 #include <vnet/lisp-cp/lisp_cp_messages.h>
19 #include <vnet/lisp-cp/control.h>
20 #include <vnet/lisp-cp/lisp_msg_serdes.h>
21 #include <vlibapi/api.h>
22 #include <vnet/lisp-cp/packets.h>
23
24 /* FIXME */
25 #include <vlibapi/api_helper_macros.h>
26 vpe_api_main_t vpe_api_main;
27
28 #define _assert(e)                    \
29   error = CLIB_ERROR_ASSERT (e);      \
30   if (error)                          \
31     goto done;
32
33 static void print_chunk(u8 * b, int * offset, int c, char * des)
34 {
35   int i, n = offset[0] + c;;
36   for (i = offset[0]; i < n; i++)
37   {
38     printf("0x%02x, ", b[i]);
39   }
40   printf(" // %s\n", des);
41   *offset += c;
42 }
43
44 void print_map_request(map_request_hdr_t * h)
45 {
46 #define pchunk(_count, _desc) \
47   print_chunk((u8 *)h, &offset, _count, _desc)
48
49   int offset = 0;
50
51   pchunk(4, "data");
52   pchunk(8, "Nonce");
53   pchunk(2, "Source-EID-AFI");
54   pchunk(4, "Source EID Address");
55   pchunk(2, "ITR-RLOC-AFI 1");
56   pchunk(4, "ITR-RLOC Address 1");
57   pchunk(2, "ITR-RLOC-AFI 2");
58   pchunk(16, "ITR-RLOC Address 2");
59   pchunk(1, "REC: reserved");
60   pchunk(1, "REC: EID mask-len");
61   pchunk(2, "REC: EID-prefix-AFI");
62   pchunk(4, "REC: EID-prefix");
63   printf("\n");
64 }
65
66 static clib_error_t * test_lisp_msg_push_ecm ()
67 {
68   vlib_main_t * vm = vlib_get_main ();
69   clib_error_t * error = 0;
70   gid_address_t la, ra;
71   vlib_buffer_t * b = 0;
72   u32 buff_len = 900;
73   int lp = 0x15, rp = 0x14;
74
75   b = clib_mem_alloc (buff_len);
76   memset((u8 *)b, 0, buff_len);
77   b->current_length = buff_len;
78   b->current_data = sizeof(udp_header_t) + sizeof(ip4_header_t) +
79     sizeof(ecm_hdr_t) + 1;
80
81   la.type = GID_ADDR_IP_PREFIX;
82   la.ippref.addr.ip.v4.as_u32 = 0xa1b2c3d4;
83   la.ippref.addr.version = IP4;
84
85   ra.type = GID_ADDR_IP_PREFIX;
86   ra.ippref.addr.ip.v4.as_u32 = 0x90817263;
87   ra.ippref.addr.version = IP4;
88
89   ecm_hdr_t * lh = lisp_msg_push_ecm (vm, b, lp, rp, &la, &ra);
90
91   u8 expected_ecm_hdr[] = {
92     0x80, 0x00, 0x00, 0x00
93   };
94   _assert(0 == memcmp(expected_ecm_hdr, lh, sizeof(expected_ecm_hdr)));
95
96   ip4_header_t * ih = (ip4_header_t *) (lh + 1);
97   /* clear ip checksum */
98   memset((u8 *)ih + 10, 0, 2);
99
100   u8 expected_ip4_hdr[] = {
101     0x45,                   /* version; IHL */
102     0x00,                   /* services */
103     0x03, 0xa0,             /* total length */
104     0x00, 0x00,             /* identification */
105     0x40, 0x00,             /* flags; fragment offset*/
106     0xff,                   /* TTL */
107     0x11,                   /* protocol */
108     0x00, 0x00,             /* header checksum */
109     0xd4, 0xc3, 0xb2, 0xa1, /* src IP */
110     0x63, 0x72, 0x81, 0x90, /* dst IP */
111   };
112   _assert(0 == memcmp(ih, expected_ip4_hdr, sizeof(expected_ip4_hdr)));
113
114   udp_header_t * uh = (udp_header_t *) (ih + 1);
115   /* clear udp checksum */
116   memset((u8 *)uh + 6, 0, 2);
117
118   u8 expected_udp_hdr[] = {
119     0x00, 0x15, /* src port */
120     0x00, 0x14, /* dst port */
121     0x03, 0x8c, /* length */
122     0x00, 0x00, /* checksum */
123   };
124   _assert(0 == memcmp(uh, expected_udp_hdr, sizeof(expected_udp_hdr)));
125
126 done:
127   clib_mem_free (b);
128   return error;
129 }
130
131 static clib_error_t * test_lisp_msg_parse_mapping_record ()
132 {
133   clib_error_t * error = 0;
134   locator_t probed;
135   locator_t * locs = 0;
136   vlib_buffer_t * b = 0;
137   gid_address_t eid;
138   u32 buff_len = 500;
139
140   b = clib_mem_alloc (buff_len);
141   memset((u8 *)b, 0, buff_len);
142
143   u8 map_reply_records[] = {
144     /* 1. record */
145     0x01, 0x02, 0x03, 0x04, /* record TTL */
146     0x01,                   /* locator count */
147     0x00, 0x00, 0x00,       /* eid-mask-len; ... */
148     0x00, 0x00,             /* reserved; map-version num */
149     0x00, 0x01,             /* EID-Prefix-AFI */
150     0x33, 0x44, 0x55, 0x66, /* eid-prefix */
151     /* loc */
152     0x0a,                   /* prority */
153     0x0b,                   /* weight */
154     0x0c,                   /* m-prority */
155     0x0d,                   /* m-weight */
156     0x00, 0x00,             /* unused flags */
157     0x00, 0x01,             /* Loc-AFI */
158     0xaa, 0xbb, 0xcc, 0xdd, /* Loator */
159   };
160   b->current_length = buff_len;
161   clib_memcpy(b->data, map_reply_records, sizeof(map_reply_records));
162
163   lisp_msg_parse_mapping_record (b, &eid, &locs, &probed);
164   _assert(vec_len (locs) == 1);
165   _assert(eid.ippref.addr.ip.v4.as_u32 == 0x66554433);
166   _assert(locs[0].local == 0);
167   _assert(locs[0].address.ippref.addr.ip.v4.as_u32 == 0xddccbbaa);
168   _assert(locs[0].address.type == GID_ADDR_IP_PREFIX);
169   _assert(locs[0].priority == 0xa);
170   _assert(locs[0].weight == 0xb);
171   _assert(locs[0].mpriority == 0xc);
172   _assert(locs[0].mweight == 0xd);
173
174 done:
175   clib_mem_free (b);
176   if (locs)
177     vec_free (locs);
178   return error;
179 }
180
181 static map_request_hdr_t *
182 build_map_request (lisp_cp_main_t * lcm, vlib_buffer_t * b,
183                    gid_address_t * rlocs)
184 {
185   gid_address_t _seid, * seid = &_seid;
186   gid_address_t _deid, * deid = &_deid;
187   u8 is_smr_invoked = 1;
188   u8 rloc_probe_set = 0;
189   u64 nonce = 0;
190   map_request_hdr_t * h = 0;
191   memset (deid, 0, sizeof (deid[0]));
192   memset (seid, 0, sizeof (seid[0]));
193
194   gid_address_type (seid) = GID_ADDR_IP_PREFIX;
195   ip_address_t * ip_addr = &gid_address_ip (seid);
196   ip_addr_v4 (ip_addr).as_u32 = 0x12345678;
197   seid->ippref.addr.version = IP4;
198
199   gid_address_type (deid) = GID_ADDR_IP_PREFIX;
200   ip_address_t * ip_addr2 = &gid_address_ip (deid);
201   ip_addr_v4 (ip_addr2).as_u32 = 0x9abcdef0;
202   deid->ippref.addr.version = IP4;
203   gid_address_ippref_len (deid) = 24;
204
205   h = lisp_msg_put_mreq (lcm, b, seid, deid, rlocs,
206                      is_smr_invoked, rloc_probe_set, &nonce);
207   vec_free(rlocs);
208   return h;
209 }
210
211 static void
212 generate_rlocs (gid_address_t **rlocs, u32 * count)
213 {
214   gid_address_t gid_addr_data, * gid_addr = &gid_addr_data;
215   memset (gid_addr, 0, sizeof (gid_addr[0]));
216   ip_address_t * addr = &gid_address_ip (gid_addr);
217
218   gid_address_type (gid_addr) = GID_ADDR_IP_PREFIX;
219
220   ip_addr_version (addr) = IP4;
221   ip_addr_v4 (addr).data_u32 = 0x10203040;
222   vec_add1 (rlocs[0], gid_addr[0]);
223
224   ip_addr_v6 (addr).as_u32[0] = 0xffeeddcc;
225   ip_addr_v6 (addr).as_u32[1] = 0xbbaa9988;
226   ip_addr_v6 (addr).as_u32[2] = 0x77665544;
227   ip_addr_v6 (addr).as_u32[3] = 0x33221100;
228   ip_addr_version (addr) = IP6;
229   vec_add1 (rlocs[0], gid_addr[0]);
230 }
231
232 static clib_error_t * test_lisp_msg_parse ()
233 {
234   gid_address_t eid;
235   lisp_cp_main_t * lcm = vnet_lisp_cp_get_main();
236   map_request_hdr_t *h;
237   gid_address_t gid;
238   clib_error_t * error = 0;
239   vlib_buffer_t * b;
240   gid_address_t * rlocs_decode = 0, * rlocs = 0;
241   u32 rloc_count_parse = 0;
242
243   u8 * data = clib_mem_alloc(500);
244   memset(data, 0, 500);
245   b = (vlib_buffer_t *) data;
246
247   generate_rlocs (&rlocs_decode, &rloc_count_parse);
248   h = build_map_request (lcm, b, rlocs_decode);
249
250   vlib_buffer_pull(b, sizeof(*h));
251   u32 len = lisp_msg_parse_addr(b, &gid);
252   _assert (len == 2 + 4
253       /* Source-EID-AFI field lenght + IPv4 address length */);
254   _assert (gid.ippref.addr.ip.v4.as_u32 == 0x12345678);
255   _assert (gid.ippref.addr.version == IP4);
256
257   u8 rloc_count = MREQ_ITR_RLOC_COUNT(h) + 1;
258   lisp_msg_parse_itr_rlocs (b, &rlocs, rloc_count);
259
260   _assert (vec_len (rlocs) == 2);
261   _assert (rlocs[0].ippref.addr.ip.v4.as_u32 == 0x10203040);
262   _assert (rlocs[0].ippref.addr.version == IP4);
263
264   _assert (rlocs[1].ippref.addr.ip.v6.as_u32[0] == 0xffeeddcc);
265   _assert (rlocs[1].ippref.addr.ip.v6.as_u32[1] == 0xbbaa9988);
266   _assert (rlocs[1].ippref.addr.ip.v6.as_u32[2] == 0x77665544);
267   _assert (rlocs[1].ippref.addr.ip.v6.as_u32[3] == 0x33221100);
268   _assert (rlocs[1].ippref.addr.version == IP6);
269
270   lisp_msg_parse_eid_rec (b, &eid);
271   _assert (eid.ippref.addr.ip.v4.as_u32 == 0x9abcdef0);
272   _assert (eid.ippref.addr.version == IP4);
273   _assert (eid.ippref.len == 24);
274
275 done:
276   clib_mem_free (data);
277   if (rlocs)
278     vec_free (rlocs);
279   return error;
280 }
281
282 static clib_error_t * test_lisp_msg_put_mreq_with_lcaf ()
283 {
284   lisp_cp_main_t * lcm = vnet_lisp_cp_get_main ();
285   clib_error_t * error = 0;
286   map_request_hdr_t *h = 0;
287   gid_address_t * rlocs = 0;
288
289   ip_prefix_t ippref;
290   ip_prefix_version (&ippref) = IP4;
291   ip4_address_t * ip = &ip_prefix_v4 (&ippref);
292   ip->as_u32 = 0x11223344;
293
294   gid_address_t g =
295     {
296       .type = GID_ADDR_IP_PREFIX,
297       .ippref = ippref,
298       .vni = 0x90919293,
299       .vni_mask = 0x17
300     };
301   vec_add1 (rlocs, g);
302
303   u8 * data = clib_mem_alloc (500);
304   memset (data, 0, 500);
305
306   h = build_map_request (lcm, (vlib_buffer_t *) data, rlocs);
307
308   /* clear Nonce to simplify comparison */
309   memset ((u8 *)h + 4, 0, 8);
310
311   u8 expected_data[] =
312     {
313       0x10, 0x40, 0x00, 0x01, /* type; flags; IRC; REC count */
314       0x00, 0x00, 0x00, 0x00,
315       0x00, 0x00, 0x00, 0x00, /* nonce */
316       0x00, 0x01,             /* Source-EID-AFI */
317       0x78, 0x56, 0x34, 0x12, /* Source EID Address */
318
319       /* RLOCs */
320       0x40, 0x03,             /* AFI = LCAF*/
321       /* LCAF header*/
322       0x00, 0x00,             /* reserved1, flags */
323       0x02,                   /* type = Instance ID */
324       0x17,                   /* IID mask-len */
325       0x00, 0x0a,             /* lenght */
326       0x90, 0x91, 0x92, 0x93, /* IID / VNI */
327
328       0x00, 0x01,             /* AFI = ipv4 */
329       0x44, 0x33, 0x22, 0x11, /* ITR-RLOC Address 1 */
330
331       /* record */
332       0x00,                   /* reserved */
333       0x18,                   /* EID mask-len */
334       0x00, 0x01,             /* EID-prefix-AFI */
335       0xf0, 0xde, 0xbc, 0x9a, /* EID-prefix */
336     };
337
338   _assert (0 == memcmp (expected_data, (u8 *) h, sizeof (expected_data)));
339 done:
340   clib_mem_free (data);
341   return error;
342 }
343
344 static clib_error_t * test_lisp_msg_put_mreq ()
345 {
346   lisp_cp_main_t * lcm = vnet_lisp_cp_get_main();
347   clib_error_t * error = 0;
348   map_request_hdr_t *h;
349   gid_address_t * rlocs = 0;
350   u32 rloc_count = 0;
351
352   u8 * data = clib_mem_alloc(500);
353   memset(data, 0, 500);
354
355   generate_rlocs (&rlocs, &rloc_count);
356   h = build_map_request (lcm, (vlib_buffer_t *) data, rlocs);
357
358   /* clear Nonce to simplify comparison */
359   memset((u8 *)h + 4, 0, 8);
360
361   print_map_request(h);
362
363   u8 expected_data[50] = {
364     0x10, 0x40, 0x01, 0x01, /* type; flags; IRC; REC count */
365     0x00, 0x00, 0x00, 0x00,
366     0x00, 0x00, 0x00, 0x00, /* nonce */
367     0x00, 0x01,             /* Source-EID-AFI */
368     0x78, 0x56, 0x34, 0x12, /* Source EID Address */
369
370     /* RLOCs */
371     0x00, 0x01,             /* ITR-RLOC-AFI 1 */
372     0x40, 0x30, 0x20, 0x10, /* ITR-RLOC Address 1 */
373     0x00, 0x02,             /* ITR-RLOC-AFI 2 */
374     0xcc, 0xdd, 0xee, 0xff,
375     0x88, 0x99, 0xaa, 0xbb,
376     0x44, 0x55, 0x66, 0x77,
377     0x00, 0x11, 0x22, 0x33, /* ITR-RLOC Address 2 */
378
379     /* record */
380     0x00,                   /* reserved */
381     0x18,                   /* EID mask-len */
382     0x00, 0x01,             /* EID-prefix-AFI */
383     0xf0, 0xde, 0xbc, 0x9a, /* EID-prefix */
384   };
385   _assert (0 == memcmp (expected_data, (u8 *) h, sizeof (expected_data)));
386
387 done:
388   clib_mem_free (data);
389   return error;
390 }
391
392 /* generate a vector of eid records */
393 static mapping_t *
394 build_test_map_records ()
395 {
396   mapping_t * records = 0;
397
398   mapping_t r = {
399     .ttl = 0x44332211,
400     .eid = {
401       .type = GID_ADDR_MAC,
402       .mac = {1, 2, 3, 4, 5, 6},
403       .vni = 0x0
404     }
405   };
406
407   locator_t loc = {
408     .weight = 1,
409     .priority = 2,
410     .local = 1,
411     .address = {
412       .type = GID_ADDR_IP_PREFIX,
413       .ippref = {
414         .addr = {
415           .ip.v4.as_u32 = 0x99887766,
416           .version = IP4
417         }
418       }
419     }
420   };
421   vec_add1 (r.locators, loc);
422   vec_add1 (records, r);
423
424   return records;
425 }
426
427 static void
428 free_test_map_records (mapping_t * maps)
429 {
430   mapping_t * map;
431   vec_foreach (map, maps)
432     {
433       vec_free (map->locators);
434     }
435   vec_free (maps);
436 }
437
438 static clib_error_t *
439 test_lisp_map_register ()
440 {
441   vlib_buffer_t *b;
442   clib_error_t * error = 0;
443   u64 nonce;
444   u32 msg_len = 0;
445   mapping_t * records = build_test_map_records ();
446
447   u8 * data = clib_mem_alloc(500);
448   memset(data, 0, 500);
449   b = (vlib_buffer_t *) data;
450
451   lisp_msg_put_map_register (b, records, 1 /* want map notify */,
452                             20 /* length of HMAC_SHA_1_96 */,
453                             &nonce, &msg_len);
454   free_test_map_records (records);
455
456   /* clear Nonce to simplify comparison */
457   memset((u8 *)b->data + 4, 0, 8);
458
459   /* clear authentication data */
460   memset ((u8 *)b->data + 16, 0, 20);
461
462   u8 expected_data[] = {
463     0x30, 0x00, 0x01, 0x01, /* type; rsvd; want notify; REC count */
464     0x00, 0x00, 0x00, 0x00,
465     0x00, 0x00, 0x00, 0x00, /* nonce */
466     0x00, 0x00, 0x00, 0x00, /* key id, auth data length:
467                               both are zeroes because those are set in another
468                               function (see auth_data_len_by_key_id())*/
469     0x00, 0x00, 0x00, 0x00,
470     0x00, 0x00, 0x00, 0x00,
471     0x00, 0x00, 0x00, 0x00,
472     0x00, 0x00, 0x00, 0x00,
473     0x00, 0x00, 0x00, 0x00, /* auth data */
474
475     /* first record */
476     0x44, 0x33, 0x22, 0x11, /* ttl */
477     0x01, 0x00, 0x00, 0x00, /* loc count, eid len, ACT, A */
478     0x00, 0x00, 0x40, 0x05, /* rsvd, map ver num, AFI = MAC */
479     0x01, 0x02, 0x03, 0x04,
480     0x05, 0x06,             /* MAC EID */
481
482     /* locator 1 */
483     0x02, 0x01, 0x00, 0x00, /* prio, weight, mprio, mweight */
484     0x00, 0x04, 0x00, 0x01, /* flags, AFI = ipv4 */
485     0x66, 0x77, 0x88, 0x99, /* ipv4 locator address */
486   };
487   _assert (0 == memcmp (expected_data, b->data, sizeof (expected_data)));
488 done:
489   clib_mem_free (data);
490   return error;
491 }
492
493 static clib_error_t *
494 test_lisp_parse_lcaf ()
495 {
496   int i;
497   clib_error_t * error = 0;
498   gid_address_t eid;
499   locator_t * locs = 0;
500   locator_t probed;
501   vlib_buffer_t * b = 0;
502   u32 buff_len = 500;
503
504   b = clib_mem_alloc (buff_len);
505   memset ((u8 *)b, 0, buff_len);
506
507   u8 map_reply_records[] =
508     {
509       /* 1. record */
510       0x01, 0x02, 0x03, 0x04, /* record TTL */
511       0x03,                   /* locator count */
512       0x00, 0x00, 0x00,       /* eid-mask-len; ... */
513       0x00, 0x00,             /* reserved; map-version num */
514       0x00, 0x01,             /* EID-Prefix-AFI */
515       0x33, 0x44, 0x55, 0x66, /* eid-prefix */
516
517       /* 1st locator */
518       0x0a,                   /* prority */
519       0x0b,                   /* weight */
520       0x0c,                   /* m-prority */
521       0x0d,                   /* m-weight */
522       0x00, 0x00,             /* unused flags */
523       0x40, 0x03,             /* Loc-AFI = LCAF*/
524
525       /* LCAF header*/
526       0x00, 0x00,             /* reserved1, flags */
527       0x02,                   /* type = Instance ID */
528       0x18,                   /* IID mask-len */
529       0x00, 0x0a,             /* lenght */
530       /* LCAF Instance ID */
531       0x00, 0x00, 0x00, 0x09, /* iid */
532       0x00, 0x01,             /* AFI = ipv4 */
533       0x10, 0xbb, 0xcc, 0xdd, /* ipv4 loator address */
534
535       /* 2nd locator */
536       0x07,                   /* prority */
537       0x06,                   /* weight */
538       0x05,                   /* m-prority */
539       0x04,                   /* m-weight */
540       0x00, 0x00,             /* unused flags */
541       0x40, 0x03,             /* Loc-AFI = LCAF*/
542
543       /* LCAF header*/
544       0x00, 0x00,             /* reserved1, flags */
545       0x02,                   /* type = Instance ID */
546       0x18,                   /* IID mask-len */
547       0x00, 0x16,             /* iid length + next AFI lenght */
548       /* LCAF Instance ID */
549       0x22, 0x44, 0x66, 0x88, /* iid */
550       0x00, 0x02,             /* AFI = ipv6 */
551       0xcc, 0xdd, 0xee, 0xff,
552       0x88, 0x99, 0xaa, 0xbb,
553       0x44, 0x55, 0x66, 0x77,
554       0x00, 0x11, 0x22, 0x33, /* ipv6 locator address */
555
556       /* 3rd locator */
557       0x0a,                   /* prority */
558       0x0b,                   /* weight */
559       0x0c,                   /* m-prority */
560       0x0d,                   /* m-weight */
561       0x00, 0x00,             /* unused flags */
562       0x00, 0x01,             /* Loc-AFI */
563       0xaa, 0xbb, 0xcc, 0xdd, /* Loator */
564     };
565
566   b->current_length = buff_len;
567   memcpy (b->data, map_reply_records, sizeof (map_reply_records));
568
569   lisp_msg_parse_mapping_record (b, &eid, &locs, &probed);
570   _assert (vec_len (locs) == 3);
571   _assert (eid.ippref.addr.ip.v4.as_u32 == 0x66554433);
572
573   /* check 1st locator - an LCAF with ipv4 */
574   _assert (locs[0].local == 0);
575   _assert (locs[0].priority == 0xa);
576   _assert (locs[0].weight == 0xb);
577   _assert (locs[0].mpriority == 0xc);
578   _assert (locs[0].mweight == 0xd);
579
580   _assert (gid_address_type (&locs[0].address) == GID_ADDR_IP_PREFIX);
581   _assert (gid_address_vni (&locs[0].address) == 0x09);
582   ip_prefix_t * ip_pref = &gid_address_ippref (&locs[0].address);
583   _assert (IP4 == ip_prefix_version (ip_pref));
584
585   /* 2nd locator - LCAF entry with ipv6 address */
586   _assert (locs[1].local == 0);
587   _assert (locs[1].priority == 0x7);
588   _assert (locs[1].weight == 0x6);
589   _assert (locs[1].mpriority == 0x5);
590   _assert (locs[1].mweight == 0x4);
591
592   _assert (gid_address_type (&locs[1].address) == GID_ADDR_IP_PREFIX);
593   _assert (0x22446688 == gid_address_vni (&locs[1].address));
594   ip_pref = &gid_address_ippref (&locs[1].address);
595   _assert (IP6 == ip_prefix_version (ip_pref));
596
597   /* 3rd locator - simple ipv4 address */
598   _assert (gid_address_type (&locs[2].address) == GID_ADDR_IP_PREFIX);
599 done:
600   clib_mem_free (b);
601
602   for (i = 0; i < 3; i++)
603     locator_free (&locs[i]);
604   vec_free (locs);
605   return error;
606 }
607
608 #define foreach_test_case                 \
609   _(lisp_msg_put_mreq)                    \
610   _(lisp_msg_put_mreq_with_lcaf)          \
611   _(lisp_msg_push_ecm)                    \
612   _(lisp_msg_parse)                       \
613   _(lisp_msg_parse_mapping_record)        \
614   _(lisp_parse_lcaf)                      \
615   _(lisp_map_register)
616
617 int run_tests (void)
618 {
619   clib_error_t * error;
620
621 #define _(_test_name)                   \
622   error = test_ ## _test_name ();       \
623   if (error)                            \
624     {                                   \
625       clib_error_report (error);        \
626       return 0;                         \
627     }
628
629   foreach_test_case
630 #undef _
631
632   return 0;
633 }
634
635 int main()
636 {
637   return run_tests ();
638 }
639 #undef _assert