[libcamera-devel] [RFC PATCH 0/2] Refactor lc-compliance using Catch2

Nícolas F. R. A. Prado nfraprado at collabora.com
Thu Apr 15 23:48:10 CEST 2021


This is just a prototype, not ready for merge, to refactor lc-compliance and
better structure the test cases. It uses Catch2 [1], as a single header file,
for the test framework.

Important limitations:
- Catch2 doesn't support skipping tests [2], so for this prototype I just put a
  warning and succeeded the test.
- Catch2 doesn't offer a TestSuite concept per se to group tests, instead tags
  may be added to test cases and a grouping can be achieved that way.

Catch2 offers its own command line parsing (which hasn't yet been wired up for
this patch), which can be used to select which test cases are run, either by
their names or tags.

One really interesting feature of Catch2 is that it uses a single assert macro,
and C++ operators can be used for comparison. This is what a failure would look
like:

	../src/lc-compliance/simple_capture.cpp:111: FAILED:
	  REQUIRE( captureCount_ == captureLimit_ )
	with expansion:
	  3 == 2
	with message:
	  Using 0 role, 3 requests, and 1 start cycles

[1] https://github.com/catchorg/Catch2
[2] https://github.com/catchorg/Catch2/issues/395

Nícolas F. R. A. Prado (2):
  lc-compliance: Make SimpleCapture::stop() idempotent
  lc-compliance: Refactor lc-compliance using Catch2

 src/lc-compliance/catch.hpp          | 17937 +++++++++++++++++++++++++
 src/lc-compliance/main.cpp           |    48 +-
 src/lc-compliance/simple_capture.cpp |    94 +-
 src/lc-compliance/simple_capture.h   |    10 +-
 src/lc-compliance/single_stream.cpp  |    92 +-
 5 files changed, 18017 insertions(+), 164 deletions(-)
 create mode 100644 src/lc-compliance/catch.hpp

-- 
2.31.1



More information about the libcamera-devel mailing list