From: Lukasz Wojciechowski Date: Thu, 16 Oct 2014 17:23:13 +0000 (+0200) Subject: Create cynara_async_tests group X-Git-Tag: security-manager_5.5_testing~191 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8e2f08dd2a0b070735bc185672e722ff0ddf764a;p=platform%2Fcore%2Ftest%2Fsecurity-tests.git Create cynara_async_tests group Create a test group for asynchronous API tests and add CynaraTestAsync::Client initialization test. Change-Id: I0e8cc37cd16282a7834cc61dd72e1aa90fb9129e --- diff --git a/tests/cynara-tests/CMakeLists.txt b/tests/cynara-tests/CMakeLists.txt index b4788719..05d9c2a2 100644 --- a/tests/cynara-tests/CMakeLists.txt +++ b/tests/cynara-tests/CMakeLists.txt @@ -19,9 +19,11 @@ SET(CYNARA_TARGET_TEST_SOURCES ${PROJECT_SOURCE_DIR}/tests/cynara-tests/common/cynara_test_client.cpp ${PROJECT_SOURCE_DIR}/tests/cynara-tests/common/cynara_test_client_async_client.cpp ${PROJECT_SOURCE_DIR}/tests/cynara-tests/common/cynara_test_client_async_status_monitor.cpp + ${PROJECT_SOURCE_DIR}/tests/cynara-tests/common/cynara_test_commons.cpp ${PROJECT_SOURCE_DIR}/tests/cynara-tests/common/cynara_test_env.cpp ${PROJECT_SOURCE_DIR}/tests/cynara-tests/cynara-test.cpp ${PROJECT_SOURCE_DIR}/tests/cynara-tests/test_cases.cpp + ${PROJECT_SOURCE_DIR}/tests/cynara-tests/test_cases_async.cpp ) #header directories diff --git a/tests/cynara-tests/common/cynara_test_commons.cpp b/tests/cynara-tests/common/cynara_test_commons.cpp new file mode 100644 index 00000000..74c821e5 --- /dev/null +++ b/tests/cynara-tests/common/cynara_test_commons.cpp @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2014 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. + */ + +#include +#include + +#include +#include + +#include + +void environmentWrap(const char *testName, const std::function &func) +{ + CynaraTestEnv env(testName); + env.save(); + + try { + func(); + } catch (const DPL::Test::TestRunner::TestFailed &e) { + env.restore(); + throw e; + } catch (const DPL::Test::TestRunner::Ignored &e) { + env.restore(); + throw e; + } catch (const DPL::Exception &e) { + env.restore(); + throw e; + } catch (const std::exception &e) { + env.restore(); + throw e; + } catch (...) { + env.restore(); + throw std::runtime_error("Unknown exception"); + } + env.restore(); +} diff --git a/tests/cynara-tests/common/cynara_test_commons.h b/tests/cynara-tests/common/cynara_test_commons.h new file mode 100644 index 00000000..2d971039 --- /dev/null +++ b/tests/cynara-tests/common/cynara_test_commons.h @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2014 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 cynara_test_commons.h + * @author Lukasz Wojciechowski + * @version 1.0 + * @brief Definition of environment wrap for test cases + */ + +#ifndef CYNARA_TEST_COMMONS_H_ +#define CYNARA_TEST_COMMONS_H_ + +#include + +void environmentWrap(const char *testName, const std::function &func); + +#define RUN_CYNARA_TEST(Proc) \ + RUNNER_TEST(Proc) \ + { \ + environmentWrap(#Proc, Proc##_func); \ + } + +#endif /* CYNARA_TEST_COMMONS_H_ */ diff --git a/tests/cynara-tests/test_cases.cpp b/tests/cynara-tests/test_cases.cpp index cb32d5f4..a5c2bc73 100644 --- a/tests/cynara-tests/test_cases.cpp +++ b/tests/cynara-tests/test_cases.cpp @@ -18,51 +18,19 @@ * @file test_cases.cpp * @author Aleksander Zdyb * @author Marcin Niesluchowski + * @author Lukasz Wojciechowski * @version 1.1 * @brief Tests for libcynara-client and libcynara-admin */ -#include +#include + #include #include #include -#include -#include #include -void environmentWrap(const char *testName, const std::function &func) -{ - CynaraTestEnv env(testName); - env.save(); - - try { - func(); - } catch (const DPL::Test::TestRunner::TestFailed &e) { - env.restore(); - throw e; - } catch (const DPL::Test::TestRunner::Ignored &e) { - env.restore(); - throw e; - } catch (const DPL::Exception &e) { - env.restore(); - throw e; - } catch (const std::exception &e) { - env.restore(); - throw e; - } catch (...) { - env.restore(); - throw std::runtime_error("Unknown exception"); - } - env.restore(); -} - -#define RUN_CYNARA_TEST(Proc) \ - RUNNER_TEST(Proc) \ - { \ - environmentWrap(#Proc, Proc##_func); \ - } - void tc01_cynara_initialize_func() { CynaraTestClient(); diff --git a/tests/cynara-tests/test_cases_async.cpp b/tests/cynara-tests/test_cases_async.cpp new file mode 100644 index 00000000..74b045c5 --- /dev/null +++ b/tests/cynara-tests/test_cases_async.cpp @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2014 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_cases_async.cpp + * @author Lukasz Wojciechowski + * @version 1.0 + * @brief Tests for libcynara-client-async + */ + +#include +#include + +#include + +void tca01_initialize_func() +{ + CynaraTestClientAsync::Client client; +} + +RUNNER_TEST_GROUP_INIT(cynara_async_tests) + +RUN_CYNARA_TEST(tca01_initialize)