From 18f41e12bcc413b74003b5300bcef069837d02c5 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Wed, 21 Dec 2016 16:38:16 -0800 Subject: [PATCH] eina: try slight improvement of eina tests suite. Still need to go through individual test to improve them. --- src/Makefile_Eina.am | 2 +- src/tests/eina/eina_suite.c | 6 ++ src/tests/eina/eina_suite.h | 1 - src/tests/eina/eina_suite.x | 40 +++++++++++++ src/tests/eina/eina_test_stringshare.c | 103 +++++++++------------------------ 5 files changed, 75 insertions(+), 77 deletions(-) create mode 100644 src/tests/eina/eina_suite.x diff --git a/src/Makefile_Eina.am b/src/Makefile_Eina.am index 5ac7b15..1c9540b 100644 --- a/src/Makefile_Eina.am +++ b/src/Makefile_Eina.am @@ -300,7 +300,6 @@ tests/eina/eina_suite.c \ tests/eina/eina_suite.h \ tests/eina/eina_test_abi.c \ tests/eina/eina_test_fp.c \ -tests/eina/eina_test_stringshare.c \ tests/eina/eina_test_ustringshare.c \ tests/eina/eina_test_ustr.c \ tests/eina/eina_test_binshare.c \ @@ -384,5 +383,6 @@ lib/eina/eina_strbuf_template_c.x \ lib/eina/eina_binbuf_template_c.x \ lib/eina/eina_inline_private.h \ tests/eina/sample.gpx \ +tests/eina/eina_suite.x \ lib/eina/eina_config.h.in \ $(bin_SCRIPTS) diff --git a/src/tests/eina/eina_suite.c b/src/tests/eina/eina_suite.c index f9bbbd8..24719fe 100644 --- a/src/tests/eina/eina_suite.c +++ b/src/tests/eina/eina_suite.c @@ -20,9 +20,15 @@ # include "config.h" #endif +#include +#include +#include +#include + #include #include "eina_suite.h" +#include "eina_suite.x" #include "../efl_check.h" static const Efl_Test_Case etc[] = { diff --git a/src/tests/eina/eina_suite.h b/src/tests/eina/eina_suite.h index 3bda471..6f46580 100644 --- a/src/tests/eina/eina_suite.h +++ b/src/tests/eina/eina_suite.h @@ -21,7 +21,6 @@ #include -void eina_test_stringshare(TCase *tc); void eina_test_ustringshare(TCase *tc); void eina_test_binshare(TCase *tc); void eina_test_inarray(TCase *tc); diff --git a/src/tests/eina/eina_suite.x b/src/tests/eina/eina_suite.x new file mode 100644 index 0000000..4c9274e --- /dev/null +++ b/src/tests/eina/eina_suite.x @@ -0,0 +1,40 @@ +#ifndef EINA_SUITE_X +#define EINA_SUITE_X + +#define EINA_TEST_START(Func) \ + START_TEST(Func) \ + { \ + eina_init(); \ + do \ + { + + +#define EINA_TEST_END \ + } while(0); \ + eina_shutdown(); \ + } \ + END_TEST + +#define EINA_TEST_CODE + +#include "eina_test_stringshare.c" + +#undef EINA_TEST_START +#undef EINA_TEST_END +#undef EINA_TEST_CODE + +#define EINA_TEST_START(Func) \ + tcase_add_test(tc, Func); \ + while (0) \ + { + +#define EINA_TEST_END \ + } + +static void +eina_test_stringshare(TCase *tc) +{ +#include "eina_test_stringshare.c" +} + +#endif diff --git a/src/tests/eina/eina_test_stringshare.c b/src/tests/eina/eina_test_stringshare.c index 0aa1beb..2f46ab7 100644 --- a/src/tests/eina/eina_test_stringshare.c +++ b/src/tests/eina/eina_test_stringshare.c @@ -16,30 +16,30 @@ * if not, see . */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include -#include -#include -#include +#define TEST0 "test/0" +#define TEST1 "test/1" -#include +#ifdef EINA_TEST_CODE -#include "eina_suite.h" +static const char* +my_vprintf(const char *fmt, ...) +{ + const char *ret; + va_list ap; + va_start(ap, fmt); + ret = eina_stringshare_vprintf(fmt, ap); + va_end(ap); + return ret; +} -#define TEST0 "test/0" -#define TEST1 "test/1" +#endif -START_TEST(eina_stringshare_simple) +EINA_TEST_START(eina_stringshare_simple) { const char *t0; const char *t1; Eina_Slice slice; - eina_init(); - t0 = eina_stringshare_add(TEST0); t1 = eina_stringshare_add(TEST1); @@ -61,19 +61,15 @@ START_TEST(eina_stringshare_simple) eina_stringshare_del(t0); eina_stringshare_del(t0); eina_stringshare_del(t1); - - eina_shutdown(); } -END_TEST +EINA_TEST_END -START_TEST(eina_stringshare_simple_refplace) +EINA_TEST_START(eina_stringshare_simple_refplace) { const char *t0; const char *t1; Eina_Slice slice; - eina_init(); - t0 = eina_stringshare_add(TEST0); t1 = eina_stringshare_add(TEST1); @@ -96,18 +92,14 @@ START_TEST(eina_stringshare_simple_refplace) eina_stringshare_del(t0); eina_stringshare_del(t1); - - eina_shutdown(); } -END_TEST +EINA_TEST_END -START_TEST(eina_stringshare_small) +EINA_TEST_START(eina_stringshare_small) { char buf[4]; int i; - eina_init(); - for (i = 0; i < 3; i++) { const char *t0, *t1; @@ -135,19 +127,15 @@ START_TEST(eina_stringshare_small) eina_stringshare_del(t0); eina_stringshare_del(t1); } - - eina_shutdown(); } -END_TEST +EINA_TEST_END -START_TEST(eina_stringshare_test_share) +EINA_TEST_START(eina_stringshare_test_share) { const char *t0; const char *t1; - eina_init(); - t0 = eina_stringshare_add(TEST0); t1 = eina_stringshare_add(TEST0); @@ -160,18 +148,14 @@ START_TEST(eina_stringshare_test_share) eina_stringshare_del(t0); eina_stringshare_del(t1); - - eina_shutdown(); } -END_TEST +EINA_TEST_END -START_TEST(eina_stringshare_putstuff) +EINA_TEST_START(eina_stringshare_putstuff) { const char *tmp; int i; - eina_init(); - for (i = 10000; i > 0; --i) { char build[64] = "string_"; @@ -180,12 +164,10 @@ START_TEST(eina_stringshare_putstuff) tmp = eina_stringshare_add(build); fail_if(tmp != eina_stringshare_add(build)); } - - eina_shutdown(); } -END_TEST +EINA_TEST_END -START_TEST(eina_stringshare_collision) +EINA_TEST_START(eina_stringshare_collision) { Eina_Array *ea; char buffer[50]; @@ -193,8 +175,6 @@ START_TEST(eina_stringshare_collision) srand(time(NULL)); - eina_init(); - ea = eina_array_new(256); fail_if(!ea); @@ -227,24 +207,11 @@ START_TEST(eina_stringshare_collision) for (i = 0; i < 1000; ++i) eina_stringshare_del(eina_array_pop(ea)); - eina_shutdown(); - eina_array_free(ea); } -END_TEST - -static const char* -my_vprintf(const char *fmt, ...) -{ - const char *ret; - va_list ap; - va_start(ap, fmt); - ret = eina_stringshare_vprintf(fmt, ap); - va_end(ap); - return ret; -} +EINA_TEST_END -START_TEST(eina_stringshare_print) +EINA_TEST_START(eina_stringshare_print) { const char *t1; const char *t2; @@ -271,19 +238,5 @@ START_TEST(eina_stringshare_print) eina_stringshare_del(t1); eina_stringshare_del(t2); eina_stringshare_del(t3); - - -} -END_TEST - -void -eina_test_stringshare(TCase *tc) -{ - tcase_add_test(tc, eina_stringshare_simple); - tcase_add_test(tc, eina_stringshare_simple_refplace); - tcase_add_test(tc, eina_stringshare_small); - tcase_add_test(tc, eina_stringshare_test_share); - tcase_add_test(tc, eina_stringshare_collision); - tcase_add_test(tc, eina_stringshare_putstuff); - tcase_add_test(tc, eina_stringshare_print); } +EINA_TEST_END -- 2.7.4