zeek/testing/btest/language/port.zeek
Robin Sommer 789cb376fd GH-239: Rename bro to zeek, bro-config to zeek-config, and bro-path-dev to zeek-path-dev.
This also installs symlinks from "zeek" and "bro-config" to a wrapper
script that prints a deprecation warning.

The btests pass, but this is still WIP. broctl renaming is still
missing.

#239
2019-05-01 21:43:45 +00:00

40 lines
1,018 B
Text

# @TEST-EXEC: zeek -b %INPUT >out
# @TEST-EXEC: btest-diff out
function test_case(msg: string, expect: bool)
{
print fmt("%s (%s)", msg, expect ? "PASS" : "FAIL");
}
event zeek_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 );
}