diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..f072b9f --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,35 @@ +name: C++ + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + unit-tests: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install -y cmake g++ + + - name: Configure + run: | + cmake -S . -B build \ + -DNSQUEUE_BUILD_TESTS=ON \ + -DNSQUEUE_BUILD_BENCHMARKS=OFF \ + -DCMAKE_BUILD_TYPE=Release + + - name: Build + run: | + cmake --build build --config Release + + - name: Run unit tests + run: | + ctest --test-dir build -L unit --output-on-failure diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 1c40323..a2ce6d0 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -8,15 +8,31 @@ FetchContent_Declare( FetchContent_MakeAvailable(Catch2) -add_executable(spsc_test +add_executable(spsc_unit_tests spsc_test.cc ) -target_link_libraries(spsc_test - PRIVATE - nsqueue - Catch2::Catch2WithMain +target_link_libraries(spsc_unit_tests + PRIVATE nsqueue Catch2::Catch2WithMain ) include(Catch) -catch_discover_tests(spsc_test) +catch_discover_tests( + spsc_unit_tests + TEST_SPEC "[unit]" + PROPERTIES LABELS unit +) + +add_executable(spsc_stress_tests + spsc_test.cc +) + +target_link_libraries(spsc_stress_tests + PRIVATE nsqueue Catch2::Catch2WithMain +) + +catch_discover_tests( + spsc_stress_tests + TEST_SPEC "[stress]" + PROPERTIES LABELS stress +) diff --git a/tests/spsc_test.cc b/tests/spsc_test.cc index 0e199a0..3de3143 100644 --- a/tests/spsc_test.cc +++ b/tests/spsc_test.cc @@ -113,7 +113,7 @@ TEST_CASE("wrap around", "[unit]"){ REQUIRE(q.empty()); }; -TEST_CASE("stress", "[unit]"){ +TEST_CASE("stress", "[stress]"){ constexpr int N = 200'000; nsqueue::spsc_queue q;