Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unit testing improvements - v2 #1987

Closed
wants to merge 7 commits into from

Conversation

jasonish
Copy link
Member

@jasonish jasonish commented Apr 7, 2016

Redmine issue: https://redmine.openinfosecfoundation.org/issues/1758
Previous PR: #1984

  • First we convert all tests to be 1 for pass, 0 for fail.
  • Then we refactor the registration code to not take a success value, as 1 is pass, 2 is fail.
  • Introduce new macros for unit testing: FAIL_IF, FAIL_IF_NOT, FAIL_IF_NULL, FAIL_IF_NOT_NULL, PASS_IF and PASS
  • Convert conf.c to use new macros.
  • Some other minor unit test updates to make use of macros.

Prscript:

Unit testing support macros for failing on expressions,
as well as passing tests on expressions.

If fatal unittests are enabled BUG_ON will be triggered for
an assertion providing the line number of the failure, otherwise
the test will simply fail.

Moved the fatal flag to a global var instead of a configuration
parameter for ease of access from a macro.
Also don't bother with cleanup on failure.
@inliniac
Copy link
Contributor

inliniac commented Apr 8, 2016

Wrt doxygen and the unittests framework. If I apply @regit #1959, it will document not just the framework, but all the the tests as well. I think that would be a bit excessive. Maybe we can use 2 different defines for the tests and the framework.

@inliniac
Copy link
Contributor

inliniac commented Apr 8, 2016

Merged, thanks Jason!

@inliniac inliniac closed this Apr 8, 2016
@jasonish jasonish deleted the dev-unit-test-support-v2 branch April 8, 2016 16:35
@jasonish
Copy link
Member Author

jasonish commented Apr 8, 2016

Wrt doxygen and the unittests framework. If I apply @regit #1959, it will document not just the framework, but all the the tests as well. I think that would be a bit excessive. Maybe we can use 2 different defines for the tests and the framework.

Two thoughts:

  • Build the unit test support code no matter what. Only wrap the actual unit tests in UNITTESTS.
  • Or as you suggests, keep UNITTESTS as is, and wrap the support code in UNITTESTS_SUPPORT?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants