xref: /netbsd-src/external/mit/libuv/dist/test/test-loop-configure.c (revision 0e552da7216834a96e91ad098e59272b41087480)
1*0e552da7Schristos /* Copyright (c) 2014, Ben Noordhuis <info@bnoordhuis.nl>
2*0e552da7Schristos  *
3*0e552da7Schristos  * Permission to use, copy, modify, and/or distribute this software for any
4*0e552da7Schristos  * purpose with or without fee is hereby granted, provided that the above
5*0e552da7Schristos  * copyright notice and this permission notice appear in all copies.
6*0e552da7Schristos  *
7*0e552da7Schristos  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8*0e552da7Schristos  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9*0e552da7Schristos  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
10*0e552da7Schristos  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11*0e552da7Schristos  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
12*0e552da7Schristos  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
13*0e552da7Schristos  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
14*0e552da7Schristos  */
15*0e552da7Schristos 
16*0e552da7Schristos #include "uv.h"
17*0e552da7Schristos #include "task.h"
18*0e552da7Schristos 
timer_cb(uv_timer_t * handle)19*0e552da7Schristos static void timer_cb(uv_timer_t* handle) {
20*0e552da7Schristos   uv_close((uv_handle_t*) handle, NULL);
21*0e552da7Schristos }
22*0e552da7Schristos 
23*0e552da7Schristos 
TEST_IMPL(loop_configure)24*0e552da7Schristos TEST_IMPL(loop_configure) {
25*0e552da7Schristos   uv_timer_t timer_handle;
26*0e552da7Schristos   uv_loop_t loop;
27*0e552da7Schristos   ASSERT(0 == uv_loop_init(&loop));
28*0e552da7Schristos #ifdef _WIN32
29*0e552da7Schristos   ASSERT(UV_ENOSYS == uv_loop_configure(&loop, UV_LOOP_BLOCK_SIGNAL, 0));
30*0e552da7Schristos #else
31*0e552da7Schristos   ASSERT(0 == uv_loop_configure(&loop, UV_LOOP_BLOCK_SIGNAL, SIGPROF));
32*0e552da7Schristos #endif
33*0e552da7Schristos   ASSERT(0 == uv_timer_init(&loop, &timer_handle));
34*0e552da7Schristos   ASSERT(0 == uv_timer_start(&timer_handle, timer_cb, 10, 0));
35*0e552da7Schristos   ASSERT(0 == uv_run(&loop, UV_RUN_DEFAULT));
36*0e552da7Schristos   ASSERT(0 == uv_loop_close(&loop));
37*0e552da7Schristos   return 0;
38*0e552da7Schristos }
39