History log of /dovecot/src/lib-test/test-common.h
Revision Date Author Comments Expand
37bf0a2059868bb31f25543e9ca11dd9c77bc198 27-Nov-2017 Timo Sirainen <timo.sirainen@dovecot.fi>

lib-test: Add test_expect_fatal_string()

440f9bf580c42860f741560cbc3789be959cf777 23-Dec-2016 Timo Sirainen <timo.sirainen@dovecot.fi>

lib-test: test_run*() - use const for test_functions[] array

b7a60785a9ed8a1afef479ccc30bc23a9c46feef 23-Dec-2016 Timo Sirainen <timo.sirainen@dovecot.fi>

lib-test: test_run_named*() - use const for tests[] array

957d34edbe3599fbb4e7c0bcf3785bd7fd4862c4 14-Dec-2016 Timo Sirainen <timo.sirainen@dovecot.fi>

lib-test: Change test_fatal_func_t to take unsigned int stage as parameter. It could never be -1, so this makes it clearer. It also removes annoying casts when comparing stage to e.g. N_ELEMENTS().

bc15567c91fb9d3915b04013ee0cc744c7a18eab 14-Dec-2016 Timo Sirainen <timo.sirainen@dovecot.fi>

lib-test: test_run_with_fatals() now takes a const array

76d4cc8e7aea32e91a48c83dabcccb196ea8019b 14-Dec-2016 Timo Sirainen <timo.sirainen@dovecot.fi>

lib-test: Introduce test_fatal_func_t as typedef and comment how it works.

11d88fd444070c67d09fe17e4dcb6c319d8833c2 30-Sep-2016 Timo Sirainen <timo.sirainen@dovecot.fi>

lib-test: Added test_ostream for testing nonblocking ostreams.

bd1e1a9720ce4617f7d97be75cffc45e905bb791 10-Aug-2016 Phil Carmody <phil@dovecot.fi>

lib-test: test-exit helper to stop valgrind complaining about fork()s fork()s that want to _exit() will cause valgrind's full memory leak checker to complain a lot - this performs a quick cleanup first. Before: phil@phil:~/repos/dovecot-core$ valgrind --trace-children=yes --leak-check=full --show-leak-kinds=all src/lib/test-lib --match unix ==19576== total heap usage: 4 allocs, 0 frees, 17,858 bytes allocated istream unix ......................................................... : ok 0 / 1 tests failed ==19575== total heap usage: 7 allocs, 7 frees, 19,327 bytes allocated After: phil@phil:~/repos/dovecot-core$ valgrind --trace-children=yes --leak-check=full --show-leak-kinds=all src/lib/test-lib --match unix istream unix ......................................................... : ok ==4993== total heap usage: 4 allocs, 4 frees, 17,858 bytes allocated 0 / 1 tests failed ==4992== total heap usage: 7 allocs, 7 frees, 19,327 bytes allocated Signed-off-by: Phil Carmody <phil@dovecot.fi>

d48ce437e36df095b4c8299d84d6eeb20c280994 08-Aug-2016 Phil Carmody <phil@dovecot.fi>

lib-test: enable naming of tests, such that only a subset is run How to use these will become clear in a subsequent patch. Even if you don't want to name tests, the macros can reduce redundancy in the code, as the list of test function prototypes and the list of test functions to call become the same lists, expanded through 2 different macros. Signed-off-by: Phil Carmody <phil@dovecot.fi>

0e0a294cfa87a8e44f29997cac48fd5030767b2b 08-Aug-2016 Phil Carmody <phil@dovecot.fi>

lib-test: improve expected error handling If we expect a specific error string, then when we see it, suppress it. We do not suppress errors expected by count, because if we get unexpected errors, then we do not want them suppressed, and we have no way of distinguishing between the expected and unexpected errors. This of course favours the use of the expected string version of the helper, but alas that's not always usable, as you can only expect one at a time. Additionally, if we failed to see an expected message, then when we no longer expect to see it, reset the expected message state to not cascade further test assertion failures. Signed-off-by: Phil Carmody <phil@dovecot.fi> Conflicts: src/lib-test/test-common.c

3c16f16e005a5d863faad157dba4a82ecb170239 21-Jun-2016 Baofeng Wang <baofeng.wang@dovecot.fi>

lib-test: add test_assert_failed_strcmp to expose strings. the macro is used to facilitate any test to show string comparision contents when they doesn't match.

