]> git.ipfire.org Git - thirdparty/bird.git/blobdiff - filter/test.conf
Merge branch 'master' into mq-filter-stack
[thirdparty/bird.git] / filter / test.conf
index e25105d34a9ddcde621dac678c490c00a928a792..9abd76f320b0d291ee5d195bf941584091e44663 100644 (file)
@@ -7,8 +7,7 @@
 router id 62.168.0.1;
 
 /* We have to setup any protocol */
-protocol static { ipv4; }
-
+protocol device { }
 
 
 
@@ -25,8 +24,19 @@ function onef(int a)
        return 1;
 }
 
+function twof(int a)
+{
+       return 2;
+}
 
+function oneg(int a)
+{
+       return 1;
+}
 
+bt_test_same(onef, onef, 1);
+bt_test_same(onef, oneg, 1);
+bt_test_same(onef, twof, 0);
 
 /*
  *     Testing boolean expressions
@@ -62,7 +72,6 @@ bt_test_suite(t_bool, "Testing boolean expressions");
 
 
 
-
 /*
  *     Testing integers
  *     ----------------
@@ -126,6 +135,7 @@ int set is;
        bt_assert(2 ~ [ 1, 2, 3 ]);
        bt_assert(5 ~ [ 4 .. 7 ]);
        bt_assert(1 !~ [ 2, 3, 4 ]);
+       bt_assert(999 !~ [ 666, 333 ]);
 
        is = [ 2, 3, 4, 7..11 ];
        bt_assert(10 ~ is);
@@ -589,14 +599,11 @@ function mkpath(int a; int b)
 
 function t_path()
 bgpmask pm1;
-bgpmask pm2;
 bgppath p2;
 {
-       pm1 =  / 4 3 2 1 /;
-       pm2 = [= 4 3 2 1 =];
+       pm1 = [= 4 3 2 1 =];
 
-       bt_assert(pm1 = pm2);
-       bt_assert(format(pm2) = "[= 4 3 2 1 =]");
+       bt_assert(format(pm1) = "[= 4 3 2 1 =]");
 
        bt_assert(+empty+ = +empty+);
        bt_assert(10 !~ +empty+);
@@ -609,17 +616,14 @@ bgppath p2;
        bt_assert(format(p2) = "(path 4 3 2 1)");
        bt_assert(p2.len = 4);
        bt_assert(p2 ~ pm1);
-       bt_assert(p2 ~ pm2);
        bt_assert(3 ~ p2);
        bt_assert(p2 ~ [2, 10..20]);
        bt_assert(p2 ~ [4, 10..20]);
 
        p2 = prepend(p2, 5);
        bt_assert(p2 !~ pm1);
-       bt_assert(p2 !~ pm2);
        bt_assert(10 !~ p2);
        bt_assert(p2 !~ [8, ten..(2*ten)]);
-       bt_assert(p2 ~  / ? 4 3 2 1 /);
        bt_assert(p2 ~ [= * 4 3 * 1 =]);
        bt_assert(p2 ~ [= (3+2) (2*2) 3 2 1 =]);
        bt_assert(p2 ~ mkpath(5, 4));
@@ -1011,6 +1015,59 @@ bt_test_suite(t_lclist_set, "Testing sets of large communities");
 
 
 
+/*
+ *     Testing Route Distinguishers
+ *     ----------------------------
+ */
+
+function t_rd()
+rd x;
+{
+       x = 12345:20000;
+       bt_assert(format(x) = "12345:20000");
+
+       bt_assert(x = 12345:20000);
+       bt_assert(x < 12345:20010);
+       bt_assert(x != 12346:20000);
+       bt_assert(x != 2:12345:20000);
+       bt_assert(!(x > 12345:200010));
+
+       bt_assert(format(10.0.0.1:1000) = "10.0.0.1:1000");
+       bt_assert(format(100000:20000) = "100000:20000");
+       bt_assert(format(2:100000:20000) = "100000:20000");
+       bt_assert(format(2:1000:1000) = "2:1000:1000");
+}
+
+bt_test_suite(t_rd, "Testing route distinguishers");
+
+
+
+
+/*
+ *     Testing sets of Route Distinguishers
+ *     ------------------------------------
+ */
+
+function t_rd_set()
+rd set rds;
+{
+       rds = [10:20, 100000:100..100000:200];
+       bt_assert(format(rds)  = "[10:20, 100000:100..100000:200]");
+
+       bt_assert(10:20  ~ rds);
+       bt_assert(10:21 !~ rds);
+       bt_assert(100000:90 !~ rds);
+       bt_assert(100000:100 ~ rds);
+       bt_assert(100000:128 ~ rds);
+       bt_assert(100000:200 ~ rds);
+       bt_assert(100010:150 !~ rds);
+}
+
+bt_test_suite(t_rd_set, "Testing sets of route distinguishers");
+
+
+
+
 /*
  *     Testing defined() function
  *     --------------------------
@@ -1060,6 +1117,11 @@ int i;
        return 0;
 }
 
+function callmeagain(int a; int b; int c)
+{
+       return a + b + c;
+}
+
 function fifteen()
 {
        return 15;
@@ -1076,6 +1138,7 @@ function t_call_function()
        bt_assert(callme(3, 2) = 6);
        bt_assert(callme(4, 4) = 16);
        bt_assert(callme(7, 2) = 14);
+       bt_assert(callmeagain(1, 2, 3) = 6);
 }
 
 bt_test_suite(t_call_function, "Testing calling functions");
@@ -1289,7 +1352,7 @@ bt_test_suite(t_mixed_prefix, "Testing mixed net types");
 
 filter vpn_filter
 {
-       bt_assert(format(net) = "0:1:2 10.1.10.0/24");
+       bt_assert(format(net) = "1:2 10.1.10.0/24");
        bt_assert(net.type = NET_VPN4);
        bt_assert(net.type != NET_IP4);
        bt_assert(net.type != NET_IP6);
@@ -1300,6 +1363,13 @@ filter vpn_filter
          NET_IP6: print "IPV6";
        }
 
+       bt_check_assign(from, 10.20.30.40);
+       bt_check_assign(gw, 55.55.55.44);
+
+       bgp_community.add((3,5));
+       bgp_ext_community.add((ro, 135, 999));
+       bgp_large_community.add((6464156, 89646354, 8675643));
+
        accept;
 }
 
@@ -1311,3 +1381,9 @@ protocol static
        vpn4 { table v4; import filter vpn_filter; };
        route 0:1:2 10.1.10.0/24 unreachable;
 }
+
+protocol static
+{
+       ipv6 { import where false; };
+       route fd01::/48 unreachable;
+}