mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
Add more tests for previously-untested BIFs
This commit is contained in:
parent
1059d9aa75
commit
15689ce005
18 changed files with 184 additions and 0 deletions
3
testing/btest/Baseline/bifs.bytestring_to_hexstr/out
Normal file
3
testing/btest/Baseline/bifs.bytestring_to_hexstr/out
Normal file
|
@ -0,0 +1,3 @@
|
|||
3034
|
||||
|
||||
00
|
3
testing/btest/Baseline/bifs.convert_for_pattern/out
Normal file
3
testing/btest/Baseline/bifs.convert_for_pattern/out
Normal file
|
@ -0,0 +1,3 @@
|
|||
foo
|
||||
|
||||
b\[a\-z\]\+
|
10
testing/btest/Baseline/bifs.file_mode/out
Normal file
10
testing/btest/Baseline/bifs.file_mode/out
Normal file
|
@ -0,0 +1,10 @@
|
|||
rw-r--r--
|
||||
rwxrwxrwx
|
||||
rwxrwxrwt
|
||||
rwxr-x--T
|
||||
rwsr-xr-x
|
||||
r-S------
|
||||
rwxr-sr-x
|
||||
r--r-S---
|
||||
--xr-xrwx
|
||||
---------
|
9
testing/btest/Baseline/bifs.is_port/out
Normal file
9
testing/btest/Baseline/bifs.is_port/out
Normal file
|
@ -0,0 +1,9 @@
|
|||
T
|
||||
F
|
||||
F
|
||||
F
|
||||
T
|
||||
F
|
||||
F
|
||||
F
|
||||
T
|
2
testing/btest/Baseline/bifs.merge_pattern/out
Normal file
2
testing/btest/Baseline/bifs.merge_pattern/out
Normal file
|
@ -0,0 +1,2 @@
|
|||
match
|
||||
match
|
2
testing/btest/Baseline/bifs.parse_dotted_addr/out
Normal file
2
testing/btest/Baseline/bifs.parse_dotted_addr/out
Normal file
|
@ -0,0 +1,2 @@
|
|||
192.168.0.2
|
||||
1234::1
|
5
testing/btest/Baseline/bifs.parse_ftp/out
Normal file
5
testing/btest/Baseline/bifs.parse_ftp/out
Normal file
|
@ -0,0 +1,5 @@
|
|||
[h=192.168.0.2, p=257/tcp, valid=T]
|
||||
[h=192.168.0.2, p=257/tcp, valid=T]
|
||||
[h=fe80::12, p=1234/tcp, valid=T]
|
||||
[h=192.168.0.2, p=257/tcp, valid=T]
|
||||
[h=::, p=1234/tcp, valid=T]
|
2
testing/btest/Baseline/bifs.raw_bytes_to_v4_addr/out
Normal file
2
testing/btest/Baseline/bifs.raw_bytes_to_v4_addr/out
Normal file
|
@ -0,0 +1,2 @@
|
|||
65.66.67.68
|
||||
0.0.0.0
|
6
testing/btest/Baseline/bifs.string_to_pattern/out
Normal file
6
testing/btest/Baseline/bifs.string_to_pattern/out
Normal file
|
@ -0,0 +1,6 @@
|
|||
/^?(foo)$?/
|
||||
/^?()$?/
|
||||
/^?(b[a-z]+)$?/
|
||||
/^?(foo)$?/
|
||||
/^?()$?/
|
||||
/^?(b\[a\-z\]\+)$?/
|
10
testing/btest/bifs/bytestring_to_hexstr.bro
Normal file
10
testing/btest/bifs/bytestring_to_hexstr.bro
Normal file
|
@ -0,0 +1,10 @@
|
|||
#
|
||||
# @TEST-EXEC: bro %INPUT >out
|
||||
# @TEST-EXEC: btest-diff out
|
||||
|
||||
event bro_init()
|
||||
{
|
||||
print bytestring_to_hexstr("04");
|
||||
print bytestring_to_hexstr("");
|
||||
print bytestring_to_hexstr("\0");
|
||||
}
|
10
testing/btest/bifs/convert_for_pattern.bro
Normal file
10
testing/btest/bifs/convert_for_pattern.bro
Normal file
|
@ -0,0 +1,10 @@
|
|||
#
|
||||
# @TEST-EXEC: bro %INPUT >out
|
||||
# @TEST-EXEC: btest-diff out
|
||||
|
||||
event bro_init()
|
||||
{
|
||||
print convert_for_pattern("foo");
|
||||
print convert_for_pattern("");
|
||||
print convert_for_pattern("b[a-z]+");
|
||||
}
|
36
testing/btest/bifs/file_mode.bro
Normal file
36
testing/btest/bifs/file_mode.bro
Normal file
|
@ -0,0 +1,36 @@
|
|||
#
|
||||
# @TEST-EXEC: bro %INPUT >out
|
||||
# @TEST-EXEC: btest-diff out
|
||||
|
||||
event bro_init()
|
||||
{
|
||||
local a = 420; # octal: 0644
|
||||
print file_mode(a);
|
||||
|
||||
a = 511; # octal: 0777
|
||||
print file_mode(a);
|
||||
|
||||
a = 1023; # octal: 01777
|
||||
print file_mode(a);
|
||||
|
||||
a = 1000; # octal: 01750
|
||||
print file_mode(a);
|
||||
|
||||
a = 2541; # octal: 04755
|
||||
print file_mode(a);
|
||||
|
||||
a = 2304; # octal: 04400
|
||||
print file_mode(a);
|
||||
|
||||
a = 1517; # octal: 02755
|
||||
print file_mode(a);
|
||||
|
||||
a = 1312; # octal: 02440
|
||||
print file_mode(a);
|
||||
|
||||
a = 111; # octal: 0157
|
||||
print file_mode(a);
|
||||
|
||||
a = 0;
|
||||
print file_mode(a);
|
||||
}
|
22
testing/btest/bifs/is_port.bro
Normal file
22
testing/btest/bifs/is_port.bro
Normal file
|
@ -0,0 +1,22 @@
|
|||
#
|
||||
# @TEST-EXEC: bro %INPUT >out
|
||||
# @TEST-EXEC: btest-diff out
|
||||
|
||||
event bro_init()
|
||||
{
|
||||
local a = 123/tcp;
|
||||
local b = 123/udp;
|
||||
local c = 123/icmp;
|
||||
|
||||
print is_tcp_port(a);
|
||||
print is_tcp_port(b);
|
||||
print is_tcp_port(c);
|
||||
|
||||
print is_udp_port(a);
|
||||
print is_udp_port(b);
|
||||
print is_udp_port(c);
|
||||
|
||||
print is_icmp_port(a);
|
||||
print is_icmp_port(b);
|
||||
print is_icmp_port(c);
|
||||
}
|
17
testing/btest/bifs/merge_pattern.bro
Normal file
17
testing/btest/bifs/merge_pattern.bro
Normal file
|
@ -0,0 +1,17 @@
|
|||
#
|
||||
# @TEST-EXEC: bro %INPUT >out
|
||||
# @TEST-EXEC: btest-diff out
|
||||
|
||||
event bro_init()
|
||||
{
|
||||
local a = /foo/;
|
||||
local b = /b[a-z]+/;
|
||||
local c = merge_pattern(a, b);
|
||||
|
||||
if ( "bar" == c )
|
||||
print "match";
|
||||
|
||||
if ( "foo" == c )
|
||||
print "match";
|
||||
|
||||
}
|
9
testing/btest/bifs/parse_dotted_addr.bro
Normal file
9
testing/btest/bifs/parse_dotted_addr.bro
Normal file
|
@ -0,0 +1,9 @@
|
|||
#
|
||||
# @TEST-EXEC: bro %INPUT >out
|
||||
# @TEST-EXEC: btest-diff out
|
||||
|
||||
event bro_init()
|
||||
{
|
||||
print parse_dotted_addr("192.168.0.2");
|
||||
print parse_dotted_addr("1234::1");
|
||||
}
|
15
testing/btest/bifs/parse_ftp.bro
Normal file
15
testing/btest/bifs/parse_ftp.bro
Normal file
|
@ -0,0 +1,15 @@
|
|||
#
|
||||
# @TEST-EXEC: bro %INPUT >out
|
||||
# @TEST-EXEC: btest-diff out
|
||||
|
||||
event bro_init()
|
||||
{
|
||||
print parse_ftp_port("192,168,0,2,1,1");
|
||||
|
||||
print parse_eftp_port("|1|192.168.0.2|257|");
|
||||
print parse_eftp_port("|2|fe80::12|1234|");
|
||||
|
||||
print parse_ftp_pasv("227 Entering Passive Mode (192,168,0,2,1,1)");
|
||||
|
||||
print parse_ftp_epsv("229 Entering Extended Passive Mode (|||1234|)");
|
||||
}
|
9
testing/btest/bifs/raw_bytes_to_v4_addr.bro
Normal file
9
testing/btest/bifs/raw_bytes_to_v4_addr.bro
Normal file
|
@ -0,0 +1,9 @@
|
|||
#
|
||||
# @TEST-EXEC: bro %INPUT >out
|
||||
# @TEST-EXEC: btest-diff out
|
||||
|
||||
event bro_init()
|
||||
{
|
||||
print raw_bytes_to_v4_addr("ABCD");
|
||||
print raw_bytes_to_v4_addr("ABC");
|
||||
}
|
14
testing/btest/bifs/string_to_pattern.bro
Normal file
14
testing/btest/bifs/string_to_pattern.bro
Normal file
|
@ -0,0 +1,14 @@
|
|||
#
|
||||
# @TEST-EXEC: bro %INPUT >out
|
||||
# @TEST-EXEC: btest-diff out
|
||||
|
||||
event bro_init()
|
||||
{
|
||||
print string_to_pattern("foo", F);
|
||||
print string_to_pattern("", F);
|
||||
print string_to_pattern("b[a-z]+", F);
|
||||
|
||||
print string_to_pattern("foo", T);
|
||||
print string_to_pattern("", T);
|
||||
print string_to_pattern("b[a-z]+", T);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue