[quagga-dev 11694] [PATCH 2/2] tests: fix tests for 055086f (well-known attr check)

David Lamparter equinox at opensourcerouting.org
Thu Oct 30 06:09:47 GMT 2014


Fix tests/aspathtest.c by including an ORIGIN attribute in the
testcases.  After 055086f "bgpd: well-known attr check only run for
v4/uni, which could cause a crash," we're now checking for it and tests
are failing due to that.

Note that test #11 ("4b AS4_PATH w/o AS_PATH") is no longer accepted as
OK since the function now checks for the existence of an AS_PATH attr.

Fixes: 055086f ("bgpd: well-known attr check only run for v4/uni"...)
Signed-off-by: David Lamparter <equinox at opensourcerouting.org>
---
 tests/aspath_test.c | 76 +++++++++++++++++++++++++++++++++--------------------
 1 file changed, 48 insertions(+), 28 deletions(-)

diff --git a/tests/aspath_test.c b/tests/aspath_test.c
index 0e57c53..71a3102 100644
--- a/tests/aspath_test.c
+++ b/tests/aspath_test.c
@@ -453,6 +453,13 @@ static struct test_segment {
   },  { NULL, NULL, {0}, 0, { NULL, 0, 0 } }
 };
 
+#define COMMON_ATTRS \
+      BGP_ATTR_FLAG_TRANS, \
+      BGP_ATTR_ORIGIN, \
+      1, \
+      BGP_ORIGIN_EGP
+#define COMMON_ATTR_SIZE 4
+
 /* */
 static struct aspath_tests {
   const char *desc;
@@ -474,11 +481,12 @@ static struct aspath_tests {
     "8466 3 52737 4096",
     AS2_DATA, 0,
     0,
-    { BGP_ATTR_FLAG_TRANS,
-      BGP_ATTR_AS_PATH, 
+    { COMMON_ATTRS,
+      BGP_ATTR_FLAG_TRANS,
+      BGP_ATTR_AS_PATH,
       10,
     },
-    3,
+    COMMON_ATTR_SIZE + 3,
   },
   /* 1 */
   {
@@ -487,11 +495,12 @@ static struct aspath_tests {
     "8466 3 52737 4096",
     AS2_DATA, -1,
     0,
-    { BGP_ATTR_FLAG_TRANS,
+    { COMMON_ATTRS,
+      BGP_ATTR_FLAG_TRANS,
       BGP_ATTR_AS_PATH, 
       8,
     },
-    3,
+    COMMON_ATTR_SIZE + 3,
   },
   /* 2 */
   {
@@ -500,11 +509,12 @@ static struct aspath_tests {
     "8466 3 52737 4096",
     AS2_DATA, -1,
     0,
-    { BGP_ATTR_FLAG_TRANS,
+    { COMMON_ATTRS,
+      BGP_ATTR_FLAG_TRANS,
       BGP_ATTR_AS_PATH, 
       12,
     },
-    3,
+    COMMON_ATTR_SIZE + 3,
   },
   /* 3 */
   {
@@ -513,11 +523,12 @@ static struct aspath_tests {
     "8466 3 52737 4096",
     AS2_DATA, -1,
     0,
-    { BGP_ATTR_FLAG_TRANS|BGP_ATTR_FLAG_OPTIONAL,
+    { COMMON_ATTRS,
+      BGP_ATTR_FLAG_TRANS|BGP_ATTR_FLAG_OPTIONAL,
       BGP_ATTR_AS_PATH, 
       10,
     },
-    3,
+    COMMON_ATTR_SIZE + 3,
   },
   /* 4 */
   {
@@ -526,11 +537,12 @@ static struct aspath_tests {
     "8466 3 52737 4096",
     AS2_DATA, -1,
     0,
-    { BGP_ATTR_FLAG_TRANS|BGP_ATTR_FLAG_OPTIONAL,
+    { COMMON_ATTRS,
+      BGP_ATTR_FLAG_TRANS|BGP_ATTR_FLAG_OPTIONAL,
       BGP_ATTR_AS4_PATH, 
       10,
     },
-    3,
+    COMMON_ATTR_SIZE + 3,
   },
   /* 5 */
   {
@@ -539,11 +551,12 @@ static struct aspath_tests {
     "8466 3 52737 4096",
     AS4_DATA, -1,
     PEER_CAP_AS4_RCV,
-    { BGP_ATTR_FLAG_TRANS|BGP_ATTR_FLAG_OPTIONAL,
+    { COMMON_ATTRS,
+      BGP_ATTR_FLAG_TRANS|BGP_ATTR_FLAG_OPTIONAL,
       BGP_ATTR_AS4_PATH, 
       10,
     },
-    3,
+    COMMON_ATTR_SIZE + 3,
   },
   /* 6 */
   {
@@ -552,11 +565,12 @@ static struct aspath_tests {
     "8466 3 52737 4096",
     AS4_DATA, 0,
     PEER_CAP_AS4_RCV|PEER_CAP_AS4_ADV,
-    { BGP_ATTR_FLAG_TRANS,
+    { COMMON_ATTRS,
+      BGP_ATTR_FLAG_TRANS,
       BGP_ATTR_AS_PATH, 
       18,
     },
-    3,
+    COMMON_ATTR_SIZE + 3,
   },
   /* 7 */
   {
@@ -565,11 +579,12 @@ static struct aspath_tests {
     "8466 3 52737 4096",
     AS4_DATA, -1,
     PEER_CAP_AS4_RCV|PEER_CAP_AS4_ADV,
-    { BGP_ATTR_FLAG_TRANS,
+    { COMMON_ATTRS,
+      BGP_ATTR_FLAG_TRANS,
       BGP_ATTR_AS_PATH, 
       16,
     },
-    3,
+    COMMON_ATTR_SIZE + 3,
   },
   /* 8 */
   {
@@ -578,11 +593,12 @@ static struct aspath_tests {
     "8466 3 52737 4096",
     AS4_DATA, -1,
     PEER_CAP_AS4_RCV|PEER_CAP_AS4_ADV,
-    { BGP_ATTR_FLAG_TRANS,
+    { COMMON_ATTRS,
+      BGP_ATTR_FLAG_TRANS,
       BGP_ATTR_AS_PATH, 
       20,
     },
-    3,
+    COMMON_ATTR_SIZE + 3,
   },
   /* 9 */
   {
@@ -591,11 +607,12 @@ static struct aspath_tests {
     "8466 3 52737 4096",
     AS4_DATA, -1,
     PEER_CAP_AS4_RCV|PEER_CAP_AS4_ADV,
-    { BGP_ATTR_FLAG_TRANS,
+    { COMMON_ATTRS,
+      BGP_ATTR_FLAG_TRANS,
       BGP_ATTR_AS_PATH, 
       22,
     },
-    3,
+    COMMON_ATTR_SIZE + 3,
   },
   /* 10 */
   {
@@ -604,24 +621,26 @@ static struct aspath_tests {
     "8466 3 52737 4096",
     AS4_DATA, -1,
     PEER_CAP_AS4_RCV|PEER_CAP_AS4_ADV,
-    { BGP_ATTR_FLAG_TRANS|BGP_ATTR_FLAG_OPTIONAL,
+    { COMMON_ATTRS,
+      BGP_ATTR_FLAG_TRANS|BGP_ATTR_FLAG_OPTIONAL,
       BGP_ATTR_AS_PATH, 
       18,
     },
-    3,
+    COMMON_ATTR_SIZE + 3,
   },
   /* 11 */
   {
     "4b AS4_PATH w/o AS_PATH",
     &test_segments[6],
     NULL,
-    AS4_DATA, 0,
+    AS4_DATA, -1,
     PEER_CAP_AS4_ADV,
-    { BGP_ATTR_FLAG_TRANS|BGP_ATTR_FLAG_OPTIONAL,
+    { COMMON_ATTRS,
+      BGP_ATTR_FLAG_TRANS|BGP_ATTR_FLAG_OPTIONAL,
       BGP_ATTR_AS4_PATH, 
       14,
     },
-    3,
+    COMMON_ATTR_SIZE + 3,
   },
   /* 12 */
   {
@@ -630,11 +649,12 @@ static struct aspath_tests {
     "8466 3 52737 4096 (123 456 789)",
     AS4_DATA, 0,
     PEER_CAP_AS4_ADV,
-    { BGP_ATTR_FLAG_TRANS|BGP_ATTR_FLAG_OPTIONAL,
+    { COMMON_ATTRS,
+      BGP_ATTR_FLAG_TRANS|BGP_ATTR_FLAG_OPTIONAL,
       BGP_ATTR_AS4_PATH, 
       14,
     },
-    3,
+    COMMON_ATTR_SIZE + 3,
     &test_segments[0],
   },
   { NULL, NULL, NULL, 0, 0, 0, { 0 }, 0 },
-- 
1.8.5.5





More information about the Quagga-dev mailing list