From 13f644f78336c79850b332c35ad439fda8dac4fa Mon Sep 17 00:00:00 2001 From: Luis Pabon Date: Wed, 23 Apr 2014 16:18:57 -0400 Subject: build: Support for unit tests using Cmockery2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch will allow for developers to create unit tests for their code. Documentation has been added to the patch and is available here: doc/hacker-guide/en-US/markdown/unittest.md Also, unit tests are run when RPM is created. This patch is a replacement for http://review.gluster.org/#/c/7281 which removed unit test infrastucture from the repo due to multiple conflicts. Cmockery2 is now available in Fedora and EPEL, and soon to be available in Debian and Ubuntu. For all other operating systems, please install from the source: https://github.com/lpabon/cmockery2 BUG: 1067059 Change-Id: I1b36cb1f56fd10916f9bf535e8ad080a3358289f Signed-off-by: Luis Pabón Reviewed-on: http://review.gluster.org/7538 Tested-by: Gluster Build System Reviewed-by: Niels de Vos Reviewed-by: Vijay Bellur --- doc/hacker-guide/en-US/markdown/unittest.md | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'doc') diff --git a/doc/hacker-guide/en-US/markdown/unittest.md b/doc/hacker-guide/en-US/markdown/unittest.md index 73fe775d450..42dc210959e 100644 --- a/doc/hacker-guide/en-US/markdown/unittest.md +++ b/doc/hacker-guide/en-US/markdown/unittest.md @@ -193,11 +193,10 @@ Now you can add the following for each of the unit tests that you would like to ``` ### UNIT TEST xxx_unittest ### -xxx_unittest_CPPFLAGS = $(UNITTEST_CPPFLAGS) $(xxx_CPPFLAGS) +xxx_unittest_CPPFLAGS = $(xxx_CPPFLAGS) xxx_unittest_SOURCES = xxx.c \ unittest/xxx_unittest.c xxx_unittest_CFLAGS = $(UNITTEST_CFLAGS) -xxx_unittest_LDADD = $(UNITTEST_LDADD) xxx_unittest_LDFLAGS = $(UNITTEST_LDFLAGS) noinst_PROGRAMS += xxx_unittest TESTS += xxx_unittest @@ -214,11 +213,10 @@ You may see that the linker will complain about missing functions needed by the You can type `make` in the directory where the C file is located. Once you built it and there are no errors, you can execute the test either by directly executing the program (in our example above it is called `xxx_unittest` ), or by running `make check`. #### Debugging -Sometimes you may need to debug your unit test. To do that, you will have to point `gdb` to the actual binary which is located in the `.libs` subdirectory. For example, you can do the following from the root of the source tree to debug `mem_pool_unittest`: +Sometimes you may need to debug your unit test. To do that, you will have to point `gdb` to the binary which is located in the same directory as the source. For example, you can do the following from the root of the source tree to debug `mem_pool_unittest`: ``` -$ export LD_LIBRARY_PATH=cmockery2/.libs -$ gdb ./libglusterfs/src/.libs/mem_pool_unittest +$ gdb libglusterfs/src/mem_pool_unittest ``` -- cgit