From 937e4fef9a46da03ba922381115151e46803310a Mon Sep 17 00:00:00 2001 From: Tobin Ehlis Date: Wed, 21 Sep 2016 17:32:26 -0600 Subject: [PATCH] tests: Update error monitor to handle multiple expected errors --- tests/layer_validation_tests.cpp | 45 +++++++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/tests/layer_validation_tests.cpp b/tests/layer_validation_tests.cpp index 0445573..a9fa83e 100644 --- a/tests/layer_validation_tests.cpp +++ b/tests/layer_validation_tests.cpp @@ -35,6 +35,7 @@ #include "test_common.h" #include "vk_layer_config.h" #include "vkrenderframework.h" +#include #define GLM_FORCE_RADIANS #include "glm/glm.hpp" @@ -130,9 +131,9 @@ class ErrorMonitor { void SetDesiredFailureMsg(VkFlags msgFlags, const char *msgString) { // also discard all collected messages to this point test_platform_thread_lock_mutex(&m_mutex); - m_failureMsg.clear(); + m_failureMsgs.clear(); m_otherMsgs.clear(); - m_desiredMsg = msgString; + m_desiredMsgs.insert(msgString); m_msgFound = VK_FALSE; m_msgFlags = msgFlags; m_desiredMsgSet = true; @@ -146,14 +147,20 @@ class ErrorMonitor { *m_bailout = true; } string errorString(msgString); - if (m_desiredMsgSet && errorString.find(m_desiredMsg) != string::npos) { - if (m_msgFound) { // If multiple matches, don't lose all but the last! - m_otherMsgs.push_back(m_failureMsg); + bool found_expected = false; + for (auto desired_msg : m_desiredMsgs) { + if (errorString.find(desired_msg) != string::npos) { + found_expected = true; + m_failureMsgs.insert(errorString); + m_msgFound = VK_TRUE; + result = VK_TRUE; + // We only want one match for each expected error so remove from set here + // Since we're about the break the loop it's ok to remove from set we're iterating over + m_desiredMsgs.erase(desired_msg); + break; } - m_failureMsg = errorString; - m_msgFound = VK_TRUE; - result = VK_TRUE; - } else { + } + if (!found_expected) { printf("Unexpected: %s\n", msgString); m_otherMsgs.push_back(errorString); } @@ -163,8 +170,6 @@ class ErrorMonitor { vector GetOtherFailureMsgs(void) { return m_otherMsgs; } - string GetFailureMsg(void) { return m_failureMsg; } - VkDebugReportFlagsEXT GetMessageFlags(void) { return m_msgFlags; } VkBool32 DesiredMsgFound(void) { return m_msgFound; } @@ -189,27 +194,29 @@ class ErrorMonitor { } void VerifyFound() { - // Not seeing the desired message is a failure. /Before/ throwing, dump - // any other messages. + // Not seeing the desired message is a failure. /Before/ throwing, dump any other messages. if (!DesiredMsgFound()) { DumpFailureMsgs(); - FAIL() << "Did not receive expected error '" << m_desiredMsg << "'"; + for (auto desired_msg : m_desiredMsgs) { + FAIL() << "Did not receive expected error '" << desired_msg << "'"; + } } } void VerifyNotFound() { - // ExpectSuccess() configured us to match anything. Any error is a - // failure. + // ExpectSuccess() configured us to match anything. Any error is a failure. if (DesiredMsgFound()) { DumpFailureMsgs(); - FAIL() << "Expected to succeed but got error: " << GetFailureMsg(); + for (auto msg : m_failureMsgs) { + FAIL() << "Expected to succeed but got error: " << msg; + } } } private: VkFlags m_msgFlags; - string m_desiredMsg; - string m_failureMsg; + std::unordered_set m_desiredMsgs; + std::unordered_set m_failureMsgs; vector m_otherMsgs; test_platform_thread_mutex m_mutex; bool *m_bailout; -- 2.7.4