Test rework #2: Ecore_Con
authorVincent Torri <vincent dot torri at gmail dot com>
Thu, 4 Feb 2016 13:12:28 +0000 (14:12 +0100)
committerTom Hacohen <tom@stosb.com>
Tue, 16 Feb 2016 12:41:06 +0000 (12:41 +0000)
src/tests/ecore_con/ecore_con_suite.c
src/tests/ecore_con/ecore_con_test_ecore_con.c
src/tests/ecore_con/ecore_con_test_ecore_con_eet.c
src/tests/ecore_con/ecore_con_test_ecore_con_url.c

index 331f660..a3ef616 100644 (file)
 # include <config.h>
 #endif
 
-#include <stdlib.h>
-#include <stdio.h>
-
-#include "Ecore.h"
-
 #include "ecore_con_suite.h"
+#include "../efl_check.h"
 
-typedef struct _Ecore_Con_Test_Case Ecore_Con_Test_Case;
-
-struct _Ecore_Con_Test_Case
-{
-   const char *test_case;
-   void      (*build)(TCase *tc);
-};
-
-static const Ecore_Con_Test_Case etc[] = {
+static const Efl_Test_Case etc[] = {
   { "Ecore_Con", ecore_con_test_ecore_con },
   { "Ecore_Con_Url", ecore_con_test_ecore_con_url },
   { "Ecore_Con_Eet", ecore_con_test_ecore_con_eet },
   { NULL, NULL }
 };
 
-static void
-_list_tests(void)
-{
-   const Ecore_Con_Test_Case *itr;
-
-   itr = etc;
-   fputs("Available Test Cases:\n", stderr);
-   for (; itr->test_case; itr++)
-     fprintf(stderr, "\t%s\n", itr->test_case);
-}
-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;
-}
-
-static Suite *
-ecore_con_suite_build(int argc, const char **argv)
-{
-   TCase *tc;
-   Suite *s;
-   int i;
-
-   s = suite_create("Ecore_Con");
-
-   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);
-
-        etc[i].build(tc);
-
-        suite_add_tcase(s, tc);
-        tcase_set_timeout(tc, 0);
-     }
-
-   return s;
-}
-
 int
 main(int argc, char **argv)
 {
-   Suite *s;
-   SRunner *sr;
-   int i, failed_count;
+   int 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("EFL_RUN_IN_TREE=1");
 
-   s = ecore_con_suite_build(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_Con", etc);
 
    return (failed_count == 0) ? 0 : 255;
 }
index d7f03e6..33dda2f 100644 (file)
@@ -2,12 +2,13 @@
 # include <config.h>
 #endif
 
-#include "ecore_con_suite.h"
-
 #include <stdio.h>
+
 #include <Ecore.h>
 #include <Ecore_Con.h>
 
+#include "ecore_con_suite.h"
+
 char sdata[] = "Server_info";
 char cdata[] = "Client_info";
 
index e6eca4d..c8801bb 100644 (file)
@@ -2,11 +2,11 @@
 # include <config.h>
 #endif
 
-#include "ecore_con_suite.h"
-
 #include <Eet.h>
 #include <Ecore_Con_Eet.h>
 
+#include "ecore_con_suite.h"
+
 #define TEST_STREAM "test_stream"
 #define SRV_MSG "Server Message"
 #define CLI_MSG "Client Message"
index 38fb234..0c1a602 100644 (file)
@@ -2,13 +2,14 @@
 # include <config.h>
 #endif
 
-#include "ecore_con_suite.h"
-
 #include <stdio.h>
+#include <unistd.h>
+
+#include <Eina.h>
 #include <Ecore.h>
 #include <Ecore_Con.h>
-#include <Eina.h>
-#include <unistd.h>
+
+#include "ecore_con_suite.h"
 
 #define COOKIEJAR "testcookieXXXXXX.jar"
 #define DEFAULT_LINK "www.google.com"