summaryrefslogtreecommitdiff
path: root/tutorial/c/lib/src/test/runner.c
blob: 3594a7e2fc6972520faaab07581a5a59bcd58c9a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#define EFL_BETA_API_SUPPORT 1

#include <check.h>
#include <Efl_Core.h>

#include <Example.h>
#include "suite.h"

EAPI_MAIN void
efl_main(void *data EINA_UNUSED, const Efl_Event *ev)
{
   Efl_Loop_Arguments *args = ev->info;
   Suite *s;
   SRunner *sr;
   TCase *tc = NULL;
   char *test = NULL;
   unsigned int i;
   int failed_count = -1;

   if (eina_array_count(args->argv) > 1)
     {
        test = eina_array_data_get(args->argv, 1);

        if (!strcmp(test, "--list"))
          {
             fprintf(stdout, "Available tests :\n");
             for (i = 0; i < sizeof (tests) / sizeof (tests[0]); i++)
               fprintf(stdout, "\t%s\n", tests[i].name);

             efl_exit(0);
             return;
          }
     }

   s = suite_create("Example");
   for (i = 0; i < sizeof (tests) / sizeof (tests[0]); i++)
     {
        if (test && strcmp(tests[i].name, test))
          continue ;

        tc =  tcase_create(tests[i].name);
        tcase_set_timeout(tc, 0);

        tests[i].build(tc);
        suite_add_tcase(s, tc);
     }

   sr = srunner_create(s);
   srunner_set_xml(sr, PACKAGE_BUILD_DIR "/check-results.xml");

   srunner_run_all(sr, CK_ENV);
   failed_count = srunner_ntests_failed(sr);
   srunner_free(sr);

   efl_exit((failed_count == 0) ? 0 : 255);
}
EFL_MAIN();