This completely refactors the go testrunner for EventsTrace. This has a number of advantages:
tests can now be run locally, without bluebox
You can run individual tests
Tests are structured in the "standard" golang way, and take advantage of the go stdlib test functionality
I added a make testbins target for the c test binaries
This also fixes a few known bugs, and probably many more:
The test runner would sometimes eat stderr messages that occur during startup
If the test runner got overwhelmed with data from stdout/stderr, it would drop the log data
If a test failed, it would sometimes hang and time out instead of immediately failing
In addition, I fixed a few bugs in the tests that I ran into while refactoring:
The tty output would try to use the escape character \x, which is not a valid JSON escape character and broke all the JSON parsers I tried.
the overlayfs test would try to remove a directory without unmounting it, which would fail
How to run tests
make testbins #make the test binaries in testing/test_bins
cd testing/testrunner
go test -c #compile the test in advance, so we don't need root to have a go environment
# run all tests
sudo ./testrunner.test
# run a single test
sudo ./testrunner.test -test.run TestEbpf/Tcpv6ConnectionClose -test.v
Known issues with individual tests:
fork_exec.c works by setting the capabilities mask to an identifiable but meaningless mask value; for whatever reason this works in the test environment, but on my machine the new capability set completely breaks the binary.
create_rename_delete_file_container.c breaks on newer kernels if you try to remove the directories before doing an unmount on ovl_mountpoint, but on the mainline tests, and only the mainline tests (which are actually kind of old), this unmount operation fails with an Invalid Argument error.
How to run tests
This completely refactors the go testrunner for EventsTrace. This has a number of advantages:
make testbins
target for the c test binariesThis also fixes a few known bugs, and probably many more:
In addition, I fixed a few bugs in the tests that I ran into while refactoring:
\x
, which is not a valid JSON escape character and broke all the JSON parsers I tried.How to run tests
Known issues with individual tests:
fork_exec.c
works by setting the capabilities mask to an identifiable but meaningless mask value; for whatever reason this works in the test environment, but on my machine the new capability set completely breaks the binary.create_rename_delete_file_container.c
breaks on newer kernels if you try to remove the directories before doing an unmount onovl_mountpoint
, but on the mainline tests, and only the mainline tests (which are actually kind of old), this unmount operation fails with an Invalid Argument error.