* @brief Tests for the ODE API
*/
+#include <unistd.h>
+
#include <iostream>
#include <string>
+#include <utility>
#include <dpl/log/log.h>
ode_internal_encryption_umount();
ode_internal_encryption_clean_password(pass);
}
+
+std::unique_ptr<ServiceManager, std::function<void(ServiceManager*)>> createScopedOdeStopper() {
+ auto sm_start = [](ServiceManager* sm) {
+ try {
+ sm->startService(true);
+ delete sm;
+ sleep(1);
+ //TODO: startService should wait until the sm is really started but it does not
+ // because of that the sleep is needed
+ } catch (...) {
+ RUNNER_ERROR_MSG("Unexpected exception during service startup");
+ }
+ };
+ std::unique_ptr<ServiceManager, decltype(sm_start)> sm_stop(
+ new ServiceManager("ode.service", { "ode.socket" }),
+ std::move(sm_start));
+
+ sm_stop->stopService(true);
+
+ return sm_stop;
+}
#pragma once
#include <utility>
+#include <functional>
+#include <memory>
+
+#include <service_manager.h>
#include <dpl/test/test_runner.h>
HelperInternalEncryption(const char* password);
~HelperInternalEncryption();
};
+
+std::unique_ptr<ServiceManager, std::function<void(ServiceManager*)>> createScopedOdeStopper();
RUNNER_TEST(T1020_internal_encryption_connection_refused)
{
- auto sm_start = [](ServiceManager* sm) {
- sm->startService(true);
- delete sm;
- sleep(1);
- //TODO: startService should wait until the sm is really started but it does not
- // because of that the sleep is needed
- };
- std::unique_ptr<ServiceManager, decltype(sm_start)> sm_stop(new ServiceManager("ode.service"), sm_start);
- sm_stop->stopService(true);
+ auto sm_stop = createScopedOdeStopper();
unsigned int options = 0;
bool result;
#include <app_install_helper.h>
#include <tests_common.h>
#include <scoped_installer.h>
-#include <service_manager.h>
#include <ode/keys.h>
#include "ode-tests-common.h"
{
HelperKeys helper(device1, password);
- auto sm_start = [](ServiceManager* sm) {
- sm->startService(true);
- delete sm;
- };
- std::unique_ptr<ServiceManager, decltype(sm_start)> sm_stop(new ServiceManager("ode.service"), sm_start);
- sm_stop->stopService(true);
+ auto sm_stop = createScopedOdeStopper();
bool result;