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i4+hcl+ZIVnnVAQ+U7Pd9P8eAOzjALa53nAzx978Sfsc 517M9V6M2dCAERtZYfTlUcM9Fi7055KsW8Ermna1qyRyA25F9ekVMSOMTvSzlUCa 7W7OE0J2uJafyP4K5gGpmHZLrirEWSrtY3oOjHO0HAjur+Ir3XwcTnB9U4ACdVQV HYnIv3QzElQV0aGeWwqKir1i9WIefpZe28h+53UP8pTnx5C5uo+U03kNibyjDDRx fMxGa5fELyTMk6kttN6TtWcIbHeWTch6qzsvYJR1Exaqql3EEbRIerlsCL5ZM2TV JP04BWzJ7Hfz6qTS3dFUiFHfZw3ptPthE/3JiAYObIFE1YdQKYjwAKHXRjjdh1kT pq0ubqx9mX8OkgVZWNC9NDIZvZpdGFBn57wfG3TN29iR/J2WELsjhPOI3tMQAWMT ZqrDl45BciFUA2lVkZ7C9tgaGMR/nok/3bTksrNcM3h2DCE8Rt28giZwvtN2nSjq 8ekT6jDs15WZd3kfVJHP4tb2MCh/IuP/8DPmUxW6jbg6tFJ+JqOSmD502pwZfxog gRbBXbdUqV9B3A== =nrJ0 -----END PGP SIGNATURE----- Merge OpenVPN 3 Core library version 3.8.5 to master Signed-off-by: David Sommerseth <davids@openvpn.net> |
||
---|---|---|
.. | ||
comp-testdata | ||
input | ||
output | ||
pki | ||
userpass | ||
.gitignore | ||
CMakeLists.txt | ||
core_tests.cpp | ||
gen_ip_shifts.py | ||
README-comp.txt | ||
README-proto-tests.rst | ||
README.md | ||
test_acc.cpp | ||
test_b64.cpp | ||
test_buffer_ip.cpp | ||
test_buffer.cpp | ||
test_capture.cpp | ||
test_clamp_typerange.cpp | ||
test_cleanup.cpp | ||
test_cliopt.cpp | ||
test_common.h | ||
test_comp.cpp | ||
test_continuation.cpp | ||
test_cpu_time.cpp | ||
test_crypto_hashstr.cpp | ||
test_crypto.cpp | ||
test_csum.cpp | ||
test_dns.cpp | ||
test_format.cpp | ||
test_header_deps.cpp | ||
test_headredact.cpp | ||
test_helper.hpp | ||
test_hostport.cpp | ||
test_http_proxy.cpp | ||
test_ip.cpp | ||
test_iphelper.cpp | ||
test_log.cpp | ||
test_mbedtls_authcert.cpp | ||
test_mbedtls_x509certinfo.cpp | ||
test_misc_unix.cpp | ||
test_numeric_cast.cpp | ||
test_openssl_authcert.cpp | ||
test_openssl_misc.cpp | ||
test_openssl_x509certinfo.cpp | ||
test_opensslpki.cpp | ||
test_optfilt.cpp | ||
test_ostream_containers.cpp | ||
test_parseargv.cpp | ||
test_path.cpp | ||
test_peer_fingerprint.cpp | ||
test_pipe.cpp | ||
test_pktid.cpp | ||
test_pktstream.cpp | ||
test_prefixlen.cpp | ||
test_proto.cpp | ||
test_psid_cookie.cpp | ||
test_randapi.cpp | ||
test_rc.cpp | ||
test_relack.cpp | ||
test_reliable.cpp | ||
test_remotelist.cpp | ||
test_route_emulation.cpp | ||
test_route.cpp | ||
test_safestr.cpp | ||
test_session_id.cpp | ||
test_sitnl.cpp | ||
test_splitlines.cpp | ||
test_ssl.cpp | ||
test_sslctx.cpp | ||
test_statickey.cpp | ||
test_streq.cpp | ||
test_time.cpp | ||
test_tun_builder.cpp | ||
test_typeindex.cpp | ||
test_userpass.cpp | ||
test_validatecreds.cpp | ||
test_verify_x509_name.cpp | ||
test_weak.cpp |
Unit test framework for OpenVPN3
The unit test framework is written in the Google Test framework.
Building/running the unit tests
Before building the unit tests themselves, you should build the dependencies as described in the README.rst.
The unit test cmake files assume here that the deps directory is on the same level as the openvpn3 directory unless overridden by the DEP_DIR variable.
The directory for cmake to build a project can be everywhere, but it is recommended to keep it outside of the source tree.
Building unit tests (assuming you are in the openvpn3 directory):
➜ mkdir ../unit_test_build
➜ cd ../unit_test_build
➜ cmake ../openvpn3
➜ cmake --build . --target coreUnitTests
Note: On Linux and Mac OS you can use make coreUnitTests
instead of cmake --build
Run the unit tests:
➜ ./test/unittests/coreUnitTests --gtest_shuffle
On a Mac with OpenSSL from homebrew:
➜ cmake ../openvpn3 -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl@1.1
Using mbed TLS instead of OpenSSL
➜ cmake ../openvpn3 -DUSE_MBEDTLS
A full list of build options can shown together with short descriptions can be shown with
➜ cmake -LH .
Examplary commands for building and running on Windows:
➜ cmake -DDEP_DIR=C:\o3\deps -DUSE_MBEDTLS=true -DCMAKE_GENERATOR_PLATFORM=x64 C:\o3\openvpn3
➜ cmake --build . --target coreUnitTests
➜ test\unittests\Debug\coreUnitTests.exe --gtest_output="xml:test_core.xml" --gtest_shuffle
Frequently used command line options
Show the help for gtest command line options:
➜ ./test/unittests/coreUnitTests --help
Run only tests starting with Base64 or a sepcific Base64 test:
➜ ./test/unittests/coreUnitTests --gtest_filter='Base64.*'
➜ ./test/unittests/coreUnitTests --gtest_filter=Base64.tooshortdest
Run all test but the Base64 tests
➜ ./test/unittests/coreUnitTests --gtest_filter='-Base64.*'
Multiple pattern can be specified with a list separated by :
➜ ./test/unittests/coreUnitTests --gtest_filter='OpenSSL_X509_get_serial.*:Base64.*'
Shuffle order the order in which the tests are run:
➜ ./test/unittests/coreUnitTests --gtest_shuffle
If a certain order yields failures, repeat that order:
➜ ./test/unittests/coreUnitTests --gtest_shuffle --gtest_random_seed=23
Run also the tests that are normally disabled
➜ ./test/unittests/coreUnitTests --gtest_also_run_disabled_tests
Writing unit tests
Each new test suite should be a new a file called test_suitename.cpp
and added to the
CMakeLists.txt
file. Each test includes an #include test_common.h
at the top to setup
common openvpn3 library parameters.
Currently all tests can fit in the same compilation unit coreUnitTests
. If a unit test
requires special compile/includes or other options that are not compatible with the rest of
the unit tests, another compilation unit should be added to the CMAKELists.txt
The test_helper.cc
file adds helper functions that can be used for unit tests. See the file
for more information.