diff options
author | Pavel Machek <pavel@ucw.cz> | 2000-04-26 10:03:50 +0200 |
---|---|---|
committer | Pavel Machek <pavel@ucw.cz> | 2000-04-26 10:03:50 +0200 |
commit | 7a86a8b08db03f002a672d1e8a6481ad52114d1e (patch) | |
tree | 8836e9031a335c91a27ff89b238cf17f008a7a53 /filter | |
parent | 471bd6c30bb0d172699ea7af8f8b9356c8fe48b3 (diff) | |
download | bird-7a86a8b08db03f002a672d1e8a6481ad52114d1e.tar bird-7a86a8b08db03f002a672d1e8a6481ad52114d1e.zip |
Added code for testing filters.
Diffstat (limited to 'filter')
-rw-r--r-- | filter/config.Y | 6 | ||||
-rw-r--r-- | filter/filter.c | 7 | ||||
-rw-r--r-- | filter/filter.h | 2 | ||||
-rw-r--r-- | filter/test.conf | 24 |
4 files changed, 34 insertions, 5 deletions
diff --git a/filter/config.Y b/filter/config.Y index 2572501..ffb9a74 100644 --- a/filter/config.Y +++ b/filter/config.Y @@ -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); diff --git a/filter/filter.c b/filter/filter.c index 172e77b..fd099a6 100644 --- a/filter/filter.c +++ b/filter/filter.c @@ -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); diff --git a/filter/filter.h b/filter/filter.h index 8645059..e86aa02 100644 --- a/filter/filter.h +++ b/filter/filter.h @@ -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 diff --git a/filter/test.conf b/filter/test.conf index f1b3b66..f044177 100644 --- a/filter/test.conf +++ b/filter/test.conf @@ -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; { |