[sheepdog] [PATCH v1] unittest: fix coredump bug for unit-test

Robin Dong robin.k.dong at gmail.com
Mon Jun 30 12:31:20 CEST 2014


From: Robin Dong <sanbai at taobao.com>

Test case in test_hash.c will call create_vdisks() which need to
check sys->cinfo.flags, but variable 'sys' is uninitialized in
unit-test environment. Therefore we need to init 'sys' before
calling create_vdisks().

Reported-by: Ruoyu <liangry at ucweb.com>
Signed-off-by: Robin Dong <sanbai at taobao.com>
---
 tests/unit/sheep/test_hash.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tests/unit/sheep/test_hash.c b/tests/unit/sheep/test_hash.c
index 26386b9..7779288 100644
--- a/tests/unit/sheep/test_hash.c
+++ b/tests/unit/sheep/test_hash.c
@@ -605,7 +605,9 @@ static Suite *test_suite(void)
 
 int main(void)
 {
+	struct system_info __sys;
 	int number_failed;
+	sys = &__sys;
 	Suite *s = test_suite();
 	SRunner *sr = srunner_create(s);
 	srunner_run_all(sr, CK_NORMAL);
-- 
1.7.12.4




More information about the sheepdog mailing list