mirror of
https://github.com/libuv/libuv
synced 2025-03-28 21:13:16 +00:00
fs: add UV_ENOENT error code, add test
This commit is contained in:
parent
efcd273d68
commit
b7d88070d8
@ -172,6 +172,7 @@ typedef enum {
|
||||
UV_ENOTCONN,
|
||||
UV_ENOTSOCK,
|
||||
UV_ENOTSUP,
|
||||
UV_ENOENT,
|
||||
UV_EPIPE,
|
||||
UV_EPROTO,
|
||||
UV_EPROTONOSUPPORT,
|
||||
|
@ -69,6 +69,7 @@ char* uv_strerror(uv_err_t err) {
|
||||
uv_err_code uv_translate_sys_error(int sys_errno) {
|
||||
switch (sys_errno) {
|
||||
case 0: return UV_OK;
|
||||
case ENOENT: return UV_ENOENT;
|
||||
case EACCES: return UV_EACCESS;
|
||||
case EBADF: return UV_EBADF;
|
||||
case EPIPE: return UV_EPIPE;
|
||||
|
@ -81,6 +81,7 @@ const char* uv_err_name(uv_err_t err) {
|
||||
case UV_ENOTCONN: return "ENOTCONN";
|
||||
case UV_ENOTSOCK: return "ENOTSOCK";
|
||||
case UV_ENOTSUP: return "ENOTSUP";
|
||||
case UV_ENOENT: return "ENOENT";
|
||||
case UV_EPIPE: return "EPIPE";
|
||||
case UV_EPROTO: return "EPROTO";
|
||||
case UV_EPROTONOSUPPORT: return "EPROTONOSUPPORT";
|
||||
|
@ -360,6 +360,41 @@ static void sendfile_cb(uv_fs_t* req) {
|
||||
}
|
||||
|
||||
|
||||
static void open_noent_cb(uv_fs_t* req) {
|
||||
ASSERT(req->fs_type == UV_FS_OPEN);
|
||||
ASSERT(req->errorno == UV_ENOENT);
|
||||
ASSERT(req->result == -1);
|
||||
open_cb_count++;
|
||||
uv_fs_req_cleanup(req);
|
||||
}
|
||||
|
||||
|
||||
TEST_IMPL(fs_file_noent) {
|
||||
uv_fs_t req;
|
||||
int r;
|
||||
|
||||
uv_init();
|
||||
loop = uv_default_loop();
|
||||
|
||||
r = uv_fs_open(loop, &req, "does_not_exist", O_RDONLY, 0, NULL);
|
||||
ASSERT(r == -1);
|
||||
ASSERT(req.result == -1);
|
||||
ASSERT(uv_last_error(loop).code == UV_ENOENT);
|
||||
uv_fs_req_cleanup(&req);
|
||||
|
||||
r = uv_fs_open(loop, &req, "does_not_exist", O_RDONLY, 0, open_noent_cb);
|
||||
ASSERT(r == 0);
|
||||
|
||||
ASSERT(open_cb_count == 0);
|
||||
uv_run(loop);
|
||||
ASSERT(open_cb_count == 1);
|
||||
|
||||
/* TODO add EACCES test */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
TEST_IMPL(fs_file_async) {
|
||||
int r;
|
||||
|
||||
|
@ -72,6 +72,7 @@ TEST_DECLARE (spawn_exit_code)
|
||||
TEST_DECLARE (spawn_stdout)
|
||||
TEST_DECLARE (spawn_stdin)
|
||||
TEST_DECLARE (spawn_and_kill)
|
||||
TEST_DECLARE (fs_file_noent)
|
||||
TEST_DECLARE (fs_file_async)
|
||||
TEST_DECLARE (fs_file_sync)
|
||||
TEST_DECLARE (fs_async_dir)
|
||||
@ -180,6 +181,7 @@ TASK_LIST_START
|
||||
TEST_ENTRY (environment_creation)
|
||||
#endif
|
||||
|
||||
TEST_ENTRY (fs_file_noent)
|
||||
TEST_ENTRY (fs_file_async)
|
||||
TEST_ENTRY (fs_file_sync)
|
||||
TEST_ENTRY (fs_async_dir)
|
||||
|
Loading…
x
Reference in New Issue
Block a user