Line data Source code
1 : /**
2 : * @file
3 : *
4 : * @brief Tests for I/O glib binding.
5 : *
6 : * @copyright BSD License (see LICENSE.md or https://www.libelektra.org)
7 : *
8 : */
9 :
10 : #include <stdio.h>
11 : #include <stdlib.h>
12 :
13 : #include <kdbio.h>
14 : #include <kdbiotest.h>
15 : #include <tests.h>
16 :
17 : #include <glib.h>
18 :
19 : #include <kdbio/glib.h>
20 :
21 : GMainLoop * loop;
22 : GMainContext * context;
23 :
24 : typedef struct
25 : {
26 : GSource source;
27 : GPollFD pollFd;
28 : } FdSource;
29 :
30 : #define FD_READ_END 0
31 : #define FD_WRITE_END 1
32 :
33 : int fds[2];
34 :
35 38 : static ElektraIoInterface * createBinding (void)
36 : {
37 38 : return elektraIoGlibNew (context);
38 : }
39 :
40 30 : static void startLoop (void)
41 : {
42 30 : g_main_loop_run (loop);
43 30 : }
44 :
45 30 : static void stopLoop (void)
46 : {
47 30 : g_main_loop_quit (loop);
48 30 : }
49 :
50 2 : int main (int argc, char ** argv)
51 : {
52 2 : context = NULL;
53 :
54 2 : init (argc, argv);
55 :
56 2 : context = g_main_context_new ();
57 2 : loop = g_main_loop_new (context, 0);
58 :
59 2 : elektraIoTestSuite (createBinding, startLoop, stopLoop);
60 :
61 2 : print_result ("iowrapper_glib");
62 :
63 2 : g_main_loop_unref (loop);
64 2 : g_main_context_unref (context);
65 :
66 2 : return nbError;
67 : }
|