fork
Fork of cpputest by
include/CppUTest/MemoryLeakWarningPlugin.h@3:9e8c8907d9ee, 2015-05-13 (annotated)
- Committer:
- Kojto
- Date:
- Wed May 13 13:20:35 2015 +0000
- Revision:
- 3:9e8c8907d9ee
- Parent:
- 1:4769360130ed
Rename console to mbed_cpputest_console (as in mbed testrunner)
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
rgrover1 | 0:0b799af9d58e | 1 | /* |
rgrover1 | 0:0b799af9d58e | 2 | * Copyright (c) 2007, Michael Feathers, James Grenning and Bas Vodde |
rgrover1 | 0:0b799af9d58e | 3 | * All rights reserved. |
rgrover1 | 0:0b799af9d58e | 4 | * |
rgrover1 | 0:0b799af9d58e | 5 | * Redistribution and use in source and binary forms, with or without |
rgrover1 | 0:0b799af9d58e | 6 | * modification, are permitted provided that the following conditions are met: |
rgrover1 | 0:0b799af9d58e | 7 | * * Redistributions of source code must retain the above copyright |
rgrover1 | 0:0b799af9d58e | 8 | * notice, this list of conditions and the following disclaimer. |
rgrover1 | 0:0b799af9d58e | 9 | * * Redistributions in binary form must reproduce the above copyright |
rgrover1 | 0:0b799af9d58e | 10 | * notice, this list of conditions and the following disclaimer in the |
rgrover1 | 0:0b799af9d58e | 11 | * documentation and/or other materials provided with the distribution. |
rgrover1 | 0:0b799af9d58e | 12 | * * Neither the name of the <organization> nor the |
rgrover1 | 0:0b799af9d58e | 13 | * names of its contributors may be used to endorse or promote products |
rgrover1 | 0:0b799af9d58e | 14 | * derived from this software without specific prior written permission. |
rgrover1 | 0:0b799af9d58e | 15 | * |
rgrover1 | 0:0b799af9d58e | 16 | * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY |
rgrover1 | 0:0b799af9d58e | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
rgrover1 | 0:0b799af9d58e | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
rgrover1 | 0:0b799af9d58e | 19 | * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY |
rgrover1 | 0:0b799af9d58e | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
rgrover1 | 0:0b799af9d58e | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
rgrover1 | 0:0b799af9d58e | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
rgrover1 | 0:0b799af9d58e | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
rgrover1 | 0:0b799af9d58e | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
rgrover1 | 0:0b799af9d58e | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
rgrover1 | 0:0b799af9d58e | 26 | */ |
rgrover1 | 0:0b799af9d58e | 27 | |
rgrover1 | 0:0b799af9d58e | 28 | #ifndef D_MemoryLeakWarningPlugin_h |
rgrover1 | 0:0b799af9d58e | 29 | #define D_MemoryLeakWarningPlugin_h |
rgrover1 | 0:0b799af9d58e | 30 | |
rgrover1 | 0:0b799af9d58e | 31 | #include "TestPlugin.h" |
rgrover1 | 0:0b799af9d58e | 32 | #include "MemoryLeakDetectorNewMacros.h" |
rgrover1 | 0:0b799af9d58e | 33 | |
rgrover1 | 0:0b799af9d58e | 34 | #define IGNORE_ALL_LEAKS_IN_TEST() MemoryLeakWarningPlugin::getFirstPlugin()->ignoreAllLeaksInTest(); |
rgrover1 | 0:0b799af9d58e | 35 | #define EXPECT_N_LEAKS(n) MemoryLeakWarningPlugin::getFirstPlugin()->expectLeaksInTest(n); |
rgrover1 | 0:0b799af9d58e | 36 | |
rgrover1 | 0:0b799af9d58e | 37 | extern void crash_on_allocation_number(unsigned alloc_number); |
rgrover1 | 0:0b799af9d58e | 38 | |
rgrover1 | 0:0b799af9d58e | 39 | class MemoryLeakDetector; |
rgrover1 | 0:0b799af9d58e | 40 | class MemoryLeakFailure; |
rgrover1 | 0:0b799af9d58e | 41 | |
rgrover1 | 0:0b799af9d58e | 42 | class MemoryLeakWarningPlugin: public TestPlugin |
rgrover1 | 0:0b799af9d58e | 43 | { |
rgrover1 | 0:0b799af9d58e | 44 | public: |
rgrover1 | 0:0b799af9d58e | 45 | MemoryLeakWarningPlugin(const SimpleString& name, MemoryLeakDetector* localDetector = 0); |
rgrover1 | 0:0b799af9d58e | 46 | virtual ~MemoryLeakWarningPlugin(); |
rgrover1 | 0:0b799af9d58e | 47 | |
rgrover1 | 0:0b799af9d58e | 48 | virtual void preTestAction(UtestShell& test, TestResult& result) _override; |
rgrover1 | 0:0b799af9d58e | 49 | virtual void postTestAction(UtestShell& test, TestResult& result) _override; |
rgrover1 | 0:0b799af9d58e | 50 | |
rgrover1 | 0:0b799af9d58e | 51 | virtual const char* FinalReport(int toBeDeletedLeaks = 0); |
rgrover1 | 0:0b799af9d58e | 52 | |
rgrover1 | 0:0b799af9d58e | 53 | void ignoreAllLeaksInTest(); |
rgrover1 | 0:0b799af9d58e | 54 | void expectLeaksInTest(int n); |
rgrover1 | 0:0b799af9d58e | 55 | |
rgrover1 | 0:0b799af9d58e | 56 | void destroyGlobalDetectorAndTurnOffMemoryLeakDetectionInDestructor(bool des); |
rgrover1 | 0:0b799af9d58e | 57 | |
rgrover1 | 0:0b799af9d58e | 58 | MemoryLeakDetector* getMemoryLeakDetector(); |
rgrover1 | 0:0b799af9d58e | 59 | |
rgrover1 | 0:0b799af9d58e | 60 | static MemoryLeakWarningPlugin* getFirstPlugin(); |
rgrover1 | 0:0b799af9d58e | 61 | |
rgrover1 | 0:0b799af9d58e | 62 | static MemoryLeakDetector* getGlobalDetector(); |
rgrover1 | 0:0b799af9d58e | 63 | static MemoryLeakFailure* getGlobalFailureReporter(); |
rgrover1 | 0:0b799af9d58e | 64 | static void setGlobalDetector(MemoryLeakDetector* detector, MemoryLeakFailure* reporter); |
rgrover1 | 0:0b799af9d58e | 65 | static void destroyGlobalDetector(); |
rgrover1 | 0:0b799af9d58e | 66 | |
rgrover1 | 0:0b799af9d58e | 67 | static void turnOffNewDeleteOverloads(); |
rgrover1 | 0:0b799af9d58e | 68 | static void turnOnNewDeleteOverloads(); |
Rohit Grover |
1:4769360130ed | 69 | static bool areNewDeleteOverloaded(); |
rgrover1 | 0:0b799af9d58e | 70 | private: |
rgrover1 | 0:0b799af9d58e | 71 | MemoryLeakDetector* memLeakDetector_; |
rgrover1 | 0:0b799af9d58e | 72 | bool ignoreAllWarnings_; |
rgrover1 | 0:0b799af9d58e | 73 | bool destroyGlobalDetectorAndTurnOfMemoryLeakDetectionInDestructor_; |
rgrover1 | 0:0b799af9d58e | 74 | int expectedLeaks_; |
rgrover1 | 0:0b799af9d58e | 75 | int failureCount_; |
rgrover1 | 0:0b799af9d58e | 76 | |
rgrover1 | 0:0b799af9d58e | 77 | static MemoryLeakWarningPlugin* firstPlugin_; |
rgrover1 | 0:0b799af9d58e | 78 | }; |
rgrover1 | 0:0b799af9d58e | 79 | |
rgrover1 | 0:0b799af9d58e | 80 | extern void* cpputest_malloc_location_with_leak_detection(size_t size, const char* file, int line); |
rgrover1 | 0:0b799af9d58e | 81 | extern void* cpputest_realloc_location_with_leak_detection(void* memory, size_t size, const char* file, int line); |
rgrover1 | 0:0b799af9d58e | 82 | extern void cpputest_free_location_with_leak_detection(void* buffer, const char* file, int line); |
rgrover1 | 0:0b799af9d58e | 83 | |
rgrover1 | 0:0b799af9d58e | 84 | #endif |