1 /*-------------------------------------------------------------------------
2 * drawElements Quality Program Tester Core
3 * ----------------------------------------
5 * Copyright 2014 The Android Open Source Project
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
21 * \brief Basic definitions.
22 *//*--------------------------------------------------------------------*/
24 #include "tcuDefs.hpp"
25 #include "deFilePath.hpp"
26 #include "qpDebugOut.h"
34 void die (const char* format, ...)
37 va_start(args, format);
42 void print (const char* format, ...)
45 va_start(args, format);
46 qpPrintv(format, args);
50 void printError (const char* format, ...)
53 va_start(args, format);
54 qpPrintErrorv(format, args);
58 static std::string formatError (const char* message, const char* expr, const char* file, int line)
60 std::ostringstream msg;
61 msg << (message ? message : "Runtime check failed");
64 msg << ": '" << expr << '\'';
67 msg << " at " << de::FilePath(file).getBaseName() << ":" << line;
72 Exception::Exception (const char* message, const char* expr, const char* file, int line)
73 : std::runtime_error(formatError(message, expr, file, line))
74 , m_message (message ? message : "Runtime check failed")
78 Exception::Exception (const std::string& message)
79 : std::runtime_error(message)
84 TestException::TestException (const char* message, const char* expr, const char* file, int line, qpTestResult result)
85 : Exception (formatError(message, expr, file, line))
90 TestException::TestException (const std::string& message, qpTestResult result)
96 TestError::TestError (const char* message, const char* expr, const char* file, int line)
97 : TestException(message, expr, file, line, QP_TEST_RESULT_FAIL)
100 TestError::TestError (const std::string& message, const char* expr, const char* file, int line)
101 : TestException(message.c_str(), expr, file, line, QP_TEST_RESULT_FAIL)
105 TestError::TestError (const std::string& message)
106 : TestException(message, QP_TEST_RESULT_FAIL)
110 InternalError::InternalError (const char* message, const char* expr, const char* file, int line)
111 : TestException(message, expr, file, line, QP_TEST_RESULT_INTERNAL_ERROR)
115 InternalError::InternalError (const std::string& message, const char* expr, const char* file, int line)
116 : TestException(message.c_str(), expr, file, line, QP_TEST_RESULT_INTERNAL_ERROR)
120 InternalError::InternalError (const std::string& message)
121 : TestException(message, QP_TEST_RESULT_INTERNAL_ERROR)
125 ResourceError::ResourceError (const char* message, const char* expr, const char* file, int line)
126 : TestException(message, expr, file, line, QP_TEST_RESULT_RESOURCE_ERROR)
130 ResourceError::ResourceError (const std::string& message)
131 : TestException(message, QP_TEST_RESULT_RESOURCE_ERROR)
135 NotSupportedError::NotSupportedError (const char* message, const char* expr, const char* file, int line)
136 : TestException(message, expr, file, line, QP_TEST_RESULT_NOT_SUPPORTED)
140 NotSupportedError::NotSupportedError (const std::string& message, const char* expr, const char* file, int line)
141 : TestException(message.c_str(), expr, file, line, QP_TEST_RESULT_NOT_SUPPORTED)
145 NotSupportedError::NotSupportedError (const std::string& message)
146 : TestException(message, QP_TEST_RESULT_NOT_SUPPORTED)