diff options
author | Alexander Kutsan <AKutsan@luxoft.com> | 2016-08-26 18:48:22 +0300 |
---|---|---|
committer | Alexander Kutsan <AKutsan@luxoft.com> | 2016-08-26 18:48:57 +0300 |
commit | d73e6dc8724c5799fae14efd4dcb214af74e4904 (patch) | |
tree | 9ebed8b422490c4d669e90e70783e4f5b55b65c9 /src/components/time_tester | |
parent | c201c11a35d360c0b96f36b103a2590bfaeb6026 (diff) | |
parent | 61ef8c42badb879216f53d240e1101b9f83a9bb7 (diff) | |
download | sdl_core-d73e6dc8724c5799fae14efd4dcb214af74e4904.tar.gz |
Merge branch 'release/4.1.0'
Diffstat (limited to 'src/components/time_tester')
29 files changed, 0 insertions, 2106 deletions
diff --git a/src/components/time_tester/CMakeLists.txt b/src/components/time_tester/CMakeLists.txt deleted file mode 100644 index 24f0fa98e3..0000000000 --- a/src/components/time_tester/CMakeLists.txt +++ /dev/null @@ -1,69 +0,0 @@ -# Copyright (c) 2014, 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. - - -set(TIME_TESTER_SRC_DIR ${COMPONENTS_DIR}/time_tester/src) - -include_directories( - include/time_tester - ${COMPONENTS_DIR}/utils/include/ - ${COMPONENTS_DIR}/protocol_handler/include/ - ${COMPONENTS_DIR}/connection_handler/include/ - ${COMPONENTS_DIR}/transport_manager/include/ - ${COMPONENTS_DIR}/application_manager/include/ - ${COMPONENTS_DIR}/policy/src/policy/include/ - ${COMPONENTS_DIR}/hmi_message_handler/include/ - ${COMPONENTS_DIR}/formatters/include/ - ${COMPONENTS_DIR}/media_manager/include/ - ${COMPONENTS_DIR}/smart_objects/include/ - ${COMPONENTS_DIR}/config_profile/include/ - ${JSONCPP_INCLUDE_DIRECTORY} - ${CMAKE_BINARY_DIR}/src/components/ - ${LOG4CXX_INCLUDE_DIRECTORY} -) - -set(SOURCES - ${TIME_TESTER_SRC_DIR}/metric_wrapper.cc - ${TIME_TESTER_SRC_DIR}/time_manager.cc - ${TIME_TESTER_SRC_DIR}/application_manager_observer.cc - ${TIME_TESTER_SRC_DIR}/transport_manager_observer.cc - ${TIME_TESTER_SRC_DIR}/protocol_handler_observer.cc - ${TIME_TESTER_SRC_DIR}/application_manager_metric.cc - ${TIME_TESTER_SRC_DIR}/transport_manager_metric.cc - ${TIME_TESTER_SRC_DIR}/protocol_handler_metric.cc -) - -add_library("TimeTester" ${SOURCES}) -target_link_libraries("TimeTester" ${LIBRARIES}) -add_dependencies("TimeTester" HMI_API MOBILE_API) - -if(BUILD_TESTS) - add_subdirectory(test) -endif() 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 deleted file mode 100644 index 1c21c0f722..0000000000 --- a/src/components/time_tester/include/time_tester/application_manager_metric.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2014, 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. - */ - -#ifndef SRC_COMPONENTS_TIME_TESTER_INCLUDE_TIME_TESTER_APPLICATION_MANAGER_MECTRIC_WRAPPER_H_ -#define SRC_COMPONENTS_TIME_TESTER_INCLUDE_TIME_TESTER_APPLICATION_MANAGER_MECTRIC_WRAPPER_H_ - -#include <string> - -#include "metric_wrapper.h" -#include "application_manager_observer.h" - - -namespace time_tester { - -class ApplicationManagerObserver; - -class ApplicationManagerMetricWrapper: public MetricWrapper { - - public: - utils::SharedPtr<application_manager::AMMetricObserver::MessageMetric> message_metric; - - protected: - virtual Json::Value GetJsonMetric(); -}; - -} -#endif // SRC_COMPONENTS_TIME_TESTER_INCLUDE_TIME_TESTER_APPLICATION_MANAGER_MECTRIC_WRAPPER_H_ 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 deleted file mode 100644 index 9c224f8920..0000000000 --- a/src/components/time_tester/include/time_tester/application_manager_observer.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2014, 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. - */ - -#ifndef SRC_COMPONENTS_TIME_TESTER_INCLUDE_TIME_TESTER_APPLICATION_MANAGER_OBSERVER_H_ -#define SRC_COMPONENTS_TIME_TESTER_INCLUDE_TIME_TESTER_APPLICATION_MANAGER_OBSERVER_H_ - -#include "utils/message_queue.h" -#include "application_manager/time_metric_observer.h" -#include "application_manager_metric.h" - - -namespace time_tester { - -class TimeManager; - -class ApplicationManagerObserver: public application_manager::AMMetricObserver { - public: - explicit ApplicationManagerObserver(TimeManager* time_manager); - virtual void OnMessage(utils::SharedPtr<MessageMetric> metric); - - private: - TimeManager* time_manager_; -}; - -} -#endif // SRC_COMPONENTS_TIME_TESTER_INCLUDE_TIME_TESTER_APPLICATION_MANAGER_OBSERVER_H_ diff --git a/src/components/time_tester/include/time_tester/json_keys.h b/src/components/time_tester/include/time_tester/json_keys.h deleted file mode 100644 index 532202067f..0000000000 --- a/src/components/time_tester/include/time_tester/json_keys.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * - * Copyright (c) 2014, 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. - */ - -#ifndef SRC_COMPONENTS_TIME_TESTER_INCLUDE_TIME_TESTER_JSON_KEYS_H_ -#define SRC_COMPONENTS_TIME_TESTER_INCLUDE_TIME_TESTER_JSON_KEYS_H_ - -namespace time_tester { - namespace strings { - const char logger[] = "logger"; - const char begin[] = "begin"; - const char end[] = "end"; - const char data_size[] = "data_size"; - const char message_id[] = "message_id"; - const char session_id[] = "session_id"; - const char correlation_id[] = "correlation_id"; - const char connection_key[] = "connection_key"; - const char stime[] = "stime"; - const char utime[] = "utime"; - const char memory[] = "RAM"; - } -} -#endif // SRC_COMPONENTS_TIME_TESTER_INCLUDE_TIME_TESTER_JSON_KEYS_H_ diff --git a/src/components/time_tester/include/time_tester/metric_wrapper.h b/src/components/time_tester/include/time_tester/metric_wrapper.h deleted file mode 100644 index a1867824d4..0000000000 --- a/src/components/time_tester/include/time_tester/metric_wrapper.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2014, 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. - */ - -#ifndef SRC_COMPONENTS_TIME_TESTER_INCLUDE_TIME_TESTER_MECTRIC_H_ -#define SRC_COMPONENTS_TIME_TESTER_INCLUDE_TIME_TESTER_MECTRIC_H_ - -#include <string> -#include "utils/resource_usage.h" -#include "json/json.h" - -namespace time_tester { - -class MetricWrapper { - utils::ResourseUsage* resources; - public: - MetricWrapper(); - /* - * @brief get current cpu and memory info and store it as member - */ - bool grabResources(); - virtual std::string GetStyledString(); - virtual ~MetricWrapper(); - protected: - virtual Json::Value GetJsonMetric(); - void Clear(); -}; - - -} // namespace time_tester -#endif // SRC_COMPONENTS_TIME_TESTER_INCLUDE_TIME_TESTER_MECTRIC_H_ 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 deleted file mode 100644 index 47db117a39..0000000000 --- a/src/components/time_tester/include/time_tester/protocol_handler_metric.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2014, 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. - */ - -#ifndef SRC_COMPONENTS_TIME_TESTER_INCLUDE_TIME_TESTER_PROTOCOL_HANDLER_MECTRIC_H_ -#define SRC_COMPONENTS_TIME_TESTER_INCLUDE_TIME_TESTER_PROTOCOL_HANDLER_MECTRIC_H_ - -#include <string> -#include "utils/shared_ptr.h" -#include "metric_wrapper.h" -#include "protocol_handler_observer.h" - -namespace time_tester { - -class ProtocolHandlerMecticWrapper: public MetricWrapper { - - public: - utils::SharedPtr<protocol_handler::PHMetricObserver::MessageMetric> message_metric; - protected: - virtual Json::Value GetJsonMetric(); -}; -} // namespace time_tester -#endif // SRC_COMPONENTS_TIME_TESTER_INCLUDE_TIME_TESTER_PROTOCOL_HANDLER_MECTRIC_H_ diff --git a/src/components/time_tester/include/time_tester/protocol_handler_observer.h b/src/components/time_tester/include/time_tester/protocol_handler_observer.h deleted file mode 100644 index 4c962cfc84..0000000000 --- a/src/components/time_tester/include/time_tester/protocol_handler_observer.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2014, 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. - */ - -#ifndef SRC_COMPONENTS_TIME_TESTER_INCLUDE_TIME_TESTER_PROTOCOL_HANDLER_OBSERVER_H_ -#define SRC_COMPONENTS_TIME_TESTER_INCLUDE_TIME_TESTER_PROTOCOL_HANDLER_OBSERVER_H_ - -#include "protocol_handler/time_metric_observer.h" -#include "utils/message_queue.h" - -namespace time_tester { - -class TimeManager; - -class ProtocolHandlerObserver: public protocol_handler::PHMetricObserver { - public: - explicit ProtocolHandlerObserver(TimeManager* time_manager); - - virtual void StartMessageProcess(uint32_t message_id, const TimevalStruct& start_time); - - virtual void EndMessageProcess(utils::SharedPtr<MessageMetric> m); - - private: - TimeManager* time_manager_; - std::map<uint32_t, TimevalStruct> time_starts; -}; -} // namespace time_tester -#endif // SRC_COMPONENTS_TIME_TESTER_INCLUDE_TIME_TESTER_PROTOCOL_HANDLER_OBSERVER_H_ diff --git a/src/components/time_tester/include/time_tester/time_manager.h b/src/components/time_tester/include/time_tester/time_manager.h deleted file mode 100644 index dc56d3682c..0000000000 --- a/src/components/time_tester/include/time_tester/time_manager.h +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (c) 2014, 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. - */ - -#ifndef SRC_COMPONENTS_TIME_MANAGER_INCLUDE_TIME_MANAGER_MEDIA_MANAGER_H_ -#define SRC_COMPONENTS_TIME_MANAGER_INCLUDE_TIME_MANAGER_MEDIA_MANAGER_H_ - -#include <string> - -#include "utils/shared_ptr.h" -#include "utils/message_queue.h" -#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 "application_manager/application_manager_impl.h" -#include "transport_manager_observer.h" -#include "transport_manager/transport_manager_impl.h" -#include "protocol_handler_observer.h" -#include "protocol_handler/protocol_handler_impl.h" - -namespace time_tester { - -using ::utils::MessageQueue; - -class TimeManager { - public: - TimeManager(); - ~TimeManager(); - void Init(protocol_handler::ProtocolHandlerImpl* ph); - void Stop(); - void SendMetric(utils::SharedPtr<MetricWrapper> metric); - private: - - class Streamer : public threads::ThreadDelegate { - public: - explicit Streamer(TimeManager* const server); - ~Streamer(); - void threadMain() OVERRIDE; - void exitThreadMain() OVERRIDE; - bool IsReady() const; - void Start(); - void Stop(); - bool Send(const std::string &msg); - void PushMessage(utils::SharedPtr<MetricWrapper> metric); - volatile bool is_client_connected_; - private: - void ShutDownAndCloseSocket(int32_t socket_fd); - TimeManager* const server_; - int32_t server_socket_fd_; - int32_t client_socket_fd_; - volatile bool stop_flag_; - MessageQueue<utils::SharedPtr<MetricWrapper> > messages_; - DISALLOW_COPY_AND_ASSIGN(Streamer); - }; - - int16_t port_; - std::string ip_; - bool is_ready_; - threads::Thread* thread_; - Streamer* streamer_; - ApplicationManagerObserver app_observer; - TransportManagerObserver tm_observer; - ProtocolHandlerObserver ph_observer; - - DISALLOW_COPY_AND_ASSIGN(TimeManager); -}; -} // namespace time_manager -#endif // SRC_COMPONENTS_TIME_MANAGER_INCLUDE_TIME_MANAGER_MEDIA_MANAGER_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 deleted file mode 100644 index 25261b007c..0000000000 --- a/src/components/time_tester/include/time_tester/transport_manager_metric.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2014, 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. - */ - -#ifndef SRC_COMPONENTS_TIME_TESTER_INCLUDE_TIME_TESTER_TRANSPORT_MANAGER_MECTRIC_H_ -#define SRC_COMPONENTS_TIME_TESTER_INCLUDE_TIME_TESTER_TRANSPORT_MANAGER_MECTRIC_H_ - -#include <string> -#include "metric_wrapper.h" -#include "transport_manager_observer.h" - -namespace time_tester { - -class TransportManagerMecticWrapper: public MetricWrapper { - public: - utils::SharedPtr<transport_manager::TMMetricObserver::MessageMetric> message_metric; - protected: - virtual Json::Value GetJsonMetric(); -}; -} // namespace time_tester -#endif // SRC_COMPONENTS_TIME_TESTER_INCLUDE_TIME_TESTER_TRANSPORT_MANAGER_MECTRIC_H_ diff --git a/src/components/time_tester/include/time_tester/transport_manager_observer.h b/src/components/time_tester/include/time_tester/transport_manager_observer.h deleted file mode 100644 index bd46ba0822..0000000000 --- a/src/components/time_tester/include/time_tester/transport_manager_observer.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2014, 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. - */ - -#ifndef SRC_COMPONENTS_TIME_TESTER_INCLUDE_TIME_TESTER_TRANSPORT_MANAGER_OBSERVER_H_ -#define SRC_COMPONENTS_TIME_TESTER_INCLUDE_TIME_TESTER_TRANSPORT_MANAGER_OBSERVER_H_ - -#include "transport_manager/time_metric_observer.h" -#include "utils/message_queue.h" -#include "utils/date_time.h" - -namespace time_tester { - -class TimeManager; - -class TransportManagerObserver: public transport_manager::TMMetricObserver { - public: - explicit TransportManagerObserver(TimeManager* time_manager); - virtual void StartRawMsg(const protocol_handler::RawMessage* ptr); - virtual void StopRawMsg(const protocol_handler::RawMessage* ptr); - private: - TimeManager* time_manager_; - std::map<const protocol_handler::RawMessage*, TimevalStruct> time_starts; -}; -} // namespace time_tester -#endif // SRC_COMPONENTS_TIME_TESTER_INCLUDE_TIME_TESTER_TRANSPORT_MANAGER_OBSERVER_H_ diff --git a/src/components/time_tester/src/application_manager_metric.cc b/src/components/time_tester/src/application_manager_metric.cc deleted file mode 100644 index 251323dc4f..0000000000 --- a/src/components/time_tester/src/application_manager_metric.cc +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2014, 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 "application_manager_metric.h" -#include "json_keys.h" -#include "application_manager/smart_object_keys.h" - -namespace time_tester { - -Json::Value ApplicationManagerMetricWrapper::GetJsonMetric() { - Json::Value result = MetricWrapper::GetJsonMetric(); - result[strings::logger] = "ApplicationManager"; - result[strings::begin] = - Json::Int64(date_time::DateTime::getuSecs(message_metric->begin)); - result[strings::end] = - Json::Int64(date_time::DateTime::getuSecs(message_metric->end)); - const NsSmartDeviceLink::NsSmartObjects::SmartObject& params = - message_metric->message->getElement(application_manager::strings::params); - result[strings::correlation_id] = - params[application_manager::strings::correlation_id].asInt(); - result[strings::connection_key] = - params[application_manager::strings::connection_key].asInt(); - return result; -} -} // 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 deleted file mode 100644 index c0d87a0551..0000000000 --- a/src/components/time_tester/src/application_manager_observer.cc +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2014, 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 "application_manager_observer.h" -#include "utils/shared_ptr.h" -#include "time_manager.h" -#include "application_manager_metric.h" - -namespace time_tester { - -ApplicationManagerObserver::ApplicationManagerObserver(TimeManager* time_manager): - time_manager_(time_manager) { -} - -void ApplicationManagerObserver::OnMessage(utils::SharedPtr<MessageMetric> metric) { - ApplicationManagerMetricWrapper* m = new ApplicationManagerMetricWrapper(); - m->message_metric = metric; - m->grabResources(); - time_manager_->SendMetric(m); -} -} // namespace time_tester diff --git a/src/components/time_tester/src/metric_wrapper.cc b/src/components/time_tester/src/metric_wrapper.cc deleted file mode 100644 index 2922bf35cb..0000000000 --- a/src/components/time_tester/src/metric_wrapper.cc +++ /dev/null @@ -1,46 +0,0 @@ -#include "metric_wrapper.h" -#include "json_keys.h" - -namespace time_tester { - - MetricWrapper::MetricWrapper(): - resources(NULL) { - } - -bool MetricWrapper::grabResources() { - Clear(); - resources = utils::Resources::getCurrentResourseUsage(); - if (NULL != resources) { - return true; - } else { - return false; - } - flush(std::cout); -} - -std::string MetricWrapper::GetStyledString() { - return GetJsonMetric().toStyledString(); -} - -Json::Value MetricWrapper::GetJsonMetric() { - Json::Value result; - if (resources) { - result[strings::stime] = resources->stime; - result[strings::utime] = resources->utime; - result[strings::memory] = resources->memory; - } - return result; -} - -void MetricWrapper::Clear() { - if (NULL != resources) { - delete resources; - resources = NULL; - } -} - -MetricWrapper::~MetricWrapper() { - Clear(); -} - -} diff --git a/src/components/time_tester/src/protocol_handler_metric.cc b/src/components/time_tester/src/protocol_handler_metric.cc deleted file mode 100644 index 93e08642f1..0000000000 --- a/src/components/time_tester/src/protocol_handler_metric.cc +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2014, 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 "protocol_handler_metric.h" -#include "json/json.h" -#include "json_keys.h" - -namespace time_tester { - -Json::Value ProtocolHandlerMecticWrapper::GetJsonMetric() { - Json::Value result = MetricWrapper::GetJsonMetric(); - result[strings::logger] = "ProtocolHandler"; - result[strings::begin] = - Json::Int64(date_time::DateTime::getuSecs(message_metric->begin)); - result[strings::end] = - Json::Int64(date_time::DateTime::getuSecs(message_metric->end)); - result[strings::message_id] = message_metric->message_id; - result[strings::connection_key] = message_metric->connection_key; - return result; -} - -} // 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 deleted file mode 100644 index 0ad6ec1c0d..0000000000 --- a/src/components/time_tester/src/protocol_handler_observer.cc +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2014, 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 "protocol_handler_observer.h" -#include "utils/date_time.h" -#include "protocol_handler_metric.h" -#include "time_manager.h" - -namespace time_tester { - -CREATE_LOGGERPTR_GLOBAL(logger_, "Utils") - -ProtocolHandlerObserver::ProtocolHandlerObserver(TimeManager *time_manager): - time_manager_(time_manager) { -} - -void ProtocolHandlerObserver::StartMessageProcess(uint32_t message_id, - const TimevalStruct &start_time) { - if (message_id == 0) { - return; - } - if (time_starts.find(message_id) != time_starts.end()) { - LOG4CXX_INFO(logger_, "Message ID already wait for stop processing" << message_id); - return; - } - time_starts[message_id] = start_time; -} - -void ProtocolHandlerObserver::EndMessageProcess(utils::SharedPtr<MessageMetric> m) { - uint32_t message_id = m->message_id; - std::map<uint32_t, TimevalStruct>::const_iterator it = time_starts.find(message_id); - if (it == time_starts.end()) { - LOG4CXX_WARN(logger_, "Cant find start time for message" << message_id); - return; - } - 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 diff --git a/src/components/time_tester/src/time_manager.cc b/src/components/time_tester/src/time_manager.cc deleted file mode 100644 index db389dbda0..0000000000 --- a/src/components/time_tester/src/time_manager.cc +++ /dev/null @@ -1,253 +0,0 @@ -/* - * Copyright (c) 2014, 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_manager.h" - -#include <sys/socket.h> -#include <sys/types.h> -#include <sys/select.h> -#include <sys/time.h> -#include <netinet/in.h> -#include <arpa/inet.h> -#include <unistd.h> -#include <string.h> - -#include "transport_manager/transport_manager_default.h" -#include "config_profile/profile.h" -#include "utils/resource_usage.h" - -namespace time_tester { - -CREATE_LOGGERPTR_GLOBAL(logger_, "TimeManager") - -TimeManager::TimeManager(): - thread_(NULL), - streamer_(NULL), - app_observer(this), - tm_observer(this), - ph_observer(this) { - ip_ = profile::Profile::instance()->server_address(); - port_ = profile::Profile::instance()->time_testing_port(); - streamer_ = new Streamer(this); - thread_ = threads::CreateThread("TimeManager", streamer_ ); -} - -TimeManager::~TimeManager() { - Stop(); -} - -void TimeManager::Init(protocol_handler::ProtocolHandlerImpl* ph) { - LOG4CXX_AUTO_TRACE(logger_); - DCHECK(ph); - if (!ph) { - LOG4CXX_DEBUG(logger_, "ProtocolHandler poiner is NULL"); - return; - } - - application_manager::ApplicationManagerImpl::instance()->SetTimeMetricObserver(&app_observer); - transport_manager::TransportManagerDefault::instance()->SetTimeMetricObserver(&tm_observer); - ph->SetTimeMetricObserver(&ph_observer); - thread_->start(threads::ThreadOptions()); -} - -void TimeManager::Stop() { - LOG4CXX_AUTO_TRACE(logger_); - threads::DeleteThread(thread_); - thread_ = NULL; -} - -void TimeManager::SendMetric(utils::SharedPtr<MetricWrapper> metric) { - if ((NULL != streamer_ )&& streamer_->is_client_connected_) { - streamer_->PushMessage(metric); - } -} - -TimeManager::Streamer::Streamer( - TimeManager* const server) - : is_client_connected_(false), - server_(server), - server_socket_fd_(0), - client_socket_fd_(0), - stop_flag_(false) { -} - -TimeManager::Streamer::~Streamer() { - Stop(); -} - -void TimeManager::Streamer::threadMain() { - LOG4CXX_AUTO_TRACE(logger_); - - Start(); - while (!stop_flag_) { - LOG4CXX_INFO(logger_, "Server socket is listening "); - client_socket_fd_ = accept(server_socket_fd_, NULL, NULL); - if (0 > client_socket_fd_) { - LOG4CXX_ERROR(logger_, "Cant open socket . Socket is busy "); - Stop(); - break; - } - LOG4CXX_INFO(logger_, "Client connected"); - - is_client_connected_ = true; - while (is_client_connected_) { - while (!messages_.empty()) { - utils::SharedPtr<MetricWrapper> metric = messages_.pop(); - is_client_connected_ = Send(metric->GetStyledString()); - } - - if (!IsReady()) { - LOG4CXX_INFO(logger_, "Client disconnected."); - break; - } - - messages_.wait(); - } - } -} - -void TimeManager::Streamer::exitThreadMain() { - LOG4CXX_AUTO_TRACE(logger_); - Stop(); - messages_.Shutdown(); -} - -void TimeManager::Streamer::Start() { - LOG4CXX_AUTO_TRACE(logger_); - server_socket_fd_ = socket(AF_INET, SOCK_STREAM, 0); - - if (0 >= server_socket_fd_) { - LOG4CXX_ERROR_EXT(logger_, "Server open error"); - return; - } else { - LOG4CXX_DEBUG(logger_, "Server socket : " << server_socket_fd_); - } - - int32_t optval = 1; - if (-1 == setsockopt(server_socket_fd_, SOL_SOCKET, SO_REUSEADDR, - &optval, sizeof optval)) { - LOG4CXX_ERROR_EXT(logger_, "Unable to set sockopt"); - return; - } - - sockaddr_in serv_addr_ = { 0 }; - serv_addr_.sin_addr.s_addr = inet_addr(server_->ip_.c_str()); - serv_addr_.sin_family = AF_INET; - serv_addr_.sin_port = htons(server_->port_); - - if (-1 == bind(server_socket_fd_, - reinterpret_cast<struct sockaddr*>(&serv_addr_), - sizeof(serv_addr_))) { - LOG4CXX_ERROR(logger_, "Unable to bind server " - << server_->ip_.c_str() << ':' << server_->port_); - return; - } - if (-1 == listen(server_socket_fd_, 1)) { - LOG4CXX_ERROR(logger_, "Streamer listen error " << strerror(errno) ); - return; - } -} - -void TimeManager::Streamer::ShutDownAndCloseSocket(int32_t socket_fd) { - LOG4CXX_AUTO_TRACE(logger_); - if (0 < socket_fd){ - LOG4CXX_INFO(logger_, "Shutdown socket"); - if (-1 == ::shutdown(socket_fd, SHUT_RDWR)) { - LOG4CXX_ERROR(logger_, "Unable to shutdown socket"); - } - if (-1 == close(socket_fd)) { - LOG4CXX_ERROR(logger_, "Unable to close socket"); - } - } else { - LOG4CXX_WARN(logger_, "Socket in not connected: " << socket_fd); - } -} - -void TimeManager::Streamer::Stop() { - LOG4CXX_AUTO_TRACE(logger_); - if (stop_flag_) { - LOG4CXX_WARN(logger_, "Already Stopped"); - return; - } - stop_flag_ = true; - messages_.Reset(); - LOG4CXX_WARN(logger_, "Stop server_socket_fd_"); - ShutDownAndCloseSocket(server_socket_fd_); - server_socket_fd_ = -1; - - LOG4CXX_WARN(logger_, "Stop client_socket_fd_"); - ShutDownAndCloseSocket(client_socket_fd_); - client_socket_fd_ = -1; - is_client_connected_ = false; -} - -bool TimeManager::Streamer::IsReady() const { - bool result = true; - fd_set fds; - FD_ZERO(&fds); - FD_SET(client_socket_fd_, &fds); - TimevalStruct tv = {0, 0}; - tv.tv_sec = 5; // set a 5 second timeout - tv.tv_usec = 0; - - const int retval = select(client_socket_fd_ + 1, 0, &fds, 0, &tv); - - if (-1 == retval) { - LOG4CXX_ERROR_EXT(logger_, "An error occurred"); - result = false; - } else if (0 == retval) { - LOG4CXX_ERROR_EXT(logger_, "The timeout expired"); - result = false; - } - - return result; -} - -bool TimeManager::Streamer::Send(const std::string& msg) { - LOG4CXX_AUTO_TRACE(logger_); - if (!IsReady()) { - LOG4CXX_ERROR_EXT(logger_, " Socket is not ready"); - return false; - } - - if (-1 == ::send(client_socket_fd_, msg.c_str(), - msg.size(), MSG_NOSIGNAL)) { - LOG4CXX_ERROR_EXT(logger_, " Unable to send"); - return false; - } - return true; -} - -void TimeManager::Streamer::PushMessage(utils::SharedPtr<MetricWrapper> metric) { - messages_.push(metric); -} -} // namespace time_tester diff --git a/src/components/time_tester/src/transport_manager_metric.cc b/src/components/time_tester/src/transport_manager_metric.cc deleted file mode 100644 index a7c9ecb5a2..0000000000 --- a/src/components/time_tester/src/transport_manager_metric.cc +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2014, 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 "transport_manager_metric.h" -#include "json/json.h" -#include "json_keys.h" -#include "application_manager/smart_object_keys.h" - -namespace time_tester { - -Json::Value TransportManagerMecticWrapper::GetJsonMetric() { - Json::Value result = MetricWrapper::GetJsonMetric(); - result[strings::logger] = "TransportManager"; - result[strings::begin] = - Json::Int64(date_time::DateTime::getuSecs(message_metric->begin)); - result[strings::end] = - Json::Int64(date_time::DateTime::getuSecs(message_metric->end)); - result[strings::data_size] = static_cast<uint32_t>(message_metric->data_size); - return result; -} - -} // 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 deleted file mode 100644 index 6c63a576e7..0000000000 --- a/src/components/time_tester/src/transport_manager_observer.cc +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2014, 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 "transport_manager_observer.h" - -#include <time.h> - -#include "transport_manager_metric.h" -#include "time_manager.h" - -namespace time_tester { - -TransportManagerObserver::TransportManagerObserver(TimeManager* time_manager): - time_manager_ (time_manager) { -} - -void TransportManagerObserver::StartRawMsg(const protocol_handler::RawMessage* ptr) { - time_starts[ptr] = date_time::DateTime::getCurrentTime(); -} - -void TransportManagerObserver::StopRawMsg(const protocol_handler::RawMessage* ptr) { - std::map<const protocol_handler::RawMessage*, TimevalStruct>::const_iterator it; - it = time_starts.find(ptr); - if (it != time_starts.end()) { - TransportManagerMecticWrapper* m = new TransportManagerMecticWrapper(); - m->message_metric = new transport_manager::TMMetricObserver::MessageMetric(); - m->message_metric->begin = it->second; - m->message_metric->end = date_time::DateTime::getCurrentTime(); - m->message_metric->data_size = ptr->data_size(); - m->grabResources(); - time_manager_->SendMetric(m); - } -} - -} //namespace time_tester diff --git a/src/components/time_tester/test/CMakeLists.txt b/src/components/time_tester/test/CMakeLists.txt deleted file mode 100644 index 006f6a430f..0000000000 --- a/src/components/time_tester/test/CMakeLists.txt +++ /dev/null @@ -1,93 +0,0 @@ -# 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. - -if(BUILD_TESTS) - -include_directories ( - ${CMAKE_SOURCE_DIR}/src/3rd_party-static/gmock-1.7.0/include - ${CMAKE_SOURCE_DIR}/src/3rd_party-static/gmock-1.7.0/gtest/include - ${COMPONENTS_DIR}/include/utils - ${COMPONENTS_DIR}/include/protocol_handler - ${COMPONENTS_DIR}/time_tester/include - ${COMPONENTS_DIR}/utils/include - ${COMPONENTS_DIR}/protocol_handler/include - ${COMPONENTS_DIR}/application_manager/include - ${COMPONENTS_DIR}/protocol_handler/test - ) - - -set(testSources - #metric_wrapper_test.cc - #time_manager_test.cc - #protocol_handler_metric_test.cc - protocol_handler_observer_test.cc - #transport_manager_metric_test.cc - transport_manager_observer_test.cc - #application_manager_metric_test.cc - application_manager_observer_test.cc -) - -set(testLibraries - gmock - TimeTester - jsoncpp - Utils - MediaManager - ProtocolHandler - v4_protocol_v1_2_no_extra - SmartObjects - ProtocolLibrary - ConfigProfile - connectionHandler - ApplicationManager - Resumption - jsoncpp - transport_manager - MediaManager - ProtocolHandler -) - -if (BUILD_USB_SUPPORT) - list(APPEND testLibraries Libusb-1.0.16) -endif() - -if (BUILD_BT_SUPPORT) - list(APPEND testLibraries bluetooth) -endif() - -if (BUILD_AVAHI_SUPPORT) - list(APPEND testLibraries avahi-client avahi-common) -endif() - -file(COPY log4cxx.properties DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) - -create_test("time_tester_test" "${testSources}" "${testLibraries}") - -endif() diff --git a/src/components/time_tester/test/application_manager_metric_test.cc b/src/components/time_tester/test/application_manager_metric_test.cc deleted file mode 100644 index 7d09cc85c9..0000000000 --- a/src/components/time_tester/test/application_manager_metric_test.cc +++ /dev/null @@ -1,118 +0,0 @@ -/* - * 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 "gtest/gtest.h" -#include "json_keys.h" -#include "utils/resource_usage.h" -#include "application_manager/smart_object_keys.h" -#include "application_manager_metric.h" - -namespace test { -namespace components { -namespace time_tester_test { - -using namespace ::time_tester; - -TEST(ApplicationManagerMetricWrapper, grabResources) { - ApplicationManagerMetricWrapper metric_test; - EXPECT_TRUE(metric_test.grabResources()); -} - -TEST(ApplicationManagerMetricWrapper, GetJsonMetric) { - ApplicationManagerMetricWrapper metric_test; - - TimevalStruct start_time; - start_time.tv_sec = 1; - start_time.tv_usec = 0; - - TimevalStruct end_time; - end_time.tv_sec = 10; - end_time.tv_usec = 0; - metric_test.message_metric = new application_manager::AMMetricObserver::MessageMetric(); - metric_test.message_metric->begin = start_time; - metric_test.message_metric->end = end_time; - NsSmartDeviceLink::NsSmartObjects::SmartObject obj; - obj["params"][application_manager::strings::correlation_id] = 11; - obj["params"][application_manager::strings::connection_key] = 12; - metric_test.message_metric->message = new NsSmartDeviceLink::NsSmartObjects::SmartObject(obj); - Json::Value jvalue = metric_test.GetJsonMetric(); - - EXPECT_EQ("null\n", jvalue[time_tester::strings::stime].toStyledString()); - EXPECT_EQ("null\n", jvalue[time_tester::strings::utime].toStyledString()); - EXPECT_EQ("null\n", jvalue[time_tester::strings::memory].toStyledString()); - - EXPECT_EQ(date_time::DateTime::getuSecs(start_time), jvalue[time_tester::strings::begin].asInt64()); - EXPECT_EQ(date_time::DateTime::getuSecs(end_time), jvalue[time_tester::strings::end].asInt64()); - EXPECT_EQ(obj["params"][application_manager::strings::correlation_id].asInt(), jvalue[time_tester::strings::correlation_id].asInt64()); - EXPECT_EQ(obj["params"][application_manager::strings::connection_key].asInt(), jvalue[time_tester::strings::connection_key].asInt()); -} - -TEST(ApplicationManagerMetricWrapper, GetJsonMetricWithGrabResources) { - ApplicationManagerMetricWrapper metric_test; - utils::ResourseUsage* resources = utils::Resources::getCurrentResourseUsage(); - EXPECT_TRUE(metric_test.grabResources()); - - TimevalStruct start_time; - start_time.tv_sec = 1; - start_time.tv_usec = 0; - - TimevalStruct end_time; - end_time.tv_sec = 10; - end_time.tv_usec = 0; - - metric_test.message_metric = new application_manager::AMMetricObserver::MessageMetric(); - metric_test.message_metric->begin = start_time; - metric_test.message_metric->end = end_time; - NsSmartDeviceLink::NsSmartObjects::SmartObject obj; - obj["params"][application_manager::strings::correlation_id] = 11; - obj["params"][application_manager::strings::connection_key] = 12; - metric_test.message_metric->message = new NsSmartDeviceLink::NsSmartObjects::SmartObject(obj); - Json::Value jvalue = metric_test.GetJsonMetric(); - - EXPECT_EQ(date_time::DateTime::getuSecs(start_time), jvalue[time_tester::strings::begin].asInt64()); - EXPECT_EQ(date_time::DateTime::getuSecs(end_time), jvalue[time_tester::strings::end].asInt64()); - EXPECT_EQ(obj["params"][application_manager::strings::correlation_id].asInt(), jvalue[time_tester::strings::correlation_id].asInt64()); - EXPECT_EQ(obj["params"][application_manager::strings::connection_key].asInt(), jvalue[time_tester::strings::connection_key].asInt()); - - EXPECT_EQ(date_time::DateTime::getuSecs(start_time), jvalue[time_tester::strings::begin].asInt64()); - EXPECT_EQ(date_time::DateTime::getuSecs(end_time), jvalue[time_tester::strings::end].asInt64()); - - EXPECT_NEAR(resources->stime, jvalue[time_tester::strings::stime].asInt(),1); - EXPECT_NEAR(resources->utime, jvalue[time_tester::strings::utime].asInt(),1); - EXPECT_EQ(resources->memory, jvalue[time_tester::strings::memory].asInt()); - - delete resources; -} - -} // namespace time_tester -} // namespace components -} // namespace test diff --git a/src/components/time_tester/test/application_manager_observer_test.cc b/src/components/time_tester/test/application_manager_observer_test.cc deleted file mode 100644 index f63394e4f2..0000000000 --- a/src/components/time_tester/test/application_manager_observer_test.cc +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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 "gtest/gtest.h" -#include "include/time_manager_mock.h" -#include "application_manager/time_metric_observer.h" -#include "application_manager_metric.h" -#include "application_manager_observer.h" -#include "utils/shared_ptr.h" -#include "time_manager.h" - -namespace test { -namespace components { -namespace time_tester_test { - -using namespace time_tester; -using ::testing::_; - -TEST(ApplicationManagerObserver, DISABLED_CallOnMessage) { - TimeManagerMock time_manager_mock; - ApplicationManagerObserver app_observer(&time_manager_mock); - typedef application_manager::AMMetricObserver::MessageMetric AMMetric; - utils::SharedPtr<AMMetric> ptr = application_manager::AMMetricObserver::MessageMetricSharedPtr(); - EXPECT_CALL(time_manager_mock, SendMetric(_)); - app_observer.OnMessage(ptr); -} - -} // namespace time_tester -} // namespace components -} // namespace test diff --git a/src/components/time_tester/test/include/time_manager_mock.h b/src/components/time_tester/test/include/time_manager_mock.h deleted file mode 100644 index dfdfa2da7b..0000000000 --- a/src/components/time_tester/test/include/time_manager_mock.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2014, 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. - */ - -#ifndef TEST_COMPONENTS_TIME_MANAGER_INCLUDE_TIME_MANAGER_MOCK_H_ -#define TEST_COMPONENTS_TIME_MANAGER_INCLUDE_TIME_MANAGER_MOCK_H_ - -#include <gmock/gmock.h> -#include "time_manager.h" -#include "metric_wrapper.h" -namespace test { -namespace components { -namespace time_tester_test { - -using namespace time_tester; -/* - * MOCK implementation of ::security_manager::SecurityManager - */ -class TimeManagerMock : public time_tester::TimeManager { - public: - MOCK_METHOD1(Init, void(protocol_handler::ProtocolHandlerImpl* ph)); - MOCK_METHOD0(Stop, void()); - MOCK_METHOD0(Start, void()); - MOCK_METHOD1(SendMetric, void(utils::SharedPtr<MetricWrapper> metric)); -}; -} // time_tester_test -} // components -} // test -#endif // TEST_COMPONENTS_TIME_MANAGER_INCLUDE_TIME_MANAGER_MOCK_H_ diff --git a/src/components/time_tester/test/log4cxx.properties b/src/components/time_tester/test/log4cxx.properties deleted file mode 100644 index 68adbfa7f3..0000000000 --- a/src/components/time_tester/test/log4cxx.properties +++ /dev/null @@ -1,19 +0,0 @@ -# Only ERROR and FATAL messages are logged to console -log4j.appender.Console=org.apache.log4j.ConsoleAppender -log4j.appender.Console.ImmediateFlush=true -log4j.appender.Console.layout=org.apache.log4j.PatternLayout -log4j.appender.Console.layout.ConversionPattern=%-5p [%d{dd MMM yyyy HH:mm:ss,SSS}][%c] %m%n -log4j.appender.Console.Threshold=DEBUG - -# Log for all SmartDeviceLinkCore messages -log4j.appender.SmartDeviceLinkCoreLogFile=org.apache.log4j.FileAppender -log4j.appender.SmartDeviceLinkCoreLogFile.File=SmartDeviceLinkCore.log -log4j.appender.SmartDeviceLinkCoreLogFile.append=true -log4j.appender.SmartDeviceLinkCoreLogFile.DatePattern='.' yyyy-MM-dd HH-mm -log4j.appender.SmartDeviceLinkCoreLogFile.ImmediateFlush=true -log4j.appender.SmartDeviceLinkCoreLogFile.layout=org.apache.log4j.PatternLayout -log4j.appender.SmartDeviceLinkCoreLogFile.layout.ConversionPattern=%-5p [%d{dd MMM yyyy HH:mm:ss,SSS}][%c] %F:%L %M: %m%n - - -# All SmartDeviceLinkCore logs -log4j.rootLogger=ALL, Console, SmartDeviceLinkCoreLogFile diff --git a/src/components/time_tester/test/metric_wrapper_test.cc b/src/components/time_tester/test/metric_wrapper_test.cc deleted file mode 100644 index 5eddf0fb62..0000000000 --- a/src/components/time_tester/test/metric_wrapper_test.cc +++ /dev/null @@ -1,82 +0,0 @@ -/* - * 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 "gtest/gtest.h" -#include "metric_wrapper.h" -#include "json_keys.h" -#include "json/json.h" -#include "utils/resource_usage.h" - -namespace test { -namespace components { -namespace time_tester_test { - -using namespace ::time_tester; - -TEST(MetricWrapper, grabResources) { - MetricWrapper metric_test; - EXPECT_TRUE(metric_test.grabResources()); -} - -TEST(MetricWrapper, GetJsonMetricWithoutGrab) { - MetricWrapper metric_test; - Json::Value jvalue = metric_test.GetJsonMetric(); - - EXPECT_EQ("null\n", jvalue[strings::stime].toStyledString()); - EXPECT_EQ("null\n", jvalue[strings::utime].toStyledString()); - EXPECT_EQ("null\n", jvalue[strings::memory].toStyledString()); -} - -TEST(MetricWrapper, GetJsonMetricWithGrabResources) { - MetricWrapper metric_test; - utils::ResourseUsage* resources = utils::Resources::getCurrentResourseUsage(); - EXPECT_TRUE(resources != NULL); - EXPECT_TRUE(metric_test.grabResources()); - Json::Value jvalue = metric_test.GetJsonMetric(); - - EXPECT_TRUE(jvalue[strings::stime].isInt()); - EXPECT_TRUE(jvalue[strings::utime].isInt()); - EXPECT_TRUE(jvalue[strings::memory].isInt()); - EXPECT_NE("null/n", jvalue[strings::stime].toStyledString()); - EXPECT_NE("null/n", jvalue[strings::utime].toStyledString()); - EXPECT_NE("null/n", jvalue[strings::memory].toStyledString()); - - EXPECT_NEAR(resources->stime, jvalue[strings::stime].asInt(),1); - EXPECT_NEAR(resources->utime, jvalue[strings::utime].asInt(),1); - EXPECT_EQ(resources->memory, jvalue[strings::memory].asInt()); - - delete resources; -} - -} // namespace time_tester -} // namespace components -} // namespace test diff --git a/src/components/time_tester/test/protocol_handler_metric_test.cc b/src/components/time_tester/test/protocol_handler_metric_test.cc deleted file mode 100644 index 150e1205fe..0000000000 --- a/src/components/time_tester/test/protocol_handler_metric_test.cc +++ /dev/null @@ -1,119 +0,0 @@ -/* - * 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 "gtest/gtest.h" -#include "json_keys.h" -#include "json/json.h" -#include "utils/resource_usage.h" -#include "protocol_handler_metric.h" -#include "protocol_handler/time_metric_observer.h" - -namespace test { -namespace components { -namespace time_tester_test { - -using namespace ::time_tester; - -TEST(ProtocolHandlerMetricTest, grabResources) { - ProtocolHandlerMecticWrapper metric_test; - EXPECT_TRUE(metric_test.grabResources()); -} - -TEST(ProtocolHandlerMetricTest, GetJsonMetric) { - ProtocolHandlerMecticWrapper metric_test; - - TimevalStruct start_time; - start_time.tv_sec = 1; - start_time.tv_usec = 0; - - TimevalStruct end_time; - end_time.tv_sec = 10; - end_time.tv_usec = 0; - metric_test.message_metric = new protocol_handler::PHMetricObserver::MessageMetric(); - metric_test.message_metric->begin = start_time; - metric_test.message_metric->end = end_time; - metric_test.message_metric->message_id = 5; - metric_test.message_metric->connection_key = 2; - Json::Value jvalue = metric_test.GetJsonMetric(); - - EXPECT_EQ("\"ProtocolHandler\"\n", jvalue[strings::logger].toStyledString()); - EXPECT_EQ("null\n", jvalue[strings::stime].toStyledString()); - EXPECT_EQ("null\n", jvalue[strings::utime].toStyledString()); - EXPECT_EQ("null\n", jvalue[strings::memory].toStyledString()); - - EXPECT_EQ(date_time::DateTime::getuSecs(start_time), jvalue[strings::begin].asInt64()); - EXPECT_EQ(date_time::DateTime::getuSecs(end_time), jvalue[strings::end].asInt64()); - EXPECT_EQ(5, jvalue[strings::message_id].asInt64()); - EXPECT_EQ(2, jvalue[strings::connection_key].asInt()); -} - -TEST(ProtocolHandlerMetricTest, GetJsonMetricWithGrabResources) { - ProtocolHandlerMecticWrapper metric_test; - utils::ResourseUsage* resources = utils::Resources::getCurrentResourseUsage(); - EXPECT_TRUE(resources != NULL); - EXPECT_TRUE(metric_test.grabResources()); - - TimevalStruct start_time; - start_time.tv_sec = 1; - start_time.tv_usec = 0; - - TimevalStruct end_time; - end_time.tv_sec = 10; - end_time.tv_usec = 0; - metric_test.message_metric = new protocol_handler::PHMetricObserver::MessageMetric(); - metric_test.message_metric->begin = start_time; - metric_test.message_metric->end = end_time; - metric_test.message_metric->message_id = 5; - metric_test.message_metric->connection_key = 2; - Json::Value jvalue = metric_test.GetJsonMetric(); - - EXPECT_TRUE(jvalue[strings::stime].isInt()); - EXPECT_TRUE(jvalue[strings::utime].isInt()); - EXPECT_TRUE(jvalue[strings::memory].isInt()); - EXPECT_NE("null/n", jvalue[strings::stime].toStyledString()); - EXPECT_NE("null/n", jvalue[strings::utime].toStyledString()); - EXPECT_NE("null/n", jvalue[strings::memory].toStyledString()); - - EXPECT_EQ(date_time::DateTime::getuSecs(start_time), jvalue[strings::begin].asInt64()); - EXPECT_EQ(date_time::DateTime::getuSecs(end_time), jvalue[strings::end].asInt64()); - EXPECT_EQ(5, jvalue[strings::message_id].asInt64()); - EXPECT_EQ(2, jvalue[strings::connection_key].asInt()); - - EXPECT_NEAR(resources->stime, jvalue[strings::stime].asInt(),1); - EXPECT_NEAR(resources->utime, jvalue[strings::utime].asInt(),1); - EXPECT_EQ(resources->memory, jvalue[strings::memory].asInt()); - delete resources; -} - -} // namespace time_tester -} // namespace components -} // namespace test diff --git a/src/components/time_tester/test/protocol_handler_observer_test.cc b/src/components/time_tester/test/protocol_handler_observer_test.cc deleted file mode 100644 index 8922334aee..0000000000 --- a/src/components/time_tester/test/protocol_handler_observer_test.cc +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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 "gtest/gtest.h" -#include "time_manager.h" -#include "include/time_manager_mock.h" -#include "protocol_handler/time_metric_observer.h" - -namespace test { -namespace components { -namespace time_tester_test { - -using namespace time_tester; -using ::testing::_; - -TEST(ProtocolHandlerObserverTest, DISABLED_MessageProcess) { - TimeManagerMock time_manager_mock; - - ProtocolHandlerObserver pr_handler(&time_manager_mock); - uint32_t message_id = 1; - TimevalStruct start_time; - start_time.tv_sec = 1; - start_time.tv_usec = 0; - pr_handler.StartMessageProcess(message_id, start_time); - - typedef protocol_handler::PHMetricObserver::MessageMetric MetricType; - utils::SharedPtr<MetricType> message_metric = new MetricType(); - message_metric->message_id = 1; - EXPECT_CALL(time_manager_mock, SendMetric(_)); - pr_handler.EndMessageProcess(message_metric); -} - -TEST(ProtocolHandlerObserverTest, MessageProcessWithZeroMessageId) { - TimeManagerMock time_manager_mock; - - ProtocolHandlerObserver pr_handler(&time_manager_mock); - uint32_t message_id = 0; - TimevalStruct start_time; - start_time.tv_sec = 1; - start_time.tv_usec = 0; - pr_handler.StartMessageProcess(message_id, start_time); - - typedef protocol_handler::PHMetricObserver::MessageMetric MetricType; - utils::SharedPtr<MetricType> message_metric = new MetricType(); - message_metric->message_id = 0; - EXPECT_CALL(time_manager_mock, SendMetric(_)).Times(0); - pr_handler.EndMessageProcess(message_metric); -} - -} // namespace time_tester -} // namespace components -} // namespace test diff --git a/src/components/time_tester/test/time_manager_test.cc b/src/components/time_tester/test/time_manager_test.cc deleted file mode 100644 index 60f3bd6814..0000000000 --- a/src/components/time_tester/test/time_manager_test.cc +++ /dev/null @@ -1,72 +0,0 @@ -/* - * 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 "gtest/gtest.h" -#include "gmock/gmock.h" -#include "time_manager.h" -#include "protocol_handler/time_metric_observer.h" -#include "protocol_handler.h" -#include "include/protocol_handler_mock.h" - -namespace test { -namespace components { -namespace time_tester_test { - -using namespace time_tester; - -class StreamerMock : public Streamer { - public: - StreamerMock(TimeManager* const server) - : Streamer(server) { - is_client_connected_ = true; - } - MOCK_METHOD1(PushMessage,void(utils::SharedPtr<MetricWrapper> metric)); -}; - -TEST(TimeManagerTest, DISABLED_MessageProcess) { - //TODO(AK) APPLINK-13351 Disable due to refactor TimeTester - protocol_handler_test::TransportManagerMock transport_manager_mock; - protocol_handler::ProtocolHandlerImpl protocol_handler_mock(&transport_manager_mock, 0, 0, 0, 0, 0); - TimeManager * time_manager = new TimeManager(); - // Streamer will be deleted by Thread - StreamerMock* streamer_mock = new StreamerMock(time_manager); - time_manager->set_streamer(streamer_mock); - time_manager->Init(&protocol_handler_mock); - utils::SharedPtr<MetricWrapper> test_metric; - EXPECT_CALL(*streamer_mock, PushMessage(test_metric)); - time_manager->SendMetric(test_metric); - delete time_manager; -} - -} // namespace time_tester -} // namespace components -} // namespace test diff --git a/src/components/time_tester/test/transport_manager_metric_test.cc b/src/components/time_tester/test/transport_manager_metric_test.cc deleted file mode 100644 index 2bb09416ed..0000000000 --- a/src/components/time_tester/test/transport_manager_metric_test.cc +++ /dev/null @@ -1,110 +0,0 @@ -/* - * 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 "gtest/gtest.h" -#include "json_keys.h" -#include "json/json.h" -#include "utils/resource_usage.h" -#include "transport_manager_metric.h" -#include "protocol_handler/time_metric_observer.h" - -namespace test { -namespace components { -namespace time_tester_test { - -using namespace ::time_tester; - -TEST(TransportManagerMetricWrapper, grabResources) { - TransportManagerMecticWrapper metric_test; - EXPECT_TRUE(metric_test.grabResources()); -} - -TEST(TransportManagerMetricWrapper, GetJsonMetric) { - TransportManagerMecticWrapper metric_test; - - TimevalStruct start_time; - start_time.tv_sec = 1; - start_time.tv_usec = 0; - - TimevalStruct end_time; - end_time.tv_sec = 10; - end_time.tv_usec = 0; - metric_test.message_metric = new transport_manager::TMMetricObserver::MessageMetric(); - metric_test.message_metric->begin = start_time; - metric_test.message_metric->end = end_time; - metric_test.message_metric->data_size = 1000; - Json::Value jvalue = metric_test.GetJsonMetric(); - - EXPECT_EQ("null\n", jvalue[strings::stime].toStyledString()); - EXPECT_EQ("null\n", jvalue[strings::utime].toStyledString()); - EXPECT_EQ("null\n", jvalue[strings::memory].toStyledString()); - - EXPECT_EQ(date_time::DateTime::getuSecs(start_time), jvalue[strings::begin].asInt64()); - EXPECT_EQ(date_time::DateTime::getuSecs(end_time), jvalue[strings::end].asInt64()); - EXPECT_EQ(1000, jvalue[strings::data_size].asInt()); -} - -TEST(TransportManagerMetricWrapper, GetJsonMetricWithGrabResources) { - TransportManagerMecticWrapper metric_test; - utils::ResourseUsage* resources = utils::Resources::getCurrentResourseUsage(); - EXPECT_TRUE(resources != NULL); - EXPECT_TRUE(metric_test.grabResources()); - - TimevalStruct start_time; - start_time.tv_sec = 1; - start_time.tv_usec = 0; - - TimevalStruct end_time; - end_time.tv_sec = 10; - end_time.tv_usec = 0; - metric_test.message_metric = new transport_manager::TMMetricObserver::MessageMetric(); - metric_test.message_metric->begin = start_time; - metric_test.message_metric->end = end_time; - - metric_test.message_metric->data_size = 1000; - Json::Value jvalue = metric_test.GetJsonMetric(); - - EXPECT_EQ("\"TransportManager\"\n", jvalue[strings::logger].toStyledString()); - EXPECT_EQ(date_time::DateTime::getuSecs(start_time), jvalue[strings::begin].asInt64()); - EXPECT_EQ(date_time::DateTime::getuSecs(end_time), jvalue[strings::end].asInt64()); - EXPECT_EQ(1000, jvalue[strings::data_size].asInt()); - - EXPECT_NEAR(resources->stime, jvalue[strings::stime].asInt(),1); - EXPECT_NEAR(resources->utime, jvalue[strings::utime].asInt(),1); - EXPECT_EQ(resources->memory, jvalue[strings::memory].asInt()); - - delete resources; -} - -} // namespace time_tester -} // namespace components -} // namespace test diff --git a/src/components/time_tester/test/transport_manager_observer_test.cc b/src/components/time_tester/test/transport_manager_observer_test.cc deleted file mode 100644 index 9dcf27bd97..0000000000 --- a/src/components/time_tester/test/transport_manager_observer_test.cc +++ /dev/null @@ -1,58 +0,0 @@ -/* - * 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 "gtest/gtest.h" -#include "include/time_manager_mock.h" -#include "protocol_handler/time_metric_observer.h" -#include "transport_manager_metric.h" -#include "transport_manager_observer.h" - -namespace test { -namespace components { -namespace time_tester_test { - -using namespace time_tester; -using ::testing::_; - -TEST(TransportManagerObserverTest, DISABLED_MessageProcess) { - TimeManagerMock time_manager_mock; - TransportManagerObserver tr_observer(&time_manager_mock); - protocol_handler::RawMessage* ptr = new ::protocol_handler::RawMessage(0, 0, NULL, 0); - tr_observer.StartRawMsg(ptr); - EXPECT_CALL(time_manager_mock, SendMetric(_)); - tr_observer.StopRawMsg(ptr); - delete ptr; -} - -} // namespace time_tester -} // namespace components -} // namespace test |