summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorKrzysztof Jackiewicz <k.jackiewicz@samsung.com>2015-01-28 14:56:18 +0100
committerMaciej J. Karpiuk <m.karpiuk2@samsung.com>2015-02-17 12:09:37 +0100
commitde72a2708601b99449b8d0c4ff8da05b1bdcad03 (patch)
tree70d8bd1368849614d2b4a017e5673f9cac3e72ee /tests
parentef12755a0563f493acb6e74526d7770ffec39cd9 (diff)
downloadkey-manager-de72a2708601b99449b8d0c4ff8da05b1bdcad03.tar.gz
key-manager-de72a2708601b99449b8d0c4ff8da05b1bdcad03.tar.bz2
key-manager-de72a2708601b99449b8d0c4ff8da05b1bdcad03.zip
Fix logs in internal tests
[Issue#] N/A [Feature/Bug] N/A [Problem] No logs from internal tests [Cause] LogSystem tag was not set [Solution] Internal tests refactored and cleaned up. Proper tag set. [Verification] Run internal tests and see if logs are visible Change-Id: Ibb8517bad710d06a62ba9ba7fbc7b9b8ed7b7c21
Diffstat (limited to 'tests')
-rw-r--r--tests/CMakeLists.txt10
-rw-r--r--tests/main.cpp69
-rw-r--r--tests/test-key-provider.cpp23
-rw-r--r--tests/test_common.h14
-rw-r--r--tests/test_db_crypto.cpp6
-rw-r--r--tests/test_descriptor-set.cpp2
-rw-r--r--tests/test_safe-buffer.cpp2
7 files changed, 72 insertions, 54 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 21478fa2..9725e5ab 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -1,9 +1,3 @@
-PKG_CHECK_MODULES(KEY_MANAGER_TEST_DEP
- dlog
- openssl
- REQUIRED
- )
-
ADD_DEFINITIONS( "-DBOOST_TEST_DYN_LINK" )
SET(KEY_MANAGER_SRC_PATH ${PROJECT_SOURCE_DIR}/src)
@@ -26,6 +20,7 @@ INCLUDE_DIRECTORIES(
)
SET(TEST_MERGED_SOURCES
+ ${KEY_MANAGER_TEST_MERGED_SRC}/main.cpp
${KEY_MANAGER_TEST_MERGED_SRC}/test_common.cpp
${KEY_MANAGER_TEST_MERGED_SRC}/DBFixture.cpp
${KEY_MANAGER_TEST_MERGED_SRC}/colour_log_formatter.cpp
@@ -42,9 +37,6 @@ SET(TEST_MERGED_SOURCES
ADD_EXECUTABLE(${TARGET_TEST_MERGED} ${TEST_MERGED_SOURCES})
TARGET_LINK_LIBRARIES(${TARGET_TEST_MERGED}
- ${KEY_MANAGER_CLIENT_DEP_LIBRARIES}
- ${KEY_MANAGER_DEP_LIBRARIES}
- ${TARGET_KEY_MANAGER_CLIENT}
${TARGET_KEY_MANAGER_COMMON}
boost_unit_test_framework
)
diff --git a/tests/main.cpp b/tests/main.cpp
new file mode 100644
index 00000000..737ae12e
--- /dev/null
+++ b/tests/main.cpp
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2000 - 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 main.cpp
+ * @author Krzysztof Jackiewicz (k.jackiewicz@samsung.com)
+ * @version 1.0
+ */
+
+#include <key-provider.h>
+#include <boost/test/unit_test.hpp>
+#include <boost/test/unit_test_log.hpp>
+#include <boost/test/results_reporter.hpp>
+#include <colour_log_formatter.h>
+#include <dpl/log/log.h>
+
+struct TestConfig {
+ TestConfig() {
+ boost::unit_test::unit_test_log.set_threshold_level( boost::unit_test::log_test_units);
+ boost::unit_test::results_reporter::set_level(boost::unit_test::SHORT_REPORT);
+ boost::unit_test::unit_test_log.set_formatter(new CKM::colour_log_formatter);
+ }
+ ~TestConfig(){
+ }
+};
+
+bool isLibInitialized = false;
+
+struct KeyProviderLib {
+ KeyProviderLib() {
+ Try {
+ CKM::KeyProvider::initializeLibrary();
+ isLibInitialized = true;
+ }
+ Catch (CKM::Exception) {
+ std::cout << "Library initialization failed!" << std::endl;
+ }
+ }
+ ~KeyProviderLib() {
+ Try { CKM::KeyProvider::closeLibrary(); }
+ Catch (CKM::Exception) {
+ std::cout << "Library deinitialization failed!" << std::endl;
+ }
+ }
+};
+
+struct LogSetup {
+ LogSetup() {
+ CKM::Singleton<CKM::Log::LogSystem>::Instance().SetTag("CKM_INTERNAL_TESTS");
+ }
+ ~LogSetup() {}
+};
+
+BOOST_GLOBAL_FIXTURE(KeyProviderLib)
+BOOST_GLOBAL_FIXTURE(TestConfig)
+BOOST_GLOBAL_FIXTURE(LogSetup)
+
diff --git a/tests/test-key-provider.cpp b/tests/test-key-provider.cpp
index f841ae36..433e8ecb 100644
--- a/tests/test-key-provider.cpp
+++ b/tests/test-key-provider.cpp
@@ -13,28 +13,7 @@ const std::string USERNAME_LONG = "SOFTWARE_CENTER_SYSTEM_SW_LAB_SECURITY_PART";
const std::string SMACK_LABEL_1 = "SAMPLE_SMACK_LABEL_1";
const std::string SMACK_LABEL_2 = "SAMPLE_SMACK_LABEL_2";
-static bool isLibInitialized = false;
-
-struct KeyProviderLib {
- KeyProviderLib() {
- Try {
- CKM::KeyProvider::initializeLibrary();
- isLibInitialized = true;
- }
- Catch (CKM::Exception) {
- std::cout << "Library initialization failed!" << std::endl;
- }
- }
- ~KeyProviderLib() {
- Try { CKM::KeyProvider::closeLibrary(); }
- Catch (CKM::Exception) {
- std::cout << "Library deinitialization failed!" << std::endl;
- }
- }
-};
-
-BOOST_GLOBAL_FIXTURE(TestConfig)
-BOOST_GLOBAL_FIXTURE(KeyProviderLib)
+extern bool isLibInitialized;
BOOST_AUTO_TEST_SUITE(KEY_PROVIDER_TEST)
BOOST_AUTO_TEST_CASE(KeyDomainKEK){
diff --git a/tests/test_common.h b/tests/test_common.h
index 5a6279cb..04878f37 100644
--- a/tests/test_common.h
+++ b/tests/test_common.h
@@ -1,20 +1,6 @@
#pragma once
#include <string>
#include <ckm/ckm-type.h>
-#include <boost/test/unit_test_log.hpp>
-#include <boost/test/results_reporter.hpp>
-#include <colour_log_formatter.h>
-
-struct TestConfig {
- TestConfig() {
- boost::unit_test::unit_test_log.set_threshold_level( boost::unit_test::log_test_units);
- boost::unit_test::results_reporter::set_level(boost::unit_test::SHORT_REPORT);
- boost::unit_test::unit_test_log.set_formatter(new CKM::colour_log_formatter);
- }
- ~TestConfig(){
- }
-private:
-};
// mirrors the API-defined value
#ifndef AES_GCM_TAG_SIZE
diff --git a/tests/test_db_crypto.cpp b/tests/test_db_crypto.cpp
index 12567206..6539876f 100644
--- a/tests/test_db_crypto.cpp
+++ b/tests/test_db_crypto.cpp
@@ -1,5 +1,4 @@
#include <boost/test/unit_test.hpp>
-#include <boost/test/results_reporter.hpp>
#include <unistd.h>
#include <db-crypto.h>
#include <iostream>
@@ -9,8 +8,6 @@
#include <test_common.h>
#include <DBFixture.h>
-BOOST_GLOBAL_FIXTURE(TestConfig)
-
using namespace CKM;
namespace
@@ -22,8 +19,7 @@ const unsigned int c_test_retries = 1000;
const unsigned int c_num_names = 500;
const unsigned int c_num_names_add_test = 5000;
const unsigned int c_names_per_label = 15;
-}
-
+} // namespace anonymous
BOOST_FIXTURE_TEST_SUITE(DBCRYPTO_TEST, DBFixture)
BOOST_AUTO_TEST_CASE(DBtestSimple) {
diff --git a/tests/test_descriptor-set.cpp b/tests/test_descriptor-set.cpp
index a58a817e..1cabe377 100644
--- a/tests/test_descriptor-set.cpp
+++ b/tests/test_descriptor-set.cpp
@@ -34,8 +34,6 @@
#include <descriptor-set.h>
-BOOST_GLOBAL_FIXTURE(TestConfig)
-
using namespace CKM;
namespace {
diff --git a/tests/test_safe-buffer.cpp b/tests/test_safe-buffer.cpp
index 691f02c3..b56e8241 100644
--- a/tests/test_safe-buffer.cpp
+++ b/tests/test_safe-buffer.cpp
@@ -5,8 +5,6 @@
#include <ckm/ckm-raw-buffer.h>
-BOOST_GLOBAL_FIXTURE(TestConfig)
-
using namespace CKM;
namespace {