tests: Fail on unexpected errors
Unexpected errors will now cause a test to fail. Explicitly calling
out unexpected errors in the test will still work, but should be used
reluctantly.
Change-Id: I5d121dc453c4acf497643bf10ad02459d0d96f15
diff --git a/tests/layer_validation_tests.cpp b/tests/layer_validation_tests.cpp
index 759b731..9f80e65 100644
--- a/tests/layer_validation_tests.cpp
+++ b/tests/layer_validation_tests.cpp
@@ -229,7 +229,6 @@
}
if (!found_expected) {
- printf("Unexpected: %s\n", msgString);
other_messages_.push_back(errorString);
}
}
@@ -238,8 +237,6 @@
return result;
}
- vector<string> GetOtherFailureMsgs(void) const { return other_messages_; }
-
VkDebugReportFlagsEXT GetMessageFlags(void) const { return message_flags_; }
VkBool32 AnyDesiredMsgFound(void) const { return message_found_; }
@@ -248,12 +245,11 @@
void SetBailout(bool *bailout) { bailout_ = bailout; }
- void DumpFailureMsgs(void) const {
- vector<string> otherMsgs = GetOtherFailureMsgs();
- if (otherMsgs.size()) {
- cout << "Other error messages logged for this test were:" << endl;
- for (auto iter = otherMsgs.begin(); iter != otherMsgs.end(); iter++) {
- cout << " " << *iter << endl;
+ void ReportUnexpectedErrors(void) const {
+ if (other_messages_.size() > 0) {
+ cout << "Unexpected error messages logged for this test are:" << endl;
+ for (auto const &msg : other_messages_) {
+ ADD_FAILURE() << " " << msg;
}
}
}
@@ -270,7 +266,6 @@
void VerifyFound() {
// Not seeing the desired message is a failure. /Before/ throwing, dump any other messages.
if (!AllDesiredMsgsFound()) {
- DumpFailureMsgs();
for (auto desired_msg : desired_message_strings_) {
ADD_FAILURE() << "Did not receive expected error '" << desired_msg << "'";
}
@@ -278,17 +273,22 @@
ADD_FAILURE() << "Did not receive expected error ENUM '" << desired_id << "'";
}
}
+
+ ReportUnexpectedErrors();
+
Reset();
}
void VerifyNotFound() {
// ExpectSuccess() configured us to match anything. Any error is a failure.
if (AnyDesiredMsgFound()) {
- DumpFailureMsgs();
for (auto msg : failure_message_strings_) {
ADD_FAILURE() << "Expected to succeed but got error: " << msg;
}
}
+
+ ReportUnexpectedErrors();
+
Reset();
}
@@ -419,6 +419,11 @@
virtual void TearDown() {
// Clean up resources before we reset
ShutdownFramework();
+
+ // Shutting down the framework may have triggered some unexpected errors. Let's check one last time before we destroy the
+ // error monitor.
+ m_errorMonitor->ReportUnexpectedErrors();
+
delete m_errorMonitor;
}