1b3a9b9e7e51e526065a9858b806b35c81cb4b6c 15-Jun-2015 Phil Carmody <phil@dovecot.fi>

lib-test: test_expect_error_string() to match a single known message This gives us very fine control over what is acceptable as an expected warning. Alas you have to do it for each message individually. Signed-off-by: Phil Carmody <phil@dovecot.fi>

7d442a685dd22588aceb75e630b69e28357acaae 15-Jun-2015 Phil Carmody <phil@dovecot.fi>

lib-test: let tests invoke i_warning/i_error behaviour Error-handling paths should be testable too. Permit a test case to register that a known number of warnings/errors are to be expected, and to verify that those warnings did occur afterwards. Too many messages will fail the test exactly as it did in the past, they're unexpected messages. However, too few messages will also cause the test case to fail. Signed-off-by: Phil Carmody <phil@dovecot.fi>

a4e0dc5b1c4ff4caccfb928e3be0542905b0ec9a 30-Jul-2014 Phil Carmody <phil@dovecot.fi>

lib-test: permit tests of fatal conditions Some functions have no mechanism of reporting an error, and mustn't continue, so fatality is the only way out. (E.g. memory allocation failures.) This addition is for those situations. Semantics of failure tests are very different from normal tests: - The test function must have the following prototype: enum fatal_test_state test_fatal_things(int index); - The index it will be called with starts at 0, and increments each time. - It must call test_start() at the start of its first call. - Apart from its final call, it must call a function it expects to trap the fatal error handler. If that fails to trap, it must return FATAL_TEST_FAILURE - After returning FATAL_TEST_FAILURE, it will continue to be called as normal. - When there are no more tests to perform, it must clean up, call test_end() and return FATAL_TEST_FINISHED. It will not be called again. - If it detects errors in this protocol, it must not i_assert(), as that will be treated as an expected fatal, it must return FATAL_TEST_ABORT. It will then not be called again. It must not call test_end() in this case. Signed-off-by: Phil Carmody <phil@dovecot.fi>

0db47f171fc79209f95703f8f928c8487df15fcf 28-Jul-2014 Phil Carmody <phil@dovecot.fi>

lib-test: make internal helpers static These functions should only be called from within test_run(), as some of the test-suite sanity checks can be subvirted if these are exposed. Signed-off-by: Phil Carmody <phil@dovecot.fi>

00a34f888890caf56c66ff4d15445cab58ebd8d2 02-Jul-2014 Phil Carmody <phil@dovecot.fi>

lib-test: test-common - add test_out_quiet() to reduce verbosity Like test_out() but only prints anything if success is false. This makes it quite much like test_assert(), except that it doesn't print the code fragment, it prints a custom string. However, it still counts as a test in the total count, unlike test_assert*()s. Signed-off-by: Phil Carmody <phil@dovecot.fi>

dad57bb15da9dc03c40b0a4ddf72749704ea4e1b 27-Jun-2014 Phil Carmody <phil@dovecot.fi>

lib-test: Enable looped tests to abort early on first failure Give them the ability to query the current failure state. Signed-off-by: Phil Carmody <phil@dovecot.fi>

aebf030c0dc21b57ec13eb684fe70b482b8bb446 09-Jun-2014 Phil Carmody <phil@dovecot.fi>

lib-test: test_assert helper for loops If you're repeatedly testing the same expression in a loop, it's good to know where you are in the loop. Add an additional parameter for these cases. Signed-off-by: Phil Carmody <phil@dovecot.fi>

a10ed8c47534b4c6b6bf2711ccfe577e720a47b4 23-Jun-2012 Timo Sirainen <tss@iki.fi>

Marked functions parameters that are allowed to be NULL. Some APIs were also changed. The non-obvious APIs where NULL parameter was changed to "" are master_service_init() and auth_master_user_list_init(). These checks can currently be enabled only on a patched clang: http://llvm.org/bugs/show_bug.cgi?id=6786

