diff options
author | Colm Donelan <Colm.Donelan@arm.com> | 2019-10-11 13:09:49 +0100 |
---|---|---|
committer | Colm Donelan <Colm.Donelan@arm.com> | 2019-10-11 13:12:37 +0100 |
commit | a21620d32a8a0a8d527c061e2a22d51009d75877 (patch) | |
tree | b08ffee4cddb1bb3b1d206c67ea80bc2093d7bf5 /tests/profiling/GatordMockService.cpp | |
parent | 67ef2a52c3cdcc37538d77711bbcea2f0e5655e5 (diff) | |
download | armnn-a21620d32a8a0a8d527c061e2a22d51009d75877.tar.gz |
IVGCVSW-3721 Add support for startup sequence (Mock Gatord service).
* Receive and process the stream metadata from the client.
* Send the connection ack packet.
* Wait in a receiving thread and print the packets.
* GatordMockTest and Impl for PeriodicCounterCapture CommandHandler
* CaptureData class to retain packet data
* MockUtils
* Update SocketProfilingConnection to fix non blocking receipt of packets.
* Restructure directory layout following review comments.
* Extract the mock service into a static library in the cmake files.
Signed-off-by: Colm Donelan <Colm.Donelan@arm.com>
Signed-off-by: Keith Davis <keith.davis@arm.com>
Signed-off-by: Mike Kelly <mike.kelly@arm.com>
Signed-off-by: Finn Williams <Finn.Williams@arm.com>
Signed-off-by: Kevin May <kevin.may@arm.com>
Change-Id: I33c1c9f93976708c9315f71290d42cff53b8c075
Diffstat (limited to 'tests/profiling/GatordMockService.cpp')
-rw-r--r-- | tests/profiling/GatordMockService.cpp | 71 |
1 files changed, 0 insertions, 71 deletions
diff --git a/tests/profiling/GatordMockService.cpp b/tests/profiling/GatordMockService.cpp deleted file mode 100644 index c774ab0b45..0000000000 --- a/tests/profiling/GatordMockService.cpp +++ /dev/null @@ -1,71 +0,0 @@ -// -// Copyright © 2019 Arm Ltd. All rights reserved. -// SPDX-License-Identifier: MIT -// - -#include "GatordMockService.hpp" - -#include <cerrno> -#include <fcntl.h> -#include <iostream> -#include <string> -#include <sys/socket.h> -#include <sys/un.h> - -namespace armnn -{ - -namespace gatordmock -{ - - -bool GatordMockService::OpenListeningSocket(std::string udsNamespace) -{ - m_ListeningSocket = socket(PF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0); - if (-1 == m_ListeningSocket) - { - std::cerr << ": Socket construction failed: " << strerror(errno) << std::endl; - return false; - } - - sockaddr_un udsAddress; - memset(&udsAddress, 0, sizeof(sockaddr_un)); - // We've set the first element of sun_path to be 0, skip over it and copy the namespace after it. - memcpy(udsAddress.sun_path + 1, udsNamespace.c_str(), strlen(udsNamespace.c_str())); - udsAddress.sun_family = AF_UNIX; - - // Bind the socket to the UDS namespace. - if (-1 == bind(m_ListeningSocket, reinterpret_cast<const sockaddr *>(&udsAddress), sizeof(sockaddr_un))) - { - std::cerr << ": Binding on socket failed: " << strerror(errno) << std::endl; - return false; - } - // Listen for 1 connection. - if (-1 == listen(m_ListeningSocket, 1)) - { - std::cerr << ": Listen call on socket failed: " << strerror(errno) << std::endl; - return false; - } - std::cout << "Bound to UDS namespace: \\0" << udsNamespace << std::endl; - return true; -} - -int GatordMockService::BlockForOneClient() -{ - std::cout << "Waiting for client connection." << std::endl; - - int accepted = accept4(m_ListeningSocket, nullptr, nullptr, SOCK_CLOEXEC); - if (-1 == accepted) - { - std::cerr << ": Failure when waiting for a client connection: " << strerror(errno) << std::endl; - return -1; - } - - std::cout << "Client connection established." << std::endl; - return accepted; -} - - -} // namespace gatordmock - -} // namespace armnn |