0
0
mirror of https://github.com/OpenVPN/openvpn3.git synced 2024-09-20 04:02:15 +02:00
openvpn3/test/unittests
David Sommerseth 149ec03864 OpenVPN 3 Core library version 3.8.5
-----BEGIN PGP SIGNATURE-----
 
 iQJHBAABCAAxFiEEgDq5E1p1aZrNLFFkhs+UTJZx/fIFAmYmR6wTHGRhdmlkc0Bv
 cGVudnBuLm5ldAAKCRCGz5RMlnH98rZPD/4vNyAZYSVN5HXO9SdrxCju/8VDxuDj
 0/CuS444NC4RKNLJIlorlLSi1zeL4fjuSRtEkLwB8QzCc3/sxEFFIqVk974zytMi
 ohBlNqISJTSUqugMZg1UfcySJSqHGaQfNfaiywSrQAe7hrCVPrUu+cAcXNsBeBPa
 fDOggL6K/7EVCwvZ5gcGUY0lw/LIriFkh40XD8LY+aYhGonPzDGnuQjcYHU48Hlp
 3ufsjLIQdLs4jCTmzSlURcXvaxi04o4WV+YOEGrUYSXeY8+6J4T8uKXqlMyoKQ+C
 w/m8Kgr5gQf/E020LYpWPoPWkoPrRRtBLvvXAighNEKMEtefSqxQtE1r/c/rMU12
 VeSX5LwJ3VRhCiZuTJD+08aRrGQNf+Fm6nswnyLw66bFGyIpPErEwhhbJsmPmaNN
 pOrbAxsAMwc/+jy0gqw7XFT/oDts+VN8WiYSRRaHfZ68lCvgf9AYirtygJy6oNYM
 WLTDOJjMwb42qBqyo6eYjos5yU57F5thV9M6qY5ycCIO0AIM0cFrRkZjNLF1pWS6
 6n8pwpPab29nUy3Ql3PZhW7t/4bhz0todfN7egHZrrvCkCOSQ/5DDWLLBI6ow9bM
 fXKB1sVjkNLPrHJ//5Hqh0GdO/Uc8GqdOIFngCnnjR3CS/ax+PZoAawCn1XbBpUW
 ddgSpAigLtFsLg==
 =3t/k
 -----END PGP SIGNATURE-----
gpgsig -----BEGIN PGP SIGNATURE-----
 
 iQJHBAABCAAxFiEEgDq5E1p1aZrNLFFkhs+UTJZx/fIFAmY03Y8THGRhdmlkc0Bv
 cGVudnBuLm5ldAAKCRCGz5RMlnH98sRwEACMzTmRreCO3jz456Q9gJS/kV1Ll/NB
 xOfEnhttxc19t+kjKL/AQOW3kfvP34uJUQdQAvjmp/HyJYGXQuNwGDW2/VD6aRaM
 e8agFKtKT6cGYPV3NoL3i4+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>