/dovecot/src/anvil/main.c /dovecot/src/auth/auth-master-connection.c /dovecot/src/auth/auth-master-connection.h /dovecot/src/auth/auth-request-handler.c /dovecot/src/auth/auth-request.c /dovecot/src/auth/auth-request.h /dovecot/src/auth/auth-settings.h /dovecot/src/auth/auth-stream.h /dovecot/src/auth/auth-worker-server.c /dovecot/src/auth/auth.c /dovecot/src/auth/auth.h /dovecot/src/auth/db-checkpassword.h /dovecot/src/auth/db-ldap.c /dovecot/src/auth/db-ldap.h /dovecot/src/auth/db-passwd-file.c /dovecot/src/auth/main.c /dovecot/src/auth/mech-anonymous.c /dovecot/src/auth/mech-apop.c /dovecot/src/auth/mech-cram-md5.c /dovecot/src/auth/mech-ntlm.c /dovecot/src/auth/mech-otp-skey-common.c /dovecot/src/auth/mech-plain-common.c /dovecot/src/auth/mech-rpa.c /dovecot/src/auth/mech-winbind.c /dovecot/src/auth/mech.c /dovecot/src/auth/password-scheme-otp.c /dovecot/src/auth/password-scheme.h /dovecot/src/auth/userdb-passwd.c /dovecot/src/auth/userdb-static.c /dovecot/src/auth/userdb.h /dovecot/src/config/config-parser-private.h /dovecot/src/config/config-request.h /dovecot/src/config/doveconf.c /dovecot/src/config/main.c /dovecot/src/dict/main.c /dovecot/src/director/director-connection.c /dovecot/src/director/director-test.c /dovecot/src/director/director.h /dovecot/src/dns/dns-client.c /dovecot/src/doveadm/doveadm-director.c /dovecot/src/doveadm/doveadm-log.c /dovecot/src/doveadm/doveadm-mail-fetch.c /dovecot/src/doveadm/doveadm-mail-iter.h /dovecot/src/doveadm/doveadm-mail-mailbox-status.c /dovecot/src/doveadm/dsync/doveadm-dsync.c /dovecot/src/doveadm/dsync/dsync-brain.c /dovecot/src/doveadm/dsync/dsync-mailbox-import.c /dovecot/src/doveadm/dsync/dsync-slave-io.c /dovecot/src/doveadm/main.c /dovecot/src/imap-login/client.c /dovecot/src/imap-login/client.h /dovecot/src/imap/cmd-append.c /dovecot/src/imap/cmd-expunge.c /dovecot/src/imap/imap-client.h /dovecot/src/imap/imap-commands-util.h /dovecot/src/imap/imap-expunge.h /dovecot/src/imap/imap-fetch-body.c /dovecot/src/imap/imap-fetch.h /dovecot/src/imap/imap-search.h /dovecot/src/imap/imap-sync.c /dovecot/src/indexer/indexer.c /dovecot/src/indexer/master-connection.c /dovecot/src/ipc/client.c /dovecot/src/ipc/main.c /dovecot/src/lib-auth/auth-client-request.c /dovecot/src/lib-auth/auth-client.h /dovecot/src/lib-auth/auth-master.c /dovecot/src/lib-auth/auth-master.h /dovecot/src/lib-dict/dict.h /dovecot/src/lib-dns/dns-lookup.h /dovecot/src/lib-imap-client/imapc-connection.h /dovecot/src/lib-imap-storage/imap-msgpart.c /dovecot/src/lib-imap/imap-base-subject.c /dovecot/src/lib-imap/imap-parser.c /dovecot/src/lib-imap/imap-parser.h /dovecot/src/lib-imap/imap-url.c /dovecot/src/lib-imap/imap-util.h /dovecot/src/lib-index/mail-cache-lookup.c /dovecot/src/lib-index/mail-cache-transaction.c /dovecot/src/lib-index/mail-index-alloc-cache.c /dovecot/src/lib-index/mail-index-alloc-cache.h /dovecot/src/lib-index/mail-index-map-hdr.c /dovecot/src/lib-index/mail-index-map.c /dovecot/src/lib-index/mail-index-util.h /dovecot/src/lib-index/mail-index-view.c /dovecot/src/lib-index/mail-index.c /dovecot/src/lib-index/mail-index.h /dovecot/src/lib-lda/mail-deliver.h /dovecot/src/lib-lda/smtp-client.h /dovecot/src/lib-mail/istream-binary-converter.c /dovecot/src/lib-mail/istream-dot.c /dovecot/src/lib-mail/istream-header-filter.h /dovecot/src/lib-mail/message-header-parser.h /dovecot/src/lib-mail/message-parser.h /dovecot/src/lib-mail/message-part-serialize.c /dovecot/src/lib-mail/message-search.h /dovecot/src/lib-mail/message-size.c /dovecot/src/lib-mail/message-size.h /dovecot/src/lib-mail/rfc822-parser.h /dovecot/src/lib-mail/test-istream-header-filter.c /dovecot/src/lib-master/anvil-client.h /dovecot/src/lib-master/ipc-client.h /dovecot/src/lib-master/ipc-server.c /dovecot/src/lib-master/master-service-settings-cache.h /dovecot/src/lib-master/master-service-settings.h /dovecot/src/lib-master/master-service.c /dovecot/src/lib-master/master-service.h /dovecot/src/lib-master/mountpoint-list.c /dovecot/src/lib-ntlm/ntlm-encrypt.c /dovecot/src/lib-ntlm/ntlm-encrypt.h /dovecot/src/lib-otp/otp-parse.c /dovecot/src/lib-settings/settings-parser.c /dovecot/src/lib-settings/settings.h /dovecot/src/lib-sql/driver-mysql.c /dovecot/src/lib-sql/driver-pgsql.c /dovecot/src/lib-sql/driver-sqlpool.c /dovecot/src/lib-sql/sql-api.c /dovecot/src/lib-storage/index/dbox-common/dbox-file-fix.c /dovecot/src/lib-storage/index/dbox-common/dbox-save.h /dovecot/src/lib-storage/index/dbox-common/dbox-storage.c /dovecot/src/lib-storage/index/dbox-common/dbox-sync-rebuild.c /dovecot/src/lib-storage/index/dbox-multi/mdbox-map.c /dovecot/src/lib-storage/index/dbox-multi/mdbox-storage.c /dovecot/src/lib-storage/index/dbox-multi/mdbox-storage.h /dovecot/src/lib-storage/index/dbox-multi/mdbox-sync.c /dovecot/src/lib-storage/index/dbox-single/sdbox-storage.c /dovecot/src/lib-storage/index/imapc/imapc-mail.c /dovecot/src/lib-storage/index/index-mail-headers.c /dovecot/src/lib-storage/index/index-mail.c /dovecot/src/lib-storage/index/index-mail.h /dovecot/src/lib-storage/index/index-search.c /dovecot/src/lib-storage/index/index-sort.c /dovecot/src/lib-storage/index/index-storage.h /dovecot/src/lib-storage/index/index-sync-changes.h /dovecot/src/lib-storage/index/maildir/maildir-filename-flags.c /dovecot/src/lib-storage/index/maildir/maildir-filename-flags.h /dovecot/src/lib-storage/index/maildir/maildir-mail.c /dovecot/src/lib-storage/index/maildir/maildir-save.c /dovecot/src/lib-storage/index/maildir/maildir-storage.c /dovecot/src/lib-storage/index/maildir/maildir-storage.h /dovecot/src/lib-storage/index/maildir/maildir-sync-index.c /dovecot/src/lib-storage/index/maildir/maildir-sync.c /dovecot/src/lib-storage/index/maildir/maildir-sync.h /dovecot/src/lib-storage/index/maildir/maildir-uidlist.c /dovecot/src/lib-storage/index/maildir/maildir-uidlist.h /dovecot/src/lib-storage/index/maildir/maildir-util.c /dovecot/src/lib-storage/index/mbox/mbox-file.c /dovecot/src/lib-storage/index/mbox/mbox-lock.c /dovecot/src/lib-storage/index/mbox/mbox-mail.c /dovecot/src/lib-storage/index/mbox/mbox-storage.c /dovecot/src/lib-storage/index/mbox/mbox-sync-parse.c /dovecot/src/lib-storage/index/mbox/mbox-sync.c /dovecot/src/lib-storage/index/raw/raw-storage.c /dovecot/src/lib-storage/index/shared/shared-storage.c /dovecot/src/lib-storage/list/mailbox-list-delete.c /dovecot/src/lib-storage/list/mailbox-list-fs-iter.c /dovecot/src/lib-storage/list/mailbox-list-fs.c /dovecot/src/lib-storage/list/mailbox-list-index-status.c /dovecot/src/lib-storage/list/mailbox-list-index.c /dovecot/src/lib-storage/list/mailbox-list-maildir.c /dovecot/src/lib-storage/mail-namespace.h /dovecot/src/lib-storage/mail-search.h /dovecot/src/lib-storage/mail-storage-service.c /dovecot/src/lib-storage/mail-storage-service.h /dovecot/src/lib-storage/mail-storage.c /dovecot/src/lib-storage/mail-storage.h /dovecot/src/lib-storage/mail-thread.h /dovecot/src/lib-storage/mail.c /dovecot/src/lib-storage/mailbox-get.c /dovecot/src/lib-storage/mailbox-list-private.h /dovecot/src/lib-storage/mailbox-list.c /dovecot/src/lib-storage/mailbox-list.h /dovecot/src/lib-storage/mailbox-tree.c /dovecot/src/lib-storage/mailbox-tree.h test-common.h /dovecot/src/lib/base64.h /dovecot/src/lib/buffer.h /dovecot/src/lib/child-wait.h /dovecot/src/lib/eacces-error.h /dovecot/src/lib/failures.c /dovecot/src/lib/file-dotlock.c /dovecot/src/lib/hash.c /dovecot/src/lib/hash.h /dovecot/src/lib/hash2.h /dovecot/src/lib/ioloop-notify-fd.h /dovecot/src/lib/ioloop.c /dovecot/src/lib/ioloop.h /dovecot/src/lib/iso8601-date.c /dovecot/src/lib/istream-base64-encoder.c /dovecot/src/lib/istream-chain.c /dovecot/src/lib/istream-chain.h /dovecot/src/lib/istream-crlf.c /dovecot/src/lib/istream-private.h /dovecot/src/lib/istream-seekable.h /dovecot/src/lib/istream.c /dovecot/src/lib/istream.h /dovecot/src/lib/lib-signals.c /dovecot/src/lib/lib-signals.h /dovecot/src/lib/macros.h /dovecot/src/lib/mkdir-parents.c /dovecot/src/lib/module-dir.h /dovecot/src/lib/network.c /dovecot/src/lib/network.h /dovecot/src/lib/ostream-private.h /dovecot/src/lib/ostream.c /dovecot/src/lib/ostream.h /dovecot/src/lib/restrict-access.h /dovecot/src/lib/safe-mkstemp.c /dovecot/src/lib/strfuncs.c /dovecot/src/lib/strfuncs.h /dovecot/src/lib/test-iso8601-date.c /dovecot/src/lib/uri-util.c /dovecot/src/lib/uri-util.h /dovecot/src/lib/var-expand.h /dovecot/src/lmtp/client.h /dovecot/src/lmtp/lmtp-proxy.h /dovecot/src/log/main.c /dovecot/src/login-common/client-common-auth.c /dovecot/src/login-common/login-proxy.c /dovecot/src/login-common/login-settings.h /dovecot/src/login-common/sasl-server.c /dovecot/src/login-common/ssl-proxy-openssl.c /dovecot/src/master/common.h /dovecot/src/plugins/acl/acl-backend-vfile-acllist.c /dovecot/src/plugins/acl/acl-plugin.h /dovecot/src/plugins/fts-lucene/fts-backend-lucene.c /dovecot/src/plugins/fts-lucene/lucene-wrapper.h /dovecot/src/plugins/fts-solr/solr-connection.c /dovecot/src/plugins/fts-squat/squat-trie.h /dovecot/src/plugins/fts/fts-storage.c /dovecot/src/plugins/quota/quota-dirsize.c /dovecot/src/plugins/quota/quota-fs.c /dovecot/src/plugins/quota/quota-maildir.c /dovecot/src/plugins/quota/quota.c /dovecot/src/pop3/pop3-client.h /dovecot/src/replication/aggregator/aggregator.c /dovecot/src/replication/replicator/replicator.c /dovecot/src/ssl-params/main.c /dovecot/src/stats/mail-domain.h /dovecot/src/stats/mail-ip.h /dovecot/src/stats/mail-session.h /dovecot/src/stats/mail-user.h /dovecot/src/stats/main.c
4c542561cab50e31498841aeabec7a7e889a17d7 26-Oct-2009 Timo Sirainen <tss@iki.fi>

lib-test: Added test_istream_create(). --HG-- branch : HEAD

7379a9d8a1c10e452d3d319e23ea900a358bac44 14-Aug-2009 Timo Sirainen <tss@iki.fi>

lib-test: Added test_istream_set_max_buffer_size(). --HG-- branch : HEAD

3a14416ca1f20640156c36534a7815f005c51eab 30-Jun-2009 Timo Sirainen <tss@iki.fi>

unit testing: Added support for doing test_init/run/deinit in separate functions. --HG-- branch : HEAD

40a5aeebf6b4858b93f0ddff0bf12fba769cf903 09-May-2009 Timo Sirainen <tss@iki.fi>

Tests are now run on "make check". Added initial tests for lib-index. Moved old tests away from tests/ to libraries' individual directories. --HG-- branch : HEAD