Merge #16564: test: Always define the raii_event_tests test suite

9a19c9ada5 Always define the raii_event_tests test suite (Craig Andrews)

Pull request description:

  The test suite must always be defined (even when EVENT_SET_MEM_FUNCTIONS_IMPLEMENTED is not defined) so that the test harness doesn't fail due to not being able to find the raii_event_tests test.

  This improves upon 95f97f4 actually fixing https://github.com/bitcoin/bitcoin/issues/9493

ACKs for top commit:
  MarcoFalke:
    ACK 9a19c9ada5 🎹

Tree-SHA512: 3c42f17a9b5d56c8841f3aa9ac19da91c10aff210026266f31f7eb98a62528740d7c518c121452b68e8f801d6c80ecfb627d137ec6ed533289fa3beb08b4f176
This commit is contained in:
MarcoFalke 2020-05-31 17:55:51 -04:00
commit 091cc4b94e
No known key found for this signature in database
GPG key ID: CE2B75697E69A548

View file

@ -4,9 +4,6 @@
#include <event2/event.h>
#ifdef EVENT_SET_MEM_FUNCTIONS_IMPLEMENTED
// It would probably be ideal to define dummy test(s) that report skipped, but boost::test doesn't seem to make that practical (at least not in versions available with common distros)
#include <map>
#include <stdlib.h>
@ -16,6 +13,10 @@
#include <boost/test/unit_test.hpp>
BOOST_FIXTURE_TEST_SUITE(raii_event_tests, BasicTestingSetup)
#ifdef EVENT_SET_MEM_FUNCTIONS_IMPLEMENTED
static std::map<void*, short> tags;
static std::map<void*, uint16_t> orders;
static uint16_t tagSequence = 0;
@ -34,8 +35,6 @@ static void tag_free(void* mem) {
free(mem);
}
BOOST_FIXTURE_TEST_SUITE(raii_event_tests, BasicTestingSetup)
BOOST_AUTO_TEST_CASE(raii_event_creation)
{
event_set_mem_functions(tag_malloc, realloc, tag_free);
@ -87,6 +86,14 @@ BOOST_AUTO_TEST_CASE(raii_event_order)
event_set_mem_functions(malloc, realloc, free);
}
BOOST_AUTO_TEST_SUITE_END()
#else
BOOST_AUTO_TEST_CASE(raii_event_tests_SKIPPED)
{
// It would probably be ideal to report skipped, but boost::test doesn't seem to make that practical (at least not in versions available with common distros)
BOOST_TEST_MESSAGE("Skipping raii_event_tess: libevent doesn't support event_set_mem_functions");
}
#endif // EVENT_SET_MEM_FUNCTIONS_IMPLEMENTED
BOOST_AUTO_TEST_SUITE_END()