From f235c0f5920a1dad41061311c2e89ccfb006104d Mon Sep 17 00:00:00 2001
From: Piotr Bartosiewicz
Date: Wed, 27 Aug 2014 11:44:41 +0200
Subject: [PATCH 01/16] Fix possible UB in unit tests
[Bug/Feature] Possible use of destroyed object in case when timeout
was reached.
[Cause] N/A
[Solution] N/A
[Verification] Build, install, run tests
Change-Id: Ie4cf064c4c5e5171079e836f1b4ca24b2962121c
---
tests/unit_tests/client/ut-client.cpp | 27 ++++++++++++-----------
tests/unit_tests/dbus/ut-connection.cpp | 8 +++----
tests/unit_tests/server/ut-containers-manager.cpp | 18 ++++++++-------
tests/unit_tests/server/ut-input-monitor.cpp | 8 +++++++
tests/unit_tests/utils/ut-callback-guard.cpp | 2 +-
tests/unit_tests/utils/ut-glib-loop.cpp | 7 +++---
6 files changed, 40 insertions(+), 30 deletions(-)
diff --git a/tests/unit_tests/client/ut-client.cpp b/tests/unit_tests/client/ut-client.cpp
index dc6045a..f3c636f 100644
--- a/tests/unit_tests/client/ut-client.cpp
+++ b/tests/unit_tests/client/ut-client.cpp
@@ -47,8 +47,8 @@ const std::string TEST_DBUS_CONFIG_PATH =
SC_TEST_CONFIG_INSTALL_DIR "/client/ut-client/test-dbus-daemon.conf";
struct Loop {
- Loop() { sc_start_glib_loop(); };
- ~Loop() { sc_stop_glib_loop(); };
+ Loop() { sc_start_glib_loop(); }
+ ~Loop() { sc_stop_glib_loop(); }
};
struct Fixture {
@@ -58,7 +58,7 @@ struct Fixture {
Fixture(): cm(TEST_DBUS_CONFIG_PATH)
{
cm.startAll();
- };
+ }
};
const int EVENT_TIMEOUT = 5000; ///< ms
@@ -99,15 +99,6 @@ int getArrayStringLength(ScArrayString astring, int max_len = -1)
return i;
}
-Latch signalReceivedLatch;
-std::vector< std::tuple > receivedSignalMsg;
-
-void NotificationTestCallback(const char* container, const char* application, const char* message)
-{
- receivedSignalMsg.push_back(std::make_tuple(container, application, message));
- signalReceivedLatch.set();
-}
-
} // namespace
BOOST_FIXTURE_TEST_SUITE(Client, Fixture)
@@ -198,6 +189,16 @@ BOOST_AUTO_TEST_CASE(SetActiveContainerTest)
BOOST_AUTO_TEST_CASE(NotificationTest)
{
+ // TODO add a void* to callback parameter and pass this two variables
+ // so that they no longer need to be global
+ static Latch signalReceivedLatch;
+ static std::vector< std::tuple > receivedSignalMsg;
+
+ auto callback = [](const char* container, const char* application, const char* message) {
+ receivedSignalMsg.push_back(std::make_tuple(container, application, message));
+ signalReceivedLatch.set();
+ };
+
std::map clients;
for (const auto& it : EXPECTED_DBUSES_STARTED) {
ScClient client = sc_client_create();
@@ -206,7 +207,7 @@ BOOST_AUTO_TEST_CASE(NotificationTest)
clients[it.first] = client;
}
for (auto& client : clients) {
- ScStatus status = sc_notification(client.second, NotificationTestCallback);
+ ScStatus status = sc_notification(client.second, callback);
BOOST_REQUIRE_EQUAL(SCCLIENT_SUCCESS, status);
}
for (auto& client : clients) {
diff --git a/tests/unit_tests/dbus/ut-connection.cpp b/tests/unit_tests/dbus/ut-connection.cpp
index 18d4f7b..1352f85 100644
--- a/tests/unit_tests/dbus/ut-connection.cpp
+++ b/tests/unit_tests/dbus/ut-connection.cpp
@@ -375,6 +375,7 @@ BOOST_AUTO_TEST_CASE(MethodAsyncCallTest)
ScopedDbusDaemon daemon;
ScopedGlibLoop loop;
Latch nameAcquired;
+ Latch callDone;
DbusConnection::Pointer conn1 = DbusConnection::create(DBUS_ADDRESS);
DbusConnection::Pointer conn2 = DbusConnection::create(DBUS_ADDRESS);
@@ -406,8 +407,6 @@ BOOST_AUTO_TEST_CASE(MethodAsyncCallTest)
};
conn1->registerObject(TESTAPI_OBJECT_PATH, TESTAPI_DEFINITION, handler);
- Latch callDone;
-
auto asyncResult1 = [&](dbus::AsyncMethodCallResult& asyncMethodCallResult) {
BOOST_CHECK(g_variant_is_of_type(asyncMethodCallResult.get(), G_VARIANT_TYPE_UNIT));
callDone.set();
@@ -455,6 +454,8 @@ BOOST_AUTO_TEST_CASE(MethodAsyncCallAsyncHandlerTest)
ScopedDbusDaemon daemon;
ScopedGlibLoop loop;
Latch nameAcquired;
+ Latch handlerDone;
+ Latch callDone;
DbusConnection::Pointer conn1 = DbusConnection::create(DBUS_ADDRESS);
DbusConnection::Pointer conn2 = DbusConnection::create(DBUS_ADDRESS);
@@ -464,7 +465,6 @@ BOOST_AUTO_TEST_CASE(MethodAsyncCallAsyncHandlerTest)
[] {});
BOOST_REQUIRE(nameAcquired.wait(EVENT_TIMEOUT));
- Latch handlerDone;
std::string strResult;
MethodResultBuilder::Pointer deferredResult;
@@ -486,8 +486,6 @@ BOOST_AUTO_TEST_CASE(MethodAsyncCallAsyncHandlerTest)
};
conn1->registerObject(TESTAPI_OBJECT_PATH, TESTAPI_DEFINITION, handler);
- Latch callDone;
-
auto asyncResult = [&](dbus::AsyncMethodCallResult& asyncMethodCallResult) {
const gchar* ret = NULL;
g_variant_get(asyncMethodCallResult.get(), "(&s)", &ret);
diff --git a/tests/unit_tests/server/ut-containers-manager.cpp b/tests/unit_tests/server/ut-containers-manager.cpp
index e8dc5de..e578a35 100644
--- a/tests/unit_tests/server/ut-containers-manager.cpp
+++ b/tests/unit_tests/server/ut-containers-manager.cpp
@@ -415,13 +415,14 @@ BOOST_AUTO_TEST_CASE(NotifyActiveContainerTest)
ContainersManager cm(TEST_DBUS_CONFIG_PATH);
cm.startAll();
+ Latch signalReceivedLatch;
+ std::map> signalReceivedSourcesMap;
+
std::map> dbuses;
for (int i = 1; i <= TEST_DBUS_CONNECTION_CONTAINERS_COUNT; ++i) {
dbuses[i] = std::unique_ptr(new DbusAccessory(i));
}
- Latch signalReceivedLatch;
- std::map> signalReceivedSourcesMap;
auto handler = [](Latch& latch,
std::vector& receivedSignalSources,
const std::string& /*senderBusName*/,
@@ -518,15 +519,16 @@ BOOST_AUTO_TEST_CASE(MoveFileTest)
ContainersManager cm(TEST_DBUS_CONFIG_PATH);
cm.startAll();
+ Latch notificationLatch;
+ std::string notificationSource;
+ std::string notificationPath;
+ std::string notificationRetcode;
+
std::map> dbuses;
for (int i = 1; i <= 2; ++i) {
dbuses[i] = std::unique_ptr(new DbusAccessory(i));
}
- Latch notificationLatch;
- std::string notificationSource;
- std::string notificationPath;
- std::string notificationRetcode;
auto handler = [&](const std::string& /*senderBusName*/,
const std::string& objectPath,
const std::string& interface,
@@ -763,11 +765,11 @@ BOOST_AUTO_TEST_CASE(GetContainerDbusesTest)
BOOST_AUTO_TEST_CASE(ContainerDbusesSignalsTest)
{
- DbusAccessory host(DbusAccessory::HOST_ID);
-
Latch signalLatch;
DbusAccessory::Dbuses collectedDbuses;
+ DbusAccessory host(DbusAccessory::HOST_ID);
+
auto onSignal = [&] (const std::string& /*senderBusName*/,
const std::string& objectPath,
const std::string& interface,
diff --git a/tests/unit_tests/server/ut-input-monitor.cpp b/tests/unit_tests/server/ut-input-monitor.cpp
index 13f1d51..99b0bd2 100644
--- a/tests/unit_tests/server/ut-input-monitor.cpp
+++ b/tests/unit_tests/server/ut-input-monitor.cpp
@@ -113,6 +113,8 @@ BOOST_AUTO_TEST_CASE(Config_deviceFilePathNotExisting)
InputMonitorException);
}
+namespace {
+
void sendNEvents(Fixture& f, unsigned int noOfEventsToSend)
{
Latch eventLatch;
@@ -146,6 +148,8 @@ void sendNEvents(Fixture& f, unsigned int noOfEventsToSend)
BOOST_CHECK(!eventLatch.wait(10));
}
+} // namespace
+
BOOST_AUTO_TEST_CASE(Event_oneAtATime)
{
sendNEvents(*this, 1);
@@ -156,6 +160,8 @@ BOOST_AUTO_TEST_CASE(Event_tenAtATime)
sendNEvents(*this, 10);
}
+namespace {
+
void sendNEventsWithPauses(Fixture& f, unsigned int noOfEventsToSend)
{
Latch eventLatch;
@@ -194,6 +200,8 @@ void sendNEventsWithPauses(Fixture& f, unsigned int noOfEventsToSend)
BOOST_CHECK(!eventLatch.wait(10));
}
+} // namespace
+
BOOST_AUTO_TEST_CASE(Event_oneAtATimeWithPauses)
{
sendNEventsWithPauses(*this, 1);
diff --git a/tests/unit_tests/utils/ut-callback-guard.cpp b/tests/unit_tests/utils/ut-callback-guard.cpp
index 6a503b0..9e1e6b2 100644
--- a/tests/unit_tests/utils/ut-callback-guard.cpp
+++ b/tests/unit_tests/utils/ut-callback-guard.cpp
@@ -68,9 +68,9 @@ BOOST_AUTO_TEST_CASE(SimpleTest)
BOOST_AUTO_TEST_CASE(ThreadTest)
{
- CallbackGuard guard;
Latch trackerCreated;
Latch trackerCanBeDestroyed;
+ CallbackGuard guard;
std::future future = std::async(std::launch::async, [&]() -> bool {
CallbackGuard::Tracker tracker = guard.spawn();
diff --git a/tests/unit_tests/utils/ut-glib-loop.cpp b/tests/unit_tests/utils/ut-glib-loop.cpp
index 63fc3ee..af07eef 100644
--- a/tests/unit_tests/utils/ut-glib-loop.cpp
+++ b/tests/unit_tests/utils/ut-glib-loop.cpp
@@ -29,7 +29,7 @@
#include "utils/latch.hpp"
#include "utils/glib-loop.hpp"
-#include
+#include
BOOST_AUTO_TEST_SUITE(UtilsGlibLoopSuite)
@@ -48,11 +48,12 @@ const unsigned int TIMER_WAIT_FOR = 2 * TIMER_NUMBER * TIMER_INTERVAL_MS;
BOOST_AUTO_TEST_CASE(GlibTimerEventTest)
{
ScopedGlibLoop loop;
- CallbackGuard guard;
Latch latch;
+ std::atomic_uint counter(0);
+
+ CallbackGuard guard;
Glib::OnTimerEventCallback callback = [&]()->bool {
- static unsigned int counter = 0;
latch.set();
if (++counter >= TIMER_NUMBER) {
return false;
--
2.7.4
From 325048b28534032b1401f65eed2580e9a9d64167 Mon Sep 17 00:00:00 2001
From: Dariusz Michaluk
Date: Fri, 22 Aug 2014 11:29:37 +0200
Subject: [PATCH 02/16] Fix incorrect network configuration
[Feature] Fix incorrect network configuration.
[Cause] Incorrect network netmask, filter name, ip address.
[Solution] N/A
[Verification] Build, install on new minimal image, run tests.
Change-Id: Idc1ddcd06c73297581f778b78d392bc34020c3cc
Signed-off-by: Dariusz Michaluk
---
server/configs/libvirt-config/business-network.xml | 2 +-
server/configs/libvirt-config/business-nwfilter.xml | 6 +++---
server/configs/libvirt-config/business.xml | 2 +-
server/configs/libvirt-config/private-network.xml | 2 +-
server/configs/libvirt-config/private-nwfilter.xml | 6 +++---
server/configs/libvirt-config/private.xml | 2 +-
tests/integration_tests/network_tests/network_common.py | 2 +-
7 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/server/configs/libvirt-config/business-network.xml b/server/configs/libvirt-config/business-network.xml
index beb5c80..dbfc6c4 100644
--- a/server/configs/libvirt-config/business-network.xml
+++ b/server/configs/libvirt-config/business-network.xml
@@ -4,7 +4,7 @@
-
+
diff --git a/server/configs/libvirt-config/business-nwfilter.xml b/server/configs/libvirt-config/business-nwfilter.xml
index ea7453e..6548f58 100644
--- a/server/configs/libvirt-config/business-nwfilter.xml
+++ b/server/configs/libvirt-config/business-nwfilter.xml
@@ -1,8 +1,8 @@
-
+
-
+
-
+
diff --git a/server/configs/libvirt-config/business.xml b/server/configs/libvirt-config/business.xml
index c2539e9..7564d8b 100644
--- a/server/configs/libvirt-config/business.xml
+++ b/server/configs/libvirt-config/business.xml
@@ -99,7 +99,7 @@
-
+
diff --git a/server/configs/libvirt-config/private-network.xml b/server/configs/libvirt-config/private-network.xml
index f917b52..7dec5a9 100644
--- a/server/configs/libvirt-config/private-network.xml
+++ b/server/configs/libvirt-config/private-network.xml
@@ -4,7 +4,7 @@
-
+
diff --git a/server/configs/libvirt-config/private-nwfilter.xml b/server/configs/libvirt-config/private-nwfilter.xml
index f3bd8ca..12dc793 100644
--- a/server/configs/libvirt-config/private-nwfilter.xml
+++ b/server/configs/libvirt-config/private-nwfilter.xml
@@ -1,8 +1,8 @@
-
+
-
+
-
+
diff --git a/server/configs/libvirt-config/private.xml b/server/configs/libvirt-config/private.xml
index d6ce465..b665a80 100644
--- a/server/configs/libvirt-config/private.xml
+++ b/server/configs/libvirt-config/private.xml
@@ -99,7 +99,7 @@
-
+
diff --git a/tests/integration_tests/network_tests/network_common.py b/tests/integration_tests/network_tests/network_common.py
index 2b64920..63289a6 100755
--- a/tests/integration_tests/network_tests/network_common.py
+++ b/tests/integration_tests/network_tests/network_common.py
@@ -235,7 +235,7 @@ def twoNetworks():
# 0. Test data
containers_list = [CONTAINER_T1, CONTAINER_T2]
dest_containers_list = [CONTAINER_T2, CONTAINER_T1]
- test_ip_list = [["192.168.101.2"], ["192.168.102.2"]]
+ test_ip_list = [["10.0.101.2"], ["10.0.102.2"]]
test_1_expected_res = [ 0, 0]
test_2_expected_res = [-1, -1]
--
2.7.4
From 269a8b8134def75be0b97c9379282a6845e93f48 Mon Sep 17 00:00:00 2001
From: Mateusz Malicki
Date: Wed, 27 Aug 2014 14:19:40 +0200
Subject: [PATCH 03/16] Added extra parameter to be passed to client callback
functions
[Bug/Feature] Possibility to pass parameters to callback functions
[Cause] N/A
[Solution] N/A
[Verification] Build, install, run tests
Change-Id: I8f060912aa3370b697c384289395ec1b884e3288
---
client/security-containers-client-impl.cpp | 14 +++++-----
client/security-containers-client-impl.hpp | 5 ++--
client/security-containers-client.cpp | 11 +++++---
client/security-containers-client.h | 14 +++++++---
tests/unit_tests/client/ut-client.cpp | 41 +++++++++++++++++++++---------
5 files changed, 56 insertions(+), 29 deletions(-)
diff --git a/client/security-containers-client-impl.cpp b/client/security-containers-client-impl.cpp
index 9e0a54a..3487dab 100644
--- a/client/security-containers-client-impl.cpp
+++ b/client/security-containers-client-impl.cpp
@@ -317,16 +317,16 @@ ScStatus Client::sc_set_active_container(const char* id) noexcept
return callMethod(HOST_INTERFACE, api::host::METHOD_SET_ACTIVE_CONTAINER, args_in);
}
-ScStatus Client::sc_container_dbus_state(ScContainerDbusStateCallback containerDbusStateCallback)
- noexcept
+ScStatus Client::sc_container_dbus_state(ScContainerDbusStateCallback containerDbusStateCallback,
+ void* data) noexcept
{
assert(containerDbusStateCallback);
- auto onSigal = [ = ](GVariant * parameters) {
+ auto onSigal = [=](GVariant * parameters) {
const char* container;
const char* dbusAddress;
g_variant_get(parameters, "(&s&s)", &container, &dbusAddress);
- containerDbusStateCallback(container, dbusAddress);
+ containerDbusStateCallback(container, dbusAddress, data);
};
return signalSubscribe(HOST_INTERFACE,
@@ -345,16 +345,16 @@ ScStatus Client::sc_notify_active_container(const char* application, const char*
args_in);
}
-ScStatus Client::sc_notification(ScNotificationCallback notificationCallback) noexcept
+ScStatus Client::sc_notification(ScNotificationCallback notificationCallback, void* data) noexcept
{
assert(notificationCallback);
- auto onSigal = [ = ](GVariant * parameters) {
+ auto onSigal = [=](GVariant * parameters) {
const char* container;
const char* application;
const char* message;
g_variant_get(parameters, "(&s&s&s)", &container, &application, &message);
- notificationCallback(container, application, message);
+ notificationCallback(container, application, message, data);
};
return signalSubscribe(CONTAINER_INTERFACE, api::container::SIGNAL_NOTIFICATION, onSigal);
diff --git a/client/security-containers-client-impl.hpp b/client/security-containers-client-impl.hpp
index d6c9c0d..13f06d3 100644
--- a/client/security-containers-client-impl.hpp
+++ b/client/security-containers-client-impl.hpp
@@ -124,7 +124,8 @@ public:
/**
* @see ::sc_container_dbus_state
*/
- ScStatus sc_container_dbus_state(ScContainerDbusStateCallback containerDbusStateCallback) noexcept;
+ ScStatus sc_container_dbus_state(ScContainerDbusStateCallback containerDbusStateCallback,
+ void* data) noexcept;
/**
* @see ::sc_notify_active_container
@@ -134,7 +135,7 @@ public:
/**
* @see ::sc_notification
*/
- ScStatus sc_notification(ScNotificationCallback notificationCallback) noexcept;
+ ScStatus sc_notification(ScNotificationCallback notificationCallback, void* data) noexcept;
/**
* @see ::sc_start_glib_loop
*/
diff --git a/client/security-containers-client.cpp b/client/security-containers-client.cpp
index f0b3f63..285d373 100644
--- a/client/security-containers-client.cpp
+++ b/client/security-containers-client.cpp
@@ -127,9 +127,10 @@ API ScStatus sc_set_active_container(ScClient client, const char* id)
}
API ScStatus sc_container_dbus_state(ScClient client,
- ScContainerDbusStateCallback containerDbusStateCallback)
+ ScContainerDbusStateCallback containerDbusStateCallback,
+ void* data)
{
- return getClient(client).sc_container_dbus_state(containerDbusStateCallback);
+ return getClient(client).sc_container_dbus_state(containerDbusStateCallback, data);
}
API ScStatus sc_notify_active_container(ScClient client,
@@ -139,7 +140,9 @@ API ScStatus sc_notify_active_container(ScClient client,
return getClient(client).sc_notify_active_container(application, message);
}
-API ScStatus sc_notification(ScClient client, ScNotificationCallback notificationCallback)
+API ScStatus sc_notification(ScClient client,
+ ScNotificationCallback notificationCallback,
+ void* data)
{
- return getClient(client).sc_notification(notificationCallback);
+ return getClient(client).sc_notification(notificationCallback, data);
}
diff --git a/client/security-containers-client.h b/client/security-containers-client.h
index aeb69fb..d1d6e95 100644
--- a/client/security-containers-client.h
+++ b/client/security-containers-client.h
@@ -150,7 +150,9 @@ void sc_string_free(ScString string);
/**
* Dbus state change callback function signature.
*/
-typedef void (*ScContainerDbusStateCallback)(const char* containerId, const char* dbusAddress);
+typedef void (*ScContainerDbusStateCallback)(const char* containerId,
+ const char* dbusAddress,
+ void* data);
/**
* Get dbus address of each container.
@@ -197,10 +199,12 @@ ScStatus sc_set_active_container(ScClient client, const char* id);
*
* @param client security-containers-server's client
* @param containerDbusStateCallback callback function
+ * @param data some extra data that will be passed to callback function
* @return status of this function call
*/
ScStatus sc_container_dbus_state(ScClient client,
- ScContainerDbusStateCallback containerDbusStateCallback);
+ ScContainerDbusStateCallback containerDbusStateCallback,
+ void* data);
/*************************************************************************************************
@@ -214,7 +218,8 @@ ScStatus sc_container_dbus_state(ScClient client,
*/
typedef void (*ScNotificationCallback)(const char* container,
const char* application,
- const char* message);
+ const char* message,
+ void* data);
/**
* Send message to active container.
*
@@ -232,9 +237,10 @@ ScStatus sc_notify_active_container(ScClient client, const char* application, co
*
* @param client security-containers-server's client
* @param notificationCallback callback function
+ * @param data some extra data that will be passed to callback function
* @return status of this function call
*/
-ScStatus sc_notification(ScClient client, ScNotificationCallback notificationCallback);
+ScStatus sc_notification(ScClient client, ScNotificationCallback notificationCallback, void* data);
#ifdef __cplusplus
}
#endif
diff --git a/tests/unit_tests/client/ut-client.cpp b/tests/unit_tests/client/ut-client.cpp
index f3c636f..c6249cd 100644
--- a/tests/unit_tests/client/ut-client.cpp
+++ b/tests/unit_tests/client/ut-client.cpp
@@ -189,16 +189,25 @@ BOOST_AUTO_TEST_CASE(SetActiveContainerTest)
BOOST_AUTO_TEST_CASE(NotificationTest)
{
- // TODO add a void* to callback parameter and pass this two variables
- // so that they no longer need to be global
- static Latch signalReceivedLatch;
- static std::vector< std::tuple > receivedSignalMsg;
-
- auto callback = [](const char* container, const char* application, const char* message) {
- receivedSignalMsg.push_back(std::make_tuple(container, application, message));
- signalReceivedLatch.set();
+ const std::string MSG_CONTENT = "msg";
+ const std::string MSG_APP = "app";
+
+ struct CallbackData {
+ Latch signalReceivedLatch;
+ std::vector< std::tuple > receivedSignalMsg;
+ };
+
+ auto callback = [](const char* container,
+ const char* application,
+ const char* message,
+ void* data)
+ {
+ CallbackData& callbackData = *reinterpret_cast(data);
+ callbackData.receivedSignalMsg.push_back(std::make_tuple(container, application, message));
+ callbackData.signalReceivedLatch.set();
};
+ CallbackData callbackData;
std::map clients;
for (const auto& it : EXPECTED_DBUSES_STARTED) {
ScClient client = sc_client_create();
@@ -207,16 +216,24 @@ BOOST_AUTO_TEST_CASE(NotificationTest)
clients[it.first] = client;
}
for (auto& client : clients) {
- ScStatus status = sc_notification(client.second, callback);
+ ScStatus status = sc_notification(client.second, callback, &callbackData);
BOOST_REQUIRE_EQUAL(SCCLIENT_SUCCESS, status);
}
for (auto& client : clients) {
- ScStatus status = sc_notify_active_container(client.second, "app", "msg");
+ ScStatus status = sc_notify_active_container(client.second,
+ MSG_APP.c_str(),
+ MSG_CONTENT.c_str());
BOOST_REQUIRE_EQUAL(SCCLIENT_SUCCESS, status);
}
- BOOST_CHECK(signalReceivedLatch.waitForN(clients.size() - 1, EVENT_TIMEOUT));
- BOOST_CHECK(signalReceivedLatch.empty());
+ BOOST_CHECK(callbackData.signalReceivedLatch.waitForN(clients.size() - 1, EVENT_TIMEOUT));
+ BOOST_CHECK(callbackData.signalReceivedLatch.empty());
+
+ for (const auto& msg : callbackData.receivedSignalMsg) {
+ BOOST_CHECK(clients.count(std::get<0>(msg)) > 0);
+ BOOST_CHECK_EQUAL(std::get<1>(msg), MSG_APP);
+ BOOST_CHECK_EQUAL(std::get<2>(msg), MSG_CONTENT);
+ }
for (auto& client : clients) {
sc_client_free(client.second);
--
2.7.4
From 7b9356173b7765ab27d2796ecd3f4afa8fdfb263 Mon Sep 17 00:00:00 2001
From: Mateusz Malicki
Date: Wed, 27 Aug 2014 15:25:45 +0200
Subject: [PATCH 04/16] Added sc_file_move_request client library function
[Bug/Feature] Added sc_file_move_request client library function
[Cause] N/A
[Solution] N/A
[Verification] Build, install, run tests
Change-Id: I6c0449a06a4b9b3ad9c17fda16d00099100f71ed
---
client/security-containers-client-impl.cpp | 27 +++++++++++++++++++++++++++
client/security-containers-client-impl.hpp | 4 ++++
client/security-containers-client.cpp | 5 +++++
client/security-containers-client.h | 9 +++++++++
tests/unit_tests/client/ut-client.cpp | 16 ++++++++++++++++
5 files changed, 61 insertions(+)
diff --git a/client/security-containers-client-impl.cpp b/client/security-containers-client-impl.cpp
index 3487dab..8486ae7 100644
--- a/client/security-containers-client-impl.cpp
+++ b/client/security-containers-client-impl.cpp
@@ -345,6 +345,33 @@ ScStatus Client::sc_notify_active_container(const char* application, const char*
args_in);
}
+ScStatus Client::sc_file_move_request(const char* destContainer, const char* path) noexcept
+{
+ assert(destContainer);
+ assert(path);
+
+ GVariant* out;
+ GVariant* args_in = g_variant_new("(ss)", destContainer, path);
+ ScStatus ret = callMethod(CONTAINER_INTERFACE,
+ api::container::METHOD_FILE_MOVE_REQUEST,
+ args_in,
+ "(s)",
+ &out);
+
+ if (ret != SCCLIENT_SUCCESS) {
+ return ret;
+ }
+ const gchar* retcode = NULL;;
+ g_variant_get(out, "(&s)", &retcode);
+ if (strcmp(retcode, api::container::FILE_MOVE_SUCCEEDED.c_str()) != 0) {
+ mStatus = Status(SCCLIENT_CUSTOM_ERROR, retcode);
+ g_variant_unref(out);
+ return sc_get_status();
+ }
+ g_variant_unref(out);
+ return ret;
+}
+
ScStatus Client::sc_notification(ScNotificationCallback notificationCallback, void* data) noexcept
{
assert(notificationCallback);
diff --git a/client/security-containers-client-impl.hpp b/client/security-containers-client-impl.hpp
index 13f06d3..10aecaf 100644
--- a/client/security-containers-client-impl.hpp
+++ b/client/security-containers-client-impl.hpp
@@ -133,6 +133,10 @@ public:
ScStatus sc_notify_active_container(const char* application, const char* message) noexcept;
/**
+ * @see ::sc_file_move_request
+ */
+ ScStatus sc_file_move_request(const char* destContainer, const char* path) noexcept;
+ /**
* @see ::sc_notification
*/
ScStatus sc_notification(ScNotificationCallback notificationCallback, void* data) noexcept;
diff --git a/client/security-containers-client.cpp b/client/security-containers-client.cpp
index 285d373..b1eb521 100644
--- a/client/security-containers-client.cpp
+++ b/client/security-containers-client.cpp
@@ -140,6 +140,11 @@ API ScStatus sc_notify_active_container(ScClient client,
return getClient(client).sc_notify_active_container(application, message);
}
+API ScStatus sc_file_move_request(ScClient client, const char* destContainer, const char* path)
+{
+ return getClient(client).sc_file_move_request(destContainer, path);
+}
+
API ScStatus sc_notification(ScClient client,
ScNotificationCallback notificationCallback,
void* data)
diff --git a/client/security-containers-client.h b/client/security-containers-client.h
index d1d6e95..1632497 100644
--- a/client/security-containers-client.h
+++ b/client/security-containers-client.h
@@ -231,6 +231,15 @@ typedef void (*ScNotificationCallback)(const char* container,
ScStatus sc_notify_active_container(ScClient client, const char* application, const char* message);
/**
+ * Move file between containers.
+ *
+ * @param client security-containers-server's client
+ * @param destContainer destination container id
+ * @param path path to moved file
+ */
+ScStatus sc_file_move_request(ScClient client, const char* destContainer, const char* path);
+
+/**
* Register notification callback function.
*
* The callback function will be invoked on a different thread.
diff --git a/tests/unit_tests/client/ut-client.cpp b/tests/unit_tests/client/ut-client.cpp
index c6249cd..bbf2013 100644
--- a/tests/unit_tests/client/ut-client.cpp
+++ b/tests/unit_tests/client/ut-client.cpp
@@ -29,6 +29,7 @@
#include "utils/latch.hpp"
#include "containers-manager.hpp"
+#include "container-dbus-definitions.hpp"
#include