|
| 1 | +# Running Tests |
| 2 | + |
| 3 | +This repository has a GoogleTest-based suite (see `tests/`). The tests target the CMake option `BUILD_TESTING=ON` and require the same dependencies as the main build plus GoogleTest (fetched automatically via `FetchContent`). |
| 4 | + |
| 5 | +## Prerequisites |
| 6 | + |
| 7 | +- CMake ≥ 3.20 |
| 8 | +- A C++ compiler (GCC/Clang) with C++17 or later |
| 9 | +- Ninja build system |
| 10 | +- Python 3 with `conan` installed. A virtual environment is recommended: |
| 11 | + |
| 12 | +```bash |
| 13 | +python3 -m venv .venv |
| 14 | +source .venv/bin/activate |
| 15 | +pip install conan |
| 16 | +``` |
| 17 | + |
| 18 | +If Conan cannot supply SystemC/CCI on your host, use the Docker flow below or point CMake at a local SystemC install via `SYSTEMC_HOME`. |
| 19 | + |
| 20 | +## Configure and Build |
| 21 | + |
| 22 | +```bash |
| 23 | +cmake --preset Debug -B build -DBUILD_TESTING=ON -DCMAKE_CXX_STANDARD=20 |
| 24 | +cmake --build build -j |
| 25 | +``` |
| 26 | + |
| 27 | +## Run Tests |
| 28 | + |
| 29 | +```bash |
| 30 | +cd build |
| 31 | + |
| 32 | +# unit tests |
| 33 | +ctest --output-on-failure |
| 34 | + |
| 35 | +# transaction recording example binary |
| 36 | +./examples/transaction_recording/transaction_recording |
| 37 | +``` |
| 38 | + |
| 39 | +## Run Tests in Docker (Linux toolchain) |
| 40 | + |
| 41 | +If your host setup cannot fetch SystemC via Conan, use the provided Dockerfile: |
| 42 | + |
| 43 | +```bash |
| 44 | +# from repo root |
| 45 | +docker build -f Dockerfile.test -t scc-tests . |
| 46 | +docker run --rm -v "$PWD":/work -w /work scc-tests /bin/bash -lc "\ |
| 47 | + cmake --preset Debug -B build -DBUILD_TESTING=ON -DCMAKE_CXX_STANDARD=20 && \ |
| 48 | + cmake --build build -j && \ |
| 49 | + cd build && ctest --output-on-failure && \ |
| 50 | + ./examples/transaction_recording/transaction_recording" |
| 51 | +``` |
| 52 | + |
| 53 | +## CI |
| 54 | + |
| 55 | +### Unit Tests |
| 56 | +Tests run in `.github/workflows/ci-unit-tests.yml`, which configures with `-DBUILD_TESTING=ON`, builds, and runs `ctest` with C++20. |
| 57 | + |
| 58 | +### C++ Standards Compliance |
| 59 | +The repository is tested for compliance with multiple C++ standards in `.github/workflows/ci-compliance.yml`. This workflow: |
| 60 | +- Tests against C++11, C++14, C++17, and C++20 |
| 61 | +- Builds the project with each standard |
| 62 | +- Runs the `transaction_recording` example to verify basic functionality |
| 63 | + |
| 64 | +To test a specific C++ standard locally: |
| 65 | + |
| 66 | +```bash |
| 67 | +cmake --preset Debug -B build -DCMAKE_CXX_STANDARD=<11|14|17|20> |
| 68 | +cmake --build build -j |
| 69 | +./build/examples/transaction_recording/transaction_recording |
| 70 | +``` |
0 commit comments