Add tests for untested BIFs

This commit is contained in:
Daniel Thayer 2012-08-03 17:24:04 -05:00
parent 0006644e65
commit 10b671a638
17 changed files with 160 additions and 0 deletions

View file

@ -0,0 +1 @@
PIA_TCP

View 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]

View file

@ -0,0 +1 @@
found bro_init

View file

@ -0,0 +1,4 @@
ASCII text, with no line terminators
text/plain; charset=us-ascii
PNG image data
image/png; charset=binary

View file

@ -0,0 +1,4 @@
1970-01-01 00:00:00
000000 19700101
1973-11-29 21:33:09
213309 19731129

View 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);
}

View file

@ -0,0 +1,9 @@
#
# @TEST-EXEC: bro %INPUT
event bro_init()
{
local a = bro_version();
if ( |a| == 0 )
exit(1);
}

View 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);
}

View 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
}

View file

@ -0,0 +1,9 @@
#
# @TEST-EXEC: bro %INPUT
event bro_init()
{
local a = current_time();
if ( a <= double_to_time(0) )
exit(1);
}

View 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);
}

View file

@ -0,0 +1,9 @@
#
# @TEST-EXEC: bro %INPUT
event bro_init()
{
local a = gethostname();
if ( |a| == 0 )
exit(1);
}

View file

@ -0,0 +1,9 @@
#
# @TEST-EXEC: bro %INPUT
event bro_init()
{
local a = getpid();
if ( a == 0 )
exit(1);
}

View 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";
}
}

View 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);
}

View file

@ -0,0 +1,9 @@
#
# @TEST-EXEC: bro %INPUT
event bro_init()
{
local a = resource_usage();
if ( a$version != bro_version() )
exit(1);
}

View 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);
}