2 * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
4 * Contact: Lukasz Kostyra <l.kostyra@samsung.com>
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License
21 * @author Lukasz Kostyra (l.kostyra@samsung.com)
22 * @brief Mini-service for IPC Socket mechanism tests
26 #include "socket-test.hpp"
27 #include "logger/logger.hpp"
28 #include "logger/backend-journal.hpp"
29 #include "ipc/internals/socket.hpp"
30 #include "ipc/exception.hpp"
35 using namespace vasum::socket_test;
37 using namespace logger;
39 // NOTE this is a single-usage program, only meant to test vasum::ipc::Socket module.
40 // It's purpose is to be activated when needed by systemd socket activation mechanism.
43 Logger::setLogLevel(LogLevel::TRACE);
44 Logger::setLogBackend(new SystemdJournalBackend());
47 Socket listeningSocket(Socket::createSocket(SOCKET_PATH));
48 if (listeningSocket.getFD() < 0) {
49 LOGE("Failed to connect to socket!");
53 std::shared_ptr<Socket> clientSocket = listeningSocket.accept();
54 LOGI("Connected! Emitting message to client.");
55 clientSocket->write(TEST_MESSAGE.c_str(), TEST_MESSAGE.size());
56 LOGI("Message sent through socket! Exiting.");
57 } catch (const IPCException& e) {
58 LOGE("IPC exception caught! " << e.what());