[Spice-devel] [PATCH spice-streaming-agent 0/4] first unit test and options parsing improvements

Frediano Ziglio fziglio at redhat.com
Thu Feb 1 10:42:20 UTC 2018


> 
> This series introduces a C++ unit test framework called Catch to the
> codebase, adds a simple unit test for the options parsing for the mjpeg
> plugin and improves on the option parsing code.
> 
> It depends on the header split-off from the previous patch set ([PATCH
> spice-streaming-agent 1/2] mjpeg plugin: split off the declaration into
> a header).
> 
> The unit test framework choice is a subject to discussion. Note Catch is
> quite new and it only has a package in Fedora 27.
> 
> 1/4 is there because otherwise I'd have to flip AC_LANG(C++) on and off
> later on.
> 

In theory should work correctly.
In practise there are some autoconf macros here and there that
could have some issues, I would use

AC_LANG_PUSH([C++])
<your code>
AC_LANG_POP([C++])

> The tests in 2/4 do not pass until 4/4, TDD excersize :)
> 

Usually we prefer test after the fix patch. This makes git bisect run scripts
easier to code if they include a "make check".

I usually develop like test first and revert+check again before sending
to ML.

> 3/4 is using BDD-style [1] test structure which I quite like, I wrote
> the tests in two steps so I'm including the patch for comparison.
> 
> Cheers,
> Lukas
> 
> [1] https://en.wikipedia.org/wiki/Behavior-driven_development
> 
> Lukáš Hrázký (4):
>   configure.ac: remove header check for stream-device.h
>   mjpeg-fallback: unittest for the options parsing
>   mjpeg-fallback-test: use BDD structure for test cases
>   mjpeg-fallback: a more C++ way of handling options
> 
>  configure.ac                          |  7 ++---
>  src/mjpeg-fallback.cpp                | 47 +++++++++++++++-------------
>  src/mjpeg-fallback.hpp                |  1 +
>  src/unittests/Makefile.am             | 12 ++++++++
>  src/unittests/test-mjpeg-fallback.cpp | 58
>  +++++++++++++++++++++++++++++++++++
>  5 files changed, 100 insertions(+), 25 deletions(-)
>  create mode 100644 src/unittests/test-mjpeg-fallback.cpp
> 

Frediano


More information about the Spice-devel mailing list