router id 62.168.0.1;
/* We have to setup any protocol */
-protocol static { ipv4; }
-
+protocol device { }
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
-
/*
* Testing integers
* ----------------
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);
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+);
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));
+/*
+ * 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
* --------------------------
return 0;
}
+function callmeagain(int a; int b; int c)
+{
+ return a + b + c;
+}
+
function fifteen()
{
return 15;
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");
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);
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;
}
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;
+}