forked from ElektraInitiative/libelektra
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestio_uv.c
55 lines (43 loc) · 977 Bytes
/
testio_uv.c
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
/**
* @file
*
* @brief Tests for I/O UV binding.
*
* @copyright BSD License (see LICENSE.md or https://www.libelektra.org)
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <kdbio.h>
#include <kdbiotest.h>
#include <tests.h>
#include <uv.h>
#include <kdbio/uv.h>
static ElektraIoInterface * createBinding (void)
{
return elektraIoUvNew (uv_default_loop ());
}
static void startLoop (void)
{
uv_run (uv_default_loop (), UV_RUN_DEFAULT);
}
static void stopLoop (void)
{
uv_stop (uv_default_loop ());
}
int main (int argc, char ** argv)
{
init (argc, argv);
elektraIoTestSuite (createBinding, startLoop, stopLoop);
// Run loop once to fire handle closed callbacks and free memory
// see http://docs.libuv.org/en/v1.x/handle.html#c.uv_close
uv_loop_t * loop = uv_default_loop ();
uv_run (loop, UV_RUN_ONCE);
#ifdef HAVE_LIBUV1
uv_loop_close (loop);
#elif HAVE_LIBUV0
uv_loop_delete (loop);
#endif
print_result ("iowrapper_uv");
return nbError;
}