From 8a99cf1bf493b74ed713feff68b2ce0347ef5697 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E9=98=B3?= <657837019@qq.com> Date: Thu, 18 Jun 2026 21:27:36 +0800 Subject: [PATCH] Add native and RISC-V unit test coverage --- .github/workflows/ci.yml | 48 ++++++++++++++++++++++++++++++++++++++++ README.md | 7 +++--- 2 files changed, 52 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..10a59a07 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,48 @@ +name: CI + +on: + push: + pull_request: + +jobs: + native-linux-unittests: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Install native toolchain + run: | + sudo apt-get update + sudo apt-get install -y g++ + + - name: Build unit tests + working-directory: build + run: | + mkdir -p bin + g++ -c -std=c++11 -Wall -pedantic-errors -Wpedantic -Wconversion -DMOODYCAMEL_STATIC -pthread -g -O0 -fno-elide-constructors -fno-exceptions ../c_api/blockingconcurrentqueue.cpp ../c_api/concurrentqueue.cpp + g++ -std=c++11 -Wall -pedantic-errors -Wpedantic -Wconversion -DMOODYCAMEL_STATIC -pthread -g -O0 -fno-elide-constructors ../tests/common/simplethread.cpp ../tests/common/systemtime.cpp ../tests/unittests/unittests.cpp blockingconcurrentqueue.o concurrentqueue.o -o bin/unittests -lrt + + - name: Run unit tests + working-directory: build + run: ./bin/unittests --disable-prompt --iterations 1 + + riscv64-linux-unittests: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Install RISC-V toolchain and QEMU + run: | + sudo apt-get update + sudo apt-get install -y g++-riscv64-linux-gnu qemu-user-static + + - name: Build RISC-V unit tests + working-directory: build + run: | + mkdir -p bin-riscv + riscv64-linux-gnu-g++ -c -std=c++11 -Wall -pedantic-errors -Wpedantic -Wconversion -DMOODYCAMEL_STATIC -pthread -g -O0 -fno-elide-constructors -fno-exceptions ../c_api/blockingconcurrentqueue.cpp ../c_api/concurrentqueue.cpp + riscv64-linux-gnu-g++ -std=c++11 -Wall -pedantic-errors -Wpedantic -Wconversion -DMOODYCAMEL_STATIC -pthread -g -O0 -fno-elide-constructors ../tests/common/simplethread.cpp ../tests/common/systemtime.cpp ../tests/unittests/unittests.cpp blockingconcurrentqueue.o concurrentqueue.o -o bin-riscv/unittests-riscv64 -lrt + + - name: Run RISC-V unit tests under QEMU + working-directory: build + run: qemu-riscv64-static -L /usr/riscv64-linux-gnu ./bin-riscv/unittests-riscv64 --disable-prompt --iterations 1 diff --git a/README.md b/README.md index c444a36c..44d6bb5e 100644 --- a/README.md +++ b/README.md @@ -454,9 +454,10 @@ I've written quite a few unit tests as well as a randomized long-running fuzz te core queue algorithm through the [CDSChecker][cdschecker] C++11 memory model model checker. Some of the inner algorithms were tested separately using the [Relacy][relacy] model checker, and full integration tests were also performed with Relacy. -I've tested -on Linux (Fedora 19) and Windows (7), but only on x86 processors so far (Intel and AMD). The code was -written to be platform-independent, however, and should work across all processors and OSes. +I've tested +on Linux (Fedora 19) and Windows (7) on x86 processors (Intel and AMD), and the GitHub Actions CI now also +cross-compiles and runs the unit tests for `riscv64` Linux under QEMU. The code was written to be +platform-independent, and should work across all processors and OSes. Due to the complexity of the implementation and the difficult-to-test nature of lock-free code in general, there may still be bugs. If anyone is seeing buggy behaviour, I'd like to hear about it! (Especially if