ef8da98bd4
Rename BufferAllocated --> BufferAllocatedRc Buffer: split RC from BufferAllocated Also make changes as needed where BufferAllocated is used Buffer: Split allocation flags into own struct Leaving flags in template causes each alias to have identical flags by different names, which requires each type to pointlessly use the nested name. Make RC: Clean up headers buffer.hpp, make_rc.hpp Signed-off-by: Charlie Vigue <charlie.vigue@openvpn.com> |
||
---|---|---|
.. | ||
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_certcheck.cpp | ||
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_loggingmixin.cpp | ||
test_make_rc.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 | ||
test_wstring.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.