mirror of
https://github.com/OpenVPN/openvpn3.git
synced 2024-09-19 19:52:15 +02:00
unittest: Add proto test cmake parameters w/README
When the test/ssl/proto was migrated to a unit test, all the build time tuneables for changing the test scope got lost. This change re-introduces these parameters in the appropriate CMakeLists.txt. Further, it adds an improved README in .rst format that describes the parameters; this is based on the original README file in test/ssl. In addition, it adds improved handling of the directory where the test certificates and key files are located; now they can be adjusted more easily. Signed-off-by: Mark Deric <jmark@openvpn.net>
This commit is contained in:
parent
68f7d7ca27
commit
1555d9581a
@ -1,7 +1,19 @@
|
||||
##
|
||||
## Tunable protoUnitTests parameters
|
||||
##
|
||||
set(TEST_PROTO_NTHREADS 1 CACHE STRING "protoUnitTests - Number of threads")
|
||||
set(TEST_PROTO_RENEG 900 CACHE STRING "protoUnitTests - Renegotiation intervall")
|
||||
set(TEST_PROTO_ITER 1000000 CACHE STRING "protoUnitTests - Number of iterations")
|
||||
set(TEST_PROTO_SITER 1 CACHE STRING "protoUnitTests - Number of high-level iterations")
|
||||
set(TEST_KEYCERT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../ssl" CACHE STRING "protoUnitTests - Certificate/private keys for testing")
|
||||
option(TEST_PROTO_VERBOSE "test/ssl/proto - Enable verbose logging" OFF)
|
||||
|
||||
|
||||
if (NOT BUILD_TESTING)
|
||||
return()
|
||||
endif()
|
||||
|
||||
|
||||
# current latest GTEST version
|
||||
set(OVPN_GTEST_VERSION release-1.11.0)
|
||||
include(dlgoogletest)
|
||||
@ -65,6 +77,18 @@ add_executable(protoUnitTests
|
||||
test_proto.cpp
|
||||
)
|
||||
|
||||
if (${TEST_PROTO_VERBOSE})
|
||||
set(PROTO_CFLAGS_VERBOSE -DVERBOSE)
|
||||
endif()
|
||||
|
||||
target_compile_definitions(protoUnitTests PRIVATE
|
||||
${PROTO_CFLAGS_VERBOSE}
|
||||
-DN_THREADS=${TEST_PROTO_NTHREADS}
|
||||
-DRENEG=${TEST_PROTO_RENEG}
|
||||
-DITER=${TEST_PROTO_ITER}
|
||||
-DSITER=${TEST_PROTO_SITER}
|
||||
-DTEST_KEYCERT_DIR=\"${TEST_KEYCERT_DIR}/\"
|
||||
)
|
||||
|
||||
if (${USE_MBEDTLS})
|
||||
target_sources(coreUnitTests PRIVATE
|
||||
|
86
test/unittests/README-proto-tests.rst
Normal file
86
test/unittests/README-proto-tests.rst
Normal file
@ -0,0 +1,86 @@
|
||||
OpenVPN protocol unit tests
|
||||
===========================
|
||||
|
||||
The :code:`protoUnitTest` utility can be tweaked with build time options changing
|
||||
the behaviour. These are set via CMake variables.
|
||||
|
||||
* :code:`TEST_PROTO_NTHREADS` - Running test threads (default :code:`1`)
|
||||
|
||||
The number of test client/server pairs running in parallel.
|
||||
|
||||
::
|
||||
|
||||
$ cd $O3/core/build && cmake -DTEST_PROTO_NTHREADS=4 ..
|
||||
$ cmake --build . -- test/unittests/protoUnitTests
|
||||
|
||||
* :code:`TEST_PROTO_RENEG` - Rengotiation (default :code:`900`)
|
||||
|
||||
To simulate less data-channel activity and more SSL renegotiations
|
||||
|
||||
::
|
||||
|
||||
$ cd $O3/core/build && cmake -DTEST_PROTO_RENEG=90 ..
|
||||
$ cmake --build . -- test/unittests/protoUnitTests
|
||||
|
||||
* :code:`TEST_PROTO_ITER` - Iterations (default :code:`1000000`)
|
||||
|
||||
For verbose output, lower the number of xmit/recv iterations by defining
|
||||
:code:`TEST_PROTO_ITER` to be :code:`10000` or less, e.g.
|
||||
|
||||
::
|
||||
|
||||
$ cd $O3/core/build && cmake -DTEST_PROTO_ITER=1000 ..
|
||||
$ cmake --build . -- test/unittests/protoUnitTests
|
||||
|
||||
* :code:`TEST_PROTO_SITER` - High-level Session Iterations (default :code:`1`)
|
||||
|
||||
::
|
||||
|
||||
$ cd $O3/core/build && cmake -DTEST_PROTO_SITER=2 ..
|
||||
$ cmake --build . -- test/unittests/protoUnitTests
|
||||
|
||||
* :code:`TEST_PROTO_VERBOSE` - Verbose log output (:code:`OFF`)
|
||||
|
||||
This will dump details of the protocol traffic as the test runs. This
|
||||
is a boolean flag.
|
||||
|
||||
::
|
||||
|
||||
$ cd $O3/core/build && cmake -DTEST_PROTO_VERBOSE=ON ..
|
||||
$ cmake --build . -- test/unittests/protoUnitTests
|
||||
|
||||
|
||||
Mbed TLS specific
|
||||
-----------------
|
||||
|
||||
Caveats
|
||||
~~~~~~~
|
||||
|
||||
When using MbedTLS as both client and server, make sure to build
|
||||
MbedTLS on Mac OS X with :code:`OSX_SERVER=1`.
|
||||
|
||||
|
||||
Typical output
|
||||
--------------
|
||||
|
||||
::
|
||||
|
||||
$ cd $O3/core/build
|
||||
$ cmake ..
|
||||
$ cmake --build . -- test/unittests/protoUnitTests
|
||||
$ time ./test/unittests/protoUnitTests
|
||||
[==========] Running 1 test from 1 test suite.
|
||||
[----------] Global test environment set-up.
|
||||
[----------] 1 test from proto
|
||||
[ RUN ] proto.base_1_thread
|
||||
*** app bytes=127454208 net_bytes=196770417 data_bytes=415976439 prog=0000379325/0000379326 D=14700/600/12600/700 N=110/110 SH=14900/17300 HE=1/0
|
||||
[ OK ] proto.base_1_thread (12775 ms)
|
||||
[----------] 1 test from proto (12775 ms total)
|
||||
|
||||
[----------] Global test environment tear-down
|
||||
[==========] 1 test from 1 test suite ran. (12775 ms total)
|
||||
[ PASSED ] 1 test.
|
||||
|
||||
real 0m12,794s
|
||||
user 0m12,518s
|
||||
sys 0m0,250s
|
@ -890,15 +890,15 @@ int test(const int thread_num)
|
||||
const Time::Duration time_step = Time::Duration::binary_ms(100);
|
||||
|
||||
// client config files
|
||||
const std::string ca_crt = read_text(UNITTEST_SOURCE_DIR "../ssl/ca.crt");
|
||||
const std::string client_crt = read_text(UNITTEST_SOURCE_DIR "../ssl/client.crt");
|
||||
const std::string client_key = read_text(UNITTEST_SOURCE_DIR "../ssl/client.key");
|
||||
const std::string server_crt = read_text(UNITTEST_SOURCE_DIR "../ssl/server.crt");
|
||||
const std::string server_key = read_text(UNITTEST_SOURCE_DIR "../ssl/server.key");
|
||||
const std::string dh_pem = read_text(UNITTEST_SOURCE_DIR "../ssl/dh.pem");
|
||||
const std::string tls_auth_key = read_text(UNITTEST_SOURCE_DIR "../ssl/tls-auth.key");
|
||||
const std::string tls_crypt_v2_server_key = read_text(UNITTEST_SOURCE_DIR "../ssl/tls-crypt-v2-server.key");
|
||||
const std::string tls_crypt_v2_client_key = read_text(UNITTEST_SOURCE_DIR "../ssl/tls-crypt-v2-client.key");
|
||||
const std::string ca_crt = read_text(TEST_KEYCERT_DIR "ca.crt");
|
||||
const std::string client_crt = read_text(TEST_KEYCERT_DIR "client.crt");
|
||||
const std::string client_key = read_text(TEST_KEYCERT_DIR "client.key");
|
||||
const std::string server_crt = read_text(TEST_KEYCERT_DIR "server.crt");
|
||||
const std::string server_key = read_text(TEST_KEYCERT_DIR "server.key");
|
||||
const std::string dh_pem = read_text(TEST_KEYCERT_DIR "dh.pem");
|
||||
const std::string tls_auth_key = read_text(TEST_KEYCERT_DIR "tls-auth.key");
|
||||
const std::string tls_crypt_v2_server_key = read_text(TEST_KEYCERT_DIR "tls-crypt-v2-server.key");
|
||||
const std::string tls_crypt_v2_client_key = read_text(TEST_KEYCERT_DIR "tls-crypt-v2-client.key");
|
||||
|
||||
// client config
|
||||
ClientSSLAPI::Config::Ptr cc(new ClientSSLAPI::Config());
|
||||
|
Loading…
Reference in New Issue
Block a user