Commit Graph
215 Commits
Author SHA1 Message Date
Martin Willi 4aaf0320d0 unit-tests: Add support for Windows build
Instead of signals we catch Windows exceptions. Currently not supported are
timers, which is more a convenience thing anyway.
2014-06-04 15:52:58 +02:00
Tobias Brunner b9dfeb5de4 unit-tests: Sync threads with main thread in test_cleanup_cancel()
Without synchronization threads could get canceled before they could
disable their cancelability.
2014-05-19 16:06:52 +02:00
Tobias Brunner 350c1dead9 unit-tests: Allow some HTTP write operations to fail
Because CURLOPT_FAILONERROR is enabled in the curl plugin an error code
will often (not always) cause the client to close the TCP connection
before the server has written the complete response.
2014-05-19 14:28:45 +02:00
Tobias Brunner deb8975bd2 unit-tests: Add a test case for HTTP response codes 2014-05-19 14:24:12 +02:00
Tobias Brunner 032dcb8989 unit-tests: Defer failures by worker threads
In some cases the main thread is not ready to immediately call siglongjmp(),
e.g. if it currently holds a mutex that is later required during
shutdown.

Therefore, we delay handling errors in worker threads until the main
thread performs the next check itself (or the test function ends).

The same issue remains with SIGALRM.
2014-05-19 14:06:55 +02:00
Tobias Brunner 435fecd751 unit-tests: Make sure plugins in the builddir are loaded
When running the tests in GDB the working directory apparently is
different.  With the relative path used previously the plugins would not
be found and those installed on the system would get used.
2014-05-19 14:06:43 +02:00
Tobias Brunner 7c888e0d23 unit-tests: Don't assert failures for unreadable settings files as root
The file can still be read by root even if nobody has read privileges.
2014-05-16 17:50:29 +02:00
Martin Willi 064fe9c963 enum: Return boolean result for enum_from_name() lookup
Handling the result for enum_from_name() is difficult, as checking for
negative return values requires a cast if the enum type is unsigned. The new
signature clearly differentiates lookup result from lookup value.

Further, this actually allows to convert real -1 enum values, which could not
be distinguished from "not-found" and the -1 return value.

This also fixes several clang warnings where enums are unsigned.
2014-05-16 15:42:07 +02:00
Martin Willi 9ee8b3b41f enum: Don't directly include enum.h
To allow enum.h to depend on utils.h definitions, avoid its direct inclusion.
Instead include utils.h, which includes enum.h as well.
2014-05-16 15:42:07 +02:00
Tobias Brunner 8b43c9ba34 settings: Adopt the new order of sections and settings when replacing configs 2014-05-15 11:28:09 +02:00
Tobias Brunner 5ac20cbb87 settings: Only purge sections if necessary
Instead of removing and caching all values of a previous config, we only
do this for actually removed sections/settings.
2014-05-15 11:28:08 +02:00
Tobias Brunner f5dd274ab8 settings: Maintain order of sections and settings while enumerating 2014-05-15 11:28:08 +02:00
Tobias Brunner 2fbbea55c5 settings: Don't overwrite values in-place
This is not thread safe.  If threads are reading from pointers to existing
values they could get a partially updated invalid value.

Refactored assignment to a separate function.
2014-05-15 11:28:08 +02:00
Tobias Brunner 2fe04fb312 unit-tests: Update settings tests to match new parser
Empty settings are now ignored, strings are supported, newlines are
handled properly (e.g. at the end of files) etc.
2014-05-15 11:28:07 +02:00
Tobias Brunner b9b1114ab1 settings: Move to a separate folder 2014-05-15 11:28:05 +02:00
Martin Willi 523dd96558 unit-tests: Document the supported env variables 2014-04-30 17:22:48 +02:00
Thomas Egerer 1b9b228c41 unit-tests: Support strongswan.conf defined plugin list and base directory
tests.load and tests.plugindir to allow the specification of the plugins
to be loaded and the directory to load them from.

Signed-off-by: Thomas Egerer <[email protected]>
2014-04-30 17:22:48 +02:00
Thomas Egerer f406a5bf72 unit-tests: Allow configuration of libstrongswan via config
By setting the environment variable TESTS_STRONGSWAN_CONF, the unit tests can
be asked to load a configuration file, thus enabling the tester to make use of
the usual configuration settings.

