Merge remote-tracking branch 'origin/topic/timw/1487-not-valid-enum'

* origin/topic/timw/1487-not-valid-enum:
  Move an assert() in input/Manager.cc to account for ValueToVal errors
  Add test for config framework
  Fix similar issues with ValueTo* methods in the input framework
  GH-1487: Handle error from ValueToVal instead of ignoring it
This commit is contained in:
Tim Wojtulewicz 2021-04-16 08:08:38 -07:00
commit df22bdd52e
10 changed files with 135 additions and 16 deletions

View file

@ -0,0 +1,20 @@
# @TEST-EXEC: btest-bg-run zeek zeek -b %INPUT
# @TEST-EXEC: btest-bg-wait 10
# @TEST-EXEC: btest-diff zeek/.stderr
# @TEST-EXEC: btest-diff zeek/.stdout
@TEST-START-FILE configfile
mycolors Red,asdf,Blue
@TEST-END-FILE
@load base/frameworks/config
type Color: enum { Red, Green, Blue, };
option mycolors = set(Red, Green);
event zeek_init()
{ Config::read_config("../configfile"); }
event Input::end_of_data(name: string, source:string)
{ print mycolors; terminate(); }

View file

@ -0,0 +1,35 @@
# @TEST-EXEC: btest-bg-run zeek zeek -b %INPUT
# @TEST-EXEC: btest-bg-wait 10
# @TEST-EXEC: btest-diff zeek/.stderr
# @TEST-EXEC: btest-diff zeek/.stdout
@TEST-START-FILE denylist.txt
#separator \x09
#fields ip colors
192.168.17.1 Red,White
192.168.27.2 White,asdf
192.168.250.3 Blue
@TEST-END-FILE
# test.zeek
type Idx: record {
ip: addr;
};
type Color: enum { Red, White, Blue, };
type Val: record {
colors: set[Color];
};
global denylist: table[addr] of Val = table();
event zeek_init() {
Input::add_table([$source="../denylist.txt", $name="denylist",
$idx=Idx, $val=Val, $destination=denylist]);
Input::remove("denylist");
}
event Input::end_of_data(name: string, source: string) {
print denylist;
}