Add community tests for various ext-community * versions.
authorclaudio <claudio@openbsd.org>
Sat, 17 Jun 2023 08:01:22 +0000 (08:01 +0000)
committerclaudio <claudio@openbsd.org>
Sat, 17 Jun 2023 08:01:22 +0000 (08:01 +0000)
While there move one test down so that the numbering is consistent again
and make the error strings for counts clear.

regress/usr.sbin/bgpd/unittests/rde_community_test.c
regress/usr.sbin/bgpd/unittests/rde_community_test.h

index 38c2a8a..4b44571 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: rde_community_test.c,v 1.6 2023/01/30 17:02:48 claudio Exp $ */
+/*     $OpenBSD: rde_community_test.c,v 1.7 2023/06/17 08:01:22 claudio Exp $ */
 
 /*
  * Copyright (c) 2019 Claudio Jeker <claudio@openbsd.org>
@@ -161,7 +161,7 @@ test_filter(size_t num, struct testfilter *f)
        if (f->next != 0) {
                if (community_count(&comm, COMMUNITY_TYPE_EXT) !=
                    f->next - 1) {
-                       printf("Test %zu: community_count unexpected "
+                       printf("Test %zu: ext community_count unexpected "
                            "return %d != %d\n", num, r, f->next - 1);
                        return -1;
                }
@@ -170,7 +170,7 @@ test_filter(size_t num, struct testfilter *f)
        if (f->nlarge != 0) {
                if (community_count(&comm, COMMUNITY_TYPE_LARGE) !=
                    f->nlarge - 1) {
-                       printf("Test %zu: community_count unexpected "
+                       printf("Test %zu: large community_count unexpected "
                            "return %d != %d\n", num, r, f->nlarge - 1);
                        return -1;
                }
index 2d2439a..0036891 100644 (file)
@@ -502,6 +502,22 @@ struct community filters[] = {
                .data2 = 196618,
                .data3 = EXT_COMMUNITY_TRANS_TWO_AS << 8 | 0x02,
        },
+       { /* 42 */
+               .flags = COMMUNITY_TYPE_EXT | (COMMUNITY_ANY << 24),
+       },
+       { /* 43 */
+               .flags = COMMUNITY_TYPE_EXT | (COMMUNITY_ANY << 8),
+               .data3 = (-1 << 8) | 0x02,
+       },
+       { /* 44 */
+               .flags = COMMUNITY_TYPE_EXT | (COMMUNITY_ANY << 8),
+               .data3 = EXT_COMMUNITY_TRANS_FOUR_AS << 8 | 0x02,
+       },
+       { /* 45 */
+               .flags = COMMUNITY_TYPE_EXT | (COMMUNITY_ANY << 16),
+               .data3 = EXT_COMMUNITY_TRANS_FOUR_AS << 8 | 0x02,
+               .data1 = 196618,
+       },
 };
 
 struct testfilter {
@@ -514,12 +530,6 @@ struct testfilter {
        int              nlarge;
        struct rde_peer *peer;
 } testfilters[] = {
-       {
-               .in = { 38, -1 },
-               .match = 30,
-               .mout = 1,
-               .peer = &peer,
-       },
        {
                .in = { 1, 2, -1 },
                .match = 1,
@@ -952,5 +962,54 @@ struct testfilter {
                .mout = 1,
                .peer = &peer_r4,
        },
+       {
+               .in = { 38, -1 },
+               .match = 30,
+               .mout = 1,
+               .peer = &peer,
+       },
+       { /* 70 */
+               .in = { 38, 39, 40, -1 },
+               .match = 42,
+               .mout = 1,
+               .delete = 42,
+               .next = 0 + 1,
+               .peer = &peer,
+       },
+       {
+               .in = { 38, 39, 40, -1 },
+               .match = 43,
+               .mout = 1,
+               .delete = 43,
+               .next = 0 + 1,
+               .peer = &peer,
+       },
+       {
+               .in = { 39, 40, -1 },
+               .match = 44,
+               .mout = 1,
+               .delete = 44,
+               .next = 0 + 1,
+               .peer = &peer,
+       },
+       {
+               .in = { 38, -1 },
+               .match = 44,
+               .mout = 0,
+               .peer = &peer,
+       },
+       {
+               .in = { 40, -1 },
+               .match = 45,
+               .mout = 1,
+               .delete = 45,
+               .next = 0 + 1,
+               .peer = &peer,
+       },
+       { /* 75 */
+               .in = { 38, 39, 41, -1 },
+               .match = 45,
+               .mout = 0,
+               .peer = &peer,
+       },
 };
-