mirror of
https://github.com/zeek/zeek.git
synced 2025-10-14 12:38:20 +00:00
Merge remote-tracking branch 'origin/topic/dnthayer/more-bif-tests'
* origin/topic/dnthayer/more-bif-tests: Add more BIF tests Add tests for untested BIFs Closes #863,
This commit is contained in:
commit
2e936c7570
26 changed files with 210 additions and 0 deletions
4
CHANGES
4
CHANGES
|
@ -1,4 +1,8 @@
|
|||
|
||||
2.1-beta-9 | 2012-08-10 12:24:29 -0700
|
||||
|
||||
* Add more BIF tests. (Daniel Thayer)
|
||||
|
||||
2.1-beta-6 | 2012-08-10 12:22:52 -0700
|
||||
|
||||
* Fix bug in input framework with an edge case. (Bernhard Amann)
|
||||
|
|
1
testing/btest/Baseline/bifs.analyzer_name/out
Normal file
1
testing/btest/Baseline/bifs.analyzer_name/out
Normal file
|
@ -0,0 +1 @@
|
|||
PIA_TCP
|
1
testing/btest/Baseline/bifs.capture_state_updates/out
Normal file
1
testing/btest/Baseline/bifs.capture_state_updates/out
Normal file
|
@ -0,0 +1 @@
|
|||
T
|
2
testing/btest/Baseline/bifs.entropy_test/out
Normal file
2
testing/btest/Baseline/bifs.entropy_test/out
Normal file
|
@ -0,0 +1,2 @@
|
|||
[entropy=4.715374, chi_square=591.981818, mean=75.472727, monte_carlo_pi=4.0, serial_correlation=-0.11027]
|
||||
[entropy=2.083189, chi_square=3906.018182, mean=69.054545, monte_carlo_pi=4.0, serial_correlation=0.849402]
|
1
testing/btest/Baseline/bifs.global_sizes/out
Normal file
1
testing/btest/Baseline/bifs.global_sizes/out
Normal file
|
@ -0,0 +1 @@
|
|||
found bro_init
|
4
testing/btest/Baseline/bifs.identify_data/out
Normal file
4
testing/btest/Baseline/bifs.identify_data/out
Normal file
|
@ -0,0 +1,4 @@
|
|||
ASCII text, with no line terminators
|
||||
text/plain; charset=us-ascii
|
||||
PNG image data
|
||||
image/png; charset=binary
|
4
testing/btest/Baseline/bifs.is_local_interface/out
Normal file
4
testing/btest/Baseline/bifs.is_local_interface/out
Normal file
|
@ -0,0 +1,4 @@
|
|||
T
|
||||
F
|
||||
F
|
||||
T
|
1
testing/btest/Baseline/bifs.reading_traces/out1
Normal file
1
testing/btest/Baseline/bifs.reading_traces/out1
Normal file
|
@ -0,0 +1 @@
|
|||
F
|
1
testing/btest/Baseline/bifs.reading_traces/out2
Normal file
1
testing/btest/Baseline/bifs.reading_traces/out2
Normal file
|
@ -0,0 +1 @@
|
|||
T
|
4
testing/btest/Baseline/bifs.strftime/out
Normal file
4
testing/btest/Baseline/bifs.strftime/out
Normal file
|
@ -0,0 +1,4 @@
|
|||
1970-01-01 00:00:00
|
||||
000000 19700101
|
||||
1973-11-29 21:33:09
|
||||
213309 19731129
|
9
testing/btest/bifs/analyzer_name.bro
Normal file
9
testing/btest/bifs/analyzer_name.bro
Normal file
|
@ -0,0 +1,9 @@
|
|||
#
|
||||
# @TEST-EXEC: bro %INPUT >out
|
||||
# @TEST-EXEC: btest-diff out
|
||||
|
||||
event bro_init()
|
||||
{
|
||||
local a = 1;
|
||||
print analyzer_name(a);
|
||||
}
|
9
testing/btest/bifs/bro_version.bro
Normal file
9
testing/btest/bifs/bro_version.bro
Normal file
|
@ -0,0 +1,9 @@
|
|||
#
|
||||
# @TEST-EXEC: bro %INPUT
|
||||
|
||||
event bro_init()
|
||||
{
|
||||
local a = bro_version();
|
||||
if ( |a| == 0 )
|
||||
exit(1);
|
||||
}
|
9
testing/btest/bifs/capture_state_updates.bro
Normal file
9
testing/btest/bifs/capture_state_updates.bro
Normal file
|
@ -0,0 +1,9 @@
|
|||
#
|
||||
# @TEST-EXEC: bro %INPUT >out
|
||||
# @TEST-EXEC: btest-diff out
|
||||
# @TEST-EXEC: test -f testfile
|
||||
|
||||
event bro_init()
|
||||
{
|
||||
print capture_state_updates("testfile");
|
||||
}
|
10
testing/btest/bifs/checkpoint_state.bro
Normal file
10
testing/btest/bifs/checkpoint_state.bro
Normal file
|
@ -0,0 +1,10 @@
|
|||
#
|
||||
# @TEST-EXEC: bro %INPUT
|
||||
# @TEST-EXEC: test -f .state/state.bst
|
||||
|
||||
event bro_init()
|
||||
{
|
||||
local a = checkpoint_state();
|
||||
if ( a != T )
|
||||
exit(1);
|
||||
}
|
11
testing/btest/bifs/current_analyzer.bro
Normal file
11
testing/btest/bifs/current_analyzer.bro
Normal file
|
@ -0,0 +1,11 @@
|
|||
#
|
||||
# @TEST-EXEC: bro %INPUT
|
||||
|
||||
event bro_init()
|
||||
{
|
||||
local a = current_analyzer();
|
||||
if ( a != 0 )
|
||||
exit(1);
|
||||
|
||||
# TODO: add a test for non-zero return value
|
||||
}
|
9
testing/btest/bifs/current_time.bro
Normal file
9
testing/btest/bifs/current_time.bro
Normal file
|
@ -0,0 +1,9 @@
|
|||
#
|
||||
# @TEST-EXEC: bro %INPUT
|
||||
|
||||
event bro_init()
|
||||
{
|
||||
local a = current_time();
|
||||
if ( a <= double_to_time(0) )
|
||||
exit(1);
|
||||
}
|
24
testing/btest/bifs/entropy_test.bro
Normal file
24
testing/btest/bifs/entropy_test.bro
Normal file
|
@ -0,0 +1,24 @@
|
|||
#
|
||||
# @TEST-EXEC: bro %INPUT >out
|
||||
# @TEST-EXEC: btest-diff out
|
||||
|
||||
event bro_init()
|
||||
{
|
||||
local a = "dh3Hie02uh^s#Sdf9L3frd243h$d78r2G4cM6*Q05d(7rh46f!0|4-f";
|
||||
if ( entropy_test_init(1) != T )
|
||||
exit(1);
|
||||
|
||||
if ( entropy_test_add(1, a) != T )
|
||||
exit(1);
|
||||
|
||||
print entropy_test_finish(1);
|
||||
|
||||
local b = "0011000aaabbbbcccc000011111000000000aaaabbbbcccc0000000";
|
||||
if ( entropy_test_init(2) != T )
|
||||
exit(1);
|
||||
|
||||
if ( entropy_test_add(2, b) != T )
|
||||
exit(1);
|
||||
|
||||
print entropy_test_finish(2);
|
||||
}
|
9
testing/btest/bifs/get_matcher_stats.bro
Normal file
9
testing/btest/bifs/get_matcher_stats.bro
Normal file
|
@ -0,0 +1,9 @@
|
|||
#
|
||||
# @TEST-EXEC: bro %INPUT
|
||||
|
||||
event bro_init()
|
||||
{
|
||||
local a = get_matcher_stats();
|
||||
if ( a$matchers == 0 )
|
||||
exit(1);
|
||||
}
|
9
testing/btest/bifs/gethostname.bro
Normal file
9
testing/btest/bifs/gethostname.bro
Normal file
|
@ -0,0 +1,9 @@
|
|||
#
|
||||
# @TEST-EXEC: bro %INPUT
|
||||
|
||||
event bro_init()
|
||||
{
|
||||
local a = gethostname();
|
||||
if ( |a| == 0 )
|
||||
exit(1);
|
||||
}
|
9
testing/btest/bifs/getpid.bro
Normal file
9
testing/btest/bifs/getpid.bro
Normal file
|
@ -0,0 +1,9 @@
|
|||
#
|
||||
# @TEST-EXEC: bro %INPUT
|
||||
|
||||
event bro_init()
|
||||
{
|
||||
local a = getpid();
|
||||
if ( a == 0 )
|
||||
exit(1);
|
||||
}
|
16
testing/btest/bifs/global_sizes.bro
Normal file
16
testing/btest/bifs/global_sizes.bro
Normal file
|
@ -0,0 +1,16 @@
|
|||
#
|
||||
# @TEST-EXEC: bro %INPUT >out
|
||||
# @TEST-EXEC: btest-diff out
|
||||
|
||||
event bro_init()
|
||||
{
|
||||
local a = global_sizes();
|
||||
for ( i in a )
|
||||
{
|
||||
# the table is quite large, so just look for one item we expect
|
||||
if ( i == "bro_init" )
|
||||
print "found bro_init";
|
||||
|
||||
}
|
||||
|
||||
}
|
16
testing/btest/bifs/identify_data.bro
Normal file
16
testing/btest/bifs/identify_data.bro
Normal file
|
@ -0,0 +1,16 @@
|
|||
#
|
||||
# @TEST-EXEC: bro %INPUT >out
|
||||
# @TEST-EXEC: btest-diff out
|
||||
|
||||
event bro_init()
|
||||
{
|
||||
# plain text
|
||||
local a = "This is a test";
|
||||
print identify_data(a, F);
|
||||
print identify_data(a, T);
|
||||
|
||||
# PNG image
|
||||
local b = "\x89\x50\x4e\x47\x0d\x0a\x1a\x0a";
|
||||
print identify_data(b, F);
|
||||
print identify_data(b, T);
|
||||
}
|
11
testing/btest/bifs/is_local_interface.bro
Normal file
11
testing/btest/bifs/is_local_interface.bro
Normal file
|
@ -0,0 +1,11 @@
|
|||
#
|
||||
# @TEST-EXEC: bro %INPUT >out
|
||||
# @TEST-EXEC: btest-diff out
|
||||
|
||||
event bro_init()
|
||||
{
|
||||
print is_local_interface(127.0.0.1);
|
||||
print is_local_interface(1.2.3.4);
|
||||
print is_local_interface([2607::a:b:c:d]);
|
||||
print is_local_interface([::1]);
|
||||
}
|
10
testing/btest/bifs/reading_traces.bro
Normal file
10
testing/btest/bifs/reading_traces.bro
Normal file
|
@ -0,0 +1,10 @@
|
|||
|
||||
# @TEST-EXEC: bro %INPUT >out1
|
||||
# @TEST-EXEC: btest-diff out1
|
||||
# @TEST-EXEC: bro -r $TRACES/web.trace %INPUT >out2
|
||||
# @TEST-EXEC: btest-diff out2
|
||||
|
||||
event bro_init()
|
||||
{
|
||||
print reading_traces();
|
||||
}
|
9
testing/btest/bifs/resource_usage.bro
Normal file
9
testing/btest/bifs/resource_usage.bro
Normal file
|
@ -0,0 +1,9 @@
|
|||
#
|
||||
# @TEST-EXEC: bro %INPUT
|
||||
|
||||
event bro_init()
|
||||
{
|
||||
local a = resource_usage();
|
||||
if ( a$version != bro_version() )
|
||||
exit(1);
|
||||
}
|
17
testing/btest/bifs/strftime.bro
Normal file
17
testing/btest/bifs/strftime.bro
Normal file
|
@ -0,0 +1,17 @@
|
|||
#
|
||||
# @TEST-EXEC: bro %INPUT >out
|
||||
# @TEST-EXEC: btest-diff out
|
||||
|
||||
event bro_init()
|
||||
{
|
||||
local f1 = "%Y-%m-%d %H:%M:%S";
|
||||
local f2 = "%H%M%S %Y%m%d";
|
||||
|
||||
local a = double_to_time(0);
|
||||
print strftime(f1, a);
|
||||
print strftime(f2, a);
|
||||
|
||||
a = double_to_time(123456789);
|
||||
print strftime(f1, a);
|
||||
print strftime(f2, a);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue