0
0
mirror of https://github.com/OpenVPN/openvpn.git synced 2024-09-19 19:42:30 +02:00
openvpn/tests/unit_tests
Frank Lichtenheld 53449cb61f Various fixes for -Wconversion errors
These are all fixes I considered "safe". They either

- Have sufficient checks/shifts for a cast to be safe
- Fix the type of a variable without requiring code changes
- Are in non-critical unittest code

v2:
 - add min_size instead of abusing min_int
v6:
 - remove change of return value of link_socket_write.
   Move to separate patch.

Change-Id: I6818b153bdeb1eed65870af99b0531e95807fe0f
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20240910122008.23507-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg29172.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2024-09-10 14:31:28 +02:00
..
example_test tests: disable automake serial_tests 2023-12-18 19:01:38 +01:00
openvpn Various fixes for -Wconversion errors 2024-09-10 14:31:28 +02:00
plugins configure: Add -Wstrict-prototypes and -Wold-style-definition 2024-06-20 17:01:31 +02:00
Makefile.am Remove openssl engine method for loading the key 2023-10-18 15:24:10 +02:00
README.md Add unit testing support via cmocka 2016-05-30 22:40:55 +02:00

Unit Tests

This directory contains unit tests for openvpn. New features/bugfixes should be written in a test friendly way and come with corresponding tests.

Run tests

Tests are run by make check. A failed tests stops test execution. To run all tests regardless of errors call make -k check.

Add new tests to existing test suite

Test suites are organized in directories. example_test/ is an example for a test suite with two test executables. Feel free to use it as a template for new tests.

Test suites

Test suites live inside a subdirectory of $ROOT/tests/unit_tests, e.g. $ROOT/tests/unit_tests/my_feature.

Test suites are configured by a Makefile.am. Tests are executed by testdrivers. One testsuite can contain more than one testdriver.

Hints

  • Name suites & testdrivers in a way that the name of the driver says something about which component/feature is tested
  • Name the testdriver executable *_testdriver. This way it gets picked up by the default .gitignore
    • If this is not feasible: Add all output to a .gitignore* Use descriptive test names: coffee_brewing__with_no_beans__fails vs. test34
  • Testing a configurable feature? Wrap test execution with a conditional (see auth_pam for an example)
  • Add multiple test-drivers when one testdriver looks crowded with tests

New Test Suites

  1. Organize tests in folders for features.
  2. Add the new test directory to SUBDIRS in Makefile.am
  3. Edit configure.ac and add the new Makefile to AC_CONFIG_FILES
  4. Run ./configure, and enable the feature you'd like to test
  5. Make sure that make check runs your tests
  6. Check: Would a stranger be able to easily find your tests by you looking at the test output?
  7. Run ./configure, and disable the feature you'd like to test
  8. Make sure that make check does not run your tests