zeek/testing/btest
Seth Hall 514dfc3479 Merge remote-tracking branch 'origin/master' into topic/seth/smb
# Conflicts:
#	testing/btest/Baseline/plugins.hooks/output
#	testing/btest/Baseline/scripts.policy.misc.dump-events/all-events.log
#	testing/btest/Baseline/scripts.policy.misc.dump-events/smtp-events.log
2016-06-29 09:43:31 -04:00
..
Baseline Merge remote-tracking branch 'origin/master' into topic/seth/smb 2016-06-29 09:43:31 -04:00
bifs Add new functions for calculating geographic distance 2016-06-07 13:11:10 -05:00
broker Merge remote-tracking branch 'origin/topic/dnthayer/ticket1595' 2016-05-12 08:06:42 -07:00
core Fixing test portability. 2016-06-15 09:05:36 -07:00
coverage Change find-bro-logs unit test to follow symlinks. 2014-10-09 16:02:13 -05:00
doc Fix some scripting tutorial examples 2016-05-05 17:23:15 -05:00
Files Finished work on unified2 analyzer. 2013-08-13 03:21:43 -04:00
istate Unit test for broccoli vector support. 2013-12-03 11:28:06 -06:00
language Merge branch 'topic/jgras/expire-redef' of https://github.com/J-Gras/bro 2016-06-14 17:22:25 -07:00
plugins Fix some failing plugin tests on OS X 10.11 2016-05-12 15:58:09 -05:00
scripts Merge remote-tracking branch 'origin/master' into topic/seth/smb 2016-06-29 09:43:31 -04:00
signatures Sorting test output for stability. 2015-04-09 15:22:59 -07:00
Traces Merge remote-tracking branch 'origin/master' into topic/seth/smb 2016-06-29 09:43:31 -04:00
.gitignore
btest.cfg Add /sbin to PATH in btest.cfg 2015-05-04 14:47:56 -05:00
Makefile Add/invoke "distclean" for testing directories. 2014-12-01 10:43:41 -06:00
random.seed
README s/bro-ids.org/bro.org/g 2013-03-07 19:33:04 -08:00

This a test suite of small "unit tests" that verify individual pieces of Bro
functionality.  They all utilize BTest, a simple framework/driver for
writing unit tests.  More information about BTest can be found at
http://www.bro.org/development/btest.html

The test suite's BTest configuration is handled through the
``btest.cfg`` file.  Of particular interest is the "TestDirs" settings,
which specifies which directories BTest will recursively search for
test files.

Significant Subdirectories
==========================

* Baseline/
	Validated baselines for comparison against the output of each
	test on future runs. If the new output differs from the Baseline
	output, then the test fails.

* Traces/
	Packet captures utilized by the various BTest tests.

* scripts/
    This hierarchy of tests emulates the hierarchy of the Bro scripts/
    directory.

* coverage/
    This collection of tests relates to checking whether we're covering
    everything we want to in terms of tests, documentation, and which
    scripts get loaded in different Bro configurations.  These tests are
    more prone to fail as new Bro scripts are developed and added to the
    distribution -- checking the individual test's comments is the best
    place to check for more details on what exactly the test is checking
    and hints on how to fix it when it fails.

Running Tests
=============

Either use the ``make all`` or ``make brief`` ``Makefile`` targets, or
run ``btest`` directly with desired options/arguments.  Examples:

* btest <no arguments>
	If you simply execute btest in this directory with no arguments,
	then all directories listed as "TestDirs" in btest.cfg will be
	searched recursively for test files.


* btest <btest options> test_directory
	You can specify a directory on the command line to run just the
	tests contained in that directory. This is useful if you wish to
	run all of a given type of test, without running all the tests
	there are. For example, "btest scripts" will run all of the Bro
	script unit tests.


* btest <btest options> test_directory/test_file
	You can specify a single test file to run just that test. This
	is useful when testing a single failing test or when developing
	a new test.

Adding Tests
=============

See either the `BTest documentation
<http://www.bro.org/development/btest.html>`_ or the existing unit
tests for examples of what they actually look like.  The essential
components of a new test include:

* A test file in one of the subdirectories listed in the ``TestDirs``
  of the ``btest.cfg`` file.

* If the unit test requires a known-good baseline output against which
  future tests will be compared (via ``btest-diff``), then that baseline
  output will need to live in the ``Baseline`` directory.  Manually
  adding that is possible, but it's easier to just use the ``-u`` or
  ``-U`` options of ``btest`` to do it for you (using ``btest -d`` on a
  test for which no baseline exists will show you the output so it can
  be verified first before adding/updating the baseline output).

If you create a new top-level testing directory for collecting related
tests, then you'll need to add it to the list of ``TestDirs`` in
``btest.cfg``. Do this only if your test really doesn't fit logically in
any of the extant directories.

Note that any new test you add this way will automatically be included
in the testing done in the NMI automated build & test environment.