[sheepdog] [PATCH v3 0/3] Introducing unittest framework to sheepdog
Liu Yuan
namei.unix at gmail.com
Sat Jun 8 12:21:33 CEST 2013
On 06/08/2013 06:17 PM, Kai Zhang wrote:
> v3:
> - fixed compile error on ubuntu 12.04
> - fixed compile error by recent applied patches
>
> v2:
> - fixed compile error
> - add --enable-unittest to ./configure options
> don't check "check" if run ./configure without --enable-unittest or --enable-coverage
> - update usage
>
> As we all known, unittest is quite important to any project which is aimed to be used in production environment.
>
> This series of patches is to introduce 'check', a popular unittest framework for C language.
>
> These patches are quite initial implemented.
> But it still shows the abilities of:
> - adding more unittests easily
> - runing unittests selectively
> - showing code coverage after running unittest
> - generating html report by lcov and genhtml
> - integrating with other CI (continuous integration) systems like Jenkins
>
> In addition, we can also benifit from unittest in the following ways:
> - help us write more testable code
> - improve the robustness of sheepdog
> - new contributors can be quickly involved by writing unittest code
>
> Usage:
> - $make check # run all unittests
> - $make check CK_RUN_SUITE=xxx_suite CK_RUN_CASE=xxx_case # run selective unittest
> - $make coverage # generate coverage report in html to directory 'coverage'
>
> There are also many things that we can improve:
> - more tests of cause
> - more functional mock programs (inspired by gmock)
>
> Another thing that I wanna share with you is that, current unittests in implemented under 'check', a C unittest framework.
> There is another test framework, google testing framework (including gtest and gmock), which is more popular and powerful.
> However, they are written in C++.
> I have tried to use gtest and gmock to write unittests in C++, but failed to compile with our code.
> We need to refine our code to be compatible with C++ compiler if we wanna adopt gtest and gmock.
>
> Kai Zhang (3):
> build: add 'make coverage' target
> unittest: add unittest for collie/common.c
> unittest: add unittest for sheep/vdi.c
>
> .gitignore | 6 +++++
> Makefile.am | 21 ++++++++++++++++++++
> collie/Makefile.am | 3 ++
> configure.ac | 16 ++++++++++++++-
> sheep/Makefile.am | 3 ++
> unittest/Makefile.am | 3 ++
> unittest/collie/Makefile.am | 22 +++++++++++++++++++++
> unittest/collie/mock_collie.c | 18 +++++++++++++++++
> unittest/collie/test_common.c | 43 +++++++++++++++++++++++++++++++++++++++++
> unittest/sheep/Makefile.am | 21 ++++++++++++++++++++
> unittest/sheep/mock_request.c | 11 ++++++++++
> unittest/sheep/mock_sheep.c | 3 ++
> unittest/sheep/mock_store.c | 24 ++++++++++++++++++++++
> unittest/sheep/test_vdi.c | 38 ++++++++++++++++++++++++++++++++++++
> 14 files changed, 231 insertions(+), 1 deletions(-)
> create mode 100644 unittest/Makefile.am
> create mode 100644 unittest/collie/Makefile.am
> create mode 100644 unittest/collie/mock_collie.c
> create mode 100644 unittest/collie/test_common.c
> create mode 100644 unittest/sheep/Makefile.am
> create mode 100644 unittest/sheep/mock_request.c
> create mode 100644 unittest/sheep/mock_sheep.c
> create mode 100644 unittest/sheep/mock_store.c
> create mode 100644 unittest/sheep/test_vdi.c
>
I am wondering if we should put unittest in tests/ and put previous
tests/* into tests/functional_test/*
Thanks,
Yuan
More information about the sheepdog
mailing list