]>
git.ipfire.org Git - thirdparty/bird.git/blob - filter/filter_test.c
4 * (c) 2015 CZ.NIC z.s.p.o.
6 * Can be freely distributed and used under the terms of the GNU GPL.
16 #include "test/birdtest.h"
17 #include "test/bt-utils.h"
19 #include "filter/filter.h"
20 #include "filter/data.h"
21 #include "filter/f-inst.h"
22 #include "conf/conf.h"
24 #define BT_CONFIG_FILE "filter/test.conf"
30 if (!bt_config_file_parse(BT_CONFIG_FILE
))
34 WALK_LIST(s
, config
->symbols
)
35 if ((s
->class == SYM_FUNCTION
) || (s
->class == SYM_FILTER
))
36 bt_assert_msg((s
->flags
& SYM_FLAG_SAME
), "Symbol %s same check", s
->name
);
42 run_function(const void *arg
)
44 const struct f_bt_test_suite
*t
= arg
;
47 return t
->result
== f_same(t
->fn
, t
->cmp
);
49 linpool
*tmp
= lp_new_default(&root_pool
);
50 enum filter_return fret
= f_eval(t
->fn
, tmp
, NULL
);
53 return (fret
< F_REJECT
);
57 bt_assert_filter(int result
, const struct f_line_item
*assert)
59 int bt_suit_case_result
= 1;
64 bt_suit_case_result
= 0;
67 bt_log_suite_case_result(bt_suit_case_result
, "Assertion at line %d (%s)",
68 assert->lineno
, assert->i_FI_ASSERT
.s
);
72 main(int argc
, char *argv
[])
77 bt_assert_hook
= bt_assert_filter
;
79 /* Initial test.conf parsing, must be done here */
80 if (!bt_config_file_parse(BT_CONFIG_FILE
))
83 bt_test_suite(t_reconfig
, "Testing reconfiguration");
85 struct f_bt_test_suite
*t
;
86 WALK_LIST(t
, config
->tests
)
87 bt_test_suite_base(run_function
, t
->fn_name
, t
, BT_FORKING
, BT_TIMEOUT
, "%s", t
->dsc
);
90 return bt_exit_value();