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

Liu Yuan namei.unix at gmail.com
Wed Apr 16 07:58:07 CEST 2014


On Wed, Apr 16, 2014 at 11:58:01AM +0800, Ruoyu wrote:
> 
> On 2014年04月16日 11:02, Liu Yuan wrote:
> >On Tue, Apr 15, 2014 at 03:45:30PM +0800, Ruoyu wrote:
> >>On 2014年04月15日 14:46, Liu Yuan wrote:
> >>>On Tue, Apr 15, 2014 at 11:37:27AM +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/test_hash.c | 94 +++++++++++++++++++++++++++++++++++++++++++-
> >>>Why we need to hard-wire some codes from md.c instead of simply #include "md." as
> >>>before?
> >>I think it is better to expose these interfaces: create_vdisks,
> >>remove_vdisks and vdisk_cmp. The patch is ugly, but at least it is
> >>runnable.
> >create_vdisks and remove_vdisks and so on are internal functions that is subject
> >to changes. If we modify some of them in md.c, we have to modify test_hash.c,
> >we should avoid it. This is why we should simply include md.c.
> Please try on current master branch: ./configure --enable-unittest
> && make && make check
> 
> Error message is as below. I think including md.c is not a good
> idea. How to avoid it?
> 
> test_vdi.c: In function ‘test_vdi’:
> test_vdi.c:20:2: error: too few arguments to function ‘add_vdi_state’
>   add_vdi_state(1, 1, true);
>   ^

append 0 as 4th parameter.

> In file included from test_vdi.c:16:0:
> ../../../sheep/sheep_priv.h:303:5: note: declared here
>  int add_vdi_state(uint32_t vid, int nr_copies, bool snapshot, uint8_t);
>      ^
> test_vdi.c:21:2: error: too few arguments to function ‘add_vdi_state’
>   add_vdi_state(2, 1, true);
>   ^
> In file included from test_vdi.c:16:0:
> ../../../sheep/sheep_priv.h:303:5: note: declared here
>  int add_vdi_state(uint32_t vid, int nr_copies, bool snapshot, uint8_t);
>      ^
> test_vdi.c:22:2: error: too few arguments to function ‘add_vdi_state’
>   add_vdi_state(3, 2, false);
>   ^
> In file included from test_vdi.c:16:0:
> ../../../sheep/sheep_priv.h:303:5: note: declared here
>  int add_vdi_state(uint32_t vid, int nr_copies, bool snapshot, uint8_t);
>      ^
> 
> test_hash.o: In function `get_total_object_size':
> sheep/md.c:156: undefined reference to `get_store_objsize'
> test_hash.o: In function `get_old_new_path':
> sheep/md.c:557: undefined reference to `is_erasure_oid'
> sheep/md.c:568: undefined reference to `is_erasure_oid'
> test_hash.o: In function `md_move_object':
> sheep/md.c:596: undefined reference to `get_store_objsize'
> test_hash.o: In function `md_exist':
> sheep/md.c:670: undefined reference to `get_store_path'
> test_hash.o: In function `md_get_stale_path':
> sheep/md.c:690: undefined reference to `is_erasure_oid'

You can simply mock these functions as in mock_xxx.c...

Thanks
Yuan



More information about the sheepdog mailing list