[sheepdog] [PATCH v2] tests/unit: unit test failed because interfaces were changed.

Liu Yuan namei.unix at gmail.com
Wed Apr 16 10:22:20 CEST 2014


On Wed, Apr 16, 2014 at 03:52:24PM +0800, Ruoyu wrote:
> This patch only let 'make check' workable, does not add any cases.
> 
> Signed-off-by: Ruoyu <liangry at ucweb.com>
> ---
>  tests/unit/sheep/Makefile.am        |  3 ++-
>  tests/unit/sheep/mock_gateway.c     | 17 +++++++++++++++++
>  tests/unit/sheep/mock_plain_store.c | 18 ++++++++++++++++++
>  tests/unit/sheep/test_vdi.c         |  6 +++---
>  4 files changed, 40 insertions(+), 4 deletions(-)
>  create mode 100644 tests/unit/sheep/mock_gateway.c
>  create mode 100644 tests/unit/sheep/mock_plain_store.c
> 
> diff --git a/tests/unit/sheep/Makefile.am b/tests/unit/sheep/Makefile.am
> index 77e0a72..824bef6 100644
> --- a/tests/unit/sheep/Makefile.am
> +++ b/tests/unit/sheep/Makefile.am
> @@ -27,7 +27,8 @@ test_cluster_driver_CFLAGS	+= -DBUILD_ZOOKEEPER
>  LIBS += -lzookeeper_mt
>  endif
>  
> -test_hash_SOURCES	= test_hash.c mock_sheep.c mock_group.c
> +test_hash_SOURCES	= test_hash.c mock_sheep.c mock_group.c \
> +				mock_plain_store.c mock_gateway.c
>  
>  clean-local:
>  	rm -f ${check_PROGRAMS} *.o
> diff --git a/tests/unit/sheep/mock_gateway.c b/tests/unit/sheep/mock_gateway.c
> new file mode 100644
> index 0000000..586983a
> --- /dev/null
> +++ b/tests/unit/sheep/mock_gateway.c
> @@ -0,0 +1,17 @@
> +/*
> + * Copyright (C) 2013 Zelin.io
> + *
> + * Kai Zhang <kyle at zelin.io>
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License version
> + * 2 as published by the Free Software Foundation.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program. If not, see <http://www.gnu.org/licenses/>.
> + */
> +
> +#include "mock.h"
> +#include "sheep_priv.h"
> +
> +MOCK_METHOD(is_erasure_oid, bool, false, uint64_t oid)
> diff --git a/tests/unit/sheep/mock_plain_store.c b/tests/unit/sheep/mock_plain_store.c
> new file mode 100644
> index 0000000..3bf502a
> --- /dev/null
> +++ b/tests/unit/sheep/mock_plain_store.c
> @@ -0,0 +1,18 @@
> +/*
> + * Copyright (C) 2013 Zelin.io
> + *
> + * Kai Zhang <kyle at zelin.io>
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License version
> + * 2 as published by the Free Software Foundation.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program. If not, see <http://www.gnu.org/licenses/>.
> + */
> +
> +#include "mock.h"
> +#include "sheep_priv.h"
> +
> +MOCK_METHOD(get_store_objsize, size_t, SD_DATA_OBJ_SIZE, uint64_t oid)
> +MOCK_METHOD(get_store_path, int, 0, uint64_t oid, uint8_t ec_index, char *path)
> diff --git a/tests/unit/sheep/test_vdi.c b/tests/unit/sheep/test_vdi.c
> index f55dcf4..2f8946b 100644
> --- a/tests/unit/sheep/test_vdi.c
> +++ b/tests/unit/sheep/test_vdi.c
> @@ -17,9 +17,9 @@
>  
>  START_TEST(test_vdi)
>  {
> -	add_vdi_state(1, 1, true);
> -	add_vdi_state(2, 1, true);
> -	add_vdi_state(3, 2, false);
> +	add_vdi_state(1, 1, true, 0);
> +	add_vdi_state(2, 1, true, 0);
> +	add_vdi_state(3, 2, false, 0);
>  
>  	ck_assert_int_eq(get_vdi_copy_number(1), 1);
>  	ck_assert_int_eq(get_vdi_copy_number(2), 1);
> -- 
> 1.8.3.2
> 
> 
> -- 
> sheepdog mailing list
> sheepdog at lists.wpkg.org
> http://lists.wpkg.org/mailman/listinfo/sheepdog

Applied thanks. Now our unit tests are very primitive, I hope someone can put
effort on it to enhance test coverage and test something that is not easy to be
tested in our functinal tests.

Thanks
Yuan



More information about the sheepdog mailing list