[prev in list] [next in list] [prev in thread] [next in thread] 

List:       quagga-dev
Subject:    [quagga-dev 10219] [PATCH 3/4] tests: update & extend AS_PATH tests
From:       David Lamparter <equinox () opensourcerouting ! org>
Date:       2013-01-23 5:06:03
Message-ID: 1358917564-635126-4-git-send-email-equinox () opensourcerouting ! org
[Download RAW message or body]

NB: these tests test for current implementation state, not for RFC
conformance.  In particular, behaviour with confederations in AS4_PATH
as well as reconcilation of short AS_PATH + AS4_PATH is currently NOT
conforming to RFC 4893/6793.

* tests/aspath_test.c:  add capability to put both AS4_PATH & AS_PATH,
  add test for AS4_PATH w/o AS_PATH, update confederation test

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
---
 tests/aspath_test.c |   40 ++++++++++++++++++++++++++++++++++------
 1 files changed, 34 insertions(+), 6 deletions(-)

diff --git a/tests/aspath_test.c b/tests/aspath_test.c
index 9170455..7fdb5e2 100644
--- a/tests/aspath_test.c
+++ b/tests/aspath_test.c
@@ -443,6 +443,7 @@ static struct aspath_tests {
   const int cap;	/* capabilities to set for peer */
   const char attrheader [1024];
   size_t len;
+  const struct test_segment *old_segment;
 } aspath_tests [] =
 {
   /* 0 */
@@ -590,10 +591,10 @@ static struct aspath_tests {
   },
   /* 11 */
   {
-    "4b AS_PATH: confed",
+    "4b AS4_PATH w/o AS_PATH",
     &test_segments[6],
-    "8466 3 52737 4096",
-    AS4_DATA, -1,
+    NULL,
+    AS4_DATA, 0,
     PEER_CAP_AS4_ADV,
     { BGP_ATTR_FLAG_TRANS|BGP_ATTR_FLAG_OPTIONAL,
       BGP_ATTR_AS4_PATH, 
@@ -601,6 +602,20 @@ static struct aspath_tests {
     },
     3,
   },
+  /* 12 */
+  {
+    "4b AS4_PATH: confed",
+    &test_segments[6],
+    "8466 3 52737 4096 (123 456 789)",
+    AS4_DATA, 0,
+    PEER_CAP_AS4_ADV,
+    { BGP_ATTR_FLAG_TRANS|BGP_ATTR_FLAG_OPTIONAL,
+      BGP_ATTR_AS4_PATH, 
+      14,
+    },
+    3,
+    &test_segments[0],
+  },
   { NULL, NULL, NULL, 0, 0, 0, { 0 }, 0 },
 };
 
@@ -1212,6 +1227,14 @@ handle_attr_test (struct aspath_tests *t)
   
   stream_write (peer.ibuf, t->attrheader, t->len);
   datalen = aspath_put (peer.ibuf, asp, t->as4 == AS4_DATA);
+  if (t->old_segment)
+    {
+      char dummyaspath[] = { BGP_ATTR_FLAG_TRANS, BGP_ATTR_AS_PATH,
+                             t->old_segment->len };
+      stream_write (peer.ibuf, dummyaspath, sizeof (dummyaspath));
+      stream_write (peer.ibuf, t->old_segment->asdata, t->old_segment->len);
+      datalen += sizeof (dummyaspath) + t->old_segment->len;
+    }
   
   ret = bgp_attr_parse (&peer, &attr, t->len + datalen, NULL, NULL);
   
@@ -1224,12 +1247,12 @@ handle_attr_test (struct aspath_tests *t)
   if (ret != 0)
     goto out;
   
-  if (attr.aspath == NULL)
+  if (t->shouldbe && attr.aspath == NULL)
     {
-      printf ("aspath is NULL!\n");
+      printf ("aspath is NULL, but should be: %s\n", t->shouldbe);
       failed++;
     }
-  if (attr.aspath && strcmp (attr.aspath->str, t->shouldbe))
+  if (t->shouldbe && attr.aspath && strcmp (attr.aspath->str, t->shouldbe))
     {
       printf ("attr str and 'shouldbe' mismatched!\n"
               "attr str:  %s\n"
@@ -1237,6 +1260,11 @@ handle_attr_test (struct aspath_tests *t)
               attr.aspath->str, t->shouldbe);
       failed++;
     }
+  if (!t->shouldbe && attr.aspath)
+    {
+      printf ("aspath should be NULL, but is: %s\n", attr.aspath->str);
+      failed++;
+    }
 
 out:
   if (attr.aspath)
-- 
1.7.8.6


_______________________________________________
Quagga-dev mailing list
Quagga-dev@lists.quagga.net
http://lists.quagga.net/mailman/listinfo/quagga-dev
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic