Test rework #3: Ecore_Cxx
authorVincent Torri <vincent dot torri at gmail dot com>
Thu, 4 Feb 2016 13:17:31 +0000 (14:17 +0100)
committerTom Hacohen <tom@stosb.com>
Tue, 16 Feb 2016 12:41:06 +0000 (12:41 +0000)
src/Makefile_Ecore_Cxx.am
src/tests/ecore_cxx/ecore_cxx_suite.cc
src/tests/ecore_cxx/ecore_cxx_suite.h [new file with mode: 0644]
src/tests/ecore_cxx/ecore_cxx_test_safe_call.cc

index c0ec604..ef97d5f 100644 (file)
@@ -34,7 +34,8 @@ TESTS += tests/ecore_cxx/ecore_cxx_suite tests/ecore_cxx/cxx_compile_test
 
 tests_ecore_cxx_ecore_cxx_suite_SOURCES = \
 tests/ecore_cxx/ecore_cxx_suite.cc \
-tests/ecore_cxx/ecore_cxx_test_safe_call.cc
+tests/ecore_cxx/ecore_cxx_test_safe_call.cc \
+tests/ecore_cxx/ecore_cxx_suite.h
 
 tests_ecore_cxx_ecore_cxx_suite_CPPFLAGS = \
 -I$(top_builddir)/src/lib/efl \
index 4d2e721..33ed9b6 100644 (file)
 # include <config.h>
 #endif
 
-#include "Ecore.hh"
+#include "ecore_cxx_suite.h"
+#include "../efl_check.h"
 
-#include <cassert>
-#include <algorithm>
-
-#include <check.h>
-
-void ecore_test_safe_call(TCase* tc);
-
-typedef struct _Ecore_Test_Case Ecore_Test_Case;
-struct _Ecore_Test_Case
-{
-   const char *test_case;
-   void (*build)(TCase *tc);
-};
-
-static const Ecore_Test_Case etc[] = {
-   { "Safe_Call", ecore_test_safe_call },
+static const Efl_Test_Case etc[] = {
+   { "Safe_Call", ecore_cxx_test_safe_call },
    { NULL, NULL }
 };
 
-static void
-_list_tests(void)
+int
+main(int argc, char* argv[])
 {
-   const Ecore_Test_Case *itr = etc;
-      fputs("Available Test Cases:\n", stderr);
-   for (; itr->test_case; itr++)
-      fprintf(stderr, "\t%s\n", itr->test_case);
-}
+   int failed_count;
 
-static Eina_Bool
-_use_test(int argc, const char **argv, const char *test_case)
-{
-   if (argc < 1)
-      return 1;
-
-   for (; argc > 0; argc--, argv++)
-      if (strcmp(test_case, *argv) == 0)
-         return 1;
-
-   return 0;
-}
-
-Suite *
-ecore_build_suite(int argc, const char **argv)
-{
-   TCase *tc;
-   Suite *s;
-   int i;
-
-   s = suite_create("Ecore");
-
-   for (i = 0; etc[i].test_case; ++i)
-     {
-        if (!_use_test(argc, argv, etc[i].test_case))
-           continue;
-
-        tc = tcase_create(etc[i].test_case);
-#ifndef _WIN32
-        tcase_set_timeout(tc, 0);
-#endif
-
-        etc[i].build(tc);
-        suite_add_tcase(s, tc);
-     }
-
-   return s;
-}
-
-int main(int argc, char* argv[])
-{
-   Suite *s;
-   SRunner *sr;
-   int i, failed_count;
-
-   for (i = 1; i < argc; i++)
-      if ((strcmp(argv[i], "-h") == 0) ||
-          (strcmp(argv[i], "--help") == 0))
-        {
-           fprintf(stderr, "Usage:\n\t%s [test_case1 .. [test_caseN]]\n",
-                   argv[0]);
-           _list_tests();
-           return 0;
-        }
-      else if ((strcmp(argv[i], "-l") == 0) ||
-               (strcmp(argv[i], "--list") == 0))
-        {
-           _list_tests();
-           return 0;
-        }
+   if (!_efl_test_option_disp(argc, argv, etc))
+     return 0;
 
    putenv(const_cast<char*>("EFL_RUN_IN_TREE=1"));
 
-   s = ecore_build_suite(argc - 1, (const char **)argv + 1);
-   sr = srunner_create(s);
-
-   srunner_set_xml(sr, TESTS_BUILD_DIR "/check-results.xml");
-
-   srunner_run_all(sr, CK_ENV);
-   failed_count = srunner_ntests_failed(sr);
-   srunner_free(sr);
+   failed_count = _efl_suite_build_and_run(argc - 1, (const char **)argv + 1,
+                                           "Ecore C++", etc);
 
    return (failed_count == 0) ? 0 : 255;
 }
diff --git a/src/tests/ecore_cxx/ecore_cxx_suite.h b/src/tests/ecore_cxx/ecore_cxx_suite.h
new file mode 100644 (file)
index 0000000..3434331
--- /dev/null
@@ -0,0 +1,11 @@
+#ifndef _ECORE_CXX_SUITE_H
+#define _ECORE_CXX_SUITE_H
+
+#include <cassert>
+#include <algorithm>
+
+#include <check.h>
+
+void ecore_cxx_test_safe_call(TCase* tc);
+
+#endif /* _ECORE_CXX_SUITE_H */
index 1425041..7202087 100644 (file)
@@ -2,14 +2,13 @@
 # include <config.h>
 #endif
 
-#include "Ecore.hh"
-#include "Eina.hh"
-
 #include <algorithm>
-
 #include <iostream>
 
-#include <check.h>
+#include <Eina.hh>
+#include <Ecore.hh>
+
+#include "ecore_cxx_suite.h"
 
 void call_async(efl::eina::mutex& mutex, efl::eina::condition_variable& cond, int& done)
 {
@@ -260,7 +259,7 @@ START_TEST(ecore_cxx_safe_call_sync)
 END_TEST
 
 void
-ecore_test_safe_call(TCase* tc)
+ecore_cxx_test_safe_call(TCase* tc)
 {
   tcase_add_test(tc, ecore_cxx_safe_call_async);
   tcase_add_test(tc, ecore_cxx_safe_call_sync);