test-pipe-set-fchmod.c
Go to the documentation of this file.
1 /* Copyright libuv project 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 
23 #include "uv.h"
24 #include "task.h"
25 
26 TEST_IMPL(pipe_set_chmod) {
28  uv_loop_t* loop;
29  int r;
30 #ifndef _WIN32
31  struct stat stat_buf;
32 #endif
33 
35 
37  ASSERT(r == 0);
38 
40  ASSERT(r == 0);
41 
42  /* No easy way to test if this works, we will only make sure that the call is
43  * successful. */
45  if (r == UV_EPERM) {
47  RETURN_SKIP("Insufficient privileges to alter pipe fmode");
48  }
49  ASSERT(r == 0);
50 #ifndef _WIN32
51  stat(TEST_PIPENAME, &stat_buf);
52  ASSERT(stat_buf.st_mode & S_IRUSR);
53  ASSERT(stat_buf.st_mode & S_IRGRP);
54  ASSERT(stat_buf.st_mode & S_IROTH);
55 #endif
56 
58  ASSERT(r == 0);
59 #ifndef _WIN32
60  stat(TEST_PIPENAME, &stat_buf);
61  ASSERT(stat_buf.st_mode & S_IWUSR);
62  ASSERT(stat_buf.st_mode & S_IWGRP);
63  ASSERT(stat_buf.st_mode & S_IWOTH);
64 #endif
65 
67  ASSERT(r == 0);
68 #ifndef _WIN32
69  stat(TEST_PIPENAME, &stat_buf);
70  ASSERT(stat_buf.st_mode & S_IRUSR);
71  ASSERT(stat_buf.st_mode & S_IRGRP);
72  ASSERT(stat_buf.st_mode & S_IROTH);
73  ASSERT(stat_buf.st_mode & S_IWUSR);
74  ASSERT(stat_buf.st_mode & S_IWGRP);
75  ASSERT(stat_buf.st_mode & S_IWOTH);
76 #endif
77 
79  ASSERT(r == UV_EBADF);
80 
81  r = uv_pipe_chmod(&pipe_handle, 12345678);
82  ASSERT(r == UV_EINVAL);
83 
86  ASSERT(r == UV_EBADF);
87 
89  return 0;
90 }
async_greeter_server_with_graceful_shutdown.loop
loop
Definition: async_greeter_server_with_graceful_shutdown.py:59
task.h
uv_pipe_init
UV_EXTERN int uv_pipe_init(uv_loop_t *, uv_pipe_t *handle, int ipc)
Definition: unix/pipe.c:33
UV_WRITABLE
@ UV_WRITABLE
Definition: uv.h:791
TEST_IMPL
TEST_IMPL(pipe_set_chmod)
Definition: test-pipe-set-fchmod.c:26
ASSERT
#define ASSERT(expr)
Definition: task.h:102
uv_close
UV_EXTERN void uv_close(uv_handle_t *handle, uv_close_cb close_cb)
Definition: unix/core.c:112
uv_default_loop
UV_EXTERN uv_loop_t * uv_default_loop(void)
Definition: uv-common.c:733
UV_READABLE
@ UV_READABLE
Definition: uv.h:790
uv.h
MAKE_VALGRIND_HAPPY
#define MAKE_VALGRIND_HAPPY()
Definition: task.h:229
fix_build_deps.r
r
Definition: fix_build_deps.py:491
pipe_handle
static uv_pipe_t pipe_handle
Definition: test-pipe-connect-prepare.c:39
uv_pipe_s
Definition: uv.h:757
RETURN_SKIP
#define RETURN_SKIP(explanation)
Definition: task.h:262
stat
#define stat
Definition: test-fs.c:50
uv_handle_s
Definition: uv.h:441
TEST_PIPENAME
#define TEST_PIPENAME
Definition: task.h:61
uv_loop_s
Definition: uv.h:1767
uv_pipe_chmod
UV_EXTERN int uv_pipe_chmod(uv_pipe_t *handle, int flags)
Definition: unix/pipe.c:326
uv_pipe_bind
UV_EXTERN int uv_pipe_bind(uv_pipe_t *handle, const char *name)
Definition: unix/pipe.c:43


grpc
Author(s):
autogenerated on Fri May 16 2025 03:00:26