File: README

package info (click to toggle)
broctl 1.4-1
  • links: PTS, VCS
  • area: main
  • in suites: buster, sid, stretch
  • size: 2,220 kB
  • sloc: python: 4,931; sh: 1,188; makefile: 70; awk: 24
file content (88 lines) | stat: -rw-r--r-- 3,594 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
This a test suite of small "unit tests" that verify individual pieces of BroCtl
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/README.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.

* Cfg/
	This is a collection of config files utilized by various BTest tests.
	The directory hierarchy emulates the hierarchy of the Bro installation
	directory.

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

In order to run the tests you must clone the entire Bro repo (not just the
broctl repo).  Next, either use the ``make all`` or ``make brief``
``Makefile`` targets to run all the tests (these will automatically build
Bro before running any of the broctl tests).  If Bro fails to build, you can
define an environment variable BROCTL_TEST_BUILDARGS which specifies 
additional options that will be passed to Bro's "configure" script.
If Bro builds successfully, but one or more tests fail, then you can
re-run all failed tests with ``make rerun``.

If you want to run just a subset of the tests, then build Bro with
``make buildbro``, followed by ``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 command" will run all of the broctl
	command 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/README.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 Bro's central automated build & test
environment.