summaryrefslogtreecommitdiff
path: root/src/mongo/unittest
diff options
context:
space:
mode:
authorKevin Pulo <kevin.pulo@mongodb.com>2020-10-26 17:11:18 +1100
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-11-02 09:58:44 +0000
commit7d8e64df2d2d56a821f638ef88aa619403d03d31 (patch)
tree6ada2d481c56b9754ec7848caf146cd94149148f /src/mongo/unittest
parent4d2dea00415bf02d2b32d0474c93d251ce6568cc (diff)
downloadmongo-7d8e64df2d2d56a821f638ef88aa619403d03d31.tar.gz
SERVER-44570 Add tripwire assertions (tassert)
Diffstat (limited to 'src/mongo/unittest')
-rw-r--r--src/mongo/unittest/unittest.h14
-rw-r--r--src/mongo/unittest/unittest_main.cpp2
2 files changed, 14 insertions, 2 deletions
diff --git a/src/mongo/unittest/unittest.h b/src/mongo/unittest/unittest.h
index 160532e4528..2ef1d7cd77e 100644
--- a/src/mongo/unittest/unittest.h
+++ b/src/mongo/unittest/unittest.h
@@ -506,12 +506,22 @@ public:
/**
* Called on the test object before running the test.
*/
- virtual void setUp() {}
+ virtual void setUp() {
+ // React to any tasserts in the unittest framework initialisation, or between tests.
+ checkForTripwireAssertions();
+ // Clear tasserts for the code that's about to be under test.
+ assertionCount.tripwire.store(0);
+ }
/**
* Called on the test object after running the test.
*/
- virtual void tearDown() {}
+ virtual void tearDown() {
+ // React to any tasserts in the code that was under test.
+ checkForTripwireAssertions();
+ // Clear tasserts in case of any between tests, or during the unittest framework shutdown.
+ assertionCount.tripwire.store(0);
+ }
protected:
/**
diff --git a/src/mongo/unittest/unittest_main.cpp b/src/mongo/unittest/unittest_main.cpp
index b1286ed772a..1056198a04f 100644
--- a/src/mongo/unittest/unittest_main.cpp
+++ b/src/mongo/unittest/unittest_main.cpp
@@ -127,5 +127,7 @@ int main(int argc, char** argv) {
std::cerr << "Global deinitilization failed: " << ret.reason() << std::endl;
}
+ ::mongo::checkForTripwireAssertions();
+
return result;
}