Signed-off-by: Thomas Egerer <[email protected]>
2014-04-30 17:22:48 +02:00
Martin Willi 20924ae28f unit-tests: Add a ck_assert_chunk_eq() convenience macro 2014-04-30 17:22:48 +02:00
Martin Willi 0456aa616f unit-tests: Silence a literal signedness warning raised by GCC 4.6.3 2014-04-30 17:22:48 +02:00
Tobias Brunner f678bce84c unit-tests: Verify two bytes at once when testing chunk_clear()
This reduces the chances of arbitrary test failures if the memory area
already got overwritten.
2014-04-02 11:50:11 +02:00
Martin Willi 70889c42a6 unit-tests: Catch timeouts during test runner deinit function
The test runner deinit function often cancels all threads from the pool. This
operation might hang on error conditions, hence we should include that hook in
the test timeout to fail properly.
2014-04-01 14:28:55 +02:00
Martin Willi 4e8ff4f010 unit-tests: Prevent a failing worker thread to go wild after it fails
A worker raises SIGUSR1 to inform the main thread that the test fails. The main
thread then starts cancelling workers, but the offending thread should be
terminated immediately to prevent it from test continuation.
2014-04-01 14:28:54 +02:00
Tobias Brunner 0462304dbb unit-tests: Fix filtered enumerator tests on 64-bit big-endian platforms
In case of sizeof(void*) == 8 and sizeof(int) == 4 on big-endian hosts
the tests failed as the actual integer value got cut off.
2014-03-27 15:35:32 +01:00
Tobias Brunner 58d8c52190 unit-tests: Fix memory leak in ntru tests 2014-03-27 10:52:45 +01:00
Andreas Steffen f0388684cd unit-test: added missing TEST_FUNCTION macros 2014-03-22 10:26:02 +01:00
Andreas Steffen 22e1aa51f9 Completed integration of ntru_crypto library into ntru plugin 2014-03-22 09:51:00 +01:00
Tobias Brunner 5dd638f45c unit-tests: Add an option to increase the verbosity when running tests
The TESTS_VERBOSITY option takes an integer from -1 to 4 that sets the
default debug level.
2014-03-20 15:49:05 +01:00
Tobias Brunner 77603e98a3 unit-tests: Add an option to run only a subset of all test suites
The TESTS_SUITES environment variable can contain a comma separated list
of names of test suites to run.
2014-03-20 15:49:05 +01:00
Tobias Brunner 636076d45d unit-tests: Actually verify registered algorithms against test vectors
Previously, the {ns}.crypto_test.on_add option had to be enabled to
actually test the algorithms, which we can't enforce for the tests in
the test_runner as the option is already read when the crypto factory
is initialized.  Even so, we wouldn't want to do this for every unit
test, which would be the result of enabling that option.
2014-03-20 15:49:05 +01:00
Tobias Brunner 6ce5aee0b2 unit-tests: Use TEST_FUNCTION macro in ntru tests 2014-03-20 15:49:05 +01:00
Tobias Brunner 31b3bb2211 unit-tests: Call functions with TEST_ prefix in ntru test 2014-03-20 15:37:44 +01:00
Tobias Brunner f51169eb09 unit-tests: Change how hashtable for testable functions is created
Because GCC does not adhere to the priorities defined for constructors
when building with --enable-monolithic (not sure if it was just luck
that it worked in non-monolithic mode - anyway, it's not very portable)
function registration would fail because the hashtable would not be
created yet.
2014-03-20 15:29:27 +01:00
Tobias Brunner 48ac56e2aa unit-tests: Generate weak keys with gcrypt plugin (but quickly) 2014-03-20 15:29:27 +01:00
Andreas Steffen 337f0c8a2f Implemented ntru_private_key class 2014-03-18 10:03:16 +01:00
Andreas Steffen 222b88a302 Added get_array() method to ntru_poly_t class 2014-02-27 22:08:22 +01:00
Andreas Steffen d12a4a67bf Defined ntru_poly_create_from_seed() and ntru_poly_create_from_data() constructors and built some unit tests for the latter) 2014-02-27 20:36:17 +01:00
Andreas Steffen bf24960cbe Implement ring multiplication method 2014-02-27 15:22:58 +01:00
Tobias Brunner 2ed241aeb3 utils: Add memrchr(3) replacement for platforms that don't support it
For instance, on Mac OS X memrchr(3) is not provided by the C library.
2014-02-26 11:05:07 +01:00
Tobias Brunner 766141bc77 utils: Add thread-safe variants of dirname(3) and basename(3) 2014-02-24 12:04:11 +01:00
Andreas Steffen e80014f1e8 index limit can be easily computed 2014-02-19 20:18:53 +01:00
Andreas Steffen 6dd05e0d58 Created ntru_poly class for sparse trinary polynomials 2014-02-18 16:17:38 +01:00
Tobias Brunner 4ab38d98a7 Fixed some typos 2014-02-18 10:36:25 +01:00
Tobias Brunner 1281c297d9 unit-tests: Ignore tests not test_runner 2014-02-18 10:09:30 +01:00
Tobias Brunner 9925eeabd2 settings: Add support to enumerate sections and key/value pairs with fallbacks 2014-02-12 14:34:33 +01:00
Tobias Brunner 79962d9e99 array: Add array_bsearch function 2014-02-12 14:34:33 +01:00
Tobias Brunner 132b00ce02 array: Add array_sort function 2014-02-12 14:34:33 +01:00
Tobias Brunner dbed07782b unit-tests: Test how settings_t handles some invalid data 2014-02-12 14:34:32 +01:00
Tobias Brunner 1713d88278 settings: Add method that allows to define fallback sections for other sections
The fallbacks are currently only used for single value lookups.
Enumerators are not affected by them.
2014-02-12 14:34:32 +01:00
Tobias Brunner 24d2bb7793 unit-tests: Add tests for includes and file loading in settings_t 2014-02-12 14:34:32 +01:00