/*
- * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2012-2015 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*
* If database is already opened do nothing.
*
- * @throw DPL::Test::TestRunner::TestFailed when opening database fails
+ * @throw DPL::Test::TestFailed when opening database fails
*/
void open(void);
/**
* @brief Close database.
*
- * @throw DPL::Test::TestRunner::TestFailed when closing database fails
+ * @throw DPL::Test::TestFailed when closing database fails
*/
void close(void);
* @param sql_query SQL query
* @param result returned result
*
- * @throw DPL::Test::TestRunner::TestFailed when execution of query fails
+ * @throw DPL::Test::TestFailed when execution of query fails
*/
void execute(const std::string& sql_query, Sqlite3DBaseSelectResult& result);
#include <cynara_test_cynara_mask.h>
#include <dpl/exception.h>
-#include <dpl/test/test_runner.h>
+#include <dpl/test/test_exception.h>
#include <exception>
try {
func();
- } catch (const DPL::Test::TestRunner::TestFailed &e) {
+ } catch (const DPL::Test::TestException &e) {
env.restore();
- throw e;
- } catch (const DPL::Test::TestRunner::Ignored &e) {
- env.restore();
- throw e;
+ throw;
} catch (const DPL::Exception &e) {
env.restore();
- throw e;
+ throw;
} catch (const std::exception &e) {
env.restore();
- throw e;
+ throw;
} catch (...) {
env.restore();
throw std::runtime_error("Unknown exception");
${PROJECT_SOURCE_DIR}/src/framework/src/dlog_log_provider.cpp
${PROJECT_SOURCE_DIR}/src/framework/src/log.cpp
${PROJECT_SOURCE_DIR}/src/framework/src/old_style_log_provider.cpp
+ ${PROJECT_SOURCE_DIR}/src/framework/src/test_failed.cpp
${PROJECT_SOURCE_DIR}/src/framework/src/test_results_collector.cpp
${PROJECT_SOURCE_DIR}/src/framework/src/test_results_collector_commons.cpp
${PROJECT_SOURCE_DIR}/src/framework/src/test_results_collector_console.cpp
--- /dev/null
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @file test_exception.h
+ * @author Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
+ * @version 1.0
+ * @brief This file is the header file of test_exception base class
+ */
+
+#ifndef DPL_TEST_EXCEPTION_H
+#define DPL_TEST_EXCEPTION_H
+
+#include <string>
+
+namespace DPL {
+namespace Test {
+
+class TestException
+{
+ public:
+ std::string GetMessage() const
+ {
+ return m_message;
+ }
+
+ protected:
+ std::string m_message;
+
+ TestException() {}
+ TestException(const std::string &message) :
+ m_message(message) {}
+
+};
+
+} // namespace Test
+} // namespace DPL
+
+#endif // DPL_TEST_EXCEPTION_H
--- /dev/null
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @file test_failed.h
+ * @author Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
+ * @version 1.0
+ * @brief This file is the header file of TestFailed class
+ */
+
+#ifndef DPL_TEST_FAILED_H
+#define DPL_TEST_FAILED_H
+
+#include <string>
+
+#include <dpl/test/test_exception.h>
+
+namespace DPL {
+namespace Test {
+
+class TestFailed : public TestException
+{
+ public:
+ TestFailed() = default;
+
+ //! \brief Failed test message creator
+ //!
+ //! \param[in] aTest string for tested expression
+ //! \param[in] aFile source file name
+ //! \param[in] aLine source file line
+ //! \param[in] aMessage error message
+ TestFailed(const char* aTest,
+ const char* aFile,
+ int aLine,
+ const std::string &aMessage);
+
+ TestFailed(const std::string &message) :
+ TestException(message)
+ {}
+};
+
+} // namespace Test
+} // namespace DPL
+
+#endif // DPL_TEST_FAILED_H
--- /dev/null
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @file test_ignored.h
+ * @author Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
+ * @version 1.0
+ * @brief This file is the header file of TestIgnored class
+ */
+
+#ifndef DPL_TEST_IGNORED_H
+#define DPL_TEST_IGNORED_H
+
+#include <string>
+
+#include <dpl/test/test_exception.h>
+
+namespace DPL {
+namespace Test {
+
+class TestIgnored : public TestException
+{
+ public:
+ TestIgnored() = default;
+
+ TestIgnored(const std::string &message) :
+ TestException(message)
+ {}
+};
+
+} // namespace Test
+} // namespace DPL
+
+#endif // DPL_TEST_IGNORED_H
#include <dpl/colors.h>
#include <dpl/gdbbacktrace.h>
#include <dpl/singleton.h>
+#include <dpl/test/test_failed.h>
+#include <dpl/test/test_ignored.h>
#include <dpl/test/test_results_collector.h>
namespace DPL {
const std::chrono::system_clock::duration& performanceMaxTime = std::chrono::microseconds::zero());
public:
- class TestFailed
- {
- private:
- std::string m_message;
-
- public:
- TestFailed()
- {}
-
- //! \brief Failed test message creator
- //!
- //! \param[in] aTest string for tested expression
- //! \param[in] aFile source file name
- //! \param[in] aLine source file line
- //! \param[in] aMessage error message
- TestFailed(const char* aTest,
- const char* aFile,
- int aLine,
- const std::string &aMessage);
-
- TestFailed(const std::string &message);
-
- std::string GetMessage() const
- {
- return m_message;
- }
- };
-
- class Ignored
- {
- private:
- std::string m_message;
-
- public:
- Ignored()
- {}
-
- Ignored(const std::string &message) :
- m_message(message)
- {}
-
- std::string GetMessage() const
- {
- return m_message;
- }
- };
-
void MarkAssertion();
void RegisterTest(const char *testName, TestCase proc);
{ \
std::ostringstream assertMsg; \
assertMsg << message << DPL::gdbbacktrace(); \
- DPL::Test::TestRunner::TestFailed e(#test, \
- __FILE__, \
- __LINE__, \
- assertMsg.str()); \
+ DPL::Test::TestFailed e(#test, \
+ __FILE__, \
+ __LINE__, \
+ assertMsg.str()); \
if (!std::uncaught_exception()) \
throw e; \
DPL::Test::TestRunnerSingleton::Instance().addFailReason(e.GetMessage()); \
if (!assertMsg.str().empty()) \
assertMsg << ". "; \
assertMsg << err << DPL::gdbbacktrace(); \
- DPL::Test::TestRunner::TestFailed e(#test, \
- __FILE__, \
- __LINE__, \
- assertMsg.str()); \
+ DPL::Test::TestFailed e(#test, \
+ __FILE__, \
+ __LINE__, \
+ assertMsg.str()); \
if (!std::uncaught_exception()) \
throw e; \
DPL::Test::TestRunnerSingleton::Instance().addFailReason(e.GetMessage()); \
* body.
*/
-#define RUNNER_IGNORED_MSG(message) \
- do \
- { \
- std::ostringstream assertMsg; \
- assertMsg << message; \
- throw DPL::Test::TestRunner::Ignored(assertMsg.str()); \
+#define RUNNER_IGNORED_MSG(message) \
+ do \
+ { \
+ std::ostringstream assertMsg; \
+ assertMsg << message; \
+ throw DPL::Test::TestIgnored(assertMsg.str()); \
} while (0)
/**
--- /dev/null
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @file test_failed.cpp
+ * @author Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
+ * @version 1.0
+ * @brief This file is the implementation file of TestFailed class
+ */
+
+#include <cstdlib>
+#include <cstring>
+#include <libgen.h>
+#include <memory>
+#include <sstream>
+
+#include <dpl/test/test_failed.h>
+
+namespace DPL {
+namespace Test {
+namespace // anonymous
+{
+std::string BaseName(const std::string &aPath)
+{
+ std::unique_ptr<char, decltype(free)*> path(strdup(aPath.c_str()), free);
+ if (!path)
+ throw std::bad_alloc();
+
+ return basename(path.get());
+}
+} // namespace anonymous
+
+//! \brief Failed test message creator
+//!
+//! \param[in] aTest string for tested expression
+//! \param[in] aFile source file name
+//! \param[in] aLine source file line
+//! \param[in] aMessage error message
+TestFailed::TestFailed(const char* aTest,
+ const char* aFile,
+ int aLine,
+ const std::string &aMessage)
+{
+ std::ostringstream assertMsg;
+ assertMsg << "[" << BaseName(aFile) << ":" << aLine
+ << "] Assertion failed ("
+ << aTest << ") " << aMessage;
+ m_message = assertMsg.str();
+}
+
+} // namespace Test
+} // namespace DPL
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2014-2015 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-/*
+/**
* @file test_runner.cpp
* @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
* @author Lukasz Wrzosek (l.wrzosek@samsung.com)
* @brief This file is the implementation file of test runner
*/
#include <stddef.h>
+#include <dpl/test/test_failed.h>
+#include <dpl/test/test_ignored.h>
#include <dpl/test/test_runner.h>
#include <dpl/test/test_results_collector.h>
#include <dpl/exception.h>
#include <algorithm>
#include <cstdio>
#include <memory.h>
-#include <libgen.h>
-#include <cstring>
-#include <cstdlib>
#include <libxml/xpath.h>
#include <libxml/xpathInternals.h>
namespace DPL {
namespace Test {
-namespace // anonymous
-{
-std::string BaseName(std::string aPath)
-{
- ScopedFree<char> path(strdup(aPath.c_str()));
- if (nullptr == path.Get()) {
- throw std::bad_alloc();
- }
- char* baseName = basename(path.Get());
- std::string retValue = baseName;
- return retValue;
-}
-} // namespace anonymous
-
-//! \brief Failed test message creator
-//!
-//! \param[in] aTest string for tested expression
-//! \param[in] aFile source file name
-//! \param[in] aLine source file line
-//! \param[in] aMessage error message
-TestRunner::TestFailed::TestFailed(const char* aTest,
- const char* aFile,
- int aLine,
- const std::string &aMessage)
-{
- std::ostringstream assertMsg;
- assertMsg << "[" << BaseName(aFile) << ":" << aLine
- << "] Assertion failed ("
- << aTest << ") " << aMessage;
- m_message = assertMsg.str();
-}
-
-TestRunner::TestFailed::TestFailed(const std::string &message)
-{
- m_message = message;
-}
void TestRunner::RegisterTest(const char *testName, TestCase proc)
{
setCurrentTestCase(nullptr);
return FAILED;
- } catch (const Ignored &e) {
+ } catch (const TestIgnored &e) {
if (m_runIgnored) {
// Simple test have to be implemented
CollectResult(testCase.name,
/*
- * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2013-2015 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-/*
+/**
* @file test_runner_child.cpp
* @author Bartlomiej Grzelewski (b.grzelewski@samsung.com)
* @version 1.0
* @brief This file is the implementation file of test runner
*/
#include <stddef.h>
+#include <dpl/test/test_failed.h>
+#include <dpl/test/test_ignored.h>
#include <dpl/test/test_runner.h>
#include <dpl/test/test_runner_child.h>
#include <dpl/test/test_results_collector.h>
{
PipeWrapper pipe;
if (!pipe.isReady()) {
- throw TestRunner::TestFailed("Pipe creation failed");
+ throw TestFailed("Pipe creation failed");
}
pid_t pid = fork();
if (pid == -1) {
- throw TestRunner::TestFailed("Child creation failed");
+ throw TestFailed("Child creation failed");
}
if (pid != 0) {
waitpid(pid, &status, 0);
if (pipeReturn == PipeWrapper::TIMEOUT) {
- throw TestRunner::TestFailed("Timeout");
+ throw TestFailed("Timeout");
}
if (pipeReturn == PipeWrapper::ERROR) {
- throw TestRunner::TestFailed("Reading pipe error");
+ throw TestFailed("Reading pipe error");
}
if (code == CHILD_TEST_PASS && msgType == MSG_TYPE_PERF_TIME) {
}
if (code == CHILD_TEST_FAIL) {
- throw TestRunner::TestFailed(message);
+ throw TestFailed(message);
} else if (code == CHILD_TEST_IGNORED) {
- throw TestRunner::Ignored(message);
+ throw TestIgnored(message);
}
} else {
// child code
try {
procChild();
- } catch (const DPL::Test::TestRunner::TestFailed &e) {
+ } catch (const DPL::Test::TestFailed &e) {
msg = e.GetMessage();
code = CHILD_TEST_FAIL;
- } catch (const DPL::Test::TestRunner::Ignored &e) {
+ } catch (const DPL::Test::TestIgnored &e) {
msg = e.GetMessage();
code = CHILD_TEST_IGNORED;
} catch (...) { // catch all exception generated by "user" code
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2014-2015 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-/*
+/**
* @file test_runner_multiprocess.cpp
* @author Marcin Niesluchowski (m.niesluchow@samsung.com)
* @version 1.0
#include <sys/file.h>
#include <dpl/exception.h>
+#include <dpl/test/test_failed.h>
+#include <dpl/test/test_ignored.h>
#include <dpl/test/test_runner.h>
#include <dpl/test/test_runner_child.h>
#include <dpl/test/test_runner_multiprocess.h>
pid_t top_pid = getpid();
if (!pipe.isReady()) {
- throw TestRunner::TestFailed("Pipe creation failed");
+ throw TestFailed("Pipe creation failed");
}
// pipe
try {
procMulti();
- } catch (const TestRunner::TestFailed &e) {
+ } catch (const TestFailed &e) {
code = MULTI_TEST_FAILED;
msg = e.GetMessage();
- } catch (const TestRunner::Ignored &e) {
+ } catch (const TestIgnored &e) {
code = MULTI_TEST_IGNORED;
msg = e.GetMessage();
} catch (const std::exception &) {
}
if (pipeReturn == PipeWrapper::ERROR) {
pipe.closeAll();
- throw TestRunner::TestFailed("Reading pipe error");
+ throw TestFailed("Reading pipe error");
} else if (pipeReturn == PipeWrapper::TIMEOUT) {
pipe.closeAll();
- throw TestRunner::TestFailed("Timeout error");
+ throw TestFailed("Timeout error");
}
msg = msg + "\n" + recMsg;
}
case MULTI_TEST_PASS:
return;
case MULTI_TEST_FAILED:
- throw TestRunner::TestFailed(msg);
+ throw TestFailed(msg);
case MULTI_TEST_IGNORED:
- throw TestRunner::Ignored(msg);
+ throw TestIgnored(msg);
default:
- throw TestRunner::TestFailed(msg);
+ throw TestFailed(msg);
}
} else {
pipe.setUsage(PipeWrapper::WRITEONLY);