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 Test case wrapper for test execution.
22 *//*--------------------------------------------------------------------*/
24 #include "tcuTestCaseWrapper.hpp"
25 #include "tcuTestLog.hpp"
31 TestCaseWrapper::TestCaseWrapper (TestContext& testCtx)
37 TestCaseWrapper::~TestCaseWrapper (void)
41 bool TestCaseWrapper::initTestCase (TestCase* testCase)
43 // Initialize test case.
44 TestLog& log = m_testCtx.getLog();
47 // Record test start time.
48 m_testStartTime = deGetMicroseconds();
55 catch (const std::bad_alloc&)
58 m_testCtx.setTestResult(QP_TEST_RESULT_RESOURCE_ERROR, "Failed to allocate memory in test case init");
59 m_testCtx.setTerminateAfter(true);
61 catch (const tcu::TestException& e)
64 m_testCtx.setTestResult(e.getTestResult(), e.getMessage());
65 m_testCtx.setTerminateAfter(e.isFatal());
68 catch (const tcu::Exception& e)
71 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, e.getMessage());
75 DE_ASSERT(success || m_testCtx.getTestResult() != QP_TEST_RESULT_LAST);
80 bool TestCaseWrapper::deinitTestCase (TestCase* testCase)
82 bool deinitOk = false;
90 catch (const tcu::Exception& e)
92 m_testCtx.getLog() << e
93 << TestLog::Message << "Error in test case deinit, test program will terminate." << TestLog::EndMessage;
97 const deInt64 duration = deGetMicroseconds()-m_testStartTime;
99 m_testCtx.getLog() << TestLog::Integer("TestDuration", "Test case duration in microseconds", "us", QP_KEY_TAG_TIME, duration);
105 TestNode::IterateResult TestCaseWrapper::iterateTestCase (TestCase* testCase)
107 // Iterate the sub-case.
108 TestLog& log = m_testCtx.getLog();
109 TestCase::IterateResult iterateResult = TestCase::STOP;
113 iterateResult = testCase->iterate();
115 catch (const std::bad_alloc&)
117 m_testCtx.setTestResult(QP_TEST_RESULT_RESOURCE_ERROR, "Failed to allocate memory during test execution");
118 m_testCtx.setTerminateAfter(true);
120 catch (const tcu::TestException& e)
123 m_testCtx.setTestResult(e.getTestResult(), e.getMessage());
124 m_testCtx.setTerminateAfter(e.isFatal());
126 catch (const tcu::Exception& e)
129 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, e.getMessage());
132 return iterateResult;