From bbfa76a2c98c0208cbca9c1f83381aeb99fff96f Mon Sep 17 00:00:00 2001 From: Benjamin Sergeant Date: Fri, 25 Oct 2019 14:46:10 -0700 Subject: [PATCH] move sentry code around and add a stub unittest for it --- CMakeLists.txt | 1 + ixsentry/CMakeLists.txt | 24 ++++++++++++++++ {ws => ixsentry/ixsentry}/IXSentryClient.cpp | 0 {ws => ixsentry/ixsentry}/IXSentryClient.h | 0 test/CMakeLists.txt | 2 ++ test/IXSentryClientTest.cpp | 30 ++++++++++++++++++++ ws/CMakeLists.txt | 3 +- ws/ws_cobra_to_sentry.cpp | 2 +- 8 files changed, 59 insertions(+), 3 deletions(-) create mode 100644 ixsentry/CMakeLists.txt rename {ws => ixsentry/ixsentry}/IXSentryClient.cpp (100%) rename {ws => ixsentry/ixsentry}/IXSentryClient.h (100%) create mode 100644 test/IXSentryClientTest.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 4592a32a..f8b8776a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -228,6 +228,7 @@ if (USE_WS OR USE_TEST) add_subdirectory(ixcrypto) add_subdirectory(ixcobra) add_subdirectory(ixsnake) + add_subdirectory(ixsentry) add_subdirectory(third_party/spdlog spdlog) diff --git a/ixsentry/CMakeLists.txt b/ixsentry/CMakeLists.txt new file mode 100644 index 00000000..c0493838 --- /dev/null +++ b/ixsentry/CMakeLists.txt @@ -0,0 +1,24 @@ +# +# Author: Benjamin Sergeant +# Copyright (c) 2019 Machine Zone, Inc. All rights reserved. +# + +set (IXSENTRY_SOURCES + ixsentry/IXSentryClient.cpp +) + +set (IXSENTRY_HEADERS + ixsentry/IXSentryClient.h +) + +add_library(ixsentry STATIC + ${IXSENTRY_SOURCES} + ${IXSENTRY_HEADERS} +) + +set(IXSENTRY_INCLUDE_DIRS + . + ../third_party + ../third_party/spdlog/include) + +target_include_directories( ixsentry PUBLIC ${IXSENTRY_INCLUDE_DIRS} ) diff --git a/ws/IXSentryClient.cpp b/ixsentry/ixsentry/IXSentryClient.cpp similarity index 100% rename from ws/IXSentryClient.cpp rename to ixsentry/ixsentry/IXSentryClient.cpp diff --git a/ws/IXSentryClient.h b/ixsentry/ixsentry/IXSentryClient.h similarity index 100% rename from ws/IXSentryClient.h rename to ixsentry/ixsentry/IXSentryClient.h diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 8f668a17..9b471c94 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -45,6 +45,7 @@ set (SOURCES IXCobraMetricsPublisherTest.cpp IXDNSLookupTest.cpp IXWebSocketSubProtocolTest.cpp + IXSentryClientTest.cpp ) # Some unittest don't work on windows yet @@ -83,5 +84,6 @@ target_link_libraries(ixwebsocket_unittest ixcobra) target_link_libraries(ixwebsocket_unittest ixwebsocket) target_link_libraries(ixwebsocket_unittest ixcrypto) target_link_libraries(ixwebsocket_unittest ixcore) +target_link_libraries(ixwebsocket_unittest ixsentry) install(TARGETS ixwebsocket_unittest DESTINATION bin) diff --git a/test/IXSentryClientTest.cpp b/test/IXSentryClientTest.cpp new file mode 100644 index 00000000..95d12e69 --- /dev/null +++ b/test/IXSentryClientTest.cpp @@ -0,0 +1,30 @@ +/* + * IXSentryClientTest.cpp + * Author: Benjamin Sergeant + * Copyright (c) 2019 Machine Zone. All rights reserved. + */ + +#include "IXTest.h" +#include "catch.hpp" +#include +#include + +using namespace ix; + +namespace ix +{ + TEST_CASE("sentry", "[sentry]") + { + SECTION("Attempt to perform nil") + { +#if 0 + SentryClient sentryClient; + std::string stack = ""; + auto frames = sentryClient.parseLuaStackTrace(stack); + + REQUIRE(frames.size() > 0); +#endif + } + } + +} // namespace ix diff --git a/ws/CMakeLists.txt b/ws/CMakeLists.txt index af58c5c8..2bd98259 100644 --- a/ws/CMakeLists.txt +++ b/ws/CMakeLists.txt @@ -34,8 +34,6 @@ add_executable(ws ../third_party/jsoncpp/jsoncpp.cpp ${STATSD_CLIENT_SOURCES} - IXSentryClient.cpp - ws_http_client.cpp ws_ping_pong.cpp ws_broadcast_server.cpp @@ -64,6 +62,7 @@ target_link_libraries(ws ixcobra) target_link_libraries(ws ixwebsocket) target_link_libraries(ws ixcrypto) target_link_libraries(ws ixcore) +target_link_libraries(ws ixsentry) if(NOT APPLE AND NOT USE_MBED_TLS) find_package(OpenSSL REQUIRED) diff --git a/ws/ws_cobra_to_sentry.cpp b/ws/ws_cobra_to_sentry.cpp index bd6f8f1c..a0917373 100644 --- a/ws/ws_cobra_to_sentry.cpp +++ b/ws/ws_cobra_to_sentry.cpp @@ -4,7 +4,7 @@ * Copyright (c) 2019 Machine Zone, Inc. All rights reserved. */ -#include "IXSentryClient.h" +#include #include #include #include