diff --git a/.github/workflows/server_workflows.yml b/.github/workflows/server_workflows.yml index 929bade..bd915a0 100644 --- a/.github/workflows/server_workflows.yml +++ b/.github/workflows/server_workflows.yml @@ -24,20 +24,20 @@ jobs: conan_audit_token: ${{ secrets.CONAN_AUDIT_TOKEN }} - name: Install Conan dependencies - run: conan build . --build=missing + run: conan build . --build=missing -s build_type=Debug - name: Run GTest - run: ctest --test-dir build/Release + run: ctest --test-dir build/Debug - name: Coverage shell: bash run: | - cd build/Release + cd build/Debug make coverage - name: Report Code Coverage uses: zgosalvez/github-actions-report-lcov@v4 with: - coverage-files: build/Release/CMakeFiles/server_library.dir/src/coverage.info + coverage-files: build/Debug/CMakeFiles/server_library.dir/src/coverage.info artifact-name: code-coverage-report github-token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 6107877..1775616 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,6 +6,12 @@ set(TEST_TARGET "server_tests_bin") set(TARGET "server_impl_bin") set(CMAKE_EXPORT_COMPILE_COMMANDS ON) +# Override Debug flags +set(CMAKE_CXX_FLAGS_DEBUG "-g -O0 --coverage") +set(CMAKE_C_FLAGS_DEBUG "-g -O0 --coverage") +set(CMAKE_EXE_LINKER_FLAGS_DEBUG "--coverage") +set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "--coverage") + find_package(GTest CONFIG REQUIRED) find_package(Threads REQUIRED) @@ -24,15 +30,14 @@ add_library(${LIBRARY} ) target_include_directories(${LIBRARY} PUBLIC include) target_compile_features(${LIBRARY} PRIVATE cxx_std_17) -target_compile_options(${LIBRARY} PRIVATE -O0 -g --coverage) target_link_libraries(${LIBRARY} PRIVATE Threads::Threads) # unit tests executable enable_testing() add_executable(${TEST_TARGET} - test/HttpServerTest.cpp - test/HttpParserTest.cpp + test/HttpServerTest.cpp + test/HttpParserTest.cpp ) target_link_libraries(${TEST_TARGET} PRIVATE ${LIBRARY} GTest::gtest_main @@ -40,18 +45,16 @@ target_link_libraries(${TEST_TARGET} include(GoogleTest) gtest_discover_tests(${TEST_TARGET}) -target_compile_options(${TEST_TARGET} PRIVATE -g -O0 -g --coverage) -target_link_options(${TEST_TARGET} PRIVATE -O0 -g --coverage) # server implementation executable add_executable(${TARGET} src/main.cpp ) -target_compile_options(${TARGET} PRIVATE -g -O0 -g --coverage) target_link_options(${TARGET} PRIVATE -O0 -g --coverage) target_link_libraries(${TARGET} PRIVATE ${LIBRARY}) + # coverage target # find required tools find_program(LCOV lcov REQUIRED) diff --git a/Dockerfile b/Dockerfile index 104534a..83d9f3f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -32,7 +32,7 @@ WORKDIR /app COPY --exclude=build/ . . # Build with Conan -RUN conan build . --build=missing +RUN conan build . --build=missing -s build_type=Release CMD ["/bin/bash"] \ No newline at end of file diff --git a/README.md b/README.md index 92f5d4a..9e4f37e 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,7 @@ A modern C++ HTTP server implementation with routing, testing, and CI-driven qua * [Using Nix](#using-nix) * [Building the Source Code](#building-the-source-code) * [Building for Release Mode](#building-for-release-mode) + * [Building for Debug Mode](#building-for-debug-mode) * [Running the Server](#running-the-server) * [Running the Tests](#running-the-tests) * [Code Coverage](#code-coverage) @@ -77,7 +78,7 @@ The cpp_http_server is ~1.562x faster in throughput or about 56.2% higher reques Calculation: 27,366.734925 RPS / 17,524.167725 RPS = ~1.5612 | Metric | **C++ Server** | **Node + Express** | -| ------------------ | ----------------- | ------------------ | +|--------------------|-------------------|--------------------| | Target rate | 30,000.00 RPS | 30,000.00 RPS | | Actual RPS | 27,366.734925 RPS | 17,524.167725 RPS | | Total requests | 280,791 | 176,924 | @@ -171,7 +172,13 @@ This project uses **Conan** for dependency management and **CMake** for builds. ### Building for Release Mode ```bash -conan build . --build=missing +conan build . --build=missing -s build_type=Release +``` + +### Building for Debug Mode + +```bash +conan build . --build=missing -s build_type=Debug ``` --- @@ -183,6 +190,9 @@ Command to run the HTTP server implementation example: ```bash # in release mode ./build/Release/server_impl_bin + +# in debug mode +./build/Debug/server_impl_bin ``` --- @@ -193,7 +203,7 @@ Command to execute the automated test suite: ```bash # run tests -./build/Release/server_tests_bin +./build/Debug/server_tests_bin ``` --- @@ -205,14 +215,14 @@ Coverage reports are generated using **lcov**. ### Generate Coverage Reports ```bash -make -C build/Release coverage +make -C build/Debug coverage ``` ### Open the Coverage Report ```bash # specific to Linux -xdg-open build/Release/CMakeFiles/server_library.dir/src/out/index.html +xdg-open build/Debug/CMakeFiles/server_library.dir/src/out/index.html ``` ---