2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License
18 * @author Kyungwook Tak(k.tak@samsung.com)
21 #define BOOST_TEST_MODULE CSR_API_TEST
25 #include <boost/test/unit_test.hpp>
26 #include <boost/test/unit_test_log.hpp>
27 #include <boost/test/results_reporter.hpp>
28 #include <colour_log_formatter.h>
30 #include <csr-engine-manager.h>
32 #include "test-common.h"
36 csr_state_e setEngineState(csr_engine_id_e id, csr_state_e state)
39 auto ret = csr_get_current_engine(id, &handle);
40 if (ret == CSR_ERROR_ENGINE_NOT_EXIST) {
41 BOOST_MESSAGE("engine not exist! engine id: " << static_cast<int>(id));
43 return CSR_STATE_DISABLE;
44 } else if (ret != CSR_ERROR_NONE) {
46 "Failed to csr_get_current_engine with ret: " <<
47 Test::capi_ec_to_string(ret));
49 return CSR_STATE_DISABLE;
52 csr_state_e current = CSR_STATE_DISABLE;
53 ret = csr_engine_get_state(handle, ¤t);
54 if (ret == CSR_ERROR_ENGINE_NOT_EXIST) {
55 BOOST_MESSAGE("Engine not exist! engine id: " << static_cast<int>(id));
56 return CSR_STATE_DISABLE;
57 } else if (ret != CSR_ERROR_NONE) {
59 "Failed to csr_engine_get_state with ret: " <<
60 Test::capi_ec_to_string(ret));
62 return CSR_STATE_DISABLE;
68 ret = csr_engine_set_state(handle, state);
69 BOOST_WARN_MESSAGE(ret != CSR_ERROR_NONE,
70 "Failed to csr_engine_set_state with ret: " <<
71 Test::capi_ec_to_string(ret));
81 boost::unit_test::unit_test_log.set_threshold_level(
82 boost::unit_test::log_test_units);
83 boost::unit_test::results_reporter::set_level(boost::unit_test::SHORT_REPORT);
84 boost::unit_test::unit_test_log.set_formatter(new Csr::Test::colour_log_formatter);
88 bool isEngineInitialized = false;
92 m_oldCsState = setEngineState(CSR_ENGINE_CS, CSR_STATE_ENABLE);
93 m_oldWpState = setEngineState(CSR_ENGINE_WP, CSR_STATE_ENABLE);
98 setEngineState(CSR_ENGINE_CS, m_oldCsState);
99 setEngineState(CSR_ENGINE_WP, m_oldWpState);
102 csr_state_e m_oldCsState;
103 csr_state_e m_oldWpState;
106 BOOST_GLOBAL_FIXTURE(TestConfig);
107 BOOST_GLOBAL_FIXTURE(Initializer);