2024-05-03 14:50:21 +02:00
..
comp-testdata Move compression unit test from common to core repository 2019-04-15 17:05:09 +02:00
input Improve psid cookie unit tests [OVPN3-1069] 2023-10-25 09:10:40 -07:00
output test_path: add missing output file for windows build 2022-07-06 11:17:18 +02:00
pki [test/misc] Convert OpenSSL PKI test to unittest 2022-07-01 15:57:30 +02:00
userpass UserPass: Add unittest 2023-11-08 21:05:01 +01:00
.gitignore unitests: added test_time to .gitignore 2023-11-24 21:06:16 +01:00
CMakeLists.txt Move test_proto into coreUnittests 2024-04-17 14:48:50 +00:00
core_tests.cpp Reformatting source code to new coding style 2023-01-18 19:24:15 +01:00
gen_ip_shifts.py Add unit test for shifts of IPv6 addresses 2023-02-01 16:43:53 +01:00
README-comp.txt Fix some typos in unittest README files 2021-02-11 02:14:19 +01:00
README-proto-tests.rst unittest: Add proto test cmake parameters w/README 2023-06-16 18:37:02 +02:00
README.md Remove OPENVPN_EXTERN 2023-04-27 23:35:41 +02:00
test_acc.cpp Add missing length check in parsing ACC messages, add more related tests 2024-01-04 17:51:23 +01:00
test_b64.cpp Reformatting source code to new coding style 2023-01-18 19:24:15 +01:00
test_buffer_ip.cpp Reformatting source code to new coding style 2023-01-18 19:24:15 +01:00
test_buffer.cpp unittests: Fix -Wsigned-compare errors 2023-02-28 12:30:30 +01:00
test_capture.cpp Reformatting source code to new coding style 2023-01-18 19:24:15 +01:00
test_clamp_typerange.cpp test_clamp_typerange: avoid -Wconversion warning 2023-10-11 12:28:55 +02:00
test_cleanup.cpp Reformatting source code to new coding style 2023-01-18 19:24:15 +01:00
test_cliopt.cpp OpenVPN 3 Core library version 3.8.5 2024-05-03 14:50:21 +02:00
test_common.h Remove OPENVPN_EXTERN 2023-04-27 23:35:41 +02:00
test_comp.cpp Switched C casts to static_cast 2023-08-23 18:44:16 +02:00
test_continuation.cpp Addressed 2nd set of -Wconversion warnings 2023-08-21 13:51:50 +00:00
test_cpu_time.cpp Switched C casts to static_cast 2023-08-23 18:44:16 +02:00
test_crypto_hashstr.cpp Reformatting source code to new coding style 2023-01-18 19:24:15 +01:00
test_crypto.cpp Addressed 2nd set of -Wconversion warnings 2023-08-21 13:51:50 +00:00
test_csum.cpp Addressed 2nd set of -Wconversion warnings 2023-08-21 13:51:50 +00:00
test_dns.cpp unittests: Fix -Wsigned-compare errors 2023-02-28 12:30:30 +01:00
test_format.cpp Fix misc wrong types 2023-09-28 11:33:44 +02:00
test_header_deps.cpp Reformatting source code to new coding style 2023-01-18 19:24:15 +01:00
test_headredact.cpp Reformatting source code to new coding style 2023-01-18 19:24:15 +01:00
test_helper.hpp Add various moves as suggested by Coverity 2024-01-31 17:02:45 +01:00
test_hostport.cpp Reformatting source code to new coding style 2023-01-18 19:24:15 +01:00
test_http_proxy.cpp unittests: Fix -Wsigned-compare errors 2023-02-28 12:30:30 +01:00
test_ip.cpp OpenVPN 3 Core library version 3.8.5 2024-05-03 14:50:21 +02:00
test_iphelper.cpp Reformatting source code to new coding style 2023-01-18 19:24:15 +01:00
test_log.cpp Fix various "auto causes copy" Coverity warnings 2024-01-31 17:02:28 +01:00
test_mbedtls_authcert.cpp Reformatting source code to new coding style 2023-01-18 19:24:15 +01:00
test_mbedtls_x509certinfo.cpp Reformatting source code to new coding style 2023-01-18 19:24:15 +01:00
test_misc_unix.cpp Eliminate some conversion warnings 2023-03-08 15:21:50 +00:00
test_numeric_cast.cpp Add numeric limiting headers and tests 2023-02-23 23:06:45 +01:00
test_openssl_authcert.cpp Reformatting source code to new coding style 2023-01-18 19:24:15 +01:00
test_openssl_misc.cpp Fix accessing a null pointer when PKCS7 is invalid 2024-01-25 12:02:12 +01:00
test_openssl_x509certinfo.cpp Reformatting source code to new coding style 2023-01-18 19:24:15 +01:00
test_opensslpki.cpp Reformatting source code to new coding style 2023-01-18 19:24:15 +01:00
test_optfilt.cpp unittests: Fix -Wsigned-compare errors 2023-02-28 12:30:30 +01:00
test_ostream_containers.cpp Improve C2os unit tests with better templates 2024-03-28 11:27:23 +00:00
test_parseargv.cpp unittests: Fix -Wsigned-compare errors 2023-02-28 12:30:30 +01:00
test_path.cpp Reformatting source code to new coding style 2023-01-18 19:24:15 +01:00
test_peer_fingerprint.cpp Addressed 2nd set of -Wconversion warnings 2023-08-21 13:51:50 +00:00
test_pipe.cpp Reformatting source code to new coding style 2023-01-18 19:24:15 +01:00
test_pktid.cpp Switched C casts to static_cast 2023-08-23 18:44:16 +02:00
test_pktstream.cpp PacketStream: templatize stream segment length word 2023-09-17 10:08:36 -06:00
test_prefixlen.cpp unittests: Fix -Wsigned-compare errors 2023-02-28 12:30:30 +01:00
test_proto.cpp Fix NONE cipher not present in IV_CIPHERS 2024-04-24 15:46:44 +00:00
test_psid_cookie.cpp remove 'prng' argument from SSLLib::RandomAPI ctor 2023-11-22 04:49:31 +01:00
test_randapi.cpp introduce base types for strong and weak RNGs 2023-11-22 04:49:31 +01:00
test_rc.cpp Reformatting source code to new coding style 2023-01-18 19:24:15 +01:00
test_relack.cpp Do not use id_t unqualified in unit tests 2023-06-22 19:07:21 +02:00
test_reliable.cpp Do not use id_t unqualified in unit tests 2023-06-22 19:07:21 +02:00
test_remotelist.cpp Reformatting source code to new coding style 2023-01-18 19:24:15 +01:00
test_route_emulation.cpp unittests: Fix -Wsigned-compare errors 2023-02-28 12:30:30 +01:00
test_route.cpp Reformatting source code to new coding style 2023-01-18 19:24:15 +01:00
test_safestr.cpp Reformatting source code to new coding style 2023-01-18 19:24:15 +01:00
test_session_id.cpp remove 'prng' argument from SSLLib::RandomAPI ctor 2023-11-22 04:49:31 +01:00
test_sitnl.cpp Change some arguments to const refs 2024-01-31 17:02:47 +01:00
test_splitlines.cpp SplitLines/UserPass: Review fixes 2023-11-08 21:05:06 +01:00
test_ssl.cpp introduce base types for strong and weak RNGs 2023-11-22 04:49:31 +01:00
test_sslctx.cpp Allow test_sslctx to work with mbed TLS 2024-02-23 15:32:58 +01:00
test_statickey.cpp remove 'prng' argument from SSLLib::RandomAPI ctor 2023-11-22 04:49:31 +01:00
test_streq.cpp Reformatting source code to new coding style 2023-01-18 19:24:15 +01:00
test_time.cpp Switched C casts to static_cast 2023-08-23 18:44:16 +02:00
test_tun_builder.cpp Fix RouteBase string formatting bug 2024-03-29 03:13:00 +00:00
test_typeindex.cpp unittests: Fix -Wsigned-compare errors 2023-02-28 12:30:30 +01:00
test_userpass.cpp test_splitlines: New UT for SplitLines 2023-11-08 21:05:05 +01:00
test_validatecreds.cpp Reformatting source code to new coding style 2023-01-18 19:24:15 +01:00
test_verify_x509_name.cpp Reformatting source code to new coding style 2023-01-18 19:24:15 +01:00
test_weak.cpp unittests: Fix -Wsigned-compare errors 2023-02-28 12:30:30 +01:00

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.