summaryrefslogtreecommitdiff
path: root/filter
diff options
context:
space:
mode:
authorPavel Tvrdik <pawel.tvrdik@gmail.com>2016-11-16 12:18:06 +0100
committerPavel Tvrdik <pawel.tvrdik@gmail.com>2016-11-16 12:22:01 +0100
commit7dea7ccb1074e83d0c5ea2f667deca1f0c938e72 (patch)
tree560749c68f031cc6cc59042e423f351f9a16ae4f /filter
parent4b135d095860cf861ff47c24a10169faa41fe35a (diff)
filter/test.conf: Replace print func with assert and format
Diffstat (limited to 'filter')
-rw-r--r--filter/test.conf84
-rw-r--r--filter/test.conf.inc5
2 files changed, 45 insertions, 44 deletions
diff --git a/filter/test.conf b/filter/test.conf
index 2ee5817a..a350e0fb 100644
--- a/filter/test.conf
+++ b/filter/test.conf
@@ -73,7 +73,7 @@ bgppath p2;
p2 = prepend( p2, 3 );
p2 = prepend( p2, 4 );
- print "Testing paths: ", p2;
+ bt_assert(format(p2) = "(path 4 3 2 1)");
bt_assert(p2.len = 4);
bt_assert(p2 ~ pm1);
bt_assert(p2 ~ pm2);
@@ -137,7 +137,7 @@ clist l2;
l = add( l, (one,2) );
bt_assert(l ~ [(*,*)]);
l = add( l, (2,one+2) );
- print "Community list (1,2) (2,3) ", l;
+ bt_assert(format(l) = "(clist (1,2) (2,3))");
bt_assert((2,3) ~ l);
bt_assert(l ~ [(1,*)]);
@@ -193,19 +193,24 @@ clist l2;
l = filter(l2, [(3,1..4)]);
l2 = filter(l2, [(3,3..6)]);
- print "clist A (1..4): ", l;
+ # lclist A (10,20,30)
+ bt_assert(format(l) = "(clist (3,1) (3,2) (3,3) (3,4))");
bt_assert(l = add(add(add(add(-empty-, (3,1)), (3,2)), (3,3)), (3,4)));
- print "clist B (3..6): ", l2;
+ # lclist B (30,40,50)
+ bt_assert(format(l2) = "(clist (3,3) (3,4) (3,5) (3,6))");
bt_assert(l2 = add(add(add(add(-empty-, (3,3)), (3,4)), (3,5)), (3,6)));
- print "clist A union B: ", add( l, l2 );
+ # lclist A union B
+ bt_assert(format(add(l, l2)) = "(clist (3,1) (3,2) (3,3) (3,4) (3,5) (3,6))");
bt_assert(add(l, l2) = add(add(add(add(add(add(-empty-, (3,1)), (3,2)), (3,3)), (3,4)), (3,5)), (3,6)));
- print "clist A isect B: ", filter( l, l2 );
+ # lclist A isect B
+ bt_assert(format(filter(l, l2)) = "(clist (3,3) (3,4))");
bt_assert(filter(l, l2) = add(add(-empty-, (3,3)), (3,4)));
- print "clist A \ B: ", delete( l, l2 );
+ # lclist A \ B
+ bt_assert(format(delete(l, l2)) = "(clist (3,1) (3,2))");
bt_assert(delete(l, l2) = add(add(-empty-, (3,1)), (3,2)));
}
@@ -228,8 +233,7 @@ eclist el2;
el = add(el, (ro, 10.20.30.40, 100));
el = add(el, (ro, 11.21.31.41.mask(16), 200));
- print "EC list (rt, 10, 20) (ro, 10.20.30.40, 100) (ro, 11.21.0.0, 200):";
- print el;
+ bt_assert(format(el) = "(eclist (rt, 10, 20) (ro, 10.20.30.40, 100) (ro, 11.21.0.0, 200))");
bt_assert(el.len = 3);
el = delete(el, (rt, 10, 20));
el = delete(el, (rt, 10, 30));
@@ -257,19 +261,24 @@ eclist el2;
el2 = filter(el, [(rt, 10, 20..40)] );
el2 = add(el2, (rt, 10, 50));
- print "eclist A (1,30,40): ", el;
+ # eclist A (1,30,40)
+ bt_assert(format(el) = "(eclist (rt, 10, 1) (rt, 10, 30) (rt, 10, 40))");
bt_assert(el = add(add(add(--empty--, (rt, 10, 1)), (rt, 10, 30)), (rt, 10, 40)));
- print "eclist B (30,40,50): ", el2;
+ # eclist B (30,40,50)
+ bt_assert(format(el2) = "(eclist (rt, 10, 30) (rt, 10, 40) (rt, 10, 50))");
bt_assert(el2 = add(add(add(--empty--, (rt, 10, 30)), (rt, 10, 40)), (rt, 10, 50)));
- print "eclist A union B: ", add(el2, el);
+ # eclist A union B
+ bt_assert(format(add(el2, el)) = "(eclist (rt, 10, 30) (rt, 10, 40) (rt, 10, 50) (rt, 10, 1))");
bt_assert(add(el2, el) = add(add(add(add(--empty--, (rt, 10, 30)), (rt, 10, 40)), (rt, 10, 50)), (rt, 10, 1)));
- print "eclist A isect B: ", filter(el, el2);
+ # eclist A isect B
+ bt_assert(format(filter(el, el2)) = "(eclist (rt, 10, 30) (rt, 10, 40))");
bt_assert(filter(el, el2) = add(add(--empty--, (rt, 10, 30)), (rt, 10, 40)));
- print "eclist A \ B: ", delete(el, el2);
+ # eclist A \ B
+ bt_assert(format(delete(el, el2)) = "(eclist (rt, 10, 1))");
bt_assert(delete(el, el2) = add(--empty--, (rt, 10, 1)));
}
@@ -296,8 +305,7 @@ lclist ll2;
ll = add(ll, (ten, 20, 30));
ll = add(ll, (1000, 2000, 3000));
ll = add(ll, mktrip(100000));
- print "LC list (10, 20, 30) (1000, 2000, 3000) (100000, 200000, 300000)";
- print ll;
+ bt_assert(format(ll) = "(lclist (10, 20, 30) (1000, 2000, 3000) (100000, 200000, 300000))");
bt_assert(ll.len = 3);
bt_assert(ll = add(add(add(---empty---, (10, 20, 30)), (1000, 2000, 3000)), (100000, 200000, 300000)));
@@ -325,16 +333,16 @@ lclist ll2;
ll2 = add(ll2, (30, 30, 30));
ll2 = add(ll2, (40, 40, 40));
- print "lclist A (10,20,30): ", ll;
- print "lclist B (30,40,50): ", ll2;
+ bt_assert(format(ll) = "(lclist (10, 10, 10) (20, 20, 20) (30, 30, 30))");
+ bt_assert(format(ll2) = "(lclist (20, 20, 20) (30, 30, 30) (40, 40, 40))");
- print "lclist A union B: ", add(ll, ll2);
- bt_assert(add(ll, ll2) = add(add(add(add(---empty---, (10,10,10)), (20,20,20)), (30,30,30)), (40,40,40)));
+ bt_assert(format(add(ll, ll2)) = "(lclist (10, 10, 10) (20, 20, 20) (30, 30, 30) (40, 40, 40))");
+ bt_assert(add(ll, ll2) = add(add(add(add(---empty---, (10,10,10)), (20,20,20)), (30,30,30)), (40,40,40)));
- print "lclist A isect B: ", filter(ll, ll2);
+ bt_assert(format(filter(ll, ll2)) = "(lclist (20, 20, 20) (30, 30, 30))");
bt_assert(filter(ll, ll2) = add(add(---empty---, (20, 20, 20)), (30, 30, 30)));
- print "lclist A \ B: ", delete(ll, ll2);
+ bt_assert(format(delete(ll, ll2)) = "(lclist (10, 10, 10))");
bt_assert(delete(ll, ll2) = add(---empty---, (10, 10, 10)));
}
@@ -385,7 +393,7 @@ function t_quad()
quad qq;
{
qq = 1.2.3.4;
- print "Testinq quad: 1.2.3.4 = ", qq;
+ bt_assert(format(qq) = "1.2.3.4");
bt_assert(qq = 1.2.3.4);
bt_assert(qq != 4.3.2.1);
}
@@ -422,7 +430,7 @@ function t_ec()
ec cc;
{
cc = (rt, 12345, 200000);
- print "Testing EC: ", cc;
+ bt_assert(format(cc) = "(rt, 12345, 200000)");
bt_assert(cc = (rt, 12345, 200000));
bt_assert(cc < (rt, 12345, 200010));
@@ -430,7 +438,7 @@ ec cc;
bt_assert(cc != (ro, 12345, 200000));
bt_assert(!(cc > (rt, 12345, 200010)));
- print "Testing EC: (ro, 100000, 20000) = ", (ro, 100000, 20000);
+ bt_assert(format((ro, 100000, 20000)) = "(ro, 100000, 20000)");
}
bt_test_suite(t_ec, "Testing Extended Communities");
@@ -449,9 +457,8 @@ function t_ec_set()
ec set ecs;
{
ecs = [(rt, ten, (one+onef(0))*10), (ro, 100000, 100..200), (rt, 12345, *)];
- print "EC set (rt, 10, 20) (ro, 100000, 100..200), (rt, 12345, *):";
- print ecs;
- print ecs2;
+ bt_assert(format(ecs) = "[(rt, 10, 20), (rt, 12345, 0)..(rt, 12345, 4294967295), (ro, 100000, 100)..(ro, 100000, 200)]");
+ bt_assert(format(ecs2) = "[(rt, 10, 20), (rt, 12345, 0)..(rt, 12345, 4294967295), (ro, 100000, 100)..(ro, 100000, 200)]");
bt_assert((rt, 10, 20) ~ ecs);
bt_assert((ro, 100000, 100) ~ ecs);
@@ -588,7 +595,7 @@ int set is;
bt_assert([1,2] != [1,3]);
bt_assert([1,4..10,20] = [1,4..10,20]);
- print "What will this do? ", [ 1, 2, 1, 1, 1, 3, 4, 1, 1, 1, 5 ];
+ bt_assert(format([ 1, 2, 1, 1, 1, 3, 4, 1, 1, 1, 5 ]) = "[1, 1, 1, 1, 1, 1, 1, 2, 3, 4, 5]");
}
bt_test_suite(t_int_set, "Testing sets of integers");
@@ -610,7 +617,7 @@ ip p;
bt_assert(p.mask(8) = 127.0.0.0);
bt_assert(1.2.3.4 = 1.2.3.4);
bt_assert(1.2.3.4 = onetwo);
- print "1.2.3.4 = ", onetwo;
+ bt_assert(format(onetwo) = "1.2.3.4");
}
bt_test_suite(t_ip, "Testing ip address");
@@ -641,7 +648,8 @@ bt_test_suite(t_ip_set, "Testing sets of ip address");
function t_enum()
{
- print "Testing enums: ", RTS_DUMMY, " ", RTS_STATIC;
+ bt_assert(format(RTS_DUMMY) = "(enum 30)0"); /* XXX */
+ bt_assert(format(RTS_STATIC) = "(enum 30)1"); /* XXX */
bt_assert(RTS_STATIC ~ [RTS_STATIC, RTS_DEVICE]);
bt_assert(RTS_BGP !~ [RTS_STATIC, RTS_DEVICE]);
}
@@ -689,7 +697,7 @@ pair set ps;
{
pp = (1, 2);
ps = [(1,(one+one)), (3,4)..(4,8), (5,*), (6,3..6)];
- print "Pair set: ", ps;
+ bt_assert(format(ps) = "[(1,2), (3,4)..(4,8), (5,0)..(5,65535), (6,3)..(6,6)]");
bt_assert(pp ~ ps);
bt_assert((3,5) ~ ps);
bt_assert((4,1) ~ ps);
@@ -706,7 +714,6 @@ pair set ps;
bt_assert((1,1) !~ ps);
ps = [(20..150, 200..300), (50100..50200, 1000..50000), (*, 5+5)];
- print "Pair set: ", ps;
bt_assert((100,200) ~ ps);
bt_assert((150,300) ~ ps);
bt_assert((50180,1200) ~ ps);
@@ -735,7 +742,7 @@ function t_string()
string st;
{
st = "Hello";
- print "Testing string: ", st;
+ bt_assert(format(st) = "Hello");
bt_assert(st ~ "Hell*");
bt_assert(st ~ "?ello");
bt_assert(st ~ "Hello");
@@ -791,7 +798,7 @@ function t_prefix()
prefix px;
{
px = 1.2.0.0/18;
- print "Testing prefixes: 1.2.0.0/18 = ", px;
+ bt_assert(format(px) = "1.2.0.0/18");
bt_assert(192.168.0.0/16 ~ 192.168.0.0/16);
bt_assert(192.168.0.0/17 ~ 192.168.0.0/16);
bt_assert(192.168.254.0/24 ~ 192.168.0.0/16);
@@ -819,8 +826,6 @@ define pxs2 = [ 10.0.0.0/16{8,12}, 20.0.0.0/16{24,28} ];
function test_pxset(prefix set pxs)
{
- print pxs;
-
bt_assert(net10 ~ pxs);
bt_assert(10.0.0.0/10 ~ pxs);
bt_assert(10.0.0.0/12 ~ pxs);
@@ -851,7 +856,7 @@ function t_prefix_sets()
prefix set pxs;
{
pxs = [ 1.2.0.0/16, 1.4.0.0/16+];
- print "Testing prefix sets: ", pxs;
+ bt_assert(format(pxs) = "[1.2.0.0/112{::0.1.0.0}, 1.4.0.0/112{::0.1.255.255}]");
bt_assert(1.2.0.0/16 ~ pxs);
bt_assert(1.4.0.0/16 ~ pxs);
bt_assert(1.4.0.0/18 ~ pxs);
@@ -886,7 +891,7 @@ function t_ip_sets()
ip set ips;
{
ips = [ 1.1.1.0 .. 1.1.1.255, ip1222];
- print "Testing IP sets: ", ips;
+ bt_assert(format(ips) = "[1.1.1.0..1.1.1.255, 1.2.2.2]");
bt_assert(1.1.1.0 ~ ips);
bt_assert(1.1.1.100 ~ ips);
bt_assert(1.2.2.2 ~ ips);
@@ -948,7 +953,6 @@ bt_test_suite(t_call_function, "Testing calling functions");
function t_include()
int i;
{
- print "Testing include";
i = 1;
include "test.conf.inc";
bt_assert(i = 42);
diff --git a/filter/test.conf.inc b/filter/test.conf.inc
index 7707ae38..8ede2d18 100644
--- a/filter/test.conf.inc
+++ b/filter/test.conf.inc
@@ -1,6 +1,3 @@
-print "Entering include";
-print "Should be 2: ", 1+1;
-print "Leaving include";
+bt_assert(1+1 = 2);
i = 42;
-