diff options
author | Konrad Lipinski <k.lipinski2@partner.samsung.com> | 2018-10-15 09:31:41 +0200 |
---|---|---|
committer | Konrad Lipinski <k.lipinski2@partner.samsung.com> | 2018-10-15 09:34:06 +0200 |
commit | 3392b1bbbc4024f980913c1ae339d219ee88a932 (patch) | |
tree | 6edef8140a18b88f542678adae45be6d580ff14e /test | |
parent | 75293c9c70f3f04c86721039bedfd6e0bf0786a8 (diff) | |
download | security-manager-3392b1bbbc4024f980913c1ae339d219ee88a932.tar.gz security-manager-3392b1bbbc4024f980913c1ae339d219ee88a932.tar.bz2 security-manager-3392b1bbbc4024f980913c1ae339d219ee88a932.zip |
Replace runtime production/test db choice with compile-time policy
Change-Id: Ia13c7ec92f0ffdf4c2341b395a31b8097b4eeddd
Diffstat (limited to 'test')
-rw-r--r-- | test/privilege_db_fixture.cpp | 3 | ||||
-rw-r--r-- | test/privilege_db_fixture.h | 1 | ||||
-rw-r--r-- | test/test_privilege_db_migration.cpp | 1 | ||||
-rw-r--r-- | test/test_privilege_db_privilege.cpp | 2 | ||||
-rw-r--r-- | test/test_privilege_db_transactions.cpp | 3 | ||||
-rw-r--r-- | test/testconfig.h | 33 |
6 files changed, 40 insertions, 3 deletions
diff --git a/test/privilege_db_fixture.cpp b/test/privilege_db_fixture.cpp index 707e61f2..4079dd54 100644 --- a/test/privilege_db_fixture.cpp +++ b/test/privilege_db_fixture.cpp @@ -30,6 +30,7 @@ #include <config.h> #include <filesystem.h> +#include <testconfig.h> #include <utils.h> #include "privilege_db.h" @@ -101,7 +102,7 @@ PrivilegeDBFixture::PrivilegeDBFixture(const std::string &src, const std::string putFile(fallback, TEST_PRIVILEGE_FALLBACK_DB_PATH); forkExecWaitpid(TEST_RULES_LOADER_CMD, "no-load"); checkMarker(preMgr); - testPrivDb = new PrivilegeDb(PrivilegeDb::Offline::no, PrivilegeDb::Db::test); + testPrivDb = new PrivilegeDb(PrivilegeDb::Offline::no, Config::DbTest()); checkMarker(PostMgrMarker::unchanged == postMgr ? preMgr : Marker::fallback); } diff --git a/test/privilege_db_fixture.h b/test/privilege_db_fixture.h index c13d13c6..9b79e0dc 100644 --- a/test/privilege_db_fixture.h +++ b/test/privilege_db_fixture.h @@ -21,6 +21,7 @@ #include <string> #include <sys/types.h> +#include "config.h" #include "privilege_db.h" #define PRIVILEGE_DB_TEMPLATE DB_TEST_DIR"/.security-manager-test.db" diff --git a/test/test_privilege_db_migration.cpp b/test/test_privilege_db_migration.cpp index 26630474..ba450ac6 100644 --- a/test/test_privilege_db_migration.cpp +++ b/test/test_privilege_db_migration.cpp @@ -23,6 +23,7 @@ #include <config.h> #include <filesystem.h> +#include <testconfig.h> #include "privilege_db.h" #include "privilege_db_fixture.h" diff --git a/test/test_privilege_db_privilege.cpp b/test/test_privilege_db_privilege.cpp index acff28c4..c121342d 100644 --- a/test/test_privilege_db_privilege.cpp +++ b/test/test_privilege_db_privilege.cpp @@ -28,7 +28,7 @@ #include <boost/test/results_reporter.hpp> #include <boost/test/utils/wrap_stringstream.hpp> -#include <config.h> // TEST_DB_PATH +#include <testconfig.h> // TEST_DB_PATH #include "privilege_db.h" #include "privilege_db_fixture.h" diff --git a/test/test_privilege_db_transactions.cpp b/test/test_privilege_db_transactions.cpp index cbfa2730..272d3465 100644 --- a/test/test_privilege_db_transactions.cpp +++ b/test/test_privilege_db_transactions.cpp @@ -29,6 +29,7 @@ #include <config.h> #include <filesystem.h> +#include <testconfig.h> #include "privilege_db.h" #include "privilege_db_fixture.h" @@ -46,7 +47,7 @@ BOOST_FIXTURE_TEST_CASE(T100_privilegedb_constructor, Empty) purgeDb(); // db init must fail w/ no loader having run beforehand - BOOST_REQUIRE_THROW(testPrivDb.reset(new PrivilegeDb(PrivilegeDb::Offline::no, PrivilegeDb::Db::test)), + BOOST_REQUIRE_THROW(testPrivDb.reset(new PrivilegeDb(PrivilegeDb::Offline::no, Config::DbTest())), PrivilegeDb::Exception::IOError); requireNoDb(); } diff --git a/test/testconfig.h b/test/testconfig.h new file mode 100644 index 00000000..215e241e --- /dev/null +++ b/test/testconfig.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2018 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 + */ +#pragma once + +#define TEST_DB_OK_MARKER "/tmp/.security-manager-test.db.ok" +#define TEST_RULES_LOADER_CMD "/usr/bin/security-manager-test-rules-loader" +#define TEST_DB_PATH "/tmp/.security-manager-test.db" +#define TEST_PRIVILEGE_FALLBACK_DB_PATH "/tmp/.security-manager-test.fallback.db" + +namespace SecurityManager { +namespace Config { + +struct DbTest { + static auto path() { return TEST_DB_PATH; } + static auto okMarkerPath() { return TEST_DB_OK_MARKER; } + static auto loaderCmd() { return TEST_RULES_LOADER_CMD; } +}; + +} // namespace Config +} // namespace SecurityManager |