On 9/9/20 9:56 AM, Seth Hall wrote:
Has anyone put any thought to how we could create and run unit tests
in Zeek plugins? I don't think any work has been done on that yet,
but I'd love to be able to create unit tests in plugins.
Yeah I've tinkered a bit with this. I was able to get a unit test to run
out of an plugin in a loaded Zeek package (for current master) by doing
two things:
- Include doctest.h in the plugin source tree.
- Move the doctest execution in src/zeek-setup.cc down until after the
plugin registration.
With this, zeek --test -ltc shows the test case, and it also runs:
==============================================================================
/home/christian/.zkg/clones/package/utest/src/Plugin.cc:21:
TEST CASE: plugin doctest
/home/christian/.zkg/clones/package/utest/src/Plugin.cc:23: SUCCESS: CHECK(
true ) is correct!
values: CHECK( true )
But that's obviously a hacky setup. To do this properly, we should add
doctest.h to the set of things that Zeek installs (so plugins don't have
to ship their own), and we'll have to rework a bit of the setup logic.
And, I don't know how/whether this will work with other
compilers/platforms; this was just my local system.
Are you up for creating an issue for this one, Seth?
Best,
Christian
_______________________________________________
zeek-dev mailing list -- zeek-dev@lists.zeek.org
To unsubscribe send an email to zeek-dev-le...@lists.zeek.org