test-async-null-cb.c
Go to the documentation of this file.
1 /* Copyright Joyent, Inc. and other Node contributors. All rights reserved.
2  *
3  * Permission is hereby granted, free of charge, to any person obtaining a copy
4  * of this software and associated documentation files (the "Software"), to
5  * deal in the Software without restriction, including without limitation the
6  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7  * sell copies of the Software, and to permit persons to whom the Software is
8  * furnished to do so, subject to the following conditions:
9  *
10  * The above copyright notice and this permission notice shall be included in
11  * all copies or substantial portions of the Software.
12  *
13  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
19  * IN THE SOFTWARE.
20  */
21 
22 #include "uv.h"
23 #include "task.h"
24 #include <string.h>
25 
28 static int check_cb_called;
30 
31 
32 static void thread_cb(void* dummy) {
33  (void) &dummy;
35 }
36 
37 
38 static void check_cb(uv_check_t* handle) {
39  ASSERT(check_cb_called == 0);
43 }
44 
45 
46 TEST_IMPL(async_null_cb) {
47  /*
48  * Fill async_handle with garbage values.
49  * uv_async_init() should properly initialize struct fields regardless of
50  * initial values.
51  * This is added to verify paddings between fields do not affect behavior.
52  */
53  memset(&async_handle, 0xff, sizeof(async_handle));
54 
58  ASSERT(0 == uv_thread_create(&thread, thread_cb, NULL));
61  ASSERT(1 == check_cb_called);
63  return 0;
64 }
task.h
memset
return memset(p, 0, total)
string.h
ASSERT
#define ASSERT(expr)
Definition: task.h:102
uv_thread_join
UV_EXTERN int uv_thread_join(uv_thread_t *tid)
Definition: libuv/src/unix/thread.c:271
uv_run
UV_EXTERN int uv_run(uv_loop_t *, uv_run_mode mode)
Definition: unix/core.c:361
uv_close
UV_EXTERN void uv_close(uv_handle_t *handle, uv_close_cb close_cb)
Definition: unix/core.c:112
check_cb_called
static int check_cb_called
Definition: test-async-null-cb.c:28
uv_default_loop
UV_EXTERN uv_loop_t * uv_default_loop(void)
Definition: uv-common.c:733
check_handle
static uv_check_t check_handle
Definition: test-async-null-cb.c:27
uv_check_s
Definition: uv.h:814
uv_async_s
Definition: uv.h:834
async_handle
static uv_async_t async_handle
Definition: test-async-null-cb.c:26
UV_RUN_DEFAULT
@ UV_RUN_DEFAULT
Definition: uv.h:254
check_cb
static void check_cb(uv_check_t *handle)
Definition: test-async-null-cb.c:38
uv_thread_create
UV_EXTERN int uv_thread_create(uv_thread_t *tid, uv_thread_cb entry, void *arg)
Definition: libuv/src/unix/thread.c:209
uv.h
MAKE_VALGRIND_HAPPY
#define MAKE_VALGRIND_HAPPY()
Definition: task.h:229
uv_async_init
UV_EXTERN int uv_async_init(uv_loop_t *, uv_async_t *async, uv_async_cb async_cb)
Definition: unix/async.c:44
uv_check_init
UV_EXTERN int uv_check_init(uv_loop_t *, uv_check_t *check)
absl::ABSL_NAMESPACE_BEGIN::dummy
int dummy
Definition: function_type_benchmark.cc:28
TEST_IMPL
TEST_IMPL(async_null_cb)
Definition: test-async-null-cb.c:46
handle
static csh handle
Definition: test_arm_regression.c:16
uv_handle_s
Definition: uv.h:441
uv_thread_t
pthread_t uv_thread_t
Definition: unix.h:134
thread
static uv_thread_t thread
Definition: test-async-null-cb.c:29
uv_async_send
UV_EXTERN int uv_async_send(uv_async_t *async)
Definition: unix/async.c:62
uv_check_start
UV_EXTERN int uv_check_start(uv_check_t *check, uv_check_cb cb)
thread_cb
static void thread_cb(void *dummy)
Definition: test-async-null-cb.c:32


grpc
Author(s):
autogenerated on Thu Mar 13 2025 03:01:29