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:
Robin Sommer 2012-08-10 12:24:29 -07:00
commit 2e936c7570
26 changed files with 210 additions and 0 deletions

View file

@ -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 2.1-beta-6 | 2012-08-10 12:22:52 -0700
* Fix bug in input framework with an edge case. (Bernhard Amann) * Fix bug in input framework with an edge case. (Bernhard Amann)

View file

@ -0,0 +1 @@
PIA_TCP

View file

@ -0,0 +1 @@
T

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 @@
T
F
F
T

View file

@ -0,0 +1 @@
F

View file

@ -0,0 +1 @@
T

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,9 @@
#
# @TEST-EXEC: bro %INPUT >out
# @TEST-EXEC: btest-diff out
# @TEST-EXEC: test -f testfile
event bro_init()
{
print capture_state_updates("testfile");
}

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 = get_matcher_stats();
if ( a$matchers == 0 )
exit(1);
}

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,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]);
}

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

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