]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Added code for testing filters.
authorPavel Machek <pavel@ucw.cz>
Wed, 26 Apr 2000 08:03:50 +0000 (08:03 +0000)
committerPavel Machek <pavel@ucw.cz>
Wed, 26 Apr 2000 08:03:50 +0000 (08:03 +0000)
filter/config.Y
filter/filter.c
filter/filter.h
filter/test.conf

index 2572501f5416db037855e210175ff70c304e1bf1..ffb9a74cc401d16c36a15c6742f6aa50e1ffb592 100644 (file)
@@ -206,10 +206,14 @@ function_body:
 CF_ADDTO(conf, function_def)
 function_def:
    FUNCTION SYM { DBG( "Begining of function %s\n", $2->name ); cf_push_scope($2); } function_params function_body {
-     extern struct f_inst *startup_func;
+     extern struct f_inst *startup_func, *test1_func, *test2_func;
      cf_define_symbol($2, SYM_FUNCTION, $5);
      if (!strcasecmp($2->name, "__startup"))
        startup_func = $5;
+     if (!strcasecmp($2->name, "__test1"))
+       test1_func = $5;
+     if (!strcasecmp($2->name, "__test2"))
+       test2_func = $5;
      $2->aux = (int) $4;
      $2->aux2 = $5;
      DBG("Hmm, we've got one function here - %s\n", $2->name); 
index 172e77bc9b69109623f0b164ac1c35fc850c9cf2..fd099a6c90beb3f519cd3e141d8487666740ff73 100644 (file)
@@ -5,8 +5,6 @@
  *
  *     Can be freely distributed and used under the terms of the GNU GPL.
  *
- *     Notice that pair is stored as integer: first << 16 | second
- *
  */
 
 #define LOCAL_DEBUG
@@ -26,7 +24,7 @@
 
 #define P(a,b) ((a<<8) | b)
 
-struct f_inst *startup_func = NULL;
+struct f_inst *startup_func = NULL, *test1_func, *test2_func;
 
 #define CMP_ERROR 999
 
@@ -630,6 +628,9 @@ void
 filters_postconfig(void)
 {
   struct f_val res;
+
+  if (!i_same(test1_func, test2_func))
+    bug("i_same does not work");
   if (startup_func) {
     debug( "Launching startup function...\n" );
     f_pool = lp_new(&root_pool, 1024);
index 86450591e7dc3817a0d30ee1150490487e0997bd..e86aa02b23549260405d545e3304f8a480b0789f 100644 (file)
@@ -99,7 +99,7 @@ void val_print(struct f_val v);
 /* User visible types, which fit in int */
 #define T_INT 0x10
 #define T_BOOL 0x11
-#define T_PAIR 0x12
+#define T_PAIR 0x12  /*        Notice that pair is stored as integer: first << 16 | second */
 
 /* Put enumerational types in 0x30..0x3f range */
 #define T_ENUM_LO 0x30
index f1b3b66ecc96e83742af8857ee7a8aa255dbcf63..f04417789cb480781971097331ef90740322c2bb 100644 (file)
@@ -116,6 +116,30 @@ ip p;
 #      print "*** FAIL: this is unreachable"; 
 }
 
+function __test1()
+{
+       if source = RTS_STATIC then {
+               bgp_community = -empty-;
+               bgp_community.add((65000,5678));
+                if bgp_path ~ / 65000 / then
+                        bgp_path.prepend(65000);
+                accept;
+        }
+       reject;
+}
+
+function __test2()
+{
+       if source = RTS_STATIC then {
+               bgp_community = -empty-;
+               bgp_community.add((65000,5678));
+                if bgp_path ~ / 65000 / then
+                        bgp_path.prepend(65000);
+                accept;
+        }
+       reject;
+}
+
 filter testf 
 int j; 
 {