From 6469f6591c80f9b8274b57528bbe06facacf492a Mon Sep 17 00:00:00 2001 From: k-morozov Date: Mon, 3 Aug 2020 17:57:33 +0300 Subject: [PATCH 01/17] fix load travis --- .travis.yml | 44 +++++++++++++++++++++----------------------- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/.travis.yml b/.travis.yml index e96ee6b..8482e9c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,8 +2,7 @@ dist: bionic language: cpp compiler: gcc sudo: required -compiler: - - gcc + os: - linux addons: @@ -36,10 +35,8 @@ script: - cmake --build . --target test - cd ${TRAVIS_BUILD_DIR}/build/bin - tar -cf AppChat-0.7.$TRAVIS_BUILD_NUMBER-Linux.tar server client - #- cmake --build . --target package after_success: - # Generate the docs only if master, and the TRAVIS_BUILD_DOCS is not zero - >- if [[ "$TRAVIS_BRANCH" = "master" && -n "$TRAVIS_BUILD_DOCS" ]] ; then cd $TRAVIS_BUILD_DIR @@ -48,13 +45,15 @@ after_success: doxygen doc/Doxyfile 2>&1 | tee doxygen.log fi + if [[ "$TRAVIS_BRANCH" = "master" ]] ; then + curl -T ${TRAVIS_BUILD_DIR}/build/bin/AppChat-0.7.$TRAVIS_BUILD_NUMBER-Linux.tar -uk-morozov:$BINTRAY_API_KEY https://api.bintray.com/content/k-morozov/AppChat/Download/0.7.$TRAVIS_BUILD_NUMBER/AppChat-0.7.$TRAVIS_BUILD_NUMBER-Linux.tar + fi + deploy: - - provider: script - skip_cleanup: true - script: - - curl -T ${TRAVIS_BUILD_DIR}/build/bin/AppChat-0.7.$TRAVIS_BUILD_NUMBER-Linux.tar -uk-morozov:$BINTRAY_API_KEY https://api.bintray.com/content/k-morozov/AppChat/Download/0.7.$TRAVIS_BUILD_NUMBER/AppChat-0.7.$TRAVIS_BUILD_NUMBER-Linux.tar - on: - branch: master + #- provider: script + # skip_cleanup: true + # script: + # - curl -T ${TRAVIS_BUILD_DIR}/build/bin/AppChat-0.7.$TRAVIS_BUILD_NUMBER-Linux.tar -uk-morozov:$BINTRAY_API_KEY https://api.bintray.com/content/k-morozov/AppChat/Download/0.7.$TRAVIS_BUILD_NUMBER/AppChat-0.7.$TRAVIS_BUILD_NUMBER-Linux.tar - provider: pages skip-cleanup: true @@ -62,18 +61,17 @@ deploy: keep-history: true local-dir: docs/html on: - branch: master + branch: master -before_deploy: - - git config --local user.name "k-morozov" - - git config --local user.email "morozov-kst@yandex.ru" - #- export TRAVIS_TAG=${TRAVIS_TAG:-$(date +'%d%m')-$TRAVIS_BUILD_NUMBER-Linux} - - git tag 0.7.$TRAVIS_BUILD_NUMBER-Linux -deploy: - - provider: releases - api_key: $GITHUB_API_KEY - file: AppChat-0.7.$TRAVIS_BUILD_NUMBER-Linux.tar - skip_cleanup: true - on: - branch: release +#before_deploy: +# - git config --local user.name "k-morozov" +# - git config --local user.email "morozov-kst@yandex.ru" +# - git tag 0.7.$TRAVIS_BUILD_NUMBER-Linux +#deploy: +# - provider: releases +# api_key: $GITHUB_API_KEY +# file: AppChat-0.7.$TRAVIS_BUILD_NUMBER-Linux.tar +# skip_cleanup: true +# on: +# branch: release From b31de6d341a685ed43daf710274f0ea79ba80223 Mon Sep 17 00:00:00 2001 From: k-morozov Date: Mon, 3 Aug 2020 18:43:43 +0300 Subject: [PATCH 02/17] remove usless dir from Doxygen --- Doxyfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Doxyfile b/Doxyfile index 938273b..f518a32 100644 --- a/Doxyfile +++ b/Doxyfile @@ -918,7 +918,9 @@ RECURSIVE = TRUE # Note that relative paths are relative to the directory from which doxygen is # run. -EXCLUDE = "lib/log/log4cplus" +EXCLUDE = "lib/log/log4cplus" +EXCLUDE += "lib/libbacktrace" + # The EXCLUDE_SYMLINKS tag can be used to select whether or not files or # directories that are symbolic links (a Unix file system feature) are excluded From a8c2f5e87f79efa2653770a3ebd976abb0beaea2 Mon Sep 17 00:00:00 2001 From: k-morozov Date: Tue, 4 Aug 2020 11:46:35 +0300 Subject: [PATCH 03/17] - add ObjectPool for connections - rewrite find free connections - add doc - add check is open socket --- src/client/CMakeLists.txt | 2 +- src/client/client/client.cpp | 42 +++++++++-------- src/client/client/client.h | 4 +- src/client/control/control.cpp | 2 +- src/client/gui/mainwindow.cpp | 4 ++ src/server/CMakeLists.txt | 3 +- src/server/channel/channel.cpp | 1 + src/server/channel/channels_manager.cpp | 5 ++- src/server/connection/connection.cpp | 38 ++++++++++------ src/server/connection/connection.h | 44 +++++++++++++++++- src/server/connection/connection_manager.cpp | 43 ++++++++++++++++++ src/server/connection/connection_manager.h | 47 ++++++++++++++++++++ src/server/connection/isubscriber.h | 3 ++ src/server/server.h | 13 ++---- 14 files changed, 204 insertions(+), 47 deletions(-) create mode 100644 src/server/connection/connection_manager.cpp create mode 100644 src/server/connection/connection_manager.h diff --git a/src/client/CMakeLists.txt b/src/client/CMakeLists.txt index 51a994b..7592e1c 100644 --- a/src/client/CMakeLists.txt +++ b/src/client/CMakeLists.txt @@ -37,7 +37,7 @@ add_executable(${CLIENT_BIN} ${CLIENT_SOURCES}) target_include_directories(${CLIENT_BIN} PUBLIC .) #**************************************************************************************************** -find_package(Boost COMPONENTS system date_time program_options regex REQUIRED) +find_package(Boost COMPONENTS system date_time REQUIRED) set_target_properties(${CLIENT_BIN} PROPERTIES CXX_STANDARD 17 diff --git a/src/client/client/client.cpp b/src/client/client/client.cpp index 102620f..83452c5 100644 --- a/src/client/client/client.cpp +++ b/src/client/client/client.cpp @@ -1,5 +1,4 @@ #include -//#include void Client::write(const std::string& message) { text_request_ptr text_request = std::make_shared(login, room_id, message); @@ -60,7 +59,9 @@ void Client::send_login_packet(packet_ptr packet) { packet->get_length_data()), error_code); if (error_code) { - sock.close(); + if (sock.is_open()) { + sock.close(); + } std::cout << "error when send login" << std::endl; return ; } @@ -69,7 +70,9 @@ void Client::send_login_packet(packet_ptr packet) { boost::asio::read(sock, boost::asio::buffer(response->get_header(), Block::Header), error_code); if (error_code) { - sock.close(); + if (sock.is_open()) { + sock.close(); + } std::cout << "error when read login-id" << std::endl; return ; } @@ -89,19 +92,16 @@ void Client::send_login_packet(packet_ptr packet) { } else { -// good_client_is_registred(); emit send_input_code(InputCode::RegistrOK); } else { if (response->get_loginid()==-1) { -// emit bad_client_is_autorisation(); emit send_input_code(InputCode::IncorrectAutor); this->close(); return; } else { -// good_client_is_autorisation(); emit send_input_code(InputCode::AutorOK); } } @@ -154,7 +154,9 @@ void Client::read_response_header() { } } else { - sock.close(); + if (sock.is_open()) { + sock.close(); + } } }); } @@ -165,12 +167,12 @@ void Client::read_response_data(registr_response_ptr packet) { boost::asio::async_read(sock, boost::asio::buffer(packet->get_data(), packet->get_length_data()), [this, packet](boost::system::error_code error, std::size_t) { if (!error) { -// std::cout << "read_response_data" << std::endl; - read_response_header(); } else { - sock.close(); + if (sock.is_open()) { + sock.close(); + } } }); } @@ -181,11 +183,12 @@ void Client::read_response_data(autor_response_ptr packet) { boost::asio::async_read(sock, boost::asio::buffer(packet->get_data(), packet->get_length_data()), [this, packet](boost::system::error_code error, std::size_t) { if (!error) { -// std::cout << "read_response_data" << std::endl; read_response_header(); } else { - sock.close(); + if (sock.is_open()) { + sock.close(); + } } }); } @@ -204,14 +207,13 @@ void Client::read_response_data(text_response_ptr packet) { read_response_header(); } else { - sock.close(); + if (sock.is_open()) { + sock.close(); + } } }); } -//void Client::read_response_join_room(join_room_request_ptr) { - -//} void Client::send_request_header() { boost::asio::async_write(sock, boost::asio::buffer(packets_to_server.front()->get_header(), Block::Header), [this](boost::system::error_code ec, std::size_t) { @@ -220,7 +222,9 @@ void Client::send_request_header() { } else { std::cout << "error start_sending" << std::endl; - sock.close(); + if (sock.is_open()) { + sock.close(); + } } }); } @@ -234,7 +238,9 @@ void Client::send_request_data() { if (!packets_to_server.empty()) send_request_header(); } else { - sock.close(); + if (sock.is_open()) { + sock.close(); + } } }); } diff --git a/src/client/client/client.h b/src/client/client/client.h index c08e77c..cb10022 100644 --- a/src/client/client/client.h +++ b/src/client/client/client.h @@ -53,7 +53,9 @@ class Client: public QObject { */ void close() { boost::asio::post(io_service, [this]() { - sock.close(); + if (sock.is_open()) { + sock.close(); + } }); } diff --git a/src/client/control/control.cpp b/src/client/control/control.cpp index 90e156c..f1bd063 100644 --- a/src/client/control/control.cpp +++ b/src/client/control/control.cpp @@ -21,7 +21,7 @@ Control::Control() { void Control::connect_to_server(const std::string& login, const std::string& password, TypeCommand command) { boost::asio::io_service io_service; boost::asio::ip::tcp::resolver resolver(io_service); - auto endpoints = resolver.resolve("127.0.0.1", "7777"); + auto endpoints = resolver.resolve("172.17.0.1", "7777"); input_request_ptr request; if (command==TypeCommand::RegistrationRequest) { diff --git a/src/client/gui/mainwindow.cpp b/src/client/gui/mainwindow.cpp index 40f0527..e66b079 100644 --- a/src/client/gui/mainwindow.cpp +++ b/src/client/gui/mainwindow.cpp @@ -33,6 +33,8 @@ void MainWindow::on_push_autorisation_clicked() password = ui->password->text(); if (logon.isEmpty() || password.isEmpty()) return; send_autorisation_info(logon.toStdString(), password.toStdString()); + ui->logon->clear(); + ui->password->clear(); } void MainWindow::on_push_send_clicked() @@ -68,6 +70,8 @@ void MainWindow::on_push_registration_clicked() password = ui->password->text(); if (logon.isEmpty() || password.isEmpty()) return; send_registration_info(logon.toStdString(), password.toStdString()); + ui->logon->clear(); + ui->password->clear(); } void MainWindow::on_push_change_room_id_clicked() diff --git a/src/server/CMakeLists.txt b/src/server/CMakeLists.txt index 927d717..5ffef7e 100644 --- a/src/server/CMakeLists.txt +++ b/src/server/CMakeLists.txt @@ -26,6 +26,7 @@ set(CHANNELS_SRC set(CONNECTIONS_SRC ${DIR_CONNECTION}/isubscriber.h ${DIR_CONNECTION}/isubscriber.cpp ${DIR_CONNECTION}/connection.h ${DIR_CONNECTION}/connection.cpp + ${DIR_CONNECTION}/connection_manager.h ${DIR_CONNECTION}/connection_manager.cpp ) #**************************************************************************************************** @@ -38,7 +39,7 @@ set(SERVER_SOURCES add_executable(${SERVER_BIN} ${SERVER_SOURCES}) target_include_directories(${SERVER_BIN} PUBLIC .) #**************************************************************************************************** -find_package(Boost COMPONENTS system date_time program_options regex REQUIRED) +find_package(Boost COMPONENTS system date_time REQUIRED) set_target_properties(${SERVER_BIN} PROPERTIES CXX_STANDARD 17 diff --git a/src/server/channel/channel.cpp b/src/server/channel/channel.cpp index ceb2247..da23778 100644 --- a/src/server/channel/channel.cpp +++ b/src/server/channel/channel.cpp @@ -16,6 +16,7 @@ void Channel::join(subscriber_ptr new_subsciber) { } void Channel::leave(subscriber_ptr subsciber) { + subsciber->set_busy(false); mutex_subs.lock(); subscribers.erase(subsciber->get_client_id()); mutex_subs.unlock(); diff --git a/src/server/channel/channels_manager.cpp b/src/server/channel/channels_manager.cpp index 00728aa..32d1c8d 100644 --- a/src/server/channel/channels_manager.cpp +++ b/src/server/channel/channels_manager.cpp @@ -2,6 +2,7 @@ ChannelsManager::ChannelsManager() { + LOG4CPLUS_INFO(logger, "create ChannelsManager"); } void ChannelsManager::join(subscriber_ptr new_sub, identifier_t room_id, database_ptr db) { @@ -28,7 +29,7 @@ void ChannelsManager::join(subscriber_ptr new_sub, identifier_t room_id, databas else { LOG4CPLUS_INFO(logger, "New subsciber client_id="<< it2->first - << "in room_id=" << it2->second); + << " in room_id=" << it2->second); } } @@ -60,5 +61,7 @@ void ChannelsManager::leave(subscriber_ptr sub) { else { LOG4CPLUS_ERROR(logger, "no room room_id=" << room_id); } + + sub->set_busy(false); } diff --git a/src/server/connection/connection.cpp b/src/server/connection/connection.cpp index c032262..c615cd3 100644 --- a/src/server/connection/connection.cpp +++ b/src/server/connection/connection.cpp @@ -19,36 +19,38 @@ void Connection::read_request_header() { switch (request->get_type_data()) { case TypeCommand::Unknown: - LOG4CPLUS_INFO(logger, get_command_str(request->get_type_data()) << "--> "); + LOG4CPLUS_INFO(logger, get_command_str(request->get_type_data()) << ": "); break; case TypeCommand::RegistrationRequest: - LOG4CPLUS_INFO(logger, get_command_str(request->get_type_data()) << "--> "); + LOG4CPLUS_INFO(logger, get_command_str(request->get_type_data()) << ": "); read_request_body(std::make_shared(request)); break; case TypeCommand::RegistrationResponse: case TypeCommand::AuthorisationRequest: - LOG4CPLUS_INFO(logger, get_command_str(request->get_type_data()) << "--> "); + LOG4CPLUS_INFO(logger, get_command_str(request->get_type_data()) << ": "); read_request_body(std::make_shared(request)); break; case TypeCommand::AutorisationResponse: case TypeCommand::EchoRequest: - LOG4CPLUS_INFO(logger, get_command_str(request->get_type_data()) << "--> "); + LOG4CPLUS_INFO(logger, get_command_str(request->get_type_data()) << ": "); read_request_body(std::make_shared(request)); break; case TypeCommand::EchoResponse: case TypeCommand::JoinRoomRequest: - LOG4CPLUS_INFO(logger, get_command_str(request->get_type_data()) << "--> "); + LOG4CPLUS_INFO(logger, get_command_str(request->get_type_data()) << ": "); read_request_body(std::make_shared(request)); break; case TypeCommand::JoinRoomResponse: case TypeCommand::LeaveRoomRequest: default: - LOG4CPLUS_INFO(logger, get_command_str(request->get_type_data()) << "--> "); + LOG4CPLUS_INFO(logger, get_command_str(request->get_type_data()) << ": "); break; } } else { ChannelsManager::Instance().leave(shared_from_this()); - socket.close(); + if (socket.is_open()) { + socket.close(); + } } }); @@ -73,6 +75,7 @@ void Connection::read_request_body(registr_request_ptr request) { else { LOG4CPLUS_WARN(logger, "this client was add to db early"); client_id=-1; + busy = false; } input_res_ptr response = std::make_shared(client_id); @@ -89,7 +92,9 @@ void Connection::read_request_body(registr_request_ptr request) { } else { ChannelsManager::Instance().leave(shared_from_this()); - socket.close(); + if (socket.is_open()) { + socket.close(); + } } }); } @@ -105,7 +110,6 @@ void Connection::read_request_body(autor_request_ptr request) { LOG4CPLUS_INFO(logger, "login=" << request->get_login() << ", pwd=" << request->get_password()); client_id = db->check_client(login, password); - input_res_ptr response = std::make_shared(client_id); LOG4CPLUS_INFO(logger, "AutorisationResponse: vers=" << response->get_protocol_version() << ", command=" @@ -114,15 +118,19 @@ void Connection::read_request_body(autor_request_ptr request) { if (client_id!=-1) { db->add_logins(login, response->get_loginid(), password); + } else { + busy = false; } boost::asio::write(socket, boost::asio::buffer(response->get_header(), Block::Header)); boost::asio::write(socket, boost::asio::buffer(response->get_data(), response->get_length_data())); - read_request_header(); + if (client_id!=-1) read_request_header(); } else { ChannelsManager::Instance().leave(shared_from_this()); - socket.close(); + if (socket.is_open()) { + socket.close(); + } } }); } @@ -145,7 +153,9 @@ void Connection::read_request_body(text_request_ptr request) { } else { ChannelsManager::Instance().leave(shared_from_this()); - socket.close(); + if (socket.is_open()) { + socket.close(); + } } }); @@ -167,7 +177,9 @@ void Connection::read_request_body(join_room_request_ptr request) { } else { ChannelsManager::Instance().leave(shared_from_this()); - socket.close(); + if (socket.is_open()) { + socket.close(); + } } }); diff --git a/src/server/connection/connection.h b/src/server/connection/connection.h index 52521f5..ef3d61f 100644 --- a/src/server/connection/connection.h +++ b/src/server/connection/connection.h @@ -26,7 +26,10 @@ class Connection : public ISubscriber, public std::enable_shared_from_this packets_to_client; @@ -77,8 +116,9 @@ class Connection : public ISubscriber, public std::enable_shared_from_thisis_busy(); + }); + if (it!=pool_connections.end()) { + (*it)->set_busy(); + (*it)->init(std::move(_socket)); + + LOG4CPLUS_INFO(logger, + "use old connection, current size pool = " << pool_connections.size()); + print_pool(); + return (*it); + } + else { + auto block = std::make_shared(std::move(_socket), db); + pool_connections.push_back(block); + + LOG4CPLUS_INFO(logger, + "create new connection, current size pool = " << pool_connections.size()); + print_pool(); + return block; + } + +} + +void ConnectionManager::print_pool() const noexcept { + LOG4CPLUS_INFO(logger, "[connections]"); + for(const auto& obj:pool_connections) { + if (obj->get_client_id()>0) { + LOG4CPLUS_INFO(logger, + "obj: login=" << obj->get_login() << ", id=" << obj->get_client_id() << ", status: " << + (obj->is_busy() ? "busy" : "free")); + } else { + LOG4CPLUS_INFO(logger, + "obj: current connection not init"); + } + } +} + diff --git a/src/server/connection/connection_manager.h b/src/server/connection/connection_manager.h new file mode 100644 index 0000000..e44076e --- /dev/null +++ b/src/server/connection/connection_manager.h @@ -0,0 +1,47 @@ +#ifndef CONNECTIONMANAGER_H +#define CONNECTIONMANAGER_H + +#include "connection.h" + + +/** + * @brief ConnectionManager + * + * @details Manager to control connections from clinets. Use ObjectPool. + */ +class ConnectionManager +{ +public: + ConnectionManager(): + logger(LOGGER("ConnectionManager")), + db(std::make_shared("history.db")) + { + LOG4CPLUS_INFO(logger, + "create ConnectionManager"); + } + ConnectionManager(const ConnectionManager&) = delete; + + /** + * @brief get new or old connection for new client + * @param _socket + */ + connection_ptr get_connection(boost::asio::ip::tcp::socket&& _socket); + + ~ConnectionManager() { + for (auto& value_con: pool_connections) { + value_con->set_busy(false); + } + pool_connections.clear(); + } +private: + std::vector pool_connections; + log4cplus::Logger logger; + database_ptr db; + + /** + * @brief print all connections + * */ + void print_pool() const noexcept; +}; + +#endif // CONNECTIONMANAGER_H diff --git a/src/server/connection/isubscriber.h b/src/server/connection/isubscriber.h index b86d3b3..38d1aa5 100644 --- a/src/server/connection/isubscriber.h +++ b/src/server/connection/isubscriber.h @@ -43,6 +43,9 @@ class ISubscriber */ virtual const std::string& get_login() const = 0; + virtual bool is_busy() const noexcept = 0; + virtual void set_busy(bool flag = true) noexcept = 0; + virtual ~ISubscriber() = default; }; diff --git a/src/server/server.h b/src/server/server.h index 75a21ea..7771061 100644 --- a/src/server/server.h +++ b/src/server/server.h @@ -4,7 +4,7 @@ #include #include -#include +#include using boost::asio::ip::tcp; @@ -20,8 +20,7 @@ class Server { */ Server(): endpoint(boost::asio::ip::tcp::v4(), 7777), - acceptor(io_service, endpoint), - db(std::make_shared("history.db")) + acceptor(io_service, endpoint) { scan_acception(); } @@ -37,10 +36,8 @@ class Server { boost::asio::io_service io_service; boost::asio::ip::tcp::endpoint endpoint; boost::asio::ip::tcp::acceptor acceptor; - database_ptr db; - - std::vector server_connections; + ConnectionManager connect_manager; private: /** * @brief Handle new connected clint. @@ -51,9 +48,7 @@ class Server { void scan_acception() { acceptor.async_accept([this](const boost::system::error_code& error, tcp::socket sock) { if (!error) { - auto connect_ptr = std::make_shared(std::move(sock), db); - server_connections.push_back(connect_ptr); - connect_ptr->start(); + connect_manager.get_connection(std::move(sock))->start(); } scan_acception(); From f77b8a2486b61f2f6c2dfd7e5cc5637e0e3ef5f2 Mon Sep 17 00:00:00 2001 From: k-morozov Date: Wed, 5 Aug 2020 17:24:23 +0300 Subject: [PATCH 04/17] add deb package --- .travis.yml | 2 +- CMakeLists.txt | 20 ++++++++++---------- lib/log/CMakeLists.txt | 8 +++----- lib/traced_exception/CMakeLists.txt | 8 +++++--- src/server/CMakeLists.txt | 5 ++--- src/server/startup_server.cpp | 5 ----- 6 files changed, 21 insertions(+), 27 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8482e9c..47255e6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -31,7 +31,7 @@ script: - mkdir ${TRAVIS_BUILD_DIR}/build - cd ${TRAVIS_BUILD_DIR}/build - cmake .. - - cmake --build . + - cmake --build . -j $(($(nproc) + 1)) - cmake --build . --target test - cd ${TRAVIS_BUILD_DIR}/build/bin - tar -cf AppChat-0.7.$TRAVIS_BUILD_NUMBER-Linux.tar server client diff --git a/CMakeLists.txt b/CMakeLists.txt index 556b9d7..2d504db 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,8 +7,8 @@ set (Boost_USE_STATIC_LIBS ON) set (Boost_USE_MULTITHREADED ON) #**************************************************************************************************** -set(SRC src) -set(LIB lib) +set(DIR_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src) +set(DIR_LIB ${CMAKE_CURRENT_SOURCE_DIR}/lib) set(PROTOCOL_LIB_NAME protocol_lib) set(LOGGER_LIB_NAME logger_lib) @@ -18,17 +18,17 @@ set(TRACEDEXCEPTION_LIB_NAME tracedexception_lib) #**************************************************************************************************** set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) +SET(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin/lib) #**************************************************************************************************** enable_testing() -add_subdirectory(${SRC}/server) -add_subdirectory(${SRC}/client) -add_subdirectory(${LIB}/protocol) -add_subdirectory(${LIB}/log) -add_subdirectory(${LIB}/storage) -add_subdirectory(${LIB}/libbacktrace) -add_subdirectory(${LIB}/traced_exception) -add_subdirectory(${SRC}/tests) +add_subdirectory(${DIR_LIB}/protocol) +add_subdirectory(${DIR_LIB}/log) +add_subdirectory(${DIR_LIB}/storage) + +add_subdirectory(${DIR_SRC}/server) +add_subdirectory(${DIR_SRC}/client) +add_subdirectory(${DIR_SRC}/tests) #**************************************************************************************************** find_package(Doxygen) diff --git a/lib/log/CMakeLists.txt b/lib/log/CMakeLists.txt index 83651b4..35b68a7 100644 --- a/lib/log/CMakeLists.txt +++ b/lib/log/CMakeLists.txt @@ -13,13 +13,11 @@ set(LOGGER_SRC logger.cpp ) -# set(LOGGER_LIB_NAME logger_lib) #**************************************************************************************************** set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic") -add_library(${LOGGER_LIB_NAME} ${LOGGER_SRC}) +add_library(${LOGGER_LIB_NAME} STATIC ${LOGGER_SRC}) target_include_directories(${LOGGER_LIB_NAME} PUBLIC .) -target_link_libraries(${LOGGER_LIB_NAME} log4cplus) +target_link_libraries(${LOGGER_LIB_NAME} log4cplus) -# use if you have log4cplus -# target_link_libraries(${LOGGER_LIB_NAME} ${LOGGER_CPLUS}) +#install(TARGETS ${LOGGER_LIB_NAME}) diff --git a/lib/traced_exception/CMakeLists.txt b/lib/traced_exception/CMakeLists.txt index 6a3a91c..08d4fef 100644 --- a/lib/traced_exception/CMakeLists.txt +++ b/lib/traced_exception/CMakeLists.txt @@ -11,9 +11,11 @@ set(TRACEDEXCEPTION_SRC traced_exception.cpp ) -add_library(${TRACEDEXCEPTION_LIB_NAME} ${TRACEDEXCEPTION_SRC}) -target_include_directories(${TRACEDEXCEPTION_LIB_NAME} PUBLIC .) +install(TARGETS ${BACKTRACE_LIB_NAME}) +add_library(${TRACEDEXCEPTION_LIB_NAME} SHARED ${TRACEDEXCEPTION_SRC}) +target_include_directories(${TRACEDEXCEPTION_LIB_NAME} PUBLIC .) find_package(Boost REQUIRED) +target_link_libraries(${TRACEDEXCEPTION_LIB_NAME} ${Boost_LIBRARIES} ${CMAKE_DL_LIBS} ${BACKTRACE_LIB_NAME}) + -target_link_libraries(${TRACEDEXCEPTION_LIB_NAME} ${Boost_LIBRARIES} ${CMAKE_DL_LIBS}) diff --git a/src/server/CMakeLists.txt b/src/server/CMakeLists.txt index 5ffef7e..b782e1d 100644 --- a/src/server/CMakeLists.txt +++ b/src/server/CMakeLists.txt @@ -11,7 +11,6 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) set (Boost_USE_STATIC_LIBS ON) set (Boost_USE_MULTITHREADED ON) -add_definitions(-DBOOST_STACKTRACE_USE_BACKTRACE) set(SERVER_BIN server) set(DIR_CONNECTION connection) @@ -49,9 +48,9 @@ set_target_properties(${SERVER_BIN} PROPERTIES ) add_dependencies(${SERVER_BIN} ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES} ${STORAGE_LIB_NAME} ${PROTOCOL_LIB_NAME} ${LOGGER_LIB_NAME} - ${BACKTRACE_LIB_NAME} ${TRACEDEXCEPTION_LIB_NAME}) + ) target_link_libraries (${SERVER_BIN} ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES} ${STORAGE_LIB_NAME} ${PROTOCOL_LIB_NAME} ${LOGGER_LIB_NAME} - ${BACKTRACE_LIB_NAME} ${TRACEDEXCEPTION_LIB_NAME}) + ) # install to bin folder our binaries install(TARGETS ${SERVER_BIN} RUNTIME DESTINATION bin) diff --git a/src/server/startup_server.cpp b/src/server/startup_server.cpp index d66638b..ae56428 100644 --- a/src/server/startup_server.cpp +++ b/src/server/startup_server.cpp @@ -1,8 +1,6 @@ #include #include -#include -#include int main([[maybe_unused]]int argc, [[maybe_unused]]char** argv) { init_logger(); @@ -12,9 +10,6 @@ int main([[maybe_unused]]int argc, [[maybe_unused]]char** argv) { try { Server server; server.run(); - } catch (const util::traced& ex) { - LOG4CPLUS_ERROR(logger, "Exception: " << ex.what()); - LOG4CPLUS_ERROR(logger, "Stacktrace:\n" << ex.trace); } catch (const std::exception & ex) { LOG4CPLUS_ERROR(logger, "exception " << ex.what()); } From 55ae13bec98758a072629ed0cc79416663e12465 Mon Sep 17 00:00:00 2001 From: k-morozov Date: Wed, 5 Aug 2020 17:43:19 +0300 Subject: [PATCH 05/17] fix build --- .travis.yml | 2 +- src/client/CMakeLists.txt | 16 ---------------- src/server/CMakeLists.txt | 4 +++- 3 files changed, 4 insertions(+), 18 deletions(-) diff --git a/.travis.yml b/.travis.yml index 47255e6..8482e9c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -31,7 +31,7 @@ script: - mkdir ${TRAVIS_BUILD_DIR}/build - cd ${TRAVIS_BUILD_DIR}/build - cmake .. - - cmake --build . -j $(($(nproc) + 1)) + - cmake --build . - cmake --build . --target test - cd ${TRAVIS_BUILD_DIR}/build/bin - tar -cf AppChat-0.7.$TRAVIS_BUILD_NUMBER-Linux.tar server client diff --git a/src/client/CMakeLists.txt b/src/client/CMakeLists.txt index 7592e1c..fa4adb6 100644 --- a/src/client/CMakeLists.txt +++ b/src/client/CMakeLists.txt @@ -49,20 +49,4 @@ set_target_properties(${CLIENT_BIN} PROPERTIES #add_dependencies(${CLIENT_BIN} ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES} Qt5::Widgets ${PROTOCOL_LIB_NAME}) target_link_libraries (${CLIENT_BIN} ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES} Qt5::Widgets ${PROTOCOL_LIB_NAME}) -# install to bin folder our binaries -install(TARGETS ${CLIENT_BIN} RUNTIME DESTINATION bin) - -# generate .deb package -set(CPACK_GENERATOR DEB) - -set(CPACK_PACKAGE_VERSION_MAJOR "${PROJECT_VERSION_MAJOR}") -set(CPACK_PACKAGE_VERSION_MINOR "${PROJECT_VERSION_MINOR}") -set(CPACK_PACKAGE_VERSION_PATCH "${PROJECT_VERSION_PATCH}") - -set(CPACK_PACKAGE_CONTACT scfocus@yandex.ru) -set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON) - -# include will generate proper code for .deb generation -include(CPack) - target_include_directories(${CLIENT_BIN} PUBLIC ${SRC}/client) diff --git a/src/server/CMakeLists.txt b/src/server/CMakeLists.txt index b782e1d..fd480ad 100644 --- a/src/server/CMakeLists.txt +++ b/src/server/CMakeLists.txt @@ -52,6 +52,8 @@ add_dependencies(${SERVER_BIN} ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES} ${ST target_link_libraries (${SERVER_BIN} ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES} ${STORAGE_LIB_NAME} ${PROTOCOL_LIB_NAME} ${LOGGER_LIB_NAME} ) +target_include_directories(${SERVER_BIN} PUBLIC ${SRC}/server}) + # install to bin folder our binaries install(TARGETS ${SERVER_BIN} RUNTIME DESTINATION bin) @@ -68,4 +70,4 @@ set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON) # include will generate proper code for .deb generation include(CPack) -target_include_directories(${SERVER_BIN} PUBLIC ${SRC}/server}) + From 111dacdddc1ec772d28942c209793955aa7c4e96 Mon Sep 17 00:00:00 2001 From: k-morozov Date: Wed, 5 Aug 2020 17:43:34 +0300 Subject: [PATCH 06/17] fix build --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 8482e9c..3df3d92 100644 --- a/.travis.yml +++ b/.travis.yml @@ -33,6 +33,7 @@ script: - cmake .. - cmake --build . - cmake --build . --target test + - cmake --build . --target package - cd ${TRAVIS_BUILD_DIR}/build/bin - tar -cf AppChat-0.7.$TRAVIS_BUILD_NUMBER-Linux.tar server client From 2716480fa1b5a5c8dfe1f7084f4bed1516475cb2 Mon Sep 17 00:00:00 2001 From: k-morozov Date: Wed, 5 Aug 2020 19:38:58 +0300 Subject: [PATCH 07/17] fix pthread gtest --- src/tests/CMakeLists.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index 2df14d0..1c9bd64 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -15,7 +15,7 @@ set(TESTS_SOURSES test_response.cpp test_datetime.cpp ) - +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread") #**************************************************************************************************** set_target_properties(${TESTS} PROPERTIES CXX_STANDARD 17 @@ -24,9 +24,10 @@ set_target_properties(${TESTS} PROPERTIES COMPILE_OPTIONS "-std=c++17;-O2;-Wall;-Wextra;-Wpedantic" ) #**************************************************************************************************** -add_executable(${TESTS_BIN} ${TESTS_SOURSES}) +add_executable(${TESTS_BIN} ${TESTS_SOURSES}) target_include_directories(${TESTS_BIN} PUBLIC .) include_directories(${GTEST_INCLUDE_DIR}) + find_package(GTest REQUIRED) find_library(UnitTests gtest) #**************************************************************************************************** From 452c3abfa51afa2858fa7cb626d3a1a9ddd6fd8e Mon Sep 17 00:00:00 2001 From: k-morozov Date: Wed, 5 Aug 2020 22:53:02 +0300 Subject: [PATCH 08/17] remove backtrace refactoring cmake fix gtest --- CMakeLists.txt | 60 ++++++++++++++++++++----------------- lib/log/CMakeLists.txt | 25 +++++++--------- lib/protocol/CMakeLists.txt | 20 +++++++------ lib/storage/CMakeLists.txt | 22 ++++++-------- src/client/CMakeLists.txt | 29 ++++++------------ src/server/CMakeLists.txt | 44 +++++---------------------- src/tests/CMakeLists.txt | 22 +++++--------- 7 files changed, 89 insertions(+), 133 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2d504db..b28145f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,43 +1,49 @@ cmake_minimum_required(VERSION 3.5) -project(AppChat) + +if (DEFINED ENV{TRAVIS_BUILD_NUMBER}) + project(AppChat VERSION 0.0.$ENV{TRAVIS_BUILD_NUMBER}) +else () + project(AppChat VERSION 0.0.1) +endif () set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) set (Boost_USE_STATIC_LIBS ON) set (Boost_USE_MULTITHREADED ON) -#**************************************************************************************************** -set(DIR_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src) -set(DIR_LIB ${CMAKE_CURRENT_SOURCE_DIR}/lib) - set(PROTOCOL_LIB_NAME protocol_lib) set(LOGGER_LIB_NAME logger_lib) set(STORAGE_LIB_NAME sqlite_db) -set(BACKTRACE_LIB_NAME backtrace) -set(TRACEDEXCEPTION_LIB_NAME tracedexception_lib) -#**************************************************************************************************** set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) SET(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin/lib) -#**************************************************************************************************** + +include_directories( + ${Boost_INCLUDE_DIR} + ${CMAKE_SOURCE_DIR}/lib/protocol + ${CMAKE_SOURCE_DIR}/lib/log + ${CMAKE_SOURCE_DIR}/lib/storage + ${CMAKE_SOURCE_DIR}/src/server + ${CMAKE_SOURCE_DIR}/src/client + ${CMAKE_SOURCE_DIR}/src/tests +) + +add_subdirectory(${CMAKE_SOURCE_DIR}/lib/protocol) +add_subdirectory(${CMAKE_SOURCE_DIR}/lib/log) +add_subdirectory(${CMAKE_SOURCE_DIR}/lib/storage) +add_subdirectory(${CMAKE_SOURCE_DIR}/src/server) +add_subdirectory(${CMAKE_SOURCE_DIR}/src/client) + enable_testing() +add_subdirectory(${CMAKE_SOURCE_DIR}/src/tests) + +set(CPACK_GENERATOR DEB) + +set(CPACK_PACKAGE_VERSION_MAJOR "${PROJECT_VERSION_MAJOR}") +set(CPACK_PACKAGE_VERSION_MINOR "${PROJECT_VERSION_MINOR}") +set(CPACK_PACKAGE_VERSION_PATCH "${PROJECT_VERSION_PATCH}") -add_subdirectory(${DIR_LIB}/protocol) -add_subdirectory(${DIR_LIB}/log) -add_subdirectory(${DIR_LIB}/storage) - -add_subdirectory(${DIR_SRC}/server) -add_subdirectory(${DIR_SRC}/client) -add_subdirectory(${DIR_SRC}/tests) - -#**************************************************************************************************** -find_package(Doxygen) -if (DOXYGEN_FOUND) - set(DOXYFILE ${CMAKE_SOURCE_DIR}/Doxyfile) - add_custom_target(doc_doxygen ALL - COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYFILE} - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - COMMENT "Generating API documentation with Doxygen") - unset(DOXYFILE) -endif() +set(CPACK_PACKAGE_CONTACT scfocus@yandex.ru) +set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON) +include(CPack) diff --git a/lib/log/CMakeLists.txt b/lib/log/CMakeLists.txt index 35b68a7..183b695 100644 --- a/lib/log/CMakeLists.txt +++ b/lib/log/CMakeLists.txt @@ -1,23 +1,20 @@ cmake_minimum_required(VERSION 3.5) -project(Logger) -set(CMAKE_CXX_STANDARD 17) -set(CMAKE_CXX_STANDARD_REQUIRED ON) - -# use if you have log4cplus -# find_library(LOGGER_CPLUS log4cplus) - -add_subdirectory(log4cplus/) set(LOGGER_SRC logger.h logger.cpp ) -#**************************************************************************************************** -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic") +add_library(${LOGGER_LIB_NAME} SHARED STATIC + ${LOGGER_SRC}) -add_library(${LOGGER_LIB_NAME} STATIC ${LOGGER_SRC}) -target_include_directories(${LOGGER_LIB_NAME} PUBLIC .) -target_link_libraries(${LOGGER_LIB_NAME} log4cplus) +set_target_properties(${LOGGER_LIB_NAME} PROPERTIES + CMAKE_CXX_STANDARD 17 + CMAKE_CXX_STANDARD_REQUIRED ON +) + +add_subdirectory(log4cplus/) +target_link_libraries(${LOGGER_LIB_NAME} log4cplus) -#install(TARGETS ${LOGGER_LIB_NAME}) +install(TARGETS ${LOGGER_LIB_NAME} DESTINATION /usr/local/bin) +install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/logger.h DESTINATION /usr/local/include/appchat/) diff --git a/lib/protocol/CMakeLists.txt b/lib/protocol/CMakeLists.txt index 6fa61c9..e302007 100644 --- a/lib/protocol/CMakeLists.txt +++ b/lib/protocol/CMakeLists.txt @@ -1,8 +1,4 @@ cmake_minimum_required(VERSION 3.5) -project(Protocol) - -set(CMAKE_CXX_STANDARD 17) -set(CMAKE_CXX_STANDARD_REQUIRED ON) set(PROTOCOL_SRC protocol.h protocol.cpp @@ -17,11 +13,17 @@ set(PROTOCOL_SRC response/response.h response/input_response.h response/input_response.cpp response/transport_response.h - ) -#**************************************************************************************************** -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic -fPIC") +add_library(${PROTOCOL_LIB_NAME} SHARED STATIC + ${PROTOCOL_SRC}) + +set_target_properties(${PROTOCOL_LIB_NAME} PROPERTIES + CXX_STANDARD 17 + CXX_STANDARD_REQUIRED ON + LINK_LIBRARIES pthread + COMPILE_OPTIONS "-std=c++17;-O2;-Wall;-Wextra;-Wpedantic;-fPIC" +) -add_library(${PROTOCOL_LIB_NAME} ${PROTOCOL_SRC}) -target_include_directories(${PROTOCOL_LIB_NAME} PUBLIC .) +install(TARGETS ${PROTOCOL_LIB_NAME} DESTINATION /usr/local/bin) +install(TARGETS ${PROTOCOL_LIB_NAME} DESTINATION lib) diff --git a/lib/storage/CMakeLists.txt b/lib/storage/CMakeLists.txt index c03bc1c..7725dd1 100644 --- a/lib/storage/CMakeLists.txt +++ b/lib/storage/CMakeLists.txt @@ -1,25 +1,21 @@ cmake_minimum_required(VERSION 3.5) -project(Storage) -set(CMAKE_CXX_STANDARD 17) -set(CMAKE_CXX_STANDARD_REQUIRED ON) -set(Boost_USE_STATIC_LIBS ON) -set(Boost_USE_MULTITHREADED ON) - -set(Storage_dir storage) - -#**************************************************************************************************** set(STORAGE_SRC database.h database.cpp ) -#**************************************************************************************************** +add_library(${STORAGE_LIB_NAME} SHARED STATIC + ${STORAGE_SRC}) -add_library(${STORAGE_LIB_NAME} ${STORAGE_SRC}) -target_include_directories(${STORAGE_LIB_NAME} PUBLIC .) +set_target_properties(${STORAGE_LIB_NAME} PROPERTIES + CMAKE_CXX_STANDARD 17 + CMAKE_CXX_STANDARD_REQUIRED ON +) -#**************************************************************************************************** find_library(SQLITE3_LIBRARY NAMES sqlite3) find_package(Boost REQUIRED) target_link_libraries (${STORAGE_LIB_NAME} ${PROTOCOL_LIB_NAME} ${LOGGER_LIB_NAME} ${SQLITE3_LIBRARY} ${Boost_LIBRARIES}) + +install(TARGETS ${STORAGE_LIB_NAME} DESTINATION /usr/local/bin) +install(TARGETS ${STORAGE_LIB_NAME} DESTINATION lib) diff --git a/src/client/CMakeLists.txt b/src/client/CMakeLists.txt index fa4adb6..cf3ab5b 100644 --- a/src/client/CMakeLists.txt +++ b/src/client/CMakeLists.txt @@ -1,26 +1,14 @@ cmake_minimum_required(VERSION 3.5) -if (DEFINED ENV{TRAVIS_BUILD_NUMBER}) - project(Client VERSION 0.0.$ENV{TRAVIS_BUILD_NUMBER}) -else () - project(Client VERSION 0.0.1) -endif () - -set(CMAKE_CXX_STANDARD 17) -set(CMAKE_CXX_STANDARD_REQUIRED ON) -set (Boost_USE_STATIC_LIBS ON) -set (Boost_USE_MULTITHREADED ON) - - set(CMAKE_AUTOUIC ON) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) -#**************************************************************************************************** + set(CLIENT_BIN client) set(Control_dir control) set(Client_dir client) set(GUI_dir gui) -#**************************************************************************************************** + set(CLIENT_SOURCES startup_client.cpp ${Client_dir}/client.h ${Client_dir}/client.cpp @@ -29,14 +17,11 @@ set(CLIENT_SOURCES ${Control_dir}/control.h ${Control_dir}/control.cpp ) -#**************************************************************************************************** find_package(Qt5 COMPONENTS Widgets REQUIRED) find_package (Threads) add_executable(${CLIENT_BIN} ${CLIENT_SOURCES}) -target_include_directories(${CLIENT_BIN} PUBLIC .) -#**************************************************************************************************** find_package(Boost COMPONENTS system date_time REQUIRED) set_target_properties(${CLIENT_BIN} PROPERTIES @@ -46,7 +31,11 @@ set_target_properties(${CLIENT_BIN} PROPERTIES COMPILE_OPTIONS "-std=c++17;-O2;-Wall;-Wextra;-Wpedantic" ) -#add_dependencies(${CLIENT_BIN} ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES} Qt5::Widgets ${PROTOCOL_LIB_NAME}) -target_link_libraries (${CLIENT_BIN} ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES} Qt5::Widgets ${PROTOCOL_LIB_NAME}) +target_link_libraries (${CLIENT_BIN} + ${CMAKE_THREAD_LIBS_INIT} + ${Boost_LIBRARIES} + Qt5::Widgets + ${PROTOCOL_LIB_NAME} +) -target_include_directories(${CLIENT_BIN} PUBLIC ${SRC}/client) +install(TARGETS ${CLIENT_BIN} RUNTIME DESTINATION bin) diff --git a/src/server/CMakeLists.txt b/src/server/CMakeLists.txt index fd480ad..644620e 100644 --- a/src/server/CMakeLists.txt +++ b/src/server/CMakeLists.txt @@ -1,22 +1,9 @@ cmake_minimum_required(VERSION 3.5) -if (DEFINED ENV{TRAVIS_BUILD_NUMBER}) - project(Server VERSION 0.0.$ENV{TRAVIS_BUILD_NUMBER}) -else () - project(Server VERSION 0.0.1) -endif () - -set(CMAKE_CXX_STANDARD 17) -set(CMAKE_CXX_STANDARD_REQUIRED ON) -set (Boost_USE_STATIC_LIBS ON) -set (Boost_USE_MULTITHREADED ON) - - set(SERVER_BIN server) set(DIR_CONNECTION connection) set(DIR_CHANNEL channel) -#**************************************************************************************************** set(CHANNELS_SRC ${DIR_CHANNEL}/iroom.h ${DIR_CHANNEL}/iroom.cpp ${DIR_CHANNEL}/channels_manager.h ${DIR_CHANNEL}/channels_manager.cpp @@ -28,7 +15,6 @@ set(CONNECTIONS_SRC ${DIR_CONNECTION}/connection_manager.h ${DIR_CONNECTION}/connection_manager.cpp ) -#**************************************************************************************************** set(SERVER_SOURCES startup_server.cpp server.h @@ -36,8 +22,7 @@ set(SERVER_SOURCES ${CHANNELS_SRC} ) add_executable(${SERVER_BIN} ${SERVER_SOURCES}) -target_include_directories(${SERVER_BIN} PUBLIC .) -#**************************************************************************************************** + find_package(Boost COMPONENTS system date_time REQUIRED) set_target_properties(${SERVER_BIN} PROPERTIES @@ -47,27 +32,14 @@ set_target_properties(${SERVER_BIN} PROPERTIES COMPILE_OPTIONS "-std=c++17;-O2;-Wall;-Wextra;-Wpedantic" ) -add_dependencies(${SERVER_BIN} ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES} ${STORAGE_LIB_NAME} ${PROTOCOL_LIB_NAME} ${LOGGER_LIB_NAME} - ) -target_link_libraries (${SERVER_BIN} ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES} ${STORAGE_LIB_NAME} ${PROTOCOL_LIB_NAME} ${LOGGER_LIB_NAME} - ) - -target_include_directories(${SERVER_BIN} PUBLIC ${SRC}/server}) +target_link_libraries (${SERVER_BIN} + ${CMAKE_THREAD_LIBS_INIT} + ${Boost_LIBRARIES} + ${STORAGE_LIB_NAME} + ${PROTOCOL_LIB_NAME} + ${LOGGER_LIB_NAME} +) -# install to bin folder our binaries install(TARGETS ${SERVER_BIN} RUNTIME DESTINATION bin) -# generate .deb package -set(CPACK_GENERATOR DEB) - -set(CPACK_PACKAGE_VERSION_MAJOR "${PROJECT_VERSION_MAJOR}") -set(CPACK_PACKAGE_VERSION_MINOR "${PROJECT_VERSION_MINOR}") -set(CPACK_PACKAGE_VERSION_PATCH "${PROJECT_VERSION_PATCH}") - -set(CPACK_PACKAGE_CONTACT scfocus@yandex.ru) -set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON) - -# include will generate proper code for .deb generation -include(CPack) - diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index 1c9bd64..6b3c305 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -1,22 +1,13 @@ cmake_minimum_required(VERSION 3.5) -project(Tests) - set(TESTS_BIN tests) -set(CMAKE_CXX_STANDARD 17) -set(CMAKE_CXX_STANDARD_REQUIRED ON) -set(Boost_USE_STATIC_LIBS ON) -set(Boost_USE_MULTITHREADED ON) - -#**************************************************************************************************** set(TESTS_SOURSES startup_tests.cpp test_request.cpp test_response.cpp test_datetime.cpp ) -SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread") -#**************************************************************************************************** +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread") set_target_properties(${TESTS} PROPERTIES CXX_STANDARD 17 CXX_STANDARD_REQUIRED ON @@ -24,12 +15,15 @@ set_target_properties(${TESTS} PROPERTIES COMPILE_OPTIONS "-std=c++17;-O2;-Wall;-Wextra;-Wpedantic" ) #**************************************************************************************************** -add_executable(${TESTS_BIN} ${TESTS_SOURSES}) -target_include_directories(${TESTS_BIN} PUBLIC .) +add_executable(${TESTS_BIN} + ${TESTS_SOURSES} +) include_directories(${GTEST_INCLUDE_DIR}) find_package(GTest REQUIRED) -find_library(UnitTests gtest) +#find_library(UnitTests gtest) #**************************************************************************************************** -target_link_libraries (${TESTS_BIN} ${CMAKE_THREAD_LIBS_INIT} ${UnitTests} ${PROTOCOL_LIB_NAME}) +target_link_libraries (${TESTS_BIN} ${CMAKE_THREAD_LIBS_INIT} gtest ${PROTOCOL_LIB_NAME}) + +add_test(NAME ${TESTS_BIN} COMMAND ${TESTS_BIN}) From 97d5c0686cda9b84ee110225a1a1819e9dcfc84e Mon Sep 17 00:00:00 2001 From: k-morozov Date: Thu, 6 Aug 2020 07:19:22 +0300 Subject: [PATCH 09/17] test --- src/tests/CMakeLists.txt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index 6b3c305..995c6fc 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -14,15 +14,13 @@ set_target_properties(${TESTS} PROPERTIES LINK_LIBRARIES pthread COMPILE_OPTIONS "-std=c++17;-O2;-Wall;-Wextra;-Wpedantic" ) -#**************************************************************************************************** + add_executable(${TESTS_BIN} ${TESTS_SOURSES} ) include_directories(${GTEST_INCLUDE_DIR}) find_package(GTest REQUIRED) -#find_library(UnitTests gtest) -#**************************************************************************************************** target_link_libraries (${TESTS_BIN} ${CMAKE_THREAD_LIBS_INIT} gtest ${PROTOCOL_LIB_NAME}) From c464127ef2671560ee583b07cf268c899eb4bdfb Mon Sep 17 00:00:00 2001 From: k-morozov Date: Thu, 6 Aug 2020 07:43:36 +0300 Subject: [PATCH 10/17] add boost::test --- .travis.yml | 10 -- CMakeLists.txt | 16 ++- src/server/CMakeLists.txt | 2 - src/tests/CMakeLists.txt | 11 +- src/tests/startup_tests.cpp | 7 +- src/tests/test_datetime.cpp | 274 ++++++++++++++++++------------------ src/tests/test_request.cpp | 263 +++++++++++++++------------------- src/tests/test_response.cpp | 104 +++++++------- 8 files changed, 324 insertions(+), 363 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3df3d92..4a052cf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,16 +17,6 @@ addons: before_script: - if [ $TRAVIS_OS_NAME == linux ]; then sudo ./scripts/install_env.sh; fi - #gtest - - sudo apt-get install libgtest-dev -y - - sudo chmod 777 /usr/src/gtest - - cd /usr/src/gtest - - cmake . - - make - - sudo cp *.a /usr/lib/ - - cd "${TRAVIS_BUILD_DIR}" - # end gtest - script: - mkdir ${TRAVIS_BUILD_DIR}/build - cd ${TRAVIS_BUILD_DIR}/build diff --git a/CMakeLists.txt b/CMakeLists.txt index b28145f..d968bf7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,16 +8,21 @@ endif () set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) -set (Boost_USE_STATIC_LIBS ON) -set (Boost_USE_MULTITHREADED ON) +set(THREADS_PREFER_PTHREAD_FLAG ON) +set(Boost_USE_STATIC_LIBS ON) +set(Boost_USE_MULTITHREADED ON) +set(Boost_USE_STATIC_RUNTIME OFF) -set(PROTOCOL_LIB_NAME protocol_lib) -set(LOGGER_LIB_NAME logger_lib) -set(STORAGE_LIB_NAME sqlite_db) +set(PROTOCOL_LIB_NAME protocol_lib) +set(LOGGER_LIB_NAME logger_lib) +set(STORAGE_LIB_NAME sqlite_db) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) SET(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin/lib) +find_package(Threads REQUIRED) +find_package(Boost REQUIRED COMPONENTS system date_time unit_test_framework REQUIRED) + include_directories( ${Boost_INCLUDE_DIR} ${CMAKE_SOURCE_DIR}/lib/protocol @@ -25,7 +30,6 @@ include_directories( ${CMAKE_SOURCE_DIR}/lib/storage ${CMAKE_SOURCE_DIR}/src/server ${CMAKE_SOURCE_DIR}/src/client - ${CMAKE_SOURCE_DIR}/src/tests ) add_subdirectory(${CMAKE_SOURCE_DIR}/lib/protocol) diff --git a/src/server/CMakeLists.txt b/src/server/CMakeLists.txt index 644620e..fbcaf81 100644 --- a/src/server/CMakeLists.txt +++ b/src/server/CMakeLists.txt @@ -23,8 +23,6 @@ set(SERVER_SOURCES ) add_executable(${SERVER_BIN} ${SERVER_SOURCES}) -find_package(Boost COMPONENTS system date_time REQUIRED) - set_target_properties(${SERVER_BIN} PROPERTIES CXX_STANDARD 17 CXX_STANDARD_REQUIRED ON diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index 995c6fc..0d8be2f 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.5) -set(TESTS_BIN tests) +set(TESTS_BIN app_chat_tests) set(TESTS_SOURSES startup_tests.cpp @@ -18,10 +18,11 @@ set_target_properties(${TESTS} PROPERTIES add_executable(${TESTS_BIN} ${TESTS_SOURSES} ) -include_directories(${GTEST_INCLUDE_DIR}) -find_package(GTest REQUIRED) - -target_link_libraries (${TESTS_BIN} ${CMAKE_THREAD_LIBS_INIT} gtest ${PROTOCOL_LIB_NAME}) +target_link_libraries (${TESTS_BIN} + ${Boost_LIBRARIES} + ${CMAKE_THREAD_LIBS_INIT} + ${PROTOCOL_LIB_NAME} +) add_test(NAME ${TESTS_BIN} COMMAND ${TESTS_BIN}) diff --git a/src/tests/startup_tests.cpp b/src/tests/startup_tests.cpp index 76f841f..5e306d2 100644 --- a/src/tests/startup_tests.cpp +++ b/src/tests/startup_tests.cpp @@ -1,6 +1,3 @@ -#include +#define BOOST_TEST_MODULE app_chat_tests -int main(int argc, char **argv) { - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} +#include diff --git a/src/tests/test_datetime.cpp b/src/tests/test_datetime.cpp index f0ef925..ffa30a9 100644 --- a/src/tests/test_datetime.cpp +++ b/src/tests/test_datetime.cpp @@ -1,205 +1,205 @@ -#include +//#include -#include +//#include -#include "datetime.h" +//#include "datetime.h" -class datetime : public ::testing::Test -{ -protected: - virtual void SetUp() override { } - virtual void TearDown() override { } -}; +//class datetime : public ::testing::Test +//{ +//protected: +// virtual void SetUp() override { } +// virtual void TearDown() override { } +//}; -TEST_F(datetime, construction_by_default) -{ - DateTime dt; +//TEST_F(datetime, construction_by_default) +//{ +// DateTime dt; - EXPECT_EQ(dt.hours, 0); - EXPECT_EQ(dt.minutes, 0); - EXPECT_EQ(dt.seconds, 0); +// EXPECT_EQ(dt.hours, 0); +// EXPECT_EQ(dt.minutes, 0); +// EXPECT_EQ(dt.seconds, 0); - EXPECT_EQ(dt.day, 0); - EXPECT_EQ(dt.month, 0); - EXPECT_EQ(dt.year, 0); -} +// EXPECT_EQ(dt.day, 0); +// EXPECT_EQ(dt.month, 0); +// EXPECT_EQ(dt.year, 0); +//} -TEST_F(datetime, construction_from_ptime) -{ - using namespace boost::posix_time; +//TEST_F(datetime, construction_from_ptime) +//{ +// using namespace boost::posix_time; - ptime pt = second_clock::universal_time(); +// ptime pt = second_clock::universal_time(); - DateTime dt(pt); +// DateTime dt(pt); - EXPECT_EQ(dt.hours, pt.time_of_day().hours()); - EXPECT_EQ(dt.minutes, pt.time_of_day().minutes()); - EXPECT_EQ(dt.seconds, pt.time_of_day().seconds()); +// EXPECT_EQ(dt.hours, pt.time_of_day().hours()); +// EXPECT_EQ(dt.minutes, pt.time_of_day().minutes()); +// EXPECT_EQ(dt.seconds, pt.time_of_day().seconds()); - EXPECT_EQ(dt.day, pt.date().day()); - EXPECT_EQ(dt.month, pt.date().month()); - EXPECT_EQ(dt.year + 2000, pt.date().year()); -} +// EXPECT_EQ(dt.day, pt.date().day()); +// EXPECT_EQ(dt.month, pt.date().month()); +// EXPECT_EQ(dt.year + 2000, pt.date().year()); +//} -TEST_F(datetime, simple_date_string) -{ - DateTime dt; +//TEST_F(datetime, simple_date_string) +//{ +// DateTime dt; - dt.day = 22; - dt.month = 7; - dt.year = 20; +// dt.day = 22; +// dt.month = 7; +// dt.year = 20; - EXPECT_EQ(dt.to_simple_date(), "22.07.2020"); +// EXPECT_EQ(dt.to_simple_date(), "22.07.2020"); - dt.day = 0; - dt.month = 0; - dt.year = 0; +// dt.day = 0; +// dt.month = 0; +// dt.year = 0; - EXPECT_EQ(dt.to_simple_date(), "00.00.2000"); +// EXPECT_EQ(dt.to_simple_date(), "00.00.2000"); - dt.day = 31; - dt.month = 12; - dt.year = 255; +// dt.day = 31; +// dt.month = 12; +// dt.year = 255; - EXPECT_EQ(dt.to_simple_date(), "31.12.2255"); -} +// EXPECT_EQ(dt.to_simple_date(), "31.12.2255"); +//} -TEST_F(datetime, simple_time_string) -{ - DateTime dt; +//TEST_F(datetime, simple_time_string) +//{ +// DateTime dt; - dt.hours = 16; - dt.minutes = 5; - dt.seconds = 50; +// dt.hours = 16; +// dt.minutes = 5; +// dt.seconds = 50; - EXPECT_EQ(dt.to_simple_time(), "16:05:50"); +// EXPECT_EQ(dt.to_simple_time(), "16:05:50"); - dt.hours = 0; - dt.minutes = 0; - dt.seconds = 0; +// dt.hours = 0; +// dt.minutes = 0; +// dt.seconds = 0; - EXPECT_EQ(dt.to_simple_time(), "00:00:00"); +// EXPECT_EQ(dt.to_simple_time(), "00:00:00"); - dt.hours = 23; - dt.minutes = 59; - dt.seconds = 59; +// dt.hours = 23; +// dt.minutes = 59; +// dt.seconds = 59; - EXPECT_EQ(dt.to_simple_time(), "23:59:59"); -} +// EXPECT_EQ(dt.to_simple_time(), "23:59:59"); +//} -TEST_F(datetime, operator_equal) -{ - DateTime lhs; +//TEST_F(datetime, operator_equal) +//{ +// DateTime lhs; - lhs.hours = 1; - lhs.minutes = 2; - lhs.seconds = 3; +// lhs.hours = 1; +// lhs.minutes = 2; +// lhs.seconds = 3; - lhs.day = 4; - lhs.month = 5; - lhs.year = 6; +// lhs.day = 4; +// lhs.month = 5; +// lhs.year = 6; - DateTime rhs; +// DateTime rhs; - rhs.hours = 1; - rhs.minutes = 2; - rhs.seconds = 3; +// rhs.hours = 1; +// rhs.minutes = 2; +// rhs.seconds = 3; - rhs.day = 4; - rhs.month = 5; - rhs.year = 6; +// rhs.day = 4; +// rhs.month = 5; +// rhs.year = 6; - EXPECT_EQ(lhs == rhs, true); +// EXPECT_EQ(lhs == rhs, true); - rhs.year = 7; +// rhs.year = 7; - EXPECT_EQ(lhs == rhs, false); +// EXPECT_EQ(lhs == rhs, false); - rhs.year = 5; +// rhs.year = 5; - EXPECT_EQ(lhs == rhs, false); -} +// EXPECT_EQ(lhs == rhs, false); +//} -TEST_F(datetime, operator_less) -{ - DateTime lhs; +//TEST_F(datetime, operator_less) +//{ +// DateTime lhs; - lhs.seconds = 1; - lhs.minutes = 2; - lhs.hours = 3; +// lhs.seconds = 1; +// lhs.minutes = 2; +// lhs.hours = 3; - lhs.day = 4; - lhs.month = 5; - lhs.year = 6; +// lhs.day = 4; +// lhs.month = 5; +// lhs.year = 6; - DateTime rhs; +// DateTime rhs; - rhs.seconds = 1; - rhs.minutes = 2; - rhs.hours = 3; +// rhs.seconds = 1; +// rhs.minutes = 2; +// rhs.hours = 3; - rhs.day = 4; - rhs.month = 5; - rhs.year = 6; +// rhs.day = 4; +// rhs.month = 5; +// rhs.year = 6; - EXPECT_EQ(lhs < rhs, false); +// EXPECT_EQ(lhs < rhs, false); - lhs.year = 7; +// lhs.year = 7; - EXPECT_EQ(lhs < rhs, false); +// EXPECT_EQ(lhs < rhs, false); - lhs.year = 6; - lhs.month = 6; +// lhs.year = 6; +// lhs.month = 6; - EXPECT_EQ(lhs < rhs, false); +// EXPECT_EQ(lhs < rhs, false); - lhs.month = 5; - lhs.day = 5; +// lhs.month = 5; +// lhs.day = 5; - EXPECT_EQ(lhs < rhs, false); +// EXPECT_EQ(lhs < rhs, false); - lhs.day = 4; - lhs.hours = 4; +// lhs.day = 4; +// lhs.hours = 4; - EXPECT_EQ(lhs < rhs, false); +// EXPECT_EQ(lhs < rhs, false); - lhs.hours = 3; - lhs.minutes = 3; +// lhs.hours = 3; +// lhs.minutes = 3; - EXPECT_EQ(lhs < rhs, false); +// EXPECT_EQ(lhs < rhs, false); - lhs.minutes = 2; - lhs.seconds = 2; +// lhs.minutes = 2; +// lhs.seconds = 2; - EXPECT_EQ(lhs < rhs, false); +// EXPECT_EQ(lhs < rhs, false); - lhs.seconds = 0; +// lhs.seconds = 0; - EXPECT_EQ(lhs < rhs, true); +// EXPECT_EQ(lhs < rhs, true); - lhs.seconds = 1; - lhs.minutes = 1; +// lhs.seconds = 1; +// lhs.minutes = 1; - EXPECT_EQ(lhs < rhs, true); +// EXPECT_EQ(lhs < rhs, true); - lhs.minutes = 2; - lhs.hours = 2; +// lhs.minutes = 2; +// lhs.hours = 2; - EXPECT_EQ(lhs < rhs, true); +// EXPECT_EQ(lhs < rhs, true); - lhs.hours = 3; - lhs.day = 3; +// lhs.hours = 3; +// lhs.day = 3; - EXPECT_EQ(lhs < rhs, true); +// EXPECT_EQ(lhs < rhs, true); - lhs.day = 4; - lhs.month = 4; +// lhs.day = 4; +// lhs.month = 4; - EXPECT_EQ(lhs < rhs, true); +// EXPECT_EQ(lhs < rhs, true); - lhs.month = 5; - lhs.year = 5; +// lhs.month = 5; +// lhs.year = 5; - EXPECT_EQ(lhs < rhs, true); -} +// EXPECT_EQ(lhs < rhs, true); +//} diff --git a/src/tests/test_request.cpp b/src/tests/test_request.cpp index 4f508a1..3fe4ecd 100644 --- a/src/tests/test_request.cpp +++ b/src/tests/test_request.cpp @@ -1,203 +1,174 @@ -#include +#include + #include #include -class request: public ::testing::Test { -protected: +/** + * @brief Unit tests for queue project. + */ +BOOST_AUTO_TEST_SUITE(test_request) - virtual void SetUp() override { +//class request: public ::testing::Test { +//protected: - } - virtual void TearDown() override { +// virtual void SetUp() override { - } - virtual void TestBody() override { +// } +// virtual void TearDown() override { - } -}; +// } +// virtual void TestBody() override { +// } +//}; -TEST_F(request, registration_basic) { +BOOST_AUTO_TEST_CASE(registration_basic) { std::string login = "vasiliy"; std::string passsword = "a1s22g_1"; RegistrationRequest request(login.data(),passsword.data()); - EXPECT_EQ(request.get_protocol_version(), PROTOCOL_VERS); - EXPECT_EQ(request.get_type_data(), TypeCommand::RegistrationRequest); - EXPECT_EQ(request.get_login(), login); - EXPECT_EQ(request.get_password(), passsword); + BOOST_CHECK(request.get_protocol_version() == PROTOCOL_VERS); + BOOST_CHECK(request.get_type_data() == TypeCommand::RegistrationRequest); + BOOST_CHECK(request.get_login() == login); + BOOST_CHECK(request.get_password() == passsword); } - -TEST_F(request, registration_empty_login) { - std::string login = ""; - std::string passsword = "a1s22g"; - RegistrationRequest request(login.data(),passsword.data()); - - EXPECT_EQ(request.get_protocol_version(), PROTOCOL_VERS); - EXPECT_EQ(request.get_type_data(), TypeCommand::RegistrationRequest); - EXPECT_EQ(request.get_login(), login); - EXPECT_EQ(request.get_password(), passsword); } +//TEST_F(request, registration_empty_login) { +// std::string login = ""; +// std::string passsword = "a1s22g"; +// RegistrationRequest request(login.data(),passsword.data()); -TEST_F(request, registration_empty_password) { - std::string login = "vasiliy"; - std::string passsword = ""; - RegistrationRequest request(login.data(), passsword.data()); +// EXPECT_EQ(request.get_protocol_version(), PROTOCOL_VERS); +// EXPECT_EQ(request.get_type_data(), TypeCommand::RegistrationRequest); +// EXPECT_EQ(request.get_login(), login); +// EXPECT_EQ(request.get_password(), passsword); +//} - EXPECT_EQ(request.get_protocol_version(), PROTOCOL_VERS); - EXPECT_EQ(request.get_type_data(), TypeCommand::RegistrationRequest); - EXPECT_EQ(request.get_login(), login); - EXPECT_EQ(request.get_password(), passsword); -} +//TEST_F(request, registration_empty_password) { +// std::string login = "vasiliy"; +// std::string passsword = ""; +// RegistrationRequest request(login.data(), passsword.data()); -TEST_F(request, registration_over_login) { - std::string fake_login = "vasiliyaaaaaaaaBBBB"; - std::string login = "vasiliyaaaaaaaa"; - std::string passsword = "a1s22g"; - RegistrationRequest request(fake_login.data(),passsword.data()); +// EXPECT_EQ(request.get_protocol_version(), PROTOCOL_VERS); +// EXPECT_EQ(request.get_type_data(), TypeCommand::RegistrationRequest); +// EXPECT_EQ(request.get_login(), login); +// EXPECT_EQ(request.get_password(), passsword); +//} - EXPECT_EQ(request.get_protocol_version(), PROTOCOL_VERS); - EXPECT_EQ(request.get_type_data(), TypeCommand::RegistrationRequest); - EXPECT_EQ(request.get_login(), login); - EXPECT_EQ(request.get_password(), passsword); -} +//TEST_F(request, registration_over_login) { +// std::string fake_login = "vasiliyaaaaaaaaBBBB"; +// std::string login = "vasiliyaaaaaaaa"; +// std::string passsword = "a1s22g"; +// RegistrationRequest request(fake_login.data(),passsword.data()); -TEST_F(request, registration_over_password) { - std::string login = "vasiliy"; - std::string fake_passsword = "12345678901234567890123456789012345"; - std::string passsword = "1234567890123456789012345678901"; - RegistrationRequest request(login.data(), fake_passsword.data()); - - EXPECT_EQ(request.get_protocol_version(), PROTOCOL_VERS); - EXPECT_EQ(request.get_type_data(), TypeCommand::RegistrationRequest); - EXPECT_EQ(request.get_login(), login); - EXPECT_EQ(request.get_password(), passsword); -} +// EXPECT_EQ(request.get_protocol_version(), PROTOCOL_VERS); +// EXPECT_EQ(request.get_type_data(), TypeCommand::RegistrationRequest); +// EXPECT_EQ(request.get_login(), login); +// EXPECT_EQ(request.get_password(), passsword); +//} -//TEST_F(request, registration_init) { +//TEST_F(request, registration_over_password) { // std::string login = "vasiliy"; +// std::string fake_passsword = "12345678901234567890123456789012345"; // std::string passsword = "1234567890123456789012345678901"; -// RegistrationRequest request(login.data(), passsword.data()); +// RegistrationRequest request(login.data(), fake_passsword.data()); // EXPECT_EQ(request.get_protocol_version(), PROTOCOL_VERS); -// EXPECT_EQ(request.get_type_data(), static_cast(TypeCommand::RegistrationRequest)); +// EXPECT_EQ(request.get_type_data(), TypeCommand::RegistrationRequest); // EXPECT_EQ(request.get_login(), login); // EXPECT_EQ(request.get_password(), passsword); - -// RegistrationRequest after_read_request; -// after_read_request.init(request.get_data()); - -// EXPECT_EQ(after_read_request.get_protocol_version(), PROTOCOL_VERS); -// EXPECT_EQ(after_read_request.get_type_data(), static_cast(TypeCommand::RegistrationRequest)); -// EXPECT_EQ(after_read_request.get_login(), login); -// EXPECT_EQ(after_read_request.get_password(), passsword); //} -TEST_F(request, autorisation_basic) { - std::string login = "vasiliy"; - std::string passsword = "a1s22g_1"; - AutorisationRequest request(login.data(),passsword.data()); - EXPECT_EQ(request.get_protocol_version(), PROTOCOL_VERS); - EXPECT_EQ(request.get_type_data(), TypeCommand::AuthorisationRequest); - EXPECT_EQ(request.get_login(), login); - EXPECT_EQ(request.get_password(), passsword); -} +//TEST_F(request, autorisation_basic) { +// std::string login = "vasiliy"; +// std::string passsword = "a1s22g_1"; -TEST_F(request, autorisation_empty_login) { - std::string login = ""; - std::string passsword = "a1s22g_1"; +// AutorisationRequest request(login.data(),passsword.data()); - AutorisationRequest request(login.data(),passsword.data()); +// EXPECT_EQ(request.get_protocol_version(), PROTOCOL_VERS); +// EXPECT_EQ(request.get_type_data(), TypeCommand::AuthorisationRequest); +// EXPECT_EQ(request.get_login(), login); +// EXPECT_EQ(request.get_password(), passsword); +//} - EXPECT_EQ(request.get_protocol_version(), PROTOCOL_VERS); - EXPECT_EQ(request.get_type_data(), TypeCommand::AuthorisationRequest); - EXPECT_EQ(request.get_login(), login); - EXPECT_EQ(request.get_password(), passsword); -} +//TEST_F(request, autorisation_empty_login) { +// std::string login = ""; +// std::string passsword = "a1s22g_1"; -TEST_F(request, autorisation_empty_password) { - std::string login = "vasiliy"; - std::string passsword = ""; +// AutorisationRequest request(login.data(),passsword.data()); - AutorisationRequest request(login.data(),passsword.data()); +// EXPECT_EQ(request.get_protocol_version(), PROTOCOL_VERS); +// EXPECT_EQ(request.get_type_data(), TypeCommand::AuthorisationRequest); +// EXPECT_EQ(request.get_login(), login); +// EXPECT_EQ(request.get_password(), passsword); +//} - EXPECT_EQ(request.get_protocol_version(), PROTOCOL_VERS); - EXPECT_EQ(request.get_type_data(), TypeCommand::AuthorisationRequest); - EXPECT_EQ(request.get_login(), login); - EXPECT_EQ(request.get_password(), passsword); -} +//TEST_F(request, autorisation_empty_password) { +// std::string login = "vasiliy"; +// std::string passsword = ""; -TEST_F(request, autorisation_over_login) { - std::string fake_login = "vasiliyaaaaaaaaBBBB"; - std::string login = "vasiliyaaaaaaaa"; - std::string passsword = "a1s22g"; - AutorisationRequest request(fake_login.data(),passsword.data()); +// AutorisationRequest request(login.data(),passsword.data()); - EXPECT_EQ(request.get_protocol_version(), PROTOCOL_VERS); - EXPECT_EQ(request.get_type_data(), TypeCommand::AuthorisationRequest); - EXPECT_EQ(request.get_login(), login); - EXPECT_EQ(request.get_password(), passsword); -} +// EXPECT_EQ(request.get_protocol_version(), PROTOCOL_VERS); +// EXPECT_EQ(request.get_type_data(), TypeCommand::AuthorisationRequest); +// EXPECT_EQ(request.get_login(), login); +// EXPECT_EQ(request.get_password(), passsword); +//} -TEST_F(request, autorisation_over_password) { - std::string login = "vasiliy"; - std::string fake_passsword = "12345678901234567890123456789012345"; - std::string passsword = "1234567890123456789012345678901"; - AutorisationRequest request(login.data(), fake_passsword.data()); - - EXPECT_EQ(request.get_protocol_version(), PROTOCOL_VERS); - EXPECT_EQ(request.get_type_data(), TypeCommand::AuthorisationRequest); - EXPECT_EQ(request.get_login(), login); - EXPECT_EQ(request.get_password(), passsword); -} +//TEST_F(request, autorisation_over_login) { +// std::string fake_login = "vasiliyaaaaaaaaBBBB"; +// std::string login = "vasiliyaaaaaaaa"; +// std::string passsword = "a1s22g"; +// AutorisationRequest request(fake_login.data(),passsword.data()); + +// EXPECT_EQ(request.get_protocol_version(), PROTOCOL_VERS); +// EXPECT_EQ(request.get_type_data(), TypeCommand::AuthorisationRequest); +// EXPECT_EQ(request.get_login(), login); +// EXPECT_EQ(request.get_password(), passsword); +//} -//TEST_F(request, autorisation_init) { +//TEST_F(request, autorisation_over_password) { // std::string login = "vasiliy"; +// std::string fake_passsword = "12345678901234567890123456789012345"; // std::string passsword = "1234567890123456789012345678901"; -// AutorisationRequest request(login.data(), passsword.data()); +// AutorisationRequest request(login.data(), fake_passsword.data()); // EXPECT_EQ(request.get_protocol_version(), PROTOCOL_VERS); -// EXPECT_EQ(request.get_type_data(), static_cast(TypeCommand::AuthorisationRequest)); +// EXPECT_EQ(request.get_type_data(), TypeCommand::AuthorisationRequest); // EXPECT_EQ(request.get_login(), login); // EXPECT_EQ(request.get_password(), passsword); +//} -// AutorisationRequest after_read_request; -// after_read_request.init(request.get_data()); -// EXPECT_EQ(after_read_request.get_protocol_version(), PROTOCOL_VERS); -// EXPECT_EQ(after_read_request.get_type_data(), static_cast(TypeCommand::AuthorisationRequest)); -// EXPECT_EQ(after_read_request.get_login(), login); -// EXPECT_EQ(after_read_request.get_password(), passsword); -//} -TEST_F(request, autorisation_basic_ptr) { - std::string login = "vasiliy"; - std::string password = "a1s22g_1"; +//TEST_F(request, autorisation_basic_ptr) { +// std::string login = "vasiliy"; +// std::string password = "a1s22g_1"; - autor_request_ptr request; - request = std::make_shared(login.data(), password.data()); +// autor_request_ptr request; +// request = std::make_shared(login.data(), password.data()); - EXPECT_EQ(request->get_protocol_version(), PROTOCOL_VERS); - EXPECT_EQ(request->get_type_data(), TypeCommand::AuthorisationRequest); - EXPECT_EQ(request->get_login(), login); - EXPECT_EQ(request->get_password(), password); -} +// EXPECT_EQ(request->get_protocol_version(), PROTOCOL_VERS); +// EXPECT_EQ(request->get_type_data(), TypeCommand::AuthorisationRequest); +// EXPECT_EQ(request->get_login(), login); +// EXPECT_EQ(request->get_password(), password); +//} -TEST_F(request, input_basic_empty_ptr) { - input_request_ptr request; - request = std::make_shared(); +//TEST_F(request, input_basic_empty_ptr) { +// input_request_ptr request; +// request = std::make_shared(); - EXPECT_EQ(request->get_protocol_version(), PROTOCOL_VERS); - EXPECT_EQ(request->get_type_data(), TypeCommand::AuthorisationRequest); -} +// EXPECT_EQ(request->get_protocol_version(), PROTOCOL_VERS); +// EXPECT_EQ(request->get_type_data(), TypeCommand::AuthorisationRequest); +//} -TEST_F(request, autorisation_basic_empty_ptr) { - autor_request_ptr request; - request = std::make_shared(); +//TEST_F(request, autorisation_basic_empty_ptr) { +// autor_request_ptr request; +// request = std::make_shared(); - EXPECT_EQ(request->get_protocol_version(), PROTOCOL_VERS); - EXPECT_EQ(request->get_type_data(), TypeCommand::AuthorisationRequest); -} +// EXPECT_EQ(request->get_protocol_version(), PROTOCOL_VERS); +// EXPECT_EQ(request->get_type_data(), TypeCommand::AuthorisationRequest); +//} diff --git a/src/tests/test_response.cpp b/src/tests/test_response.cpp index df5431d..72b95c4 100644 --- a/src/tests/test_response.cpp +++ b/src/tests/test_response.cpp @@ -1,66 +1,66 @@ -#include -#include -#include +//#include +//#include +//#include -class response: public ::testing::Test { -protected: +//class response: public ::testing::Test { +//protected: - virtual void SetUp() override { +// virtual void SetUp() override { - } - virtual void TearDown() override { +// } +// virtual void TearDown() override { - } - virtual void TestBody() override { +// } +// virtual void TestBody() override { - } -}; +// } +//}; -TEST_F(response, registration_basic) { - int32_t id = 12345; - RegistrationResponse response(id); +//TEST_F(response, registration_basic) { +// int32_t id = 12345; +// RegistrationResponse response(id); - EXPECT_EQ(response.get_protocol_version(), PROTOCOL_VERS); - EXPECT_EQ(response.get_type_data(), TypeCommand::RegistrationResponse); - EXPECT_EQ(response.get_loginid(), id); -} +// EXPECT_EQ(response.get_protocol_version(), PROTOCOL_VERS); +// EXPECT_EQ(response.get_type_data(), TypeCommand::RegistrationResponse); +// EXPECT_EQ(response.get_loginid(), id); +//} -TEST_F(response, autorisation_basic) { - uint32_t id = 1234567890; - AutorisationResponse response(id); +//TEST_F(response, autorisation_basic) { +// uint32_t id = 1234567890; +// AutorisationResponse response(id); - EXPECT_EQ(response.get_protocol_version(), PROTOCOL_VERS); - EXPECT_EQ(response.get_type_data(), TypeCommand::AutorisationResponse); - EXPECT_EQ(response.get_loginid(), id); -} +// EXPECT_EQ(response.get_protocol_version(), PROTOCOL_VERS); +// EXPECT_EQ(response.get_type_data(), TypeCommand::AutorisationResponse); +// EXPECT_EQ(response.get_loginid(), id); +//} -TEST_F(response, registration_basic_change_id) { - uint32_t id = 12345; - RegistrationResponse response(id); - id = 123; - response.set_loginid(id); - EXPECT_EQ(response.get_protocol_version(), PROTOCOL_VERS); - EXPECT_EQ(response.get_type_data(), TypeCommand::RegistrationResponse); - EXPECT_EQ(response.get_loginid(), id); +//TEST_F(response, registration_basic_change_id) { +// uint32_t id = 12345; +// RegistrationResponse response(id); +// id = 123; +// response.set_loginid(id); +// EXPECT_EQ(response.get_protocol_version(), PROTOCOL_VERS); +// EXPECT_EQ(response.get_type_data(), TypeCommand::RegistrationResponse); +// EXPECT_EQ(response.get_loginid(), id); - response.set_loginid(); - EXPECT_EQ(response.get_protocol_version(), PROTOCOL_VERS); - EXPECT_EQ(response.get_type_data(), TypeCommand::RegistrationResponse); - EXPECT_EQ(response.get_loginid(), 0); -} +// response.set_loginid(); +// EXPECT_EQ(response.get_protocol_version(), PROTOCOL_VERS); +// EXPECT_EQ(response.get_type_data(), TypeCommand::RegistrationResponse); +// EXPECT_EQ(response.get_loginid(), 0); +//} -TEST_F(response, autorisation_basic_change_id) { - uint32_t id = 1234567890; - AutorisationResponse response(id); - id = 123; - response.set_loginid(id); +//TEST_F(response, autorisation_basic_change_id) { +// uint32_t id = 1234567890; +// AutorisationResponse response(id); +// id = 123; +// response.set_loginid(id); - EXPECT_EQ(response.get_protocol_version(), PROTOCOL_VERS); - EXPECT_EQ(response.get_type_data(), TypeCommand::AutorisationResponse); - EXPECT_EQ(response.get_loginid(), id); +// EXPECT_EQ(response.get_protocol_version(), PROTOCOL_VERS); +// EXPECT_EQ(response.get_type_data(), TypeCommand::AutorisationResponse); +// EXPECT_EQ(response.get_loginid(), id); - response.set_loginid(); - EXPECT_EQ(response.get_protocol_version(), PROTOCOL_VERS); - EXPECT_EQ(response.get_type_data(), TypeCommand::AutorisationResponse); - EXPECT_EQ(response.get_loginid(), 0); -} +// response.set_loginid(); +// EXPECT_EQ(response.get_protocol_version(), PROTOCOL_VERS); +// EXPECT_EQ(response.get_type_data(), TypeCommand::AutorisationResponse); +// EXPECT_EQ(response.get_loginid(), 0); +//} From bc6de0eaa4dc05dfea663a602dde5ba8d63a09cb Mon Sep 17 00:00:00 2001 From: k-morozov Date: Thu, 6 Aug 2020 08:01:47 +0300 Subject: [PATCH 11/17] add request tests --- src/tests/test_request.cpp | 285 +++++++++++++++++-------------------- 1 file changed, 134 insertions(+), 151 deletions(-) diff --git a/src/tests/test_request.cpp b/src/tests/test_request.cpp index 3fe4ecd..0941f2f 100644 --- a/src/tests/test_request.cpp +++ b/src/tests/test_request.cpp @@ -4,171 +4,154 @@ #include /** - * @brief Unit tests for queue project. + * @brief Unit tests for AppChat project. */ BOOST_AUTO_TEST_SUITE(test_request) -//class request: public ::testing::Test { -//protected: +BOOST_AUTO_TEST_CASE(registration_basic) { + std::string login = "vasiliy"; + std::string passsword = "a1s22g_1"; -// virtual void SetUp() override { + RegistrationRequest request(login.data(),passsword.data()); -// } -// virtual void TearDown() override { + BOOST_CHECK(request.get_protocol_version() == PROTOCOL_VERS); + BOOST_CHECK(request.get_type_data() == TypeCommand::RegistrationRequest); + BOOST_CHECK(request.get_login() == login); + BOOST_CHECK(request.get_password() == passsword); +} -// } -// virtual void TestBody() override { +BOOST_AUTO_TEST_CASE(registration_empty_login) { + std::string login = ""; + std::string passsword = "a1s22g"; + RegistrationRequest request(login.data(),passsword.data()); -// } -//}; + BOOST_CHECK(request.get_protocol_version() == PROTOCOL_VERS); + BOOST_CHECK(request.get_type_data() == TypeCommand::RegistrationRequest); + BOOST_CHECK(request.get_login() == login); + BOOST_CHECK(request.get_password() == passsword); +} -BOOST_AUTO_TEST_CASE(registration_basic) { +BOOST_AUTO_TEST_CASE(registration_empty_password) { std::string login = "vasiliy"; - std::string passsword = "a1s22g_1"; + std::string passsword = ""; + RegistrationRequest request(login.data(), passsword.data()); - RegistrationRequest request(login.data(),passsword.data()); + BOOST_CHECK(request.get_protocol_version() == PROTOCOL_VERS); + BOOST_CHECK(request.get_type_data() == TypeCommand::RegistrationRequest); + BOOST_CHECK(request.get_login() == login); + BOOST_CHECK(request.get_password() == passsword); +} + +BOOST_AUTO_TEST_CASE(registration_over_login) { + std::string fake_login = "vasiliyaaaaaaaaBBBB"; + std::string login = "vasiliyaaaaaaaa"; + std::string passsword = "a1s22g"; + RegistrationRequest request(fake_login.data(),passsword.data()); + + BOOST_CHECK(request.get_protocol_version() == PROTOCOL_VERS); + BOOST_CHECK(request.get_type_data() == TypeCommand::RegistrationRequest); + BOOST_CHECK(request.get_login() == login); + BOOST_CHECK(request.get_password() == passsword); +} + +BOOST_AUTO_TEST_CASE(registration_over_password) { + std::string login = "vasiliy"; + std::string fake_passsword = "12345678901234567890123456789012345"; + std::string passsword = "1234567890123456789012345678901"; + RegistrationRequest request(login.data(), fake_passsword.data()); BOOST_CHECK(request.get_protocol_version() == PROTOCOL_VERS); BOOST_CHECK(request.get_type_data() == TypeCommand::RegistrationRequest); BOOST_CHECK(request.get_login() == login); BOOST_CHECK(request.get_password() == passsword); } + +BOOST_AUTO_TEST_CASE(autorisation_basic) { + std::string login = "vasiliy"; + std::string passsword = "a1s22g_1"; + + AutorisationRequest request(login.data(),passsword.data()); + + BOOST_CHECK(request.get_protocol_version() == PROTOCOL_VERS); + BOOST_CHECK(request.get_type_data() == TypeCommand::AuthorisationRequest); + BOOST_CHECK(request.get_login() == login); + BOOST_CHECK(request.get_password() == passsword); +} + +BOOST_AUTO_TEST_CASE(autorisation_empty_login) { + std::string login = ""; + std::string passsword = "a1s22g_1"; + + AutorisationRequest request(login.data(),passsword.data()); + + BOOST_CHECK(request.get_protocol_version() == PROTOCOL_VERS); + BOOST_CHECK(request.get_type_data() == TypeCommand::AuthorisationRequest); + BOOST_CHECK(request.get_login() == login); + BOOST_CHECK(request.get_password() == passsword); +} + +BOOST_AUTO_TEST_CASE(autorisation_empty_password) { + std::string login = "vasiliy"; + std::string passsword = ""; + + AutorisationRequest request(login.data(),passsword.data()); + + BOOST_CHECK(request.get_protocol_version() == PROTOCOL_VERS); + BOOST_CHECK(request.get_type_data() == TypeCommand::AuthorisationRequest); + BOOST_CHECK(request.get_login() == login); + BOOST_CHECK(request.get_password() == passsword); +} + +BOOST_AUTO_TEST_CASE(autorisation_over_login) { + std::string fake_login = "vasiliyaaaaaaaaBBBB"; + std::string login = "vasiliyaaaaaaaa"; + std::string passsword = "a1s22g"; + AutorisationRequest request(fake_login.data(),passsword.data()); + + BOOST_CHECK(request.get_protocol_version() == PROTOCOL_VERS); + BOOST_CHECK(request.get_type_data() == TypeCommand::AuthorisationRequest); + BOOST_CHECK(request.get_login() == login); + BOOST_CHECK(request.get_password() == passsword); +} + +BOOST_AUTO_TEST_CASE(autorisation_over_password) { + std::string login = "vasiliy"; + std::string fake_passsword = "12345678901234567890123456789012345"; + std::string passsword = "1234567890123456789012345678901"; + AutorisationRequest request(login.data(), fake_passsword.data()); + + BOOST_CHECK(request.get_protocol_version() == PROTOCOL_VERS); + BOOST_CHECK(request.get_type_data() == TypeCommand::AuthorisationRequest); + BOOST_CHECK(request.get_login() == login); + BOOST_CHECK(request.get_password() == passsword); +} + +BOOST_AUTO_TEST_CASE(autorisation_basic_ptr) { + std::string login = "vasiliy"; + std::string password = "a1s22g_1"; + + autor_request_ptr request; + request = std::make_shared(login.data(), password.data()); + + BOOST_CHECK(request->get_protocol_version() == PROTOCOL_VERS); + BOOST_CHECK(request->get_type_data() == TypeCommand::AuthorisationRequest); + BOOST_CHECK(request->get_login() == login); + BOOST_CHECK(request->get_password() == password); +} + +BOOST_AUTO_TEST_CASE(input_basic_empty_ptr) { + input_request_ptr request; + request = std::make_shared(); + + BOOST_CHECK(request->get_protocol_version() == PROTOCOL_VERS); + BOOST_CHECK(request->get_type_data() == TypeCommand::AuthorisationRequest); +} + +BOOST_AUTO_TEST_CASE(autorisation_basic_empty_ptr) { + autor_request_ptr request; + request = std::make_shared(); + + BOOST_CHECK(request->get_protocol_version() == PROTOCOL_VERS); + BOOST_CHECK(request->get_type_data() == TypeCommand::AuthorisationRequest); } -//TEST_F(request, registration_empty_login) { -// std::string login = ""; -// std::string passsword = "a1s22g"; -// RegistrationRequest request(login.data(),passsword.data()); - -// EXPECT_EQ(request.get_protocol_version(), PROTOCOL_VERS); -// EXPECT_EQ(request.get_type_data(), TypeCommand::RegistrationRequest); -// EXPECT_EQ(request.get_login(), login); -// EXPECT_EQ(request.get_password(), passsword); -//} - -//TEST_F(request, registration_empty_password) { -// std::string login = "vasiliy"; -// std::string passsword = ""; -// RegistrationRequest request(login.data(), passsword.data()); - -// EXPECT_EQ(request.get_protocol_version(), PROTOCOL_VERS); -// EXPECT_EQ(request.get_type_data(), TypeCommand::RegistrationRequest); -// EXPECT_EQ(request.get_login(), login); -// EXPECT_EQ(request.get_password(), passsword); -//} - -//TEST_F(request, registration_over_login) { -// std::string fake_login = "vasiliyaaaaaaaaBBBB"; -// std::string login = "vasiliyaaaaaaaa"; -// std::string passsword = "a1s22g"; -// RegistrationRequest request(fake_login.data(),passsword.data()); - -// EXPECT_EQ(request.get_protocol_version(), PROTOCOL_VERS); -// EXPECT_EQ(request.get_type_data(), TypeCommand::RegistrationRequest); -// EXPECT_EQ(request.get_login(), login); -// EXPECT_EQ(request.get_password(), passsword); -//} - -//TEST_F(request, registration_over_password) { -// std::string login = "vasiliy"; -// std::string fake_passsword = "12345678901234567890123456789012345"; -// std::string passsword = "1234567890123456789012345678901"; -// RegistrationRequest request(login.data(), fake_passsword.data()); - -// EXPECT_EQ(request.get_protocol_version(), PROTOCOL_VERS); -// EXPECT_EQ(request.get_type_data(), TypeCommand::RegistrationRequest); -// EXPECT_EQ(request.get_login(), login); -// EXPECT_EQ(request.get_password(), passsword); -//} - - - -//TEST_F(request, autorisation_basic) { -// std::string login = "vasiliy"; -// std::string passsword = "a1s22g_1"; - -// AutorisationRequest request(login.data(),passsword.data()); - -// EXPECT_EQ(request.get_protocol_version(), PROTOCOL_VERS); -// EXPECT_EQ(request.get_type_data(), TypeCommand::AuthorisationRequest); -// EXPECT_EQ(request.get_login(), login); -// EXPECT_EQ(request.get_password(), passsword); -//} - -//TEST_F(request, autorisation_empty_login) { -// std::string login = ""; -// std::string passsword = "a1s22g_1"; - -// AutorisationRequest request(login.data(),passsword.data()); - -// EXPECT_EQ(request.get_protocol_version(), PROTOCOL_VERS); -// EXPECT_EQ(request.get_type_data(), TypeCommand::AuthorisationRequest); -// EXPECT_EQ(request.get_login(), login); -// EXPECT_EQ(request.get_password(), passsword); -//} - -//TEST_F(request, autorisation_empty_password) { -// std::string login = "vasiliy"; -// std::string passsword = ""; - -// AutorisationRequest request(login.data(),passsword.data()); - -// EXPECT_EQ(request.get_protocol_version(), PROTOCOL_VERS); -// EXPECT_EQ(request.get_type_data(), TypeCommand::AuthorisationRequest); -// EXPECT_EQ(request.get_login(), login); -// EXPECT_EQ(request.get_password(), passsword); -//} - -//TEST_F(request, autorisation_over_login) { -// std::string fake_login = "vasiliyaaaaaaaaBBBB"; -// std::string login = "vasiliyaaaaaaaa"; -// std::string passsword = "a1s22g"; -// AutorisationRequest request(fake_login.data(),passsword.data()); - -// EXPECT_EQ(request.get_protocol_version(), PROTOCOL_VERS); -// EXPECT_EQ(request.get_type_data(), TypeCommand::AuthorisationRequest); -// EXPECT_EQ(request.get_login(), login); -// EXPECT_EQ(request.get_password(), passsword); -//} - -//TEST_F(request, autorisation_over_password) { -// std::string login = "vasiliy"; -// std::string fake_passsword = "12345678901234567890123456789012345"; -// std::string passsword = "1234567890123456789012345678901"; -// AutorisationRequest request(login.data(), fake_passsword.data()); - -// EXPECT_EQ(request.get_protocol_version(), PROTOCOL_VERS); -// EXPECT_EQ(request.get_type_data(), TypeCommand::AuthorisationRequest); -// EXPECT_EQ(request.get_login(), login); -// EXPECT_EQ(request.get_password(), passsword); -//} - - - -//TEST_F(request, autorisation_basic_ptr) { -// std::string login = "vasiliy"; -// std::string password = "a1s22g_1"; - -// autor_request_ptr request; -// request = std::make_shared(login.data(), password.data()); - -// EXPECT_EQ(request->get_protocol_version(), PROTOCOL_VERS); -// EXPECT_EQ(request->get_type_data(), TypeCommand::AuthorisationRequest); -// EXPECT_EQ(request->get_login(), login); -// EXPECT_EQ(request->get_password(), password); -//} - -//TEST_F(request, input_basic_empty_ptr) { -// input_request_ptr request; -// request = std::make_shared(); - -// EXPECT_EQ(request->get_protocol_version(), PROTOCOL_VERS); -// EXPECT_EQ(request->get_type_data(), TypeCommand::AuthorisationRequest); -//} - -//TEST_F(request, autorisation_basic_empty_ptr) { -// autor_request_ptr request; -// request = std::make_shared(); - -// EXPECT_EQ(request->get_protocol_version(), PROTOCOL_VERS); -// EXPECT_EQ(request->get_type_data(), TypeCommand::AuthorisationRequest); -//} +} // end boost::test From a9b15ed66c8789afdb6a555ce9322ef6750ce66c Mon Sep 17 00:00:00 2001 From: k-morozov Date: Thu, 6 Aug 2020 08:21:49 +0300 Subject: [PATCH 12/17] add boost::test --- src/tests/test_datetime.cpp | 270 +++++++++++++++++------------------- src/tests/test_response.cpp | 125 ++++++++--------- 2 files changed, 189 insertions(+), 206 deletions(-) diff --git a/src/tests/test_datetime.cpp b/src/tests/test_datetime.cpp index ffa30a9..3cd928d 100644 --- a/src/tests/test_datetime.cpp +++ b/src/tests/test_datetime.cpp @@ -1,205 +1,195 @@ -//#include +#include +#include +#include "datetime.h" -//#include +/** + * @brief Unit tests for AppChat project. + */ +BOOST_AUTO_TEST_SUITE(test_request) -//#include "datetime.h" +BOOST_AUTO_TEST_CASE(construction_by_default) { + DateTime dt; -//class datetime : public ::testing::Test -//{ -//protected: -// virtual void SetUp() override { } -// virtual void TearDown() override { } -//}; + BOOST_CHECK(dt.hours == 0); + BOOST_CHECK(dt.minutes == 0); + BOOST_CHECK(dt.seconds == 0); + BOOST_CHECK(dt.day == 0); + BOOST_CHECK(dt.month == 0); + BOOST_CHECK(dt.year == 0); +} -//TEST_F(datetime, construction_by_default) -//{ -// DateTime dt; +BOOST_AUTO_TEST_CASE(construction_from_ptime) { + using namespace boost::posix_time; -// EXPECT_EQ(dt.hours, 0); -// EXPECT_EQ(dt.minutes, 0); -// EXPECT_EQ(dt.seconds, 0); + ptime pt = second_clock::universal_time(); -// EXPECT_EQ(dt.day, 0); -// EXPECT_EQ(dt.month, 0); -// EXPECT_EQ(dt.year, 0); -//} + DateTime dt(pt); -//TEST_F(datetime, construction_from_ptime) -//{ -// using namespace boost::posix_time; + BOOST_CHECK(dt.hours == pt.time_of_day().hours()); + BOOST_CHECK(dt.minutes == pt.time_of_day().minutes()); + BOOST_CHECK(dt.seconds == pt.time_of_day().seconds()); -// ptime pt = second_clock::universal_time(); + BOOST_CHECK(dt.day == pt.date().day()); + BOOST_CHECK(dt.month == pt.date().month()); + BOOST_CHECK(dt.year + 2000 == pt.date().year()); +} -// DateTime dt(pt); - -// EXPECT_EQ(dt.hours, pt.time_of_day().hours()); -// EXPECT_EQ(dt.minutes, pt.time_of_day().minutes()); -// EXPECT_EQ(dt.seconds, pt.time_of_day().seconds()); - -// EXPECT_EQ(dt.day, pt.date().day()); -// EXPECT_EQ(dt.month, pt.date().month()); -// EXPECT_EQ(dt.year + 2000, pt.date().year()); -//} - -//TEST_F(datetime, simple_date_string) -//{ -// DateTime dt; +BOOST_AUTO_TEST_CASE(simple_date_string) { + DateTime dt; -// dt.day = 22; -// dt.month = 7; -// dt.year = 20; + dt.day = 22; + dt.month = 7; + dt.year = 20; -// EXPECT_EQ(dt.to_simple_date(), "22.07.2020"); + BOOST_CHECK(dt.to_simple_date() == "22.07.2020"); -// dt.day = 0; -// dt.month = 0; -// dt.year = 0; + dt.day = 0; + dt.month = 0; + dt.year = 0; -// EXPECT_EQ(dt.to_simple_date(), "00.00.2000"); + BOOST_CHECK(dt.to_simple_date() == "00.00.2000"); -// dt.day = 31; -// dt.month = 12; -// dt.year = 255; + dt.day = 31; + dt.month = 12; + dt.year = 255; -// EXPECT_EQ(dt.to_simple_date(), "31.12.2255"); -//} + BOOST_CHECK(dt.to_simple_date() == "31.12.2255"); +} -//TEST_F(datetime, simple_time_string) -//{ -// DateTime dt; +BOOST_AUTO_TEST_CASE(simple_time_string) { + DateTime dt; -// dt.hours = 16; -// dt.minutes = 5; -// dt.seconds = 50; + dt.hours = 16; + dt.minutes = 5; + dt.seconds = 50; -// EXPECT_EQ(dt.to_simple_time(), "16:05:50"); + BOOST_CHECK(dt.to_simple_time() == "16:05:50"); -// dt.hours = 0; -// dt.minutes = 0; -// dt.seconds = 0; + dt.hours = 0; + dt.minutes = 0; + dt.seconds = 0; -// EXPECT_EQ(dt.to_simple_time(), "00:00:00"); + BOOST_CHECK(dt.to_simple_time() == "00:00:00"); -// dt.hours = 23; -// dt.minutes = 59; -// dt.seconds = 59; + dt.hours = 23; + dt.minutes = 59; + dt.seconds = 59; -// EXPECT_EQ(dt.to_simple_time(), "23:59:59"); -//} + BOOST_CHECK(dt.to_simple_time() == "23:59:59"); +} -//TEST_F(datetime, operator_equal) -//{ -// DateTime lhs; +BOOST_AUTO_TEST_CASE(operator_equal) { + DateTime lhs; -// lhs.hours = 1; -// lhs.minutes = 2; -// lhs.seconds = 3; + lhs.hours = 1; + lhs.minutes = 2; + lhs.seconds = 3; -// lhs.day = 4; -// lhs.month = 5; -// lhs.year = 6; + lhs.day = 4; + lhs.month = 5; + lhs.year = 6; -// DateTime rhs; + DateTime rhs; -// rhs.hours = 1; -// rhs.minutes = 2; -// rhs.seconds = 3; + rhs.hours = 1; + rhs.minutes = 2; + rhs.seconds = 3; -// rhs.day = 4; -// rhs.month = 5; -// rhs.year = 6; + rhs.day = 4; + rhs.month = 5; + rhs.year = 6; -// EXPECT_EQ(lhs == rhs, true); + BOOST_CHECK(lhs == rhs); -// rhs.year = 7; + rhs.year = 7; -// EXPECT_EQ(lhs == rhs, false); + BOOST_CHECK(!(lhs == rhs)); -// rhs.year = 5; + rhs.year = 5; -// EXPECT_EQ(lhs == rhs, false); -//} + BOOST_CHECK(!(lhs == rhs)); +} -//TEST_F(datetime, operator_less) -//{ -// DateTime lhs; +BOOST_AUTO_TEST_CASE(operator_less) { + DateTime lhs; -// lhs.seconds = 1; -// lhs.minutes = 2; -// lhs.hours = 3; + lhs.seconds = 1; + lhs.minutes = 2; + lhs.hours = 3; -// lhs.day = 4; -// lhs.month = 5; -// lhs.year = 6; + lhs.day = 4; + lhs.month = 5; + lhs.year = 6; -// DateTime rhs; + DateTime rhs; -// rhs.seconds = 1; -// rhs.minutes = 2; -// rhs.hours = 3; + rhs.seconds = 1; + rhs.minutes = 2; + rhs.hours = 3; -// rhs.day = 4; -// rhs.month = 5; -// rhs.year = 6; + rhs.day = 4; + rhs.month = 5; + rhs.year = 6; -// EXPECT_EQ(lhs < rhs, false); + BOOST_CHECK(!(lhs < rhs)); -// lhs.year = 7; + lhs.year = 7; -// EXPECT_EQ(lhs < rhs, false); + BOOST_CHECK(!(lhs < rhs)); -// lhs.year = 6; -// lhs.month = 6; + lhs.year = 6; + lhs.month = 6; -// EXPECT_EQ(lhs < rhs, false); + BOOST_CHECK(!(lhs < rhs)); -// lhs.month = 5; -// lhs.day = 5; + lhs.month = 5; + lhs.day = 5; -// EXPECT_EQ(lhs < rhs, false); + BOOST_CHECK(!(lhs < rhs)); -// lhs.day = 4; -// lhs.hours = 4; + lhs.day = 4; + lhs.hours = 4; -// EXPECT_EQ(lhs < rhs, false); + BOOST_CHECK(!(lhs < rhs)); -// lhs.hours = 3; -// lhs.minutes = 3; + lhs.hours = 3; + lhs.minutes = 3; -// EXPECT_EQ(lhs < rhs, false); + BOOST_CHECK(!(lhs < rhs)); -// lhs.minutes = 2; -// lhs.seconds = 2; + lhs.minutes = 2; + lhs.seconds = 2; -// EXPECT_EQ(lhs < rhs, false); + BOOST_CHECK(!(lhs < rhs)); -// lhs.seconds = 0; + lhs.seconds = 0; -// EXPECT_EQ(lhs < rhs, true); + BOOST_CHECK(lhs < rhs); -// lhs.seconds = 1; -// lhs.minutes = 1; + lhs.seconds = 1; + lhs.minutes = 1; -// EXPECT_EQ(lhs < rhs, true); + BOOST_CHECK(lhs < rhs); -// lhs.minutes = 2; -// lhs.hours = 2; + lhs.minutes = 2; + lhs.hours = 2; -// EXPECT_EQ(lhs < rhs, true); + BOOST_CHECK(lhs < rhs); -// lhs.hours = 3; -// lhs.day = 3; + lhs.hours = 3; + lhs.day = 3; -// EXPECT_EQ(lhs < rhs, true); + BOOST_CHECK(lhs < rhs); -// lhs.day = 4; -// lhs.month = 4; + lhs.day = 4; + lhs.month = 4; -// EXPECT_EQ(lhs < rhs, true); + BOOST_CHECK(lhs < rhs); -// lhs.month = 5; -// lhs.year = 5; + lhs.month = 5; + lhs.year = 5; -// EXPECT_EQ(lhs < rhs, true); -//} + BOOST_CHECK(lhs < rhs); +} +} diff --git a/src/tests/test_response.cpp b/src/tests/test_response.cpp index 72b95c4..53c2bcd 100644 --- a/src/tests/test_response.cpp +++ b/src/tests/test_response.cpp @@ -1,66 +1,59 @@ -//#include -//#include -//#include - -//class response: public ::testing::Test { -//protected: - -// virtual void SetUp() override { - -// } -// virtual void TearDown() override { - -// } -// virtual void TestBody() override { - -// } -//}; - -//TEST_F(response, registration_basic) { -// int32_t id = 12345; -// RegistrationResponse response(id); - -// EXPECT_EQ(response.get_protocol_version(), PROTOCOL_VERS); -// EXPECT_EQ(response.get_type_data(), TypeCommand::RegistrationResponse); -// EXPECT_EQ(response.get_loginid(), id); -//} - -//TEST_F(response, autorisation_basic) { -// uint32_t id = 1234567890; -// AutorisationResponse response(id); - -// EXPECT_EQ(response.get_protocol_version(), PROTOCOL_VERS); -// EXPECT_EQ(response.get_type_data(), TypeCommand::AutorisationResponse); -// EXPECT_EQ(response.get_loginid(), id); -//} - -//TEST_F(response, registration_basic_change_id) { -// uint32_t id = 12345; -// RegistrationResponse response(id); -// id = 123; -// response.set_loginid(id); -// EXPECT_EQ(response.get_protocol_version(), PROTOCOL_VERS); -// EXPECT_EQ(response.get_type_data(), TypeCommand::RegistrationResponse); -// EXPECT_EQ(response.get_loginid(), id); - -// response.set_loginid(); -// EXPECT_EQ(response.get_protocol_version(), PROTOCOL_VERS); -// EXPECT_EQ(response.get_type_data(), TypeCommand::RegistrationResponse); -// EXPECT_EQ(response.get_loginid(), 0); -//} - -//TEST_F(response, autorisation_basic_change_id) { -// uint32_t id = 1234567890; -// AutorisationResponse response(id); -// id = 123; -// response.set_loginid(id); - -// EXPECT_EQ(response.get_protocol_version(), PROTOCOL_VERS); -// EXPECT_EQ(response.get_type_data(), TypeCommand::AutorisationResponse); -// EXPECT_EQ(response.get_loginid(), id); - -// response.set_loginid(); -// EXPECT_EQ(response.get_protocol_version(), PROTOCOL_VERS); -// EXPECT_EQ(response.get_type_data(), TypeCommand::AutorisationResponse); -// EXPECT_EQ(response.get_loginid(), 0); -//} +#include + +#include +#include + +/** + * @brief Unit tests for AppChat project. + */ +BOOST_AUTO_TEST_SUITE(test_request) + +BOOST_AUTO_TEST_CASE(response_registration_basic) { + identifier_t id = 12345; + RegistrationResponse response(id); + + BOOST_CHECK(response.get_protocol_version() == PROTOCOL_VERS); + BOOST_CHECK(response.get_type_data() == TypeCommand::RegistrationResponse); + BOOST_CHECK(response.get_loginid() == id); +} + +BOOST_AUTO_TEST_CASE(response_autorisation_basic) { + identifier_t id = 1234567890; + AutorisationResponse response(id); + + BOOST_CHECK(response.get_protocol_version() == PROTOCOL_VERS); + BOOST_CHECK(response.get_type_data() == TypeCommand::AutorisationResponse); + BOOST_CHECK(response.get_loginid() == id); +} + +BOOST_AUTO_TEST_CASE(response_registration_basic_change_id) { + identifier_t id = 12345; + RegistrationResponse response(id); + id = 123; + response.set_loginid(id); + BOOST_CHECK(response.get_protocol_version() == PROTOCOL_VERS); + BOOST_CHECK(response.get_type_data() == TypeCommand::RegistrationResponse); + BOOST_CHECK(response.get_loginid() == id); + + response.set_loginid(); + BOOST_CHECK(response.get_protocol_version() == PROTOCOL_VERS); + BOOST_CHECK(response.get_type_data() == TypeCommand::RegistrationResponse); + BOOST_CHECK(response.get_loginid() == 0); +} + +BOOST_AUTO_TEST_CASE(response_autorisation_basic_change_id) { + identifier_t id = 1234567890; + AutorisationResponse response(id); + id = 123; + response.set_loginid(id); + + BOOST_CHECK(response.get_protocol_version() == PROTOCOL_VERS); + BOOST_CHECK(response.get_type_data() == TypeCommand::AutorisationResponse); + BOOST_CHECK(response.get_loginid() == id); + + response.set_loginid(); + BOOST_CHECK(response.get_protocol_version() == PROTOCOL_VERS); + BOOST_CHECK(response.get_type_data() == TypeCommand::AutorisationResponse); + BOOST_CHECK(response.get_loginid() == 0); +} +} From a0b206593f04fb95027517d8949c96c97db4d8c2 Mon Sep 17 00:00:00 2001 From: k-morozov Date: Thu, 6 Aug 2020 08:55:41 +0300 Subject: [PATCH 13/17] add deb to bintray --- .travis.yml | 40 ++++++++++++++++++---------------------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4a052cf..c8dd901 100644 --- a/.travis.yml +++ b/.travis.yml @@ -38,31 +38,27 @@ after_success: if [[ "$TRAVIS_BRANCH" = "master" ]] ; then curl -T ${TRAVIS_BUILD_DIR}/build/bin/AppChat-0.7.$TRAVIS_BUILD_NUMBER-Linux.tar -uk-morozov:$BINTRAY_API_KEY https://api.bintray.com/content/k-morozov/AppChat/Download/0.7.$TRAVIS_BUILD_NUMBER/AppChat-0.7.$TRAVIS_BUILD_NUMBER-Linux.tar + curl -T ${TRAVIS_BUILD_DIR}/${BUILD_DIR}/${PROJECT_NAME}-0.0.$TRAVIS_BUILD_NUMBER-Linux.deb -uk-morozov:$BINTRAY_API_KEY "https://api.bintray.com/content/k-morozov/AppChat/Install-Linux/1/${PROJECT_NAME}-0.0.$TRAVIS_BUILD_NUMBER-Linux.deb;deb_distribution=trusty;deb_component=main;deb_architecture=amd64;publish=1" fi deploy: - #- provider: script - # skip_cleanup: true - # script: - # - curl -T ${TRAVIS_BUILD_DIR}/build/bin/AppChat-0.7.$TRAVIS_BUILD_NUMBER-Linux.tar -uk-morozov:$BINTRAY_API_KEY https://api.bintray.com/content/k-morozov/AppChat/Download/0.7.$TRAVIS_BUILD_NUMBER/AppChat-0.7.$TRAVIS_BUILD_NUMBER-Linux.tar +# - provider: pages +# skip-cleanup: true +# github-token: $GITHUB_API_KEY +# keep-history: true +# local-dir: docs/html +# on: +# branch: master - - provider: pages - skip-cleanup: true - github-token: $GITHUB_API_KEY - keep-history: true - local-dir: docs/html +before_deploy: + - git config --local user.name "k-morozov" + - git config --local user.email "morozov-kst@yandex.ru" + - git tag 0.7.$TRAVIS_BUILD_NUMBER-Linux +deploy: + - provider: releases + api_key: $GITHUB_API_KEY + file: AppChat-0.7.$TRAVIS_BUILD_NUMBER-Linux.tar + skip_cleanup: true on: - branch: master - -#before_deploy: -# - git config --local user.name "k-morozov" -# - git config --local user.email "morozov-kst@yandex.ru" -# - git tag 0.7.$TRAVIS_BUILD_NUMBER-Linux -#deploy: -# - provider: releases -# api_key: $GITHUB_API_KEY -# file: AppChat-0.7.$TRAVIS_BUILD_NUMBER-Linux.tar -# skip_cleanup: true -# on: -# branch: release + branch: release From 01cb5851ddad0afa6b19470027f75721ddccd9e3 Mon Sep 17 00:00:00 2001 From: k-morozov Date: Thu, 6 Aug 2020 09:04:06 +0300 Subject: [PATCH 14/17] fix travis --- .travis.yml | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index c8dd901..2e3cb60 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,26 +5,42 @@ sudo: required os: - linux -addons: - apt: - packages: + +matrix: + include: + # works on Precise and Trusty + - os: linux + addons: + apt: + sources: + - ubuntu-toolchain-r-test + packages: + - g++-7 - graphviz - doxygen - - libgtest-dev - sqlite3 libsqlite3-dev - libboost-test-dev - qt5-default + cache: + directories: + - $HOME/boost_1_67_0/boost + - $HOME/boost_1_67_0/stage/lib + env: + - MATRIX_EVAL="CC=gcc-7 && CXX=g++-7" + - BUILD_DIR=build + - PROJECT_NAME=AppChat -before_script: +before_install: + - eval "${MATRIX_EVAL}" - if [ $TRAVIS_OS_NAME == linux ]; then sudo ./scripts/install_env.sh; fi script: - - mkdir ${TRAVIS_BUILD_DIR}/build - - cd ${TRAVIS_BUILD_DIR}/build + - mkdir ${BUILD_DIR}/build + - cd ${BUILD_DIR}/build - cmake .. - cmake --build . - cmake --build . --target test - cmake --build . --target package - - cd ${TRAVIS_BUILD_DIR}/build/bin + - cd ${TRAVIS_BUILD_DIR}/${BUILD_DIR}/bin - tar -cf AppChat-0.7.$TRAVIS_BUILD_NUMBER-Linux.tar server client after_success: From 0ccaedb8a0f8972c63e1ed3b27615e6dc9325fda Mon Sep 17 00:00:00 2001 From: k-morozov Date: Thu, 6 Aug 2020 09:24:25 +0300 Subject: [PATCH 15/17] fix build dir --- .travis.yml | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2e3cb60..bd04728 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,6 @@ dist: bionic language: cpp compiler: gcc sudo: required - os: - linux @@ -21,10 +20,10 @@ matrix: - sqlite3 libsqlite3-dev - libboost-test-dev - qt5-default - cache: - directories: - - $HOME/boost_1_67_0/boost - - $HOME/boost_1_67_0/stage/lib +# cache: +# directories: +# - $HOME/boost_1_67_0/boost +# - $HOME/boost_1_67_0/stage/lib env: - MATRIX_EVAL="CC=gcc-7 && CXX=g++-7" - BUILD_DIR=build @@ -32,19 +31,22 @@ matrix: before_install: - eval "${MATRIX_EVAL}" + +before_script: - if [ $TRAVIS_OS_NAME == linux ]; then sudo ./scripts/install_env.sh; fi + script: - - mkdir ${BUILD_DIR}/build - - cd ${BUILD_DIR}/build + - mkdir ${BUILD_DIR} + - cd ${BUILD_DIR} - cmake .. - cmake --build . - cmake --build . --target test - cmake --build . --target package - - cd ${TRAVIS_BUILD_DIR}/${BUILD_DIR}/bin - - tar -cf AppChat-0.7.$TRAVIS_BUILD_NUMBER-Linux.tar server client after_success: - - >- +- cd ${TRAVIS_BUILD_DIR}/${BUILD_DIR}/bin +- tar -cf AppChat-0.7.$TRAVIS_BUILD_NUMBER-Linux.tar server client +- >- if [[ "$TRAVIS_BRANCH" = "master" && -n "$TRAVIS_BUILD_DOCS" ]] ; then cd $TRAVIS_BUILD_DIR echo 'Generating Doxygen code documentation...' From 1e84c2d6f06d284d2c24d48f91021fd9cf841ef0 Mon Sep 17 00:00:00 2001 From: k-morozov Date: Thu, 6 Aug 2020 10:38:45 +0300 Subject: [PATCH 16/17] fix dox --- CMakeLists.txt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index d968bf7..003aff0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -51,3 +51,13 @@ set(CPACK_PACKAGE_CONTACT scfocus@yandex.ru) set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON) include(CPack) + +find_package(Doxygen) +if (DOXYGEN_FOUND) + set(DOXYFILE ${CMAKE_SOURCE_DIR}/Doxyfile) + add_custom_target(doc_doxygen ALL + COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYFILE} + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + COMMENT "Generating API documentation with Doxygen") + unset(DOXYFILE) +endif() From 3a44214d611acc62a9e6b3f3a0597c4b45c02572 Mon Sep 17 00:00:00 2001 From: k-morozov Date: Thu, 6 Aug 2020 10:54:48 +0300 Subject: [PATCH 17/17] fix path for bintray --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index bd04728..7369ecc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -56,7 +56,7 @@ after_success: if [[ "$TRAVIS_BRANCH" = "master" ]] ; then curl -T ${TRAVIS_BUILD_DIR}/build/bin/AppChat-0.7.$TRAVIS_BUILD_NUMBER-Linux.tar -uk-morozov:$BINTRAY_API_KEY https://api.bintray.com/content/k-morozov/AppChat/Download/0.7.$TRAVIS_BUILD_NUMBER/AppChat-0.7.$TRAVIS_BUILD_NUMBER-Linux.tar - curl -T ${TRAVIS_BUILD_DIR}/${BUILD_DIR}/${PROJECT_NAME}-0.0.$TRAVIS_BUILD_NUMBER-Linux.deb -uk-morozov:$BINTRAY_API_KEY "https://api.bintray.com/content/k-morozov/AppChat/Install-Linux/1/${PROJECT_NAME}-0.0.$TRAVIS_BUILD_NUMBER-Linux.deb;deb_distribution=trusty;deb_component=main;deb_architecture=amd64;publish=1" + curl -T ${TRAVIS_BUILD_DIR}/${BUILD_DIR}/${PROJECT_NAME}-0.0.$TRAVIS_BUILD_NUMBER-Linux.deb -uk-morozov:$BINTRAY_API_KEY "https://api.bintray.com/content/k-morozov/AppChat/Install-Linux/0.7.$TRAVIS_BUILD_NUMBER/${PROJECT_NAME}-0.0.$TRAVIS_BUILD_NUMBER-Linux.deb;deb_distribution=bionic;deb_component=main;deb_architecture=amd64;publish=1" fi deploy: