diff --git a/AtlasTest/TestTools/TestTools/expect_exception.h b/AtlasTest/TestTools/TestTools/expect_exception.h index afdcc68056d6ecd735d7f940b141c447ed2c957f..dc92614fa870d942533d307a3ac0aba32517eaf8 100644 --- a/AtlasTest/TestTools/TestTools/expect_exception.h +++ b/AtlasTest/TestTools/TestTools/expect_exception.h @@ -27,7 +27,7 @@ * EXPECT_EXCEPTION (std::runtime_error, doSomething()); @endcode * - * This will produce an exception failure if @c doSomething() + * This will produce an assertion failure if @c doSomething() * does _not_ throw a @c std::runtime_error exception. */ #define EXPECT_EXCEPTION(EXC, CODE) do { \ diff --git a/AtlasTest/TestTools/TestTools/leakcheck.h b/AtlasTest/TestTools/TestTools/leakcheck.h new file mode 100644 index 0000000000000000000000000000000000000000..8d41b3a72c2a8eb212a2336aa43e2a30440930cc --- /dev/null +++ b/AtlasTest/TestTools/TestTools/leakcheck.h @@ -0,0 +1,99 @@ +// This file's extension implies that it's C, but it's really -*- C++ -*-. + +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// $Id$ +/** + * @file TestTools/leakcheck.h + * @author scott snyder <snyder@bnl.gov> + * @date Nov, 2016 + * @brief Pitifully simple leak checker for unit tests. + * Just verifies that allocations/deallocations + * match over an RAII region. + * + * Overrides the standard new/delete functions, so should not be + * #included from any code that would be included in a library. + */ + + +#ifndef TESTTOOLS_LEAKCHECK_H +#define TESTTOOLS_LEAKCHECK_H + + +#include <malloc.h> +#include <unordered_set> +#include <iostream> +#include <cassert> + + +namespace Athena_test { +std::unordered_set<void*>* allocs = nullptr; +struct LeakCheckDisable +{ + LeakCheckDisable() : m_allocs(allocs) { allocs = nullptr; } + ~LeakCheckDisable() { allocs = m_allocs; } + void insert(void* p) { if (m_allocs) m_allocs->insert(p); } + void erase(void* p) { if (m_allocs) m_allocs->erase(p); } + std::unordered_set<void*>* m_allocs; +}; +} // namespace Athena_test + + +void* operator new(std::size_t size) +{ + void* ptr = malloc(size); + if (Athena_test::allocs) { + Athena_test::LeakCheckDisable disable; + disable.insert (ptr); + } + return ptr; +} +void operator delete (void* ptr) noexcept +{ + if (Athena_test::allocs) { + Athena_test::LeakCheckDisable disable; + disable.erase (ptr); + } + free(ptr); +} +void operator delete (void* ptr, size_t) noexcept +{ + if (Athena_test::allocs) { + Athena_test::LeakCheckDisable disable; + disable.erase (ptr); + } + free(ptr); +} + + +namespace Athena_test { + + +struct Leakcheck +{ + Leakcheck() : m_old_allocs (allocs) { allocs = &m_allocs; } + ~Leakcheck(); + std::unordered_set<void*>* m_old_allocs; + std::unordered_set<void*> m_allocs; +}; + + +// Not inline; this file should NOT be included in any library. +Leakcheck::~Leakcheck() +{ + allocs = m_old_allocs; + if (!m_allocs.empty()) { + std::cerr << "Leaks!\n"; + for (void* p : m_allocs) + std::cerr << " " << p << "\n"; + assert (m_allocs.empty()); + } +} + + +} // namespace Athena_test + + +#endif // not TESTTOOLS_LEAKCHECK_H diff --git a/AtlasTest/TestTools/share/post.sh b/AtlasTest/TestTools/share/post.sh index 6e3c61170213d938843d4657e59c9001c3201cdb..de0adf8be4c78267fd7465ba25b129ffa9d4086b 100755 --- a/AtlasTest/TestTools/share/post.sh +++ b/AtlasTest/TestTools/share/post.sh @@ -143,11 +143,17 @@ PP="$PP"'|^ConditionStore +INFO Start ConditionStore' PP="$PP"'|^ConditionStore +INFO Stop ConditionStore' # Differences between Gaudi versions. -PP="$PP"'|DEBUG input handles:|DEBUG output handles:|DEBUG Data Deps for|DEBUG Property update for OutputLevel :|-ExtraInputs |-ExtraOutputs |-Cardinality |-IsClonable |-NeededResources |-Timeline ' +PP="$PP"'|DEBUG input handles:|DEBUG output handles:|DEBUG Data Deps for|DEBUG Property update for OutputLevel :|-ExtraInputs |-ExtraOutputs |-Cardinality |-IsClonable |-NeededResources |-Timeline |Service base class initialized successfully' # StoreGate INFO messages changed to VERBOSE PP="$PP"'|^(StoreGateSvc|[^ ]+Store) +(INFO|VERBOSE) (Stop|stop|Start)' +# Transient frontier warnings. +PP="$PP"'|^warn .fn-' + +# ubsan +PP="$PP"'|bits/regex.h:1545' + if [ "$extrapatterns" != "" ]; then PP="$PP""|$extrapatterns"