summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElisey Zamakhov <EZamakhov@luxoft.com>2015-10-20 12:55:19 +0300
committerElisey Zamakhov <EZamakhov@luxoft.com>2015-10-26 20:33:27 +0300
commitbd80f42b4592333d19a49c8448b96c3620fc810b (patch)
tree1fa9f0db3e09514fa73934d4fdbc6ad9599564b6
parentfb001871f96eec538c2446ab512f6098f2d51a39 (diff)
downloadsdl_core-bd80f42b4592333d19a49c8448b96c3620fc810b.tar.gz
Add MultiFrame assembling verification with DCHECKs
Added multiframes frame data and connection key verifications Add DCHECK for ProtocolHandlerImpl::OnTMMessageSendFailed Implemented ProtocolHeader and ProtocolPacket streaming to basic_ostream Fix DCHECK logging appender to Utils Minor logging fixs in ProtocolHandlerImpl, ProtocolPacket Time_tester include and build fixs cpplint fixs Issue:APPLINK-17144, APPLINK-16741
-rw-r--r--src/components/include/utils/macro.h11
-rw-r--r--src/components/protocol_handler/include/protocol_handler/protocol_handler_impl.h7
-rw-r--r--src/components/protocol_handler/include/protocol_handler/protocol_packet.h38
-rw-r--r--src/components/protocol_handler/src/incoming_data_handler.cc5
-rw-r--r--src/components/protocol_handler/src/protocol_handler_impl.cc210
-rw-r--r--src/components/protocol_handler/src/protocol_packet.cc26
-rw-r--r--src/components/time_tester/CMakeLists.txt4
-rw-r--r--src/components/time_tester/include/time_tester/application_manager_metric.h4
-rw-r--r--src/components/time_tester/include/time_tester/application_manager_observer.h2
-rw-r--r--src/components/time_tester/include/time_tester/protocol_handler_metric.h2
-rw-r--r--src/components/time_tester/include/time_tester/time_manager.h6
-rw-r--r--src/components/time_tester/include/time_tester/transport_manager_metric.h4
-rw-r--r--src/components/time_tester/src/application_manager_metric.cc4
-rw-r--r--src/components/time_tester/src/application_manager_observer.cc6
-rw-r--r--src/components/time_tester/src/metric_wrapper.cc36
-rw-r--r--src/components/time_tester/src/protocol_handler_metric.cc4
-rw-r--r--src/components/time_tester/src/protocol_handler_observer.cc13
-rw-r--r--src/components/time_tester/src/time_manager.cc2
-rw-r--r--src/components/time_tester/src/transport_manager_metric.cc4
-rw-r--r--src/components/time_tester/src/transport_manager_observer.cc6
-rw-r--r--src/components/transport_manager/src/transport_manager_impl.cc4
-rw-r--r--src/components/utils/src/threads/posix_thread.cc43
-rw-r--r--test/components/transport_manager/src/mock_connection_factory.cc18
-rw-r--r--test/components/transport_manager/src/mock_transport_adapter.cc10
24 files changed, 283 insertions, 186 deletions
diff --git a/src/components/include/utils/macro.h b/src/components/include/utils/macro.h
index 75019863b2..3e7a8c25bb 100644
--- a/src/components/include/utils/macro.h
+++ b/src/components/include/utils/macro.h
@@ -39,7 +39,6 @@
#endif
#include "logger.h"
-
// A macro to set some action for variable to avoid "unused variable" warning
#define UNUSED(x) (void)x;
// A macro to disallow the copy constructor and operator= functions
@@ -73,7 +72,7 @@
#define DCHECK(condition) \
if (!(condition)) { \
- CREATE_LOGGERPTR_LOCAL(logger_, "assert"); \
+ CREATE_LOGGERPTR_LOCAL(logger_, "Utils"); \
LOG4CXX_FATAL(logger_, "DCHECK failed with \"" << #condition \
<< "\" [" << __FUNCTION__ << "][" << __FILE__ << ':' << __LINE__ << ']'); \
ASSERT((condition)); \
@@ -85,9 +84,9 @@
*/
#define DCHECK_OR_RETURN(condition, return_value) \
if (!(condition)) { \
- CREATE_LOGGERPTR_LOCAL(logger_, "assert"); \
+ CREATE_LOGGERPTR_LOCAL(logger_, "Utils"); \
LOG4CXX_FATAL(logger_, "DCHECK failed with \"" << #condition \
- << "\" [" << __FUNCTION__ << "][" << __FILE__ << ':' << __LINE__ << ']' ); \
+ << "\" [" << __FUNCTION__ << "][" << __FILE__ << ':' << __LINE__ << ']'); \
ASSERT((condition)); \
return (return_value); \
}
@@ -97,9 +96,9 @@
*/
#define DCHECK_OR_RETURN_VOID(condition) \
if (!(condition)) { \
- CREATE_LOGGERPTR_LOCAL(logger_, "assert"); \
+ CREATE_LOGGERPTR_LOCAL(logger_, "Utils"); \
LOG4CXX_FATAL(logger_, "DCHECK failed with \"" << #condition \
- << "\" [" << __FUNCTION__ << "][" << __FILE__ << ':' << __LINE__ << ']' ); \
+ << "\" [" << __FUNCTION__ << "][" << __FILE__ << ':' << __LINE__ << ']'); \
ASSERT((condition)); \
return ; \
}
diff --git a/src/components/protocol_handler/include/protocol_handler/protocol_handler_impl.h b/src/components/protocol_handler/include/protocol_handler/protocol_handler_impl.h
index 46155c4c67..260ad16ec7 100644
--- a/src/components/protocol_handler/include/protocol_handler/protocol_handler_impl.h
+++ b/src/components/protocol_handler/include/protocol_handler/protocol_handler_impl.h
@@ -37,6 +37,8 @@
#include <memory>
#include <set>
#include <list>
+#include <cstdint>
+#include <utility> // std::make_pair
#include "utils/prioritized_queue.h"
#include "utils/message_queue.h"
#include "utils/threads/message_loop_thread.h"
@@ -493,9 +495,10 @@ class ProtocolHandlerImpl
transport_manager::TransportManager *transport_manager_;
/**
- *\brief Map of frames for messages received in multiple frames.
+ *\brief Map of frames with last frame data for messages received in multiple frames.
*/
- std::map<int32_t, ProtocolFramePtr> incomplete_multi_frame_messages_;
+ typedef std::map<int32_t, ProtocolFramePtr> MultiFrameMap;
+ MultiFrameMap incomplete_multi_frame_messages_;
/**
* \brief Map of messages (frames) received over mobile nave session
diff --git a/src/components/protocol_handler/include/protocol_handler/protocol_packet.h b/src/components/protocol_handler/include/protocol_handler/protocol_packet.h
index 0b4b253a84..db0650cfd8 100644
--- a/src/components/protocol_handler/include/protocol_handler/protocol_packet.h
+++ b/src/components/protocol_handler/include/protocol_handler/protocol_packet.h
@@ -199,10 +199,12 @@ class ProtocolPacket {
uint8_t service_type() const;
/**
- *\brief Getter of frame data (start/end session, number of frame etc)
+ *\brief Getter and setter of frame data (start/end session, number of frame etc)
*/
uint8_t frame_data() const;
+ void set_frame_data(const uint8_t frame_data);
+
/**
*\brief Getter of session number
*/
@@ -250,6 +252,11 @@ class ProtocolPacket {
*/
uint32_t payload_size() const;
+ /**
+ * \brief Getter for full header information
+ */
+ const ProtocolHeader& packet_header() const;
+
private:
/**
*\brief Protocol header
@@ -279,4 +286,33 @@ class ProtocolPacket {
* @brief Type definition for variable that hold shared pointer to protocolol packet
*/
typedef utils::SharedPtr<protocol_handler::ProtocolPacket> ProtocolFramePtr;
+
+template<typename _CharT>
+std::basic_ostream<_CharT>& operator<<(std::basic_ostream<_CharT>& stream,
+ const protocol_handler::ProtocolPacket::ProtocolHeader& header) {
+ stream << "Version: " << static_cast<uint32_t>(header.version) <<
+ ", Protection: " << (header.protection_flag ? "ON" : "OFF") <<
+ ", FrameType: " << static_cast<uint32_t>(header.frameType) <<
+ ", ServiceType: " << static_cast<uint32_t>(header.serviceType) <<
+ ", FrameData: " << static_cast<uint32_t>(header.frameData) <<
+ ", SessionId: " << static_cast<uint32_t>(header.sessionId) <<
+ ", DataSize: " << static_cast<uint32_t>(header.dataSize) <<
+ ", MessageId: " << static_cast<uint32_t>(header.messageId);
+ return stream;
+}
+template<typename _CharT>
+std::basic_ostream<_CharT>& operator<<(std::basic_ostream<_CharT>& stream,
+ const protocol_handler::ProtocolPacket& packet) {
+ stream << packet.packet_header() <<
+ ", ConnectionID: " << (packet.connection_id()) <<
+ ", TotalDataBytes: " << (packet.total_data_bytes()) <<
+ ", Data: " << static_cast<void*>(packet.data());
+ return stream;
+}
+template<typename _CharT>
+std::basic_ostream<_CharT>& operator<<(std::basic_ostream<_CharT>& stream,
+ const ProtocolFramePtr packet_ptr) {
+ stream << *packet_ptr;
+ return stream;
+}
#endif // SRC_COMPONENTS_PROTOCOL_HANDLER_INCLUDE_PROTOCOL_HANDLER_PROTOCOL_PACKET_H_
diff --git a/src/components/protocol_handler/src/incoming_data_handler.cc b/src/components/protocol_handler/src/incoming_data_handler.cc
index 840ce88947..43b0898cc2 100644
--- a/src/components/protocol_handler/src/incoming_data_handler.cc
+++ b/src/components/protocol_handler/src/incoming_data_handler.cc
@@ -126,7 +126,8 @@ uint32_t IncomingDataHandler::GetPacketSize(
case PROTOCOL_VERSION_4:
return header.dataSize + PROTOCOL_HEADER_V2_SIZE;
default:
- LOG4CXX_WARN(logger_, "Unknown version");
+ LOG4CXX_WARN(logger_, "Unknown version: " <<
+ static_cast<int>(header.version));
break;
}
return 0u;
@@ -177,6 +178,8 @@ RESULT_CODE IncomingDataHandler::CreateFrame(
ProtocolFramePtr frame(new protocol_handler::ProtocolPacket(connection_id));
const RESULT_CODE deserialize_result =
frame->deserializePacket(&*data_it, packet_size);
+ LOG4CXX_DEBUG(
+ logger_, "Deserialized frame " << frame);
if (deserialize_result != RESULT_OK) {
LOG4CXX_WARN(logger_, "Packet deserialization failed");
incoming_data.erase(incoming_data.begin(), data_it);
diff --git a/src/components/protocol_handler/src/protocol_handler_impl.cc b/src/components/protocol_handler/src/protocol_handler_impl.cc
index f75651b951..dccfffdf04 100644
--- a/src/components/protocol_handler/src/protocol_handler_impl.cc
+++ b/src/components/protocol_handler/src/protocol_handler_impl.cc
@@ -90,7 +90,8 @@ ProtocolHandlerImpl::ProtocolHandlerImpl(
{
LOG4CXX_AUTO_TRACE(logger_);
- protocol_header_validator_.set_max_payload_size(profile::Profile::instance()->maximum_payload_size());
+ protocol_header_validator_.set_max_payload_size(
+ profile::Profile::instance()->maximum_payload_size());
incoming_data_handler_.set_validator(&protocol_header_validator_);
if (message_frequency_time_ > 0u &&
@@ -103,11 +104,12 @@ ProtocolHandlerImpl::ProtocolHandlerImpl(
}
if (malformed_message_filtering_) {
- if(malformed_message_frequency_time_ > 0u &&
- malformed_message_max_frequency_ > 0u) {
+ if (malformed_message_frequency_time_ > 0u &&
+ malformed_message_max_frequency_ > 0u) {
malformed_message_meter_.set_time_range(malformed_message_frequency_time_);
- LOG4CXX_DEBUG(logger_, "Malformed frequency meter is enabled ( " << malformed_message_max_frequency_
- << " per " << malformed_message_frequency_time_ << " mSecond)");
+ LOG4CXX_DEBUG(logger_, "Malformed frequency meter is enabled ( "
+ << malformed_message_max_frequency_ << " per "
+ << malformed_message_frequency_time_ << " mSecond)");
} else {
LOG4CXX_WARN(logger_, "Malformed frequency meter is disabled");
}
@@ -296,15 +298,15 @@ RESULT_CODE ProtocolHandlerImpl::SendHeartBeatAck(ConnectionID connection_id,
uint8_t protocol_version;
if (session_observer_->ProtocolVersionUsed(connection_id,
- session_id, protocol_version)) {
- ProtocolFramePtr ptr(new protocol_handler::ProtocolPacket(connection_id,
+ session_id, protocol_version)) {
+ ProtocolFramePtr ptr(new protocol_handler::ProtocolPacket(connection_id,
protocol_version, PROTECTION_OFF, FRAME_TYPE_CONTROL,
- SERVICE_TYPE_CONTROL, FRAME_DATA_HEART_BEAT_ACK, session_id,
- 0u, message_id));
+ SERVICE_TYPE_CONTROL, FRAME_DATA_HEART_BEAT_ACK, session_id,
+ 0u, message_id));
- raw_ford_messages_to_mobile_.PostMessage(
- impl::RawFordMessageToMobile(ptr, false));
- return RESULT_OK;
+ raw_ford_messages_to_mobile_.PostMessage(
+ impl::RawFordMessageToMobile(ptr, false));
+ return RESULT_OK;
}
LOG4CXX_WARN(logger_, "SendHeartBeatAck is failed connection or session does not exist");
return RESULT_FAIL;
@@ -315,9 +317,9 @@ void ProtocolHandlerImpl::SendHeartBeat(int32_t connection_id,
LOG4CXX_AUTO_TRACE(logger_);
uint8_t protocol_version;
if (session_observer_->ProtocolVersionUsed(connection_id,
- session_id, protocol_version)) {
+ session_id, protocol_version)) {
ProtocolFramePtr ptr(new protocol_handler::ProtocolPacket(connection_id,
- protocol_version, PROTECTION_OFF, FRAME_TYPE_CONTROL,
+ protocol_version, PROTECTION_OFF, FRAME_TYPE_CONTROL,
SERVICE_TYPE_CONTROL, FRAME_DATA_HEART_BEAT, session_id,
0u, message_counters_[session_id]++));
@@ -442,10 +444,10 @@ void ProtocolHandlerImpl::OnTMMessageReceived(const RawMessagePtr tm_message) {
" msg data_size " << tm_message->data_size());
RESULT_CODE result;
- size_t malformed_occurs = false;
+ size_t malformed_occurs = 0u;
const std::list<ProtocolFramePtr> protocol_frames =
incoming_data_handler_.ProcessData(*tm_message, &result, &malformed_occurs);
- LOG4CXX_DEBUG(logger_, "Proccessed " << protocol_frames.size() << "frames");
+ LOG4CXX_DEBUG(logger_, "Proccessed " << protocol_frames.size() << " frames");
if (result != RESULT_OK) {
if (result == RESULT_MALFORMED_OCCURS) {
LOG4CXX_WARN(logger_, "Malformed message occurs, connection id "
@@ -557,9 +559,11 @@ void ProtocolHandlerImpl::OnTMMessageSend(const RawMessagePtr message) {
void ProtocolHandlerImpl::OnTMMessageSendFailed(
const transport_manager::DataSendError &error,
const RawMessagePtr message) {
+ DCHECK_OR_RETURN_VOID(message);
// TODO(PV): implement
LOG4CXX_ERROR(logger_, "Sending message " << message->data_size()
- << " bytes failed: " << error.text());
+ << "bytes failed, connection_key " << message->connection_key()
+ << "Error_text: " << error.text());
}
void ProtocolHandlerImpl::OnConnectionEstablished(
@@ -597,7 +601,7 @@ RESULT_CODE ProtocolHandlerImpl::SendFrame(const ProtocolFramePtr packet) {
if (!message_to_send) {
LOG4CXX_ERROR(logger_, "Serialization error");
return RESULT_FAIL;
- };
+ }
LOG4CXX_DEBUG(logger_,
"Message to send with connection id " <<
static_cast<int>(packet->connection_id()));
@@ -610,7 +614,7 @@ RESULT_CODE ProtocolHandlerImpl::SendFrame(const ProtocolFramePtr packet) {
transport_manager_->SendMessageToDevice(message_to_send)) {
LOG4CXX_WARN(logger_, "Can't send message to device");
return RESULT_FAIL;
- };
+ }
return RESULT_OK;
}
@@ -703,20 +707,21 @@ RESULT_CODE ProtocolHandlerImpl::SendMultiFrameMessage(
RESULT_CODE ProtocolHandlerImpl::HandleMessage(ConnectionID connection_id,
const ProtocolFramePtr packet) {
- LOG4CXX_AUTO_TRACE(logger_);
+ DCHECK_OR_RETURN(packet, RESULT_UNKNOWN);
+ LOG4CXX_DEBUG(logger_, "Handling message " << packet);
switch (packet->frame_type()) {
case FRAME_TYPE_CONTROL:
- LOG4CXX_TRACE(logger_, "handleMessage() - case FRAME_TYPE_CONTROL");
+ LOG4CXX_TRACE(logger_, "FRAME_TYPE_CONTROL");
return HandleControlMessage(connection_id, packet);
case FRAME_TYPE_SINGLE:
- LOG4CXX_TRACE(logger_, "handleMessage() - case FRAME_TYPE_SINGLE");
+ LOG4CXX_TRACE(logger_, "FRAME_TYPE_SINGLE");
return HandleSingleFrameMessage(connection_id, packet);
case FRAME_TYPE_FIRST:
case FRAME_TYPE_CONSECUTIVE:
- LOG4CXX_TRACE(logger_, "handleMessage() - case FRAME_TYPE_FIRST or FRAME_TYPE_CONSECUTIVE");
+ LOG4CXX_TRACE(logger_, "FRAME_TYPE_FIRST or FRAME_TYPE_CONSECUTIVE");
return HandleMultiFrameMessage(connection_id, packet);
default: {
- LOG4CXX_WARN(logger_, "handleMessage() - case unknown frame type"
+ LOG4CXX_WARN(logger_, "Unknown frame type"
<< packet->frame_type());
return RESULT_FAIL;
}
@@ -784,78 +789,87 @@ RESULT_CODE ProtocolHandlerImpl::HandleMultiFrameMessage(
"Packet " << packet << "; session id " << static_cast<int32_t>(key));
if (packet->frame_type() == FRAME_TYPE_FIRST) {
- LOG4CXX_DEBUG(logger_, "handleMultiFrameMessage() - FRAME_TYPE_FIRST "
- << packet->data_size());
+ LOG4CXX_TRACE(logger_, "FRAME_TYPE_FIRST");
+ // First frame has no data
+ DCHECK_OR_RETURN(packet->frame_data() == 0u, RESULT_FAIL);
+ // We can not handle more than one multiframe with the same key
+ DCHECK_OR_RETURN(incomplete_multi_frame_messages_.count(key) == 0,
+ RESULT_FAIL);
incomplete_multi_frame_messages_[key] = packet;
- } else {
- LOG4CXX_DEBUG(logger_, "handleMultiFrameMessage() - Consecutive frame");
+ return RESULT_OK;
+ }
+ DCHECK_OR_RETURN(packet->frame_type() == FRAME_TYPE_CONSECUTIVE, RESULT_FAIL)
- std::map<int32_t, ProtocolFramePtr>::iterator it =
- incomplete_multi_frame_messages_.find(key);
+ MultiFrameMap::iterator it = incomplete_multi_frame_messages_.find(key);
+ if (it == incomplete_multi_frame_messages_.end()) {
+ LOG4CXX_ERROR(logger_,
+ "Frame of multiframe message for non-existing session id " << key);
+ return RESULT_FAIL;
+ }
- if (it == incomplete_multi_frame_messages_.end()) {
- LOG4CXX_ERROR(
- logger_, "Frame of multiframe message for non-existing session id");
- return RESULT_FAIL;
- }
+ ProtocolFramePtr& assembling_frame = it->second;
+ const uint8_t previous_frame_data = assembling_frame->frame_data();
+ const uint8_t new_frame_data = packet->frame_data();
- if (it->second->appendData(packet->data(), packet->data_size())
- != RESULT_OK) {
- LOG4CXX_ERROR(logger_,
- "Failed to append frame for multiframe message.");
- return RESULT_FAIL;
- }
+ const bool is_last_consecutive = (new_frame_data == FRAME_DATA_LAST_CONSECUTIVE);
+ // The next frame data is bigger at 1
+ DCHECK_OR_RETURN((new_frame_data == (previous_frame_data + 1)) ||
+ // except the last consecutive frame
+ is_last_consecutive, RESULT_FAIL);
- if (packet->frame_data() == FRAME_DATA_LAST_CONSECUTIVE) {
- LOG4CXX_DEBUG(
- logger_,
- "Last frame of multiframe message size " << packet->data_size()
- << "; connection key " << key);
- {
- sync_primitives::AutoLock lock(protocol_observers_lock_);
- if (protocol_observers_.empty()) {
- LOG4CXX_ERROR(
- logger_,
- "Cannot handle multiframe message: no IProtocolObserver is set.");
- return RESULT_FAIL;
- }
- }
+ assembling_frame->set_frame_data(new_frame_data);
- ProtocolFramePtr completePacket = it->second;
- const uint32_t connection_key =
- session_observer_->KeyFromPair(connection_id,
- completePacket->session_id());
- const RawMessagePtr rawMessage(
- new RawMessage(connection_key,
- completePacket->protocol_version(),
- completePacket->data(),
- completePacket->total_data_bytes(),
- completePacket->service_type(),
- completePacket->payload_size()));
+ LOG4CXX_DEBUG(logger_,
+ "Appending " << packet->data_size() << " bytes "
+ << "; frame_data " << static_cast<int>(new_frame_data)
+ << "; connection key " << key);
- LOG4CXX_DEBUG(logger_,
- "total_data_bytes " << completePacket->total_data_bytes() <<
- " packet_size " << completePacket->packet_size() <<
- " data size " << completePacket->data_size() <<
- " payload_size " << completePacket->payload_size());
+ DCHECK_OR_RETURN(packet->message_id() == assembling_frame->message_id(), RESULT_FAIL);
+ if (assembling_frame->appendData(packet->data(), packet->data_size()) != RESULT_OK) {
+ LOG4CXX_ERROR(logger_, "Failed to append frame for multiframe message.");
+ return RESULT_FAIL;
+ }
- if (!rawMessage) {
+ if (is_last_consecutive) {
+ LOG4CXX_DEBUG(
+ logger_,
+ "Last frame of multiframe message size " << packet->data_size()
+ << "; connection key " << key);
+ {
+ sync_primitives::AutoLock lock(protocol_observers_lock_);
+ if (protocol_observers_.empty()) {
+ LOG4CXX_ERROR(
+ logger_,
+ "Cannot handle multiframe message: no IProtocolObserver is set.");
return RESULT_FAIL;
}
+ }
+ const uint32_t connection_key =
+ session_observer_->KeyFromPair(connection_id,
+ assembling_frame->session_id());
+ LOG4CXX_DEBUG(logger_, "Result frame" << assembling_frame <<
+ "for connection "<< connection_key);
+ const RawMessagePtr rawMessage(
+ new RawMessage(connection_key,
+ assembling_frame->protocol_version(),
+ assembling_frame->data(),
+ assembling_frame->total_data_bytes(),
+ assembling_frame->service_type(),
+ assembling_frame->payload_size()));
+ DCHECK_OR_RETURN(rawMessage, RESULT_FAIL);
#ifdef TIME_TESTER
- if (metric_observer_) {
- PHMetricObserver::MessageMetric *metric =
- new PHMetricObserver::MessageMetric();
- metric->raw_msg = rawMessage;
- metric_observer_->EndMessageProcess(metric);
- }
+ if (metric_observer_) {
+ PHMetricObserver::MessageMetric *metric =
+ new PHMetricObserver::MessageMetric();
+ metric->raw_msg = rawMessage;
+ metric_observer_->EndMessageProcess(metric);
+ }
#endif // TIME_TESTER
- // TODO(EZamakhov): check service in session
- NotifySubscribers(rawMessage);
+ // TODO(EZamakhov): check service in session
+ NotifySubscribers(rawMessage);
- incomplete_multi_frame_messages_.erase(it);
- }
+ incomplete_multi_frame_messages_.erase(it);
}
return RESULT_OK;
}
@@ -921,8 +935,8 @@ RESULT_CODE ProtocolHandlerImpl::HandleControlMessageEndSession(
// TODO(EZamakhov): add clean up output queue (for removed service)
if (session_key != 0) {
- SendEndSessionAck( connection_id, current_session_id,
- packet.protocol_version(), service_type);
+ SendEndSessionAck(connection_id, current_session_id,
+ packet.protocol_version(), service_type);
message_counters_.erase(current_session_id);
} else {
LOG4CXX_WARN(
@@ -1014,7 +1028,7 @@ class StartSessionHandler : public security_manager::SecurityManagerListener {
RESULT_CODE ProtocolHandlerImpl::HandleControlMessageStartSession(
ConnectionID connection_id, const ProtocolPacket &packet) {
LOG4CXX_DEBUG(logger_,
- "Protocol version: " <<
+ "Protocol version:" <<
static_cast<int>(packet.protocol_version()));
const ServiceType service_type = ServiceTypeFromByte(packet.service_type());
const uint8_t protocol_version = packet.protocol_version();
@@ -1099,8 +1113,7 @@ RESULT_CODE ProtocolHandlerImpl::HandleControlMessageHeartBeat(
PROTOCOL_VERSION_4 == protocol_version) {
return SendHeartBeatAck(connection_id, packet.session_id(),
packet.message_id());
- }
- else {
+ } else {
LOG4CXX_WARN(logger_, "HeartBeat is not supported");
return RESULT_HEARTBEAT_IS_NOT_SUPPORTED;
}
@@ -1264,7 +1277,7 @@ RESULT_CODE ProtocolHandlerImpl::EncryptFrame(ProtocolFramePtr packet) {
packet->connection_id(), packet->session_id(),
packet->message_id(), kRpc);
return RESULT_OK;
- };
+ }
LOG4CXX_DEBUG(logger_, "Encrypted " << packet->data_size() << " bytes to "
<< out_data_size << " bytes");
DCHECK(out_data);
@@ -1314,7 +1327,7 @@ RESULT_CODE ProtocolHandlerImpl::DecryptFrame(ProtocolFramePtr packet) {
packet->connection_id(), packet->session_id(),
packet->message_id(), kRpc);
return RESULT_ENCRYPTION_FAILED;
- };
+ }
LOG4CXX_DEBUG(logger_, "Decrypted " << packet->data_size() << " bytes to "
<< out_data_size << " bytes");
DCHECK(out_data);
@@ -1335,24 +1348,23 @@ void ProtocolHandlerImpl::SendFramesNumber(uint32_t connection_key,
session_observer_->PairFromKey(connection_key, &connection_id, &session_id);
uint8_t protocol_version;
if (session_observer_->ProtocolVersionUsed(connection_id, session_id,
- protocol_version)) {
+ protocol_version)) {
ProtocolFramePtr ptr(new protocol_handler::ProtocolPacket(connection_id,
- protocol_version, PROTECTION_OFF, FRAME_TYPE_CONTROL,
- SERVICE_TYPE_NAVI, FRAME_DATA_SERVICE_DATA_ACK,
- session_id, 0, message_counters_[session_id]++));
+ protocol_version, PROTECTION_OFF, FRAME_TYPE_CONTROL,
+ SERVICE_TYPE_NAVI, FRAME_DATA_SERVICE_DATA_ACK,
+ session_id, 0, message_counters_[session_id]++));
// Flow control data shall be 4 bytes according Ford Protocol
DCHECK(sizeof(number_of_frames) == 4);
number_of_frames = LE_TO_BE32(number_of_frames);
ptr->set_data(reinterpret_cast<const uint8_t*>(&number_of_frames),
- sizeof(number_of_frames));
- raw_ford_messages_to_mobile_.PostMessage(
- impl::RawFordMessageToMobile(ptr, false));
- LOG4CXX_DEBUG(logger_, "SendFramesNumber finished successfully");
+ sizeof(number_of_frames));
+ raw_ford_messages_to_mobile_.PostMessage(
+ impl::RawFordMessageToMobile(ptr, false));
+ LOG4CXX_DEBUG(logger_, "SendFramesNumber finished successfully");
} else {
- LOG4CXX_WARN(logger_, "SendFramesNumber is failed connection or session does not exist");
+ LOG4CXX_WARN(logger_, "SendFramesNumber is failed connection or session does not exist");
}
-
}
#ifdef TIME_TESTER
diff --git a/src/components/protocol_handler/src/protocol_packet.cc b/src/components/protocol_handler/src/protocol_packet.cc
index 2378c2cfbe..1ed6e05699 100644
--- a/src/components/protocol_handler/src/protocol_packet.cc
+++ b/src/components/protocol_handler/src/protocol_packet.cc
@@ -109,7 +109,7 @@ void ProtocolPacket::ProtocolHeader::deserialize(
switch (version) {
case PROTOCOL_VERSION_2:
case PROTOCOL_VERSION_3:
- case PROTOCOL_VERSION_4:{
+ case PROTOCOL_VERSION_4: {
if (messageSize < PROTOCOL_HEADER_V2_SIZE) {
LOG4CXX_DEBUG(logger_, "Message size less " << PROTOCOL_HEADER_V2_SIZE << " bytes");
return;
@@ -118,7 +118,8 @@ void ProtocolPacket::ProtocolHeader::deserialize(
}
break;
default:
- LOG4CXX_WARN(logger_, "Unknown version");
+ LOG4CXX_WARN(logger_, "Unknown version:" <<
+ static_cast<int>(version));
messageId = 0;
break;
}
@@ -140,7 +141,7 @@ size_t ProtocolPacket::ProtocolHeaderValidator::max_payload_size() const {
RESULT_CODE ProtocolPacket::ProtocolHeaderValidator::validate(
const ProtocolHeader& header) const {
- LOG4CXX_AUTO_TRACE(logger_);
+ LOG4CXX_DEBUG(logger_, "Validating header - " << header);
// expected payload size will be calculated depending
// on used protocol version
size_t payload_size = MAXIMUM_FRAME_DATA_V2_SIZE;
@@ -155,7 +156,7 @@ RESULT_CODE ProtocolPacket::ProtocolHeaderValidator::validate(
max_payload_size_ : MAXIMUM_FRAME_DATA_V2_SIZE;
break;
default:
- LOG4CXX_WARN(logger_, "Unknown version " <<
+ LOG4CXX_WARN(logger_, "Unknown version:" <<
static_cast<int>(header.version));
return RESULT_FAIL;
}
@@ -217,8 +218,7 @@ RESULT_CODE ProtocolPacket::ProtocolHeaderValidator::validate(
// and shall be less than payload size
if (header.dataSize > payload_size) {
LOG4CXX_WARN(logger_, "Packet data size is " << header.dataSize <<
- "and biger than allowed payload size " <<
- payload_size << " bytes");
+ " and bigger than allowed payload size " << payload_size << " bytes");
return RESULT_FAIL;
}
switch (header.frameType) {
@@ -234,7 +234,7 @@ RESULT_CODE ProtocolPacket::ProtocolHeaderValidator::validate(
break;
}
// Message ID be equal or greater than 0x01 (not actual for 1 protocol version and Control frames)
- if(header.messageId <= 0) {
+ if (header.messageId <= 0) {
if (FRAME_TYPE_CONTROL != header.frameType &&
PROTOCOL_VERSION_1 != header.version) {
LOG4CXX_WARN(logger_, "Message ID shall be greater than 0x00");
@@ -242,7 +242,7 @@ RESULT_CODE ProtocolPacket::ProtocolHeaderValidator::validate(
return RESULT_FAIL;
}
}
- LOG4CXX_DEBUG(logger_, "Message is complitly correct.");
+ LOG4CXX_DEBUG(logger_, "Message header is completely correct.");
return RESULT_OK;
}
@@ -300,7 +300,7 @@ RawMessagePtr ProtocolPacket::serializePacket() const {
header[offset++] = packet_header_.messageId >> 16;
header[offset++] = packet_header_.messageId >> 8;
header[offset++] = packet_header_.messageId;
- };
+ }
size_t total_packet_size = offset + (packet_data_.data ? packet_data_.totalDataBytes : 0);
@@ -435,6 +435,10 @@ uint8_t ProtocolPacket::frame_data() const {
return packet_header_.frameData;
}
+void ProtocolPacket::set_frame_data(const uint8_t frame_data) {
+ packet_header_.frameData = frame_data;
+}
+
uint8_t ProtocolPacket::session_id() const {
return packet_header_.sessionId;
}
@@ -486,4 +490,8 @@ uint32_t ProtocolPacket::payload_size() const {
return payload_size_;
}
+const ProtocolPacket::ProtocolHeader& ProtocolPacket::packet_header() const {
+ return packet_header_;
+}
+
} // namespace protocol_handler
diff --git a/src/components/time_tester/CMakeLists.txt b/src/components/time_tester/CMakeLists.txt
index 4ed9e584d4..9841e9a515 100644
--- a/src/components/time_tester/CMakeLists.txt
+++ b/src/components/time_tester/CMakeLists.txt
@@ -31,8 +31,8 @@
set(TIME_TESTER_SRC_DIR ${COMPONENTS_DIR}/time_tester/src)
-include_directories (
- include/time_tester
+include_directories(
+ include
${COMPONENTS_DIR}/utils/include/
${COMPONENTS_DIR}/protocol_handler/include/
${COMPONENTS_DIR}/connection_handler/include/
diff --git a/src/components/time_tester/include/time_tester/application_manager_metric.h b/src/components/time_tester/include/time_tester/application_manager_metric.h
index 1c21c0f722..4bcd26af5d 100644
--- a/src/components/time_tester/include/time_tester/application_manager_metric.h
+++ b/src/components/time_tester/include/time_tester/application_manager_metric.h
@@ -35,8 +35,8 @@
#include <string>
-#include "metric_wrapper.h"
-#include "application_manager_observer.h"
+#include "time_tester/metric_wrapper.h"
+#include "time_tester/application_manager_observer.h"
namespace time_tester {
diff --git a/src/components/time_tester/include/time_tester/application_manager_observer.h b/src/components/time_tester/include/time_tester/application_manager_observer.h
index 9c224f8920..834090be41 100644
--- a/src/components/time_tester/include/time_tester/application_manager_observer.h
+++ b/src/components/time_tester/include/time_tester/application_manager_observer.h
@@ -35,7 +35,7 @@
#include "utils/message_queue.h"
#include "application_manager/time_metric_observer.h"
-#include "application_manager_metric.h"
+#include "time_tester/application_manager_metric.h"
namespace time_tester {
diff --git a/src/components/time_tester/include/time_tester/protocol_handler_metric.h b/src/components/time_tester/include/time_tester/protocol_handler_metric.h
index 47db117a39..abcfff8552 100644
--- a/src/components/time_tester/include/time_tester/protocol_handler_metric.h
+++ b/src/components/time_tester/include/time_tester/protocol_handler_metric.h
@@ -35,7 +35,7 @@
#include <string>
#include "utils/shared_ptr.h"
-#include "metric_wrapper.h"
+#include "time_tester/metric_wrapper.h"
#include "protocol_handler_observer.h"
namespace time_tester {
diff --git a/src/components/time_tester/include/time_tester/time_manager.h b/src/components/time_tester/include/time_tester/time_manager.h
index dc56d3682c..6721e6dacb 100644
--- a/src/components/time_tester/include/time_tester/time_manager.h
+++ b/src/components/time_tester/include/time_tester/time_manager.h
@@ -40,10 +40,10 @@
#include "utils/threads/thread.h"
#include "utils/singleton.h"
#include "utils/threads/thread_delegate.h"
-#include "metric_wrapper.h"
-#include "application_manager_observer.h"
+#include "time_tester/metric_wrapper.h"
+#include "time_tester/application_manager_observer.h"
#include "application_manager/application_manager_impl.h"
-#include "transport_manager_observer.h"
+#include "time_tester/transport_manager_observer.h"
#include "transport_manager/transport_manager_impl.h"
#include "protocol_handler_observer.h"
#include "protocol_handler/protocol_handler_impl.h"
diff --git a/src/components/time_tester/include/time_tester/transport_manager_metric.h b/src/components/time_tester/include/time_tester/transport_manager_metric.h
index 25261b007c..18ab456c61 100644
--- a/src/components/time_tester/include/time_tester/transport_manager_metric.h
+++ b/src/components/time_tester/include/time_tester/transport_manager_metric.h
@@ -34,8 +34,8 @@
#define SRC_COMPONENTS_TIME_TESTER_INCLUDE_TIME_TESTER_TRANSPORT_MANAGER_MECTRIC_H_
#include <string>
-#include "metric_wrapper.h"
-#include "transport_manager_observer.h"
+#include "time_tester/metric_wrapper.h"
+#include "time_tester/transport_manager_observer.h"
namespace time_tester {
diff --git a/src/components/time_tester/src/application_manager_metric.cc b/src/components/time_tester/src/application_manager_metric.cc
index 251323dc4f..debfa9b9e9 100644
--- a/src/components/time_tester/src/application_manager_metric.cc
+++ b/src/components/time_tester/src/application_manager_metric.cc
@@ -30,8 +30,8 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include "application_manager_metric.h"
-#include "json_keys.h"
+#include "time_tester/application_manager_metric.h"
+#include "time_tester/json_keys.h"
#include "application_manager/smart_object_keys.h"
namespace time_tester {
diff --git a/src/components/time_tester/src/application_manager_observer.cc b/src/components/time_tester/src/application_manager_observer.cc
index c0d87a0551..d4bf014f60 100644
--- a/src/components/time_tester/src/application_manager_observer.cc
+++ b/src/components/time_tester/src/application_manager_observer.cc
@@ -29,10 +29,10 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include "application_manager_observer.h"
+#include "time_tester/application_manager_observer.h"
#include "utils/shared_ptr.h"
-#include "time_manager.h"
-#include "application_manager_metric.h"
+#include "time_tester/time_manager.h"
+#include "time_tester/application_manager_metric.h"
namespace time_tester {
diff --git a/src/components/time_tester/src/metric_wrapper.cc b/src/components/time_tester/src/metric_wrapper.cc
index 2922bf35cb..922a1c849e 100644
--- a/src/components/time_tester/src/metric_wrapper.cc
+++ b/src/components/time_tester/src/metric_wrapper.cc
@@ -1,5 +1,37 @@
-#include "metric_wrapper.h"
-#include "json_keys.h"
+/*
+ * Copyright (c) 2015, Ford Motor Company
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the Ford Motor Company nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "time_tester/metric_wrapper.h"
+#include "time_tester/json_keys.h"
namespace time_tester {
diff --git a/src/components/time_tester/src/protocol_handler_metric.cc b/src/components/time_tester/src/protocol_handler_metric.cc
index 93e08642f1..fd351c589f 100644
--- a/src/components/time_tester/src/protocol_handler_metric.cc
+++ b/src/components/time_tester/src/protocol_handler_metric.cc
@@ -30,9 +30,9 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include "protocol_handler_metric.h"
+#include "time_tester/protocol_handler_metric.h"
#include "json/json.h"
-#include "json_keys.h"
+#include "time_tester/json_keys.h"
namespace time_tester {
diff --git a/src/components/time_tester/src/protocol_handler_observer.cc b/src/components/time_tester/src/protocol_handler_observer.cc
index 0ad6ec1c0d..bb2e7095aa 100644
--- a/src/components/time_tester/src/protocol_handler_observer.cc
+++ b/src/components/time_tester/src/protocol_handler_observer.cc
@@ -30,10 +30,10 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include "protocol_handler_observer.h"
#include "utils/date_time.h"
-#include "protocol_handler_metric.h"
-#include "time_manager.h"
+#include "time_tester/protocol_handler_observer.h"
+#include "time_tester/protocol_handler_metric.h"
+#include "time_tester/time_manager.h"
namespace time_tester {
@@ -49,7 +49,8 @@ void ProtocolHandlerObserver::StartMessageProcess(uint32_t message_id,
return;
}
if (time_starts.find(message_id) != time_starts.end()) {
- LOG4CXX_INFO(logger_, "Message ID already wait for stop processing" << message_id);
+ LOG4CXX_DEBUG(logger_, "Already waiting for stop processing for Message ID: "
+ << message_id);
return;
}
time_starts[message_id] = start_time;
@@ -62,11 +63,11 @@ void ProtocolHandlerObserver::EndMessageProcess(utils::SharedPtr<MessageMetric>
LOG4CXX_WARN(logger_, "Cant find start time for message" << message_id);
return;
}
- m->begin= time_starts[message_id];
+ m->begin = time_starts[message_id];
m->end = date_time::DateTime::getCurrentTime();
ProtocolHandlerMecticWrapper* metric = new ProtocolHandlerMecticWrapper();
metric->message_metric = m;
metric->grabResources();
time_manager_->SendMetric(metric);
}
-} //namespace time_tester
+} // namespace time_tester
diff --git a/src/components/time_tester/src/time_manager.cc b/src/components/time_tester/src/time_manager.cc
index a0b90a8495..54c61c4a69 100644
--- a/src/components/time_tester/src/time_manager.cc
+++ b/src/components/time_tester/src/time_manager.cc
@@ -30,7 +30,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include "time_manager.h"
+#include "time_tester/time_manager.h"
#include <sys/socket.h>
#include <sys/types.h>
diff --git a/src/components/time_tester/src/transport_manager_metric.cc b/src/components/time_tester/src/transport_manager_metric.cc
index a7c9ecb5a2..dd707d7fd3 100644
--- a/src/components/time_tester/src/transport_manager_metric.cc
+++ b/src/components/time_tester/src/transport_manager_metric.cc
@@ -30,9 +30,9 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include "transport_manager_metric.h"
+#include "time_tester/transport_manager_metric.h"
#include "json/json.h"
-#include "json_keys.h"
+#include "time_tester/json_keys.h"
#include "application_manager/smart_object_keys.h"
namespace time_tester {
diff --git a/src/components/time_tester/src/transport_manager_observer.cc b/src/components/time_tester/src/transport_manager_observer.cc
index 6c63a576e7..49f95e9fa9 100644
--- a/src/components/time_tester/src/transport_manager_observer.cc
+++ b/src/components/time_tester/src/transport_manager_observer.cc
@@ -29,12 +29,12 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include "transport_manager_observer.h"
+#include "time_tester/transport_manager_observer.h"
#include <time.h>
-#include "transport_manager_metric.h"
-#include "time_manager.h"
+#include "time_tester/transport_manager_metric.h"
+#include "time_tester/time_manager.h"
namespace time_tester {
diff --git a/src/components/transport_manager/src/transport_manager_impl.cc b/src/components/transport_manager/src/transport_manager_impl.cc
index 149acad83c..e7b1f5a7c1 100644
--- a/src/components/transport_manager/src/transport_manager_impl.cc
+++ b/src/components/transport_manager/src/transport_manager_impl.cc
@@ -109,7 +109,7 @@ int TransportManagerImpl::ConnectDevice(const DeviceHandle& device_handle) {
}
DeviceUID device_id = converter_.HandleToUid(device_handle);
- LOG4CXX_DEBUG(logger_, "Convert handle to id " << device_id);
+ LOG4CXX_DEBUG(logger_, "Convert handle to id:" << device_id);
sync_primitives::AutoReadLock lock(device_to_adapter_map_lock_);
DeviceToAdapterMap::iterator it = device_to_adapter_map_.find(device_id);
@@ -135,7 +135,7 @@ int TransportManagerImpl::DisconnectDevice(const DeviceHandle& device_handle) {
return E_TM_IS_NOT_INITIALIZED;
}
DeviceUID device_id = converter_.HandleToUid(device_handle);
- LOG4CXX_DEBUG(logger_, "Convert handle to id" << device_id);
+ LOG4CXX_DEBUG(logger_, "Convert handle to id:" << device_id);
sync_primitives::AutoReadLock lock(device_to_adapter_map_lock_);
DeviceToAdapterMap::iterator it = device_to_adapter_map_.find(device_id);
diff --git a/src/components/utils/src/threads/posix_thread.cc b/src/components/utils/src/threads/posix_thread.cc
index de36ab8e08..dd31072326 100644
--- a/src/components/utils/src/threads/posix_thread.cc
+++ b/src/components/utils/src/threads/posix_thread.cc
@@ -34,6 +34,7 @@
#include <limits.h>
#include <stddef.h>
#include <signal.h>
+#include <pthread.h>
#ifdef BUILD_TESTS
// Temporary fix for UnitTest until APPLINK-9987 is resolved
@@ -41,7 +42,6 @@
#endif
#include "utils/threads/thread.h"
-#include "pthread.h"
#include "utils/atomic.h"
#include "utils/threads/thread_delegate.h"
#include "utils/logger.h"
@@ -87,7 +87,7 @@ void* Thread::threadFunc(void* arg) {
// (system signals processes only in the main thread)
sigset_t set;
sigfillset(&set);
- if(pthread_sigmask(SIG_SETMASK, &set, NULL) != 0) {
+ if (pthread_sigmask(SIG_SETMASK, &set, NULL) != 0) {
LOG4CXX_ERROR(logger_, "Set thread signal mask error");
}
LOG4CXX_DEBUG(logger_,
@@ -106,7 +106,8 @@ void* Thread::threadFunc(void* arg) {
thread->run_cond_.Wait(thread->state_lock_);
LOG4CXX_DEBUG(
logger_,
- "Thread #" << pthread_self() << " execute. " << "stopped_ = " << thread->stopped_ << "; finalized_ = " << thread->finalized_);
+ "Thread #" << pthread_self() << " execute. " << "stopped_ = "
+ << thread->stopped_ << "; finalized_ = " << thread->finalized_);
if (!thread->stopped_ && !thread->finalized_) {
thread->isThreadRunning_ = true;
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
@@ -139,8 +140,9 @@ void Thread::SetNameForId(const PlatformThreadHandle& thread_id,
const int rc = pthread_setname_np(thread_id, name.c_str());
if (rc != EOK) {
LOG4CXX_WARN(
- logger_,
- "Couldn't set pthread name \"" << name << "\", error code " << rc << " (" << strerror(rc) << ")");
+ logger_,
+ "Couldn't set pthread name \"" << name << "\", error code "
+ << rc << " (" << strerror(rc) << ")");
}
}
@@ -191,16 +193,18 @@ bool Thread::start(const ThreadOptions& options) {
int pthread_result = pthread_attr_init(&attributes);
if (pthread_result != EOK) {
LOG4CXX_WARN(
- logger_,
- "Couldn't init pthread attributes. Error code = " << pthread_result << " (\"" << strerror(pthread_result) << "\")");
+ logger_,
+ "Couldn't init pthread attributes. Error code = "<< pthread_result
+ << " (\"" << strerror(pthread_result) << "\")");
}
if (!thread_options_.is_joinable()) {
pthread_result = pthread_attr_setdetachstate(&attributes, PTHREAD_CREATE_DETACHED);
if (pthread_result != EOK) {
LOG4CXX_WARN(
- logger_,
- "Couldn't set detach state attribute. Error code = " << pthread_result << " (\"" << strerror(pthread_result) << "\")");
+ logger_,
+ "Couldn't set detach state attribute. Error code = " << pthread_result
+ << " (\"" << strerror(pthread_result) << "\")");
thread_options_.is_joinable(false);
}
}
@@ -210,11 +214,11 @@ bool Thread::start(const ThreadOptions& options) {
pthread_result = pthread_attr_setstacksize(&attributes, stack_size);
if (pthread_result != EOK) {
LOG4CXX_WARN(
- logger_,
- "Couldn't set stacksize = " << stack_size << ". Error code = " << pthread_result << " (\"" << strerror(pthread_result) << "\")");
+ logger_,
+ "Couldn't set stacksize = " << stack_size << ". Error code = "
+ << pthread_result << " (\"" << strerror(pthread_result) << "\")");
}
- }
- else {
+ } else {
ThreadOptions thread_options_temp(Thread::kMinStackSize, thread_options_.is_joinable());
thread_options_ = thread_options_temp;
}
@@ -232,14 +236,15 @@ bool Thread::start(const ThreadOptions& options) {
} else {
LOG4CXX_ERROR(
logger_,
- "Couldn't create thread " << name_ << ". Error code = " << pthread_result << " (\"" << strerror(pthread_result) << "\")");
+ "Couldn't create thread " << name_ << ". Error code = "
+ << pthread_result <<" (\"" << strerror(pthread_result) << "\")");
}
}
stopped_ = false;
run_cond_.NotifyOne();
- LOG4CXX_DEBUG(
- logger_,
- "Thread " << name_ << " #" << handle_ << " started. pthread_result = " << pthread_result);
+ LOG4CXX_DEBUG(logger_,
+ "Thread " << name_ << " #" << handle_<< " started." <<
+ " pthread_result = " << pthread_result);
pthread_attr_destroy(&attributes);
return pthread_result == EOK;
}
@@ -251,7 +256,7 @@ void Thread::stop() {
stopped_ = true;
LOG4CXX_DEBUG(logger_, "Stopping thread #" << handle_
- << " \"" << name_ << " \"");
+ << " \"" << name_ << "\"");
if (delegate_ && isThreadRunning_) {
delegate_->exitThreadMain();
@@ -271,6 +276,8 @@ void Thread::join() {
run_cond_.NotifyOne();
if (isThreadRunning_) {
if (!pthread_equal(pthread_self(), handle_)) {
+ LOG4CXX_DEBUG(logger_, "Waiting for #"<< handle_
+ << " finished iteration in thread #" << pthread_self());
state_cond_.Wait(auto_lock);
}
}
diff --git a/test/components/transport_manager/src/mock_connection_factory.cc b/test/components/transport_manager/src/mock_connection_factory.cc
index 1eb3e34a48..74c69a557a 100644
--- a/test/components/transport_manager/src/mock_connection_factory.cc
+++ b/test/components/transport_manager/src/mock_connection_factory.cc
@@ -33,17 +33,13 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-
-#include <transport_manager/mock_connection.h>
-#include "transport_manager/mock_connection_factory.h"
-
-#include <algorithm>
-
-#include "transport_manager/mock_device.h"
-#include "transport_manager/mock_transport_adapter.h"
-
-using ::transport_manager::transport_adapter::DeviceSptr;
-using ::transport_manager::ConnectError;
+#include "gtest/gtest.h"
+#include "include/time_manager_mock.h"
+#include "application_manager/time_metric_observer.h"
+#include "time_tester/application_manager_metric.h"
+#include "time_tester/application_manager_observer.h"
+#include "utils/shared_ptr.h"
+#include "time_tester/time_manager.h"
namespace test {
namespace components {
diff --git a/test/components/transport_manager/src/mock_transport_adapter.cc b/test/components/transport_manager/src/mock_transport_adapter.cc
index 1ff1348b01..46e65ee4a3 100644
--- a/test/components/transport_manager/src/mock_transport_adapter.cc
+++ b/test/components/transport_manager/src/mock_transport_adapter.cc
@@ -33,11 +33,11 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include "transport_manager/mock_connection.h"
-#include "transport_manager/mock_device.h"
-#include "transport_manager/mock_transport_adapter.h"
-#include "transport_manager/mock_device_scanner.h"
-#include "transport_manager/mock_connection_factory.h"
+#include "gtest/gtest.h"
+#include "include/time_manager_mock.h"
+#include "protocol_handler/time_metric_observer.h"
+#include "time_tester/transport_manager_metric.h"
+#include "time_tester/transport_manager_observer.h"
namespace test {
namespace components {