Skip to content

Contributing: Running Tests

Zachary Vincze edited this page May 27, 2026 · 1 revision

Running Tests

rocCV has two parallel test suites: C++ for the core library, Python for rocpycv bindings. Build with -DTESTS=ON first (see Contributing: Building).

C++ Tests

From the build/ directory:

ctest                          # run all
ctest -VV                      # verbose output
ctest -R test_op_resize        # filter by name (regex)
ctest -j$(nproc)               # parallel

Run a single test binary directly for fastest iteration:

./bin/tests/operators/test_op_resize

Each operator has its own executable under build/bin/tests/.

Python Tests

Point PYTHONPATH at the build's lib directory, then use pytest:

export PYTHONPATH=$PWD/lib:$PYTHONPATH

python3 -m pytest tests/roccv/python/                    # all
python3 -m pytest tests/roccv/python/test_op_resize.py   # one file
python3 -m pytest -v -k "resize"                         # filter by keyword

The C++ Test Framework

rocCV uses a custom test framework — not Google Test or Catch2. Each test binary has its own main(). Two macros do the work:

EXPECT_TEST_STATUS(call, expected_status);  // assert a call returns expected eTestStatusType
EXPECT_EXCEPTION(call, expected_status);    // assert a call throws with expected eStatusType

Both are defined in tests/roccv/cpp/include/test_helpers.hpp.

Golden-Model Pattern

The standard correctness check: run the operator on CPU (eDeviceType::CPU), run it on GPU (eDeviceType::GPU), compare results.

op(stream, input, gpu_output, ..., eDeviceType::GPU);
op(stream, input, cpu_output, ..., eDeviceType::CPU);
EXPECT_TEST_STATUS(compareArray(gpu_output, cpu_output, threshold), TEST_SUCCESS);

Helpers like compareArray and compareImage live in test_helpers.hpp.

Writing a New Test

  • C++: add tests/roccv/cpp/src/tests/operators/test_op_<name>.cpp — CMake GLOB_RECURSE picks it up automatically.
  • Python: add tests/roccv/python/test_op_<name>.py — pytest discovers it.

The Contributing: Writing a New Operator page covers both end-to-end.

Next Steps

Clone this wiki locally