zeek/testing/btest/language/port.bro
Jon Siwek 95ffb1cf27 Quick pass over unit tests, adding -b flag to bro so they run faster.
Doing this made bifs/ ~3x faster and language/ ~2x faster.
2012-11-30 17:44:36 -06:00

40 lines
1,016 B
Text

# @TEST-EXEC: bro -b %INPUT >out
# @TEST-EXEC: btest-diff out
function test_case(msg: string, expect: bool)
{
print fmt("%s (%s)", msg, expect ? "PASS" : "FAIL");
}
event bro_init()
{
local p1: port = 1/icmp;
local p2: port = 2/udp;
local p3: port = 3/tcp;
local p4: port = 4/unknown;
local p5 = 123/tcp;
# maximum allowed values for each port type
local p6: port = 255/icmp;
local p7: port = 65535/udp;
local p8: port = 65535/tcp;
local p9: port = 255/unknown;
# Type inference test
test_case( "type inference", type_name(p5) == "port" );
# Operator tests
test_case( "protocol ordering", p1 > p2 );
test_case( "protocol ordering", p2 > p3 );
test_case( "protocol ordering", p3 > p4 );
test_case( "protocol ordering", p8 < p7 );
test_case( "protocol ordering", p9 < p6 );
test_case( "different protocol but same numeric value", p7 != p8 );
test_case( "different protocol but same numeric value", p6 != p9 );
test_case( "equality operator", 65535/tcp == p8 );
}