Merge remote-tracking branch 'origin/master' into topic/bernhard/topk

This commit is contained in:
Bernhard Amann 2013-04-24 15:02:19 -07:00
commit dbd53a09a6
9 changed files with 285 additions and 14 deletions

View file

@ -0,0 +1,36 @@
0
0
0
0
0
0
255
255
0
0
1000
1000
12345
12345
0
0
65535
65535
4294967295
4294967295
287454020
1144201745
255
255
2864429994
2864429994
0
0
18446744073709551615
18446744073709551615
18446742974214701055
18446742974214701055
65535
65535
0
0

View file

@ -1,4 +1,6 @@
event statement
event part1
event part2
schedule statement
schedule statement in bro_init
schedule statement in global
schedule statement another in bro_init

View file

@ -1,3 +1,21 @@
[bar=4321, foo=[foo=1234, quux=9876]]
[foo=1234, quux=9876]
9876
[bar=4231, foo=[foo=1000, quux=9876]]
[foo=1000, quux=9876]
9876
[bar=4321, foo=[foo=10, quux=42]]
[foo=10, quux=42]
42
[bar=100, foo=[foo=1234, quux=9876]]
[foo=1234, quux=9876]
9876
[bar=100, foo=[foo=1001, quux=9876]]
[foo=1001, quux=9876]
9876
[bar=100, foo=[foo=11, quux=7]]
[foo=11, quux=7]
7
[a=13, c=13, v=[]]
0
[a=13, c=13, v=[test]]

View file

@ -0,0 +1,55 @@
#
# @TEST-EXEC: bro -b %INPUT >out
# @TEST-EXEC: btest-diff out
event bro_init()
{
# unsupported byte lengths
print bytestring_to_count("", T); # 0
print bytestring_to_count("", F); # 0
print bytestring_to_count("\xAA\xBB\xCC", T); # 0
print bytestring_to_count("\xAA\xBB\xCC", F); # 0
print bytestring_to_count("\xAA\xBB\xCC\xDD\xEE", T); # 0
print bytestring_to_count("\xAA\xBB\xCC\xDD\xEE", F); # 0
# 8 bit
print bytestring_to_count("\xff", T); # 255
print bytestring_to_count("\xff", F); # 255
print bytestring_to_count("\x00", T); # 0
print bytestring_to_count("\x00", F); # 0
# 16 bit
print bytestring_to_count("\x03\xe8", F); # 1000
print bytestring_to_count("\xe8\x03", T); # 1000
print bytestring_to_count("\x30\x39", F); # 12345
print bytestring_to_count("\x39\x30", T); # 12345
print bytestring_to_count("\x00\x00", F); # 0
print bytestring_to_count("\x00\x00", T); # 0
# 32 bit
print bytestring_to_count("\x00\x00\xff\xff", F); # 65535
print bytestring_to_count("\xff\xff\x00\x00", T); # 65535
print bytestring_to_count("\xff\xff\xff\xff", F); # 4294967295
print bytestring_to_count("\xff\xff\xff\xff", T); # 4294967295
print bytestring_to_count("\x11\x22\x33\x44", F); # 287454020
print bytestring_to_count("\x11\x22\x33\x44", T); # 1144201745
print bytestring_to_count("\x00\x00\x00\xff", F); # 255
print bytestring_to_count("\xff\x00\x00\x00", T); # 255
print bytestring_to_count("\xAA\xBB\xBB\xAA", F); # 2864429994
print bytestring_to_count("\xAA\xBB\xBB\xAA", T); # 2864429994
print bytestring_to_count("\x00\x00\x00\x00", F); # 0
print bytestring_to_count("\x00\x00\x00\x00", T); # 0
# 64 bit
print bytestring_to_count("\xff\xff\xff\xff\xff\xff\xff\xff", F); # 18446744073709551615
print bytestring_to_count("\xff\xff\xff\xff\xff\xff\xff\xff", T); # 18446744073709551615
print bytestring_to_count("\xff\xff\xff\x00\x00\xff\xff\xff", F); # 18446742974214701055
print bytestring_to_count("\xff\xff\xff\x00\x00\xff\xff\xff", T); # 18446742974214701055
print bytestring_to_count("\x00\x00\x00\x00\x00\x00\xff\xff", F); # 65535
print bytestring_to_count("\xff\xff\x00\x00\x00\x00\x00\x00", T); # 65535
print bytestring_to_count("\x00\x00\x00\x00\x00\x00\x00\x00", T); # 0
print bytestring_to_count("\x00\x00\x00\x00\x00\x00\x00\x00", F); # 0
}

View file

@ -9,9 +9,9 @@ event e1()
print "Error: this should not happen";
}
event e2()
event e2(s: string)
{
print "schedule statement";
print fmt("schedule statement %s", s);
}
event e3(test: string)
@ -36,7 +36,8 @@ event bro_init()
event e1();
# Test calling an event with "schedule" statement
schedule 1 sec { e2() };
schedule 1 sec { e2("in bro_init") };
schedule 3 sec { e2("another in bro_init") };
# Test calling an event that has two separate definitions
event e3("foo");
@ -47,3 +48,5 @@ event bro_init()
event e5(6); # TODO: this does not do anything
}
# scheduling in outside of an event handler shouldn't crash.
schedule 2sec { e2("in global") };

View file

@ -7,12 +7,42 @@ type MyRecord: record {
v: vector of string &default=vector();
};
event bro_init()
type Foo: record {
foo: count;
quux: count &default=9876;
};
type Bar: record {
bar: count;
foo: Foo &default=[$foo=1234];
};
function print_bar(b: Bar)
{
local r: MyRecord = [$c=13];
print r;
print |r$v|;
r$v[|r$v|] = "test";
print r;
print |r$v|;
print b;
print b$foo;
print b$foo$quux;
}
global bar: Bar = [$bar=4321];
global bar2: Bar = [$bar=4231, $foo=[$foo=1000]];
global bar3: Bar = [$bar=4321, $foo=[$foo=10, $quux=42]];
print_bar(bar);
print_bar(bar2);
print_bar(bar3);
local bar4: Bar = [$bar=100];
local bar5: Bar = [$bar=100, $foo=[$foo=1001]];
local bar6: Bar = [$bar=100, $foo=[$foo=11, $quux=7]];
print_bar(bar4);
print_bar(bar5);
print_bar(bar6);
local r: MyRecord = [$c=13];
print r;
print |r$v|;
r$v[|r$v|] = "test";
print r;
print |r$v|;