|
@ -196,9 +196,13 @@ static void chown_root_cb(uv_fs_t* req) { |
|
|
/* On windows, chown is a no-op and always succeeds. */ |
|
|
/* On windows, chown is a no-op and always succeeds. */ |
|
|
ASSERT(req->result == 0); |
|
|
ASSERT(req->result == 0); |
|
|
#else |
|
|
#else |
|
|
/* On unix, chown'ing the root directory is not allowed. */ |
|
|
/* On unix, chown'ing the root directory is not allowed -
|
|
|
ASSERT(req->result == -1); |
|
|
* unless you're root, of course. |
|
|
ASSERT(req->errorno == UV_EPERM); |
|
|
*/ |
|
|
|
|
|
if (geteuid() == 0) |
|
|
|
|
|
ASSERT(req->result == 0); |
|
|
|
|
|
else |
|
|
|
|
|
ASSERT(req->result == UV_EPERM); |
|
|
#endif |
|
|
#endif |
|
|
chown_cb_count++; |
|
|
chown_cb_count++; |
|
|
uv_fs_req_cleanup(req); |
|
|
uv_fs_req_cleanup(req); |
|
@ -207,7 +211,7 @@ static void chown_root_cb(uv_fs_t* req) { |
|
|
static void unlink_cb(uv_fs_t* req) { |
|
|
static void unlink_cb(uv_fs_t* req) { |
|
|
ASSERT(req == &unlink_req); |
|
|
ASSERT(req == &unlink_req); |
|
|
ASSERT(req->fs_type == UV_FS_UNLINK); |
|
|
ASSERT(req->fs_type == UV_FS_UNLINK); |
|
|
ASSERT(req->result != -1); |
|
|
ASSERT(req->result == 0); |
|
|
unlink_cb_count++; |
|
|
unlink_cb_count++; |
|
|
uv_fs_req_cleanup(req); |
|
|
uv_fs_req_cleanup(req); |
|
|
} |
|
|
} |
|
@ -226,7 +230,7 @@ static void close_cb(uv_fs_t* req) { |
|
|
int r; |
|
|
int r; |
|
|
ASSERT(req == &close_req); |
|
|
ASSERT(req == &close_req); |
|
|
ASSERT(req->fs_type == UV_FS_CLOSE); |
|
|
ASSERT(req->fs_type == UV_FS_CLOSE); |
|
|
ASSERT(req->result != -1); |
|
|
ASSERT(req->result == 0); |
|
|
close_cb_count++; |
|
|
close_cb_count++; |
|
|
uv_fs_req_cleanup(req); |
|
|
uv_fs_req_cleanup(req); |
|
|
if (close_cb_count == 3) { |
|
|
if (close_cb_count == 3) { |
|
@ -240,7 +244,7 @@ static void ftruncate_cb(uv_fs_t* req) { |
|
|
int r; |
|
|
int r; |
|
|
ASSERT(req == &ftruncate_req); |
|
|
ASSERT(req == &ftruncate_req); |
|
|
ASSERT(req->fs_type == UV_FS_FTRUNCATE); |
|
|
ASSERT(req->fs_type == UV_FS_FTRUNCATE); |
|
|
ASSERT(req->result != -1); |
|
|
ASSERT(req->result == 0); |
|
|
ftruncate_cb_count++; |
|
|
ftruncate_cb_count++; |
|
|
uv_fs_req_cleanup(req); |
|
|
uv_fs_req_cleanup(req); |
|
|
r = uv_fs_close(loop, &close_req, open_req1.result, close_cb); |
|
|
r = uv_fs_close(loop, &close_req, open_req1.result, close_cb); |
|
@ -252,7 +256,7 @@ static void read_cb(uv_fs_t* req) { |
|
|
int r; |
|
|
int r; |
|
|
ASSERT(req == &read_req); |
|
|
ASSERT(req == &read_req); |
|
|
ASSERT(req->fs_type == UV_FS_READ); |
|
|
ASSERT(req->fs_type == UV_FS_READ); |
|
|
ASSERT(req->result != -1); |
|
|
ASSERT(req->result >= 0); /* FIXME(bnoordhuis) Check if requested size? */ |
|
|
read_cb_count++; |
|
|
read_cb_count++; |
|
|
uv_fs_req_cleanup(req); |
|
|
uv_fs_req_cleanup(req); |
|
|
if (read_cb_count == 1) { |
|
|
if (read_cb_count == 1) { |
|
@ -272,8 +276,7 @@ static void open_cb(uv_fs_t* req) { |
|
|
ASSERT(req == &open_req1); |
|
|
ASSERT(req == &open_req1); |
|
|
ASSERT(req->fs_type == UV_FS_OPEN); |
|
|
ASSERT(req->fs_type == UV_FS_OPEN); |
|
|
if (req->result < 0) { |
|
|
if (req->result < 0) { |
|
|
/* TODO get error with uv_last_error() */ |
|
|
fprintf(stderr, "async open error: %d\n", (int) req->result); |
|
|
fprintf(stderr, "async open error: %d\n", req->errorno); |
|
|
|
|
|
ASSERT(0); |
|
|
ASSERT(0); |
|
|
} |
|
|
} |
|
|
open_cb_count++; |
|
|
open_cb_count++; |
|
@ -290,8 +293,7 @@ static void open_cb(uv_fs_t* req) { |
|
|
static void open_cb_simple(uv_fs_t* req) { |
|
|
static void open_cb_simple(uv_fs_t* req) { |
|
|
ASSERT(req->fs_type == UV_FS_OPEN); |
|
|
ASSERT(req->fs_type == UV_FS_OPEN); |
|
|
if (req->result < 0) { |
|
|
if (req->result < 0) { |
|
|
/* TODO get error with uv_last_error() */ |
|
|
fprintf(stderr, "async open error: %d\n", (int) req->result); |
|
|
fprintf(stderr, "async open error: %d\n", req->errorno); |
|
|
|
|
|
ASSERT(0); |
|
|
ASSERT(0); |
|
|
} |
|
|
} |
|
|
open_cb_count++; |
|
|
open_cb_count++; |
|
@ -304,7 +306,7 @@ static void fsync_cb(uv_fs_t* req) { |
|
|
int r; |
|
|
int r; |
|
|
ASSERT(req == &fsync_req); |
|
|
ASSERT(req == &fsync_req); |
|
|
ASSERT(req->fs_type == UV_FS_FSYNC); |
|
|
ASSERT(req->fs_type == UV_FS_FSYNC); |
|
|
ASSERT(req->result != -1); |
|
|
ASSERT(req->result == 0); |
|
|
fsync_cb_count++; |
|
|
fsync_cb_count++; |
|
|
uv_fs_req_cleanup(req); |
|
|
uv_fs_req_cleanup(req); |
|
|
r = uv_fs_close(loop, &close_req, open_req1.result, close_cb); |
|
|
r = uv_fs_close(loop, &close_req, open_req1.result, close_cb); |
|
@ -316,7 +318,7 @@ static void fdatasync_cb(uv_fs_t* req) { |
|
|
int r; |
|
|
int r; |
|
|
ASSERT(req == &fdatasync_req); |
|
|
ASSERT(req == &fdatasync_req); |
|
|
ASSERT(req->fs_type == UV_FS_FDATASYNC); |
|
|
ASSERT(req->fs_type == UV_FS_FDATASYNC); |
|
|
ASSERT(req->result != -1); |
|
|
ASSERT(req->result == 0); |
|
|
fdatasync_cb_count++; |
|
|
fdatasync_cb_count++; |
|
|
uv_fs_req_cleanup(req); |
|
|
uv_fs_req_cleanup(req); |
|
|
r = uv_fs_fsync(loop, &fsync_req, open_req1.result, fsync_cb); |
|
|
r = uv_fs_fsync(loop, &fsync_req, open_req1.result, fsync_cb); |
|
@ -328,7 +330,7 @@ static void write_cb(uv_fs_t* req) { |
|
|
int r; |
|
|
int r; |
|
|
ASSERT(req == &write_req); |
|
|
ASSERT(req == &write_req); |
|
|
ASSERT(req->fs_type == UV_FS_WRITE); |
|
|
ASSERT(req->fs_type == UV_FS_WRITE); |
|
|
ASSERT(req->result != -1); |
|
|
ASSERT(req->result >= 0); /* FIXME(bnoordhuis) Check if requested size? */ |
|
|
write_cb_count++; |
|
|
write_cb_count++; |
|
|
uv_fs_req_cleanup(req); |
|
|
uv_fs_req_cleanup(req); |
|
|
r = uv_fs_fdatasync(loop, &fdatasync_req, open_req1.result, fdatasync_cb); |
|
|
r = uv_fs_fdatasync(loop, &fdatasync_req, open_req1.result, fdatasync_cb); |
|
@ -340,7 +342,7 @@ static void create_cb(uv_fs_t* req) { |
|
|
int r; |
|
|
int r; |
|
|
ASSERT(req == &open_req1); |
|
|
ASSERT(req == &open_req1); |
|
|
ASSERT(req->fs_type == UV_FS_OPEN); |
|
|
ASSERT(req->fs_type == UV_FS_OPEN); |
|
|
ASSERT(req->result != -1); |
|
|
ASSERT(req->result >= 0); |
|
|
create_cb_count++; |
|
|
create_cb_count++; |
|
|
uv_fs_req_cleanup(req); |
|
|
uv_fs_req_cleanup(req); |
|
|
r = uv_fs_write(loop, &write_req, req->result, test_buf, sizeof(test_buf), |
|
|
r = uv_fs_write(loop, &write_req, req->result, test_buf, sizeof(test_buf), |
|
@ -352,7 +354,7 @@ static void create_cb(uv_fs_t* req) { |
|
|
static void rename_cb(uv_fs_t* req) { |
|
|
static void rename_cb(uv_fs_t* req) { |
|
|
ASSERT(req == &rename_req); |
|
|
ASSERT(req == &rename_req); |
|
|
ASSERT(req->fs_type == UV_FS_RENAME); |
|
|
ASSERT(req->fs_type == UV_FS_RENAME); |
|
|
ASSERT(req->result != -1); |
|
|
ASSERT(req->result == 0); |
|
|
rename_cb_count++; |
|
|
rename_cb_count++; |
|
|
uv_fs_req_cleanup(req); |
|
|
uv_fs_req_cleanup(req); |
|
|
} |
|
|
} |
|
@ -361,7 +363,7 @@ static void rename_cb(uv_fs_t* req) { |
|
|
static void mkdir_cb(uv_fs_t* req) { |
|
|
static void mkdir_cb(uv_fs_t* req) { |
|
|
ASSERT(req == &mkdir_req); |
|
|
ASSERT(req == &mkdir_req); |
|
|
ASSERT(req->fs_type == UV_FS_MKDIR); |
|
|
ASSERT(req->fs_type == UV_FS_MKDIR); |
|
|
ASSERT(req->result != -1); |
|
|
ASSERT(req->result == 0); |
|
|
mkdir_cb_count++; |
|
|
mkdir_cb_count++; |
|
|
ASSERT(req->path); |
|
|
ASSERT(req->path); |
|
|
ASSERT(memcmp(req->path, "test_dir\0", 9) == 0); |
|
|
ASSERT(memcmp(req->path, "test_dir\0", 9) == 0); |
|
@ -372,7 +374,7 @@ static void mkdir_cb(uv_fs_t* req) { |
|
|
static void rmdir_cb(uv_fs_t* req) { |
|
|
static void rmdir_cb(uv_fs_t* req) { |
|
|
ASSERT(req == &rmdir_req); |
|
|
ASSERT(req == &rmdir_req); |
|
|
ASSERT(req->fs_type == UV_FS_RMDIR); |
|
|
ASSERT(req->fs_type == UV_FS_RMDIR); |
|
|
ASSERT(req->result != -1); |
|
|
ASSERT(req->result == 0); |
|
|
rmdir_cb_count++; |
|
|
rmdir_cb_count++; |
|
|
ASSERT(req->path); |
|
|
ASSERT(req->path); |
|
|
ASSERT(memcmp(req->path, "test_dir\0", 9) == 0); |
|
|
ASSERT(memcmp(req->path, "test_dir\0", 9) == 0); |
|
@ -408,9 +410,8 @@ static void empty_readdir_cb(uv_fs_t* req) { |
|
|
static void file_readdir_cb(uv_fs_t* req) { |
|
|
static void file_readdir_cb(uv_fs_t* req) { |
|
|
ASSERT(req == &readdir_req); |
|
|
ASSERT(req == &readdir_req); |
|
|
ASSERT(req->fs_type == UV_FS_READDIR); |
|
|
ASSERT(req->fs_type == UV_FS_READDIR); |
|
|
ASSERT(req->result == -1); |
|
|
ASSERT(req->result == UV_ENOTDIR); |
|
|
ASSERT(req->ptr == NULL); |
|
|
ASSERT(req->ptr == NULL); |
|
|
ASSERT(uv_last_error(req->loop).code == UV_ENOTDIR); |
|
|
|
|
|
uv_fs_req_cleanup(req); |
|
|
uv_fs_req_cleanup(req); |
|
|
readdir_cb_count++; |
|
|
readdir_cb_count++; |
|
|
} |
|
|
} |
|
@ -419,7 +420,7 @@ static void file_readdir_cb(uv_fs_t* req) { |
|
|
static void stat_cb(uv_fs_t* req) { |
|
|
static void stat_cb(uv_fs_t* req) { |
|
|
ASSERT(req == &stat_req); |
|
|
ASSERT(req == &stat_req); |
|
|
ASSERT(req->fs_type == UV_FS_STAT || req->fs_type == UV_FS_LSTAT); |
|
|
ASSERT(req->fs_type == UV_FS_STAT || req->fs_type == UV_FS_LSTAT); |
|
|
ASSERT(req->result != -1); |
|
|
ASSERT(req->result == 0); |
|
|
ASSERT(req->ptr); |
|
|
ASSERT(req->ptr); |
|
|
stat_cb_count++; |
|
|
stat_cb_count++; |
|
|
uv_fs_req_cleanup(req); |
|
|
uv_fs_req_cleanup(req); |
|
@ -438,24 +439,21 @@ static void sendfile_cb(uv_fs_t* req) { |
|
|
|
|
|
|
|
|
static void open_noent_cb(uv_fs_t* req) { |
|
|
static void open_noent_cb(uv_fs_t* req) { |
|
|
ASSERT(req->fs_type == UV_FS_OPEN); |
|
|
ASSERT(req->fs_type == UV_FS_OPEN); |
|
|
ASSERT(req->errorno == UV_ENOENT); |
|
|
ASSERT(req->result == UV_ENOENT); |
|
|
ASSERT(req->result == -1); |
|
|
|
|
|
open_cb_count++; |
|
|
open_cb_count++; |
|
|
uv_fs_req_cleanup(req); |
|
|
uv_fs_req_cleanup(req); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static void open_nametoolong_cb(uv_fs_t* req) { |
|
|
static void open_nametoolong_cb(uv_fs_t* req) { |
|
|
ASSERT(req->fs_type == UV_FS_OPEN); |
|
|
ASSERT(req->fs_type == UV_FS_OPEN); |
|
|
ASSERT(req->errorno == UV_ENAMETOOLONG); |
|
|
ASSERT(req->result == UV_ENAMETOOLONG); |
|
|
ASSERT(req->result == -1); |
|
|
|
|
|
open_cb_count++; |
|
|
open_cb_count++; |
|
|
uv_fs_req_cleanup(req); |
|
|
uv_fs_req_cleanup(req); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static void open_loop_cb(uv_fs_t* req) { |
|
|
static void open_loop_cb(uv_fs_t* req) { |
|
|
ASSERT(req->fs_type == UV_FS_OPEN); |
|
|
ASSERT(req->fs_type == UV_FS_OPEN); |
|
|
ASSERT(req->errorno == UV_ELOOP); |
|
|
ASSERT(req->result == UV_ELOOP); |
|
|
ASSERT(req->result == -1); |
|
|
|
|
|
open_cb_count++; |
|
|
open_cb_count++; |
|
|
uv_fs_req_cleanup(req); |
|
|
uv_fs_req_cleanup(req); |
|
|
} |
|
|
} |
|
@ -468,9 +466,8 @@ TEST_IMPL(fs_file_noent) { |
|
|
loop = uv_default_loop(); |
|
|
loop = uv_default_loop(); |
|
|
|
|
|
|
|
|
r = uv_fs_open(loop, &req, "does_not_exist", O_RDONLY, 0, NULL); |
|
|
r = uv_fs_open(loop, &req, "does_not_exist", O_RDONLY, 0, NULL); |
|
|
ASSERT(r == -1); |
|
|
ASSERT(r == UV_ENOENT); |
|
|
ASSERT(req.result == -1); |
|
|
ASSERT(req.result == UV_ENOENT); |
|
|
ASSERT(uv_last_error(loop).code == UV_ENOENT); |
|
|
|
|
|
uv_fs_req_cleanup(&req); |
|
|
uv_fs_req_cleanup(&req); |
|
|
|
|
|
|
|
|
r = uv_fs_open(loop, &req, "does_not_exist", O_RDONLY, 0, open_noent_cb); |
|
|
r = uv_fs_open(loop, &req, "does_not_exist", O_RDONLY, 0, open_noent_cb); |
|
@ -497,9 +494,8 @@ TEST_IMPL(fs_file_nametoolong) { |
|
|
name[TOO_LONG_NAME_LENGTH] = 0; |
|
|
name[TOO_LONG_NAME_LENGTH] = 0; |
|
|
|
|
|
|
|
|
r = uv_fs_open(loop, &req, name, O_RDONLY, 0, NULL); |
|
|
r = uv_fs_open(loop, &req, name, O_RDONLY, 0, NULL); |
|
|
ASSERT(r == -1); |
|
|
ASSERT(r == UV_ENAMETOOLONG); |
|
|
ASSERT(req.result == -1); |
|
|
ASSERT(req.result == UV_ENAMETOOLONG); |
|
|
ASSERT(uv_last_error(loop).code == UV_ENAMETOOLONG); |
|
|
|
|
|
uv_fs_req_cleanup(&req); |
|
|
uv_fs_req_cleanup(&req); |
|
|
|
|
|
|
|
|
r = uv_fs_open(loop, &req, name, O_RDONLY, 0, open_nametoolong_cb); |
|
|
r = uv_fs_open(loop, &req, name, O_RDONLY, 0, open_nametoolong_cb); |
|
@ -524,9 +520,8 @@ TEST_IMPL(fs_file_loop) { |
|
|
uv_fs_req_cleanup(&req); |
|
|
uv_fs_req_cleanup(&req); |
|
|
|
|
|
|
|
|
r = uv_fs_open(loop, &req, "test_symlink", O_RDONLY, 0, NULL); |
|
|
r = uv_fs_open(loop, &req, "test_symlink", O_RDONLY, 0, NULL); |
|
|
ASSERT(r == -1); |
|
|
ASSERT(r == UV_ELOOP); |
|
|
ASSERT(req.result == -1); |
|
|
ASSERT(req.result == UV_ELOOP); |
|
|
ASSERT(uv_last_error(loop).code == UV_ELOOP); |
|
|
|
|
|
uv_fs_req_cleanup(&req); |
|
|
uv_fs_req_cleanup(&req); |
|
|
|
|
|
|
|
|
r = uv_fs_open(loop, &req, "test_symlink", O_RDONLY, 0, open_loop_cb); |
|
|
r = uv_fs_open(loop, &req, "test_symlink", O_RDONLY, 0, open_loop_cb); |
|
@ -664,69 +659,69 @@ TEST_IMPL(fs_file_sync) { |
|
|
|
|
|
|
|
|
r = uv_fs_open(loop, &open_req1, "test_file", O_WRONLY | O_CREAT, |
|
|
r = uv_fs_open(loop, &open_req1, "test_file", O_WRONLY | O_CREAT, |
|
|
S_IWUSR | S_IRUSR, NULL); |
|
|
S_IWUSR | S_IRUSR, NULL); |
|
|
ASSERT(r != -1); |
|
|
ASSERT(r >= 0); |
|
|
ASSERT(open_req1.result != -1); |
|
|
ASSERT(open_req1.result >= 0); |
|
|
uv_fs_req_cleanup(&open_req1); |
|
|
uv_fs_req_cleanup(&open_req1); |
|
|
|
|
|
|
|
|
r = uv_fs_write(loop, &write_req, open_req1.result, test_buf, |
|
|
r = uv_fs_write(loop, &write_req, open_req1.result, test_buf, |
|
|
sizeof(test_buf), -1, NULL); |
|
|
sizeof(test_buf), -1, NULL); |
|
|
ASSERT(r != -1); |
|
|
ASSERT(r >= 0); |
|
|
ASSERT(write_req.result != -1); |
|
|
ASSERT(write_req.result >= 0); |
|
|
uv_fs_req_cleanup(&write_req); |
|
|
uv_fs_req_cleanup(&write_req); |
|
|
|
|
|
|
|
|
r = uv_fs_close(loop, &close_req, open_req1.result, NULL); |
|
|
r = uv_fs_close(loop, &close_req, open_req1.result, NULL); |
|
|
ASSERT(r != -1); |
|
|
ASSERT(r == 0); |
|
|
ASSERT(close_req.result != -1); |
|
|
ASSERT(close_req.result == 0); |
|
|
uv_fs_req_cleanup(&close_req); |
|
|
uv_fs_req_cleanup(&close_req); |
|
|
|
|
|
|
|
|
r = uv_fs_open(loop, &open_req1, "test_file", O_RDWR, 0, NULL); |
|
|
r = uv_fs_open(loop, &open_req1, "test_file", O_RDWR, 0, NULL); |
|
|
ASSERT(r != -1); |
|
|
ASSERT(r >= 0); |
|
|
ASSERT(open_req1.result != -1); |
|
|
ASSERT(open_req1.result >= 0); |
|
|
uv_fs_req_cleanup(&open_req1); |
|
|
uv_fs_req_cleanup(&open_req1); |
|
|
|
|
|
|
|
|
r = uv_fs_read(loop, &read_req, open_req1.result, buf, sizeof(buf), -1, |
|
|
r = uv_fs_read(loop, &read_req, open_req1.result, buf, sizeof(buf), -1, |
|
|
NULL); |
|
|
NULL); |
|
|
ASSERT(r != -1); |
|
|
ASSERT(r >= 0); |
|
|
ASSERT(read_req.result != -1); |
|
|
ASSERT(read_req.result >= 0); |
|
|
ASSERT(strcmp(buf, test_buf) == 0); |
|
|
ASSERT(strcmp(buf, test_buf) == 0); |
|
|
uv_fs_req_cleanup(&read_req); |
|
|
uv_fs_req_cleanup(&read_req); |
|
|
|
|
|
|
|
|
r = uv_fs_ftruncate(loop, &ftruncate_req, open_req1.result, 7, NULL); |
|
|
r = uv_fs_ftruncate(loop, &ftruncate_req, open_req1.result, 7, NULL); |
|
|
ASSERT(r != -1); |
|
|
ASSERT(r == 0); |
|
|
ASSERT(ftruncate_req.result != -1); |
|
|
ASSERT(ftruncate_req.result == 0); |
|
|
uv_fs_req_cleanup(&ftruncate_req); |
|
|
uv_fs_req_cleanup(&ftruncate_req); |
|
|
|
|
|
|
|
|
r = uv_fs_close(loop, &close_req, open_req1.result, NULL); |
|
|
r = uv_fs_close(loop, &close_req, open_req1.result, NULL); |
|
|
ASSERT(r != -1); |
|
|
ASSERT(r == 0); |
|
|
ASSERT(close_req.result != -1); |
|
|
ASSERT(close_req.result == 0); |
|
|
uv_fs_req_cleanup(&close_req); |
|
|
uv_fs_req_cleanup(&close_req); |
|
|
|
|
|
|
|
|
r = uv_fs_rename(loop, &rename_req, "test_file", "test_file2", NULL); |
|
|
r = uv_fs_rename(loop, &rename_req, "test_file", "test_file2", NULL); |
|
|
ASSERT(r != -1); |
|
|
ASSERT(r == 0); |
|
|
ASSERT(rename_req.result != -1); |
|
|
ASSERT(rename_req.result == 0); |
|
|
uv_fs_req_cleanup(&rename_req); |
|
|
uv_fs_req_cleanup(&rename_req); |
|
|
|
|
|
|
|
|
r = uv_fs_open(loop, &open_req1, "test_file2", O_RDONLY, 0, NULL); |
|
|
r = uv_fs_open(loop, &open_req1, "test_file2", O_RDONLY, 0, NULL); |
|
|
ASSERT(r != -1); |
|
|
ASSERT(r >= 0); |
|
|
ASSERT(open_req1.result != -1); |
|
|
ASSERT(open_req1.result >= 0); |
|
|
uv_fs_req_cleanup(&open_req1); |
|
|
uv_fs_req_cleanup(&open_req1); |
|
|
|
|
|
|
|
|
memset(buf, 0, sizeof(buf)); |
|
|
memset(buf, 0, sizeof(buf)); |
|
|
r = uv_fs_read(loop, &read_req, open_req1.result, buf, sizeof(buf), -1, |
|
|
r = uv_fs_read(loop, &read_req, open_req1.result, buf, sizeof(buf), -1, |
|
|
NULL); |
|
|
NULL); |
|
|
ASSERT(r != -1); |
|
|
ASSERT(r >= 0); |
|
|
ASSERT(read_req.result != -1); |
|
|
ASSERT(read_req.result >= 0); |
|
|
ASSERT(strcmp(buf, "test-bu") == 0); |
|
|
ASSERT(strcmp(buf, "test-bu") == 0); |
|
|
uv_fs_req_cleanup(&read_req); |
|
|
uv_fs_req_cleanup(&read_req); |
|
|
|
|
|
|
|
|
r = uv_fs_close(loop, &close_req, open_req1.result, NULL); |
|
|
r = uv_fs_close(loop, &close_req, open_req1.result, NULL); |
|
|
ASSERT(r != -1); |
|
|
ASSERT(r == 0); |
|
|
ASSERT(close_req.result != -1); |
|
|
ASSERT(close_req.result == 0); |
|
|
uv_fs_req_cleanup(&close_req); |
|
|
uv_fs_req_cleanup(&close_req); |
|
|
|
|
|
|
|
|
r = uv_fs_unlink(loop, &unlink_req, "test_file2", NULL); |
|
|
r = uv_fs_unlink(loop, &unlink_req, "test_file2", NULL); |
|
|
ASSERT(r != -1); |
|
|
ASSERT(r == 0); |
|
|
ASSERT(unlink_req.result != -1); |
|
|
ASSERT(unlink_req.result == 0); |
|
|
uv_fs_req_cleanup(&unlink_req); |
|
|
uv_fs_req_cleanup(&unlink_req); |
|
|
|
|
|
|
|
|
/* Cleanup */ |
|
|
/* Cleanup */ |
|
@ -757,7 +752,7 @@ TEST_IMPL(fs_async_dir) { |
|
|
/* Create 2 files synchronously. */ |
|
|
/* Create 2 files synchronously. */ |
|
|
r = uv_fs_open(loop, &open_req1, "test_dir/file1", O_WRONLY | O_CREAT, |
|
|
r = uv_fs_open(loop, &open_req1, "test_dir/file1", O_WRONLY | O_CREAT, |
|
|
S_IWUSR | S_IRUSR, NULL); |
|
|
S_IWUSR | S_IRUSR, NULL); |
|
|
ASSERT(r != -1); |
|
|
ASSERT(r >= 0); |
|
|
uv_fs_req_cleanup(&open_req1); |
|
|
uv_fs_req_cleanup(&open_req1); |
|
|
r = uv_fs_close(loop, &close_req, open_req1.result, NULL); |
|
|
r = uv_fs_close(loop, &close_req, open_req1.result, NULL); |
|
|
ASSERT(r == 0); |
|
|
ASSERT(r == 0); |
|
@ -765,7 +760,7 @@ TEST_IMPL(fs_async_dir) { |
|
|
|
|
|
|
|
|
r = uv_fs_open(loop, &open_req1, "test_dir/file2", O_WRONLY | O_CREAT, |
|
|
r = uv_fs_open(loop, &open_req1, "test_dir/file2", O_WRONLY | O_CREAT, |
|
|
S_IWUSR | S_IRUSR, NULL); |
|
|
S_IWUSR | S_IRUSR, NULL); |
|
|
ASSERT(r != -1); |
|
|
ASSERT(r >= 0); |
|
|
uv_fs_req_cleanup(&open_req1); |
|
|
uv_fs_req_cleanup(&open_req1); |
|
|
r = uv_fs_close(loop, &close_req, open_req1.result, NULL); |
|
|
r = uv_fs_close(loop, &close_req, open_req1.result, NULL); |
|
|
ASSERT(r == 0); |
|
|
ASSERT(r == 0); |
|
@ -857,14 +852,14 @@ TEST_IMPL(fs_async_sendfile) { |
|
|
|
|
|
|
|
|
/* Test starts here. */ |
|
|
/* Test starts here. */ |
|
|
r = uv_fs_open(loop, &open_req1, "test_file", O_RDWR, 0, NULL); |
|
|
r = uv_fs_open(loop, &open_req1, "test_file", O_RDWR, 0, NULL); |
|
|
ASSERT(r != -1); |
|
|
ASSERT(r >= 0); |
|
|
ASSERT(open_req1.result != -1); |
|
|
ASSERT(open_req1.result >= 0); |
|
|
uv_fs_req_cleanup(&open_req1); |
|
|
uv_fs_req_cleanup(&open_req1); |
|
|
|
|
|
|
|
|
r = uv_fs_open(loop, &open_req2, "test_file2", O_WRONLY | O_CREAT, |
|
|
r = uv_fs_open(loop, &open_req2, "test_file2", O_WRONLY | O_CREAT, |
|
|
S_IWUSR | S_IRUSR, NULL); |
|
|
S_IWUSR | S_IRUSR, NULL); |
|
|
ASSERT(r != -1); |
|
|
ASSERT(r >= 0); |
|
|
ASSERT(open_req2.result != -1); |
|
|
ASSERT(open_req2.result >= 0); |
|
|
uv_fs_req_cleanup(&open_req2); |
|
|
uv_fs_req_cleanup(&open_req2); |
|
|
|
|
|
|
|
|
r = uv_fs_sendfile(loop, &sendfile_req, open_req2.result, open_req1.result, |
|
|
r = uv_fs_sendfile(loop, &sendfile_req, open_req2.result, open_req1.result, |
|
@ -910,8 +905,8 @@ TEST_IMPL(fs_fstat) { |
|
|
|
|
|
|
|
|
r = uv_fs_open(loop, &req, "test_file", O_RDWR | O_CREAT, |
|
|
r = uv_fs_open(loop, &req, "test_file", O_RDWR | O_CREAT, |
|
|
S_IWUSR | S_IRUSR, NULL); |
|
|
S_IWUSR | S_IRUSR, NULL); |
|
|
ASSERT(r != -1); |
|
|
ASSERT(r >= 0); |
|
|
ASSERT(req.result != -1); |
|
|
ASSERT(req.result >= 0); |
|
|
file = req.result; |
|
|
file = req.result; |
|
|
uv_fs_req_cleanup(&req); |
|
|
uv_fs_req_cleanup(&req); |
|
|
|
|
|
|
|
@ -947,13 +942,29 @@ TEST_IMPL(fs_fstat) { |
|
|
ASSERT(s->st_mtim.tv_nsec == t.st_mtimespec.tv_nsec); |
|
|
ASSERT(s->st_mtim.tv_nsec == t.st_mtimespec.tv_nsec); |
|
|
ASSERT(s->st_ctim.tv_sec == t.st_ctimespec.tv_sec); |
|
|
ASSERT(s->st_ctim.tv_sec == t.st_ctimespec.tv_sec); |
|
|
ASSERT(s->st_ctim.tv_nsec == t.st_ctimespec.tv_nsec); |
|
|
ASSERT(s->st_ctim.tv_nsec == t.st_ctimespec.tv_nsec); |
|
|
#elif defined(_BSD_SOURCE) || defined(_SVID_SOURCE) || defined(_XOPEN_SOURCE) |
|
|
ASSERT(s->st_birthtim.tv_sec == t.st_birthtimespec.tv_sec); |
|
|
|
|
|
ASSERT(s->st_birthtim.tv_nsec == t.st_birthtimespec.tv_nsec); |
|
|
|
|
|
ASSERT(s->st_flags == t.st_flags); |
|
|
|
|
|
ASSERT(s->st_gen == t.st_gen); |
|
|
|
|
|
#elif defined(__sun) || \ |
|
|
|
|
|
defined(_BSD_SOURCE) || \ |
|
|
|
|
|
defined(_SVID_SOURCE) || \ |
|
|
|
|
|
defined(_XOPEN_SOURCE) |
|
|
ASSERT(s->st_atim.tv_sec == t.st_atim.tv_sec); |
|
|
ASSERT(s->st_atim.tv_sec == t.st_atim.tv_sec); |
|
|
ASSERT(s->st_atim.tv_nsec == t.st_atim.tv_nsec); |
|
|
ASSERT(s->st_atim.tv_nsec == t.st_atim.tv_nsec); |
|
|
ASSERT(s->st_mtim.tv_sec == t.st_mtim.tv_sec); |
|
|
ASSERT(s->st_mtim.tv_sec == t.st_mtim.tv_sec); |
|
|
ASSERT(s->st_mtim.tv_nsec == t.st_mtim.tv_nsec); |
|
|
ASSERT(s->st_mtim.tv_nsec == t.st_mtim.tv_nsec); |
|
|
ASSERT(s->st_ctim.tv_sec == t.st_ctim.tv_sec); |
|
|
ASSERT(s->st_ctim.tv_sec == t.st_ctim.tv_sec); |
|
|
ASSERT(s->st_ctim.tv_nsec == t.st_ctim.tv_nsec); |
|
|
ASSERT(s->st_ctim.tv_nsec == t.st_ctim.tv_nsec); |
|
|
|
|
|
# if defined(__DragonFly__) || \ |
|
|
|
|
|
defined(__FreeBSD__) || \ |
|
|
|
|
|
defined(__OpenBSD__) || \ |
|
|
|
|
|
defined(__NetBSD__) |
|
|
|
|
|
ASSERT(s->st_birthtim.tv_sec == t.st_birthtim.tv_sec); |
|
|
|
|
|
ASSERT(s->st_birthtim.tv_nsec == t.st_birthtim.tv_nsec); |
|
|
|
|
|
ASSERT(s->st_flags == t.st_flags); |
|
|
|
|
|
ASSERT(s->st_gen == t.st_gen); |
|
|
|
|
|
# endif |
|
|
#else |
|
|
#else |
|
|
ASSERT(s->st_atim.tv_sec == t.st_atime); |
|
|
ASSERT(s->st_atim.tv_sec == t.st_atime); |
|
|
ASSERT(s->st_atim.tv_nsec == 0); |
|
|
ASSERT(s->st_atim.tv_nsec == 0); |
|
@ -1004,8 +1015,8 @@ TEST_IMPL(fs_chmod) { |
|
|
|
|
|
|
|
|
r = uv_fs_open(loop, &req, "test_file", O_RDWR | O_CREAT, |
|
|
r = uv_fs_open(loop, &req, "test_file", O_RDWR | O_CREAT, |
|
|
S_IWUSR | S_IRUSR, NULL); |
|
|
S_IWUSR | S_IRUSR, NULL); |
|
|
ASSERT(r != -1); |
|
|
ASSERT(r >= 0); |
|
|
ASSERT(req.result != -1); |
|
|
ASSERT(req.result >= 0); |
|
|
file = req.result; |
|
|
file = req.result; |
|
|
uv_fs_req_cleanup(&req); |
|
|
uv_fs_req_cleanup(&req); |
|
|
|
|
|
|
|
@ -1101,8 +1112,8 @@ TEST_IMPL(fs_chown) { |
|
|
|
|
|
|
|
|
r = uv_fs_open(loop, &req, "test_file", O_RDWR | O_CREAT, |
|
|
r = uv_fs_open(loop, &req, "test_file", O_RDWR | O_CREAT, |
|
|
S_IWUSR | S_IRUSR, NULL); |
|
|
S_IWUSR | S_IRUSR, NULL); |
|
|
ASSERT(r != -1); |
|
|
ASSERT(r >= 0); |
|
|
ASSERT(req.result != -1); |
|
|
ASSERT(req.result >= 0); |
|
|
file = req.result; |
|
|
file = req.result; |
|
|
uv_fs_req_cleanup(&req); |
|
|
uv_fs_req_cleanup(&req); |
|
|
|
|
|
|
|
@ -1167,8 +1178,8 @@ TEST_IMPL(fs_link) { |
|
|
|
|
|
|
|
|
r = uv_fs_open(loop, &req, "test_file", O_RDWR | O_CREAT, |
|
|
r = uv_fs_open(loop, &req, "test_file", O_RDWR | O_CREAT, |
|
|
S_IWUSR | S_IRUSR, NULL); |
|
|
S_IWUSR | S_IRUSR, NULL); |
|
|
ASSERT(r != -1); |
|
|
ASSERT(r >= 0); |
|
|
ASSERT(req.result != -1); |
|
|
ASSERT(req.result >= 0); |
|
|
file = req.result; |
|
|
file = req.result; |
|
|
uv_fs_req_cleanup(&req); |
|
|
uv_fs_req_cleanup(&req); |
|
|
|
|
|
|
|
@ -1186,15 +1197,15 @@ TEST_IMPL(fs_link) { |
|
|
uv_fs_req_cleanup(&req); |
|
|
uv_fs_req_cleanup(&req); |
|
|
|
|
|
|
|
|
r = uv_fs_open(loop, &req, "test_file_link", O_RDWR, 0, NULL); |
|
|
r = uv_fs_open(loop, &req, "test_file_link", O_RDWR, 0, NULL); |
|
|
ASSERT(r != -1); |
|
|
ASSERT(r >= 0); |
|
|
ASSERT(req.result != -1); |
|
|
ASSERT(req.result >= 0); |
|
|
link = req.result; |
|
|
link = req.result; |
|
|
uv_fs_req_cleanup(&req); |
|
|
uv_fs_req_cleanup(&req); |
|
|
|
|
|
|
|
|
memset(buf, 0, sizeof(buf)); |
|
|
memset(buf, 0, sizeof(buf)); |
|
|
r = uv_fs_read(loop, &req, link, buf, sizeof(buf), 0, NULL); |
|
|
r = uv_fs_read(loop, &req, link, buf, sizeof(buf), 0, NULL); |
|
|
ASSERT(r != -1); |
|
|
ASSERT(r >= 0); |
|
|
ASSERT(req.result != -1); |
|
|
ASSERT(req.result >= 0); |
|
|
ASSERT(strcmp(buf, test_buf) == 0); |
|
|
ASSERT(strcmp(buf, test_buf) == 0); |
|
|
|
|
|
|
|
|
close(link); |
|
|
close(link); |
|
@ -1206,15 +1217,15 @@ TEST_IMPL(fs_link) { |
|
|
ASSERT(link_cb_count == 1); |
|
|
ASSERT(link_cb_count == 1); |
|
|
|
|
|
|
|
|
r = uv_fs_open(loop, &req, "test_file_link2", O_RDWR, 0, NULL); |
|
|
r = uv_fs_open(loop, &req, "test_file_link2", O_RDWR, 0, NULL); |
|
|
ASSERT(r != -1); |
|
|
ASSERT(r >= 0); |
|
|
ASSERT(req.result != -1); |
|
|
ASSERT(req.result >= 0); |
|
|
link = req.result; |
|
|
link = req.result; |
|
|
uv_fs_req_cleanup(&req); |
|
|
uv_fs_req_cleanup(&req); |
|
|
|
|
|
|
|
|
memset(buf, 0, sizeof(buf)); |
|
|
memset(buf, 0, sizeof(buf)); |
|
|
r = uv_fs_read(loop, &req, link, buf, sizeof(buf), 0, NULL); |
|
|
r = uv_fs_read(loop, &req, link, buf, sizeof(buf), 0, NULL); |
|
|
ASSERT(r != -1); |
|
|
ASSERT(r >= 0); |
|
|
ASSERT(req.result != -1); |
|
|
ASSERT(req.result >= 0); |
|
|
ASSERT(strcmp(buf, test_buf) == 0); |
|
|
ASSERT(strcmp(buf, test_buf) == 0); |
|
|
|
|
|
|
|
|
close(link); |
|
|
close(link); |
|
@ -1243,14 +1254,12 @@ TEST_IMPL(fs_readlink) { |
|
|
ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT)); |
|
|
ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT)); |
|
|
ASSERT(dummy_cb_count == 1); |
|
|
ASSERT(dummy_cb_count == 1); |
|
|
ASSERT(req.ptr == NULL); |
|
|
ASSERT(req.ptr == NULL); |
|
|
ASSERT(req.result == -1); |
|
|
ASSERT(req.result == UV_ENOENT); |
|
|
ASSERT(req.errorno == UV_ENOENT); |
|
|
|
|
|
uv_fs_req_cleanup(&req); |
|
|
uv_fs_req_cleanup(&req); |
|
|
|
|
|
|
|
|
ASSERT(-1 == uv_fs_readlink(loop, &req, "no_such_file", NULL)); |
|
|
ASSERT(UV_ENOENT == uv_fs_readlink(loop, &req, "no_such_file", NULL)); |
|
|
ASSERT(req.ptr == NULL); |
|
|
ASSERT(req.ptr == NULL); |
|
|
ASSERT(req.result == -1); |
|
|
ASSERT(req.result == UV_ENOENT); |
|
|
ASSERT(req.errorno == UV_ENOENT); |
|
|
|
|
|
uv_fs_req_cleanup(&req); |
|
|
uv_fs_req_cleanup(&req); |
|
|
|
|
|
|
|
|
MAKE_VALGRIND_HAPPY(); |
|
|
MAKE_VALGRIND_HAPPY(); |
|
@ -1275,8 +1284,8 @@ TEST_IMPL(fs_symlink) { |
|
|
|
|
|
|
|
|
r = uv_fs_open(loop, &req, "test_file", O_RDWR | O_CREAT, |
|
|
r = uv_fs_open(loop, &req, "test_file", O_RDWR | O_CREAT, |
|
|
S_IWUSR | S_IRUSR, NULL); |
|
|
S_IWUSR | S_IRUSR, NULL); |
|
|
ASSERT(r != -1); |
|
|
ASSERT(r >= 0); |
|
|
ASSERT(req.result != -1); |
|
|
ASSERT(req.result >= 0); |
|
|
file = req.result; |
|
|
file = req.result; |
|
|
uv_fs_req_cleanup(&req); |
|
|
uv_fs_req_cleanup(&req); |
|
|
|
|
|
|
|
@ -1290,14 +1299,14 @@ TEST_IMPL(fs_symlink) { |
|
|
/* sync symlink */ |
|
|
/* sync symlink */ |
|
|
r = uv_fs_symlink(loop, &req, "test_file", "test_file_symlink", 0, NULL); |
|
|
r = uv_fs_symlink(loop, &req, "test_file", "test_file_symlink", 0, NULL); |
|
|
#ifdef _WIN32 |
|
|
#ifdef _WIN32 |
|
|
if (r == -1) { |
|
|
if (r < 0) { |
|
|
if (uv_last_error(loop).code == UV_ENOTSUP) { |
|
|
if (r == UV_ENOTSUP) { |
|
|
/*
|
|
|
/*
|
|
|
* Windows doesn't support symlinks on older versions. |
|
|
* Windows doesn't support symlinks on older versions. |
|
|
* We just pass the test and bail out early if we get ENOTSUP. |
|
|
* We just pass the test and bail out early if we get ENOTSUP. |
|
|
*/ |
|
|
*/ |
|
|
return 0; |
|
|
return 0; |
|
|
} else if (uv_last_error(loop).code == UV_EPERM) { |
|
|
} else if (r == UV_EPERM) { |
|
|
/*
|
|
|
/*
|
|
|
* Creating a symlink is only allowed when running elevated. |
|
|
* Creating a symlink is only allowed when running elevated. |
|
|
* We pass the test and bail out early if we get UV_EPERM. |
|
|
* We pass the test and bail out early if we get UV_EPERM. |
|
@ -1311,25 +1320,25 @@ TEST_IMPL(fs_symlink) { |
|
|
uv_fs_req_cleanup(&req); |
|
|
uv_fs_req_cleanup(&req); |
|
|
|
|
|
|
|
|
r = uv_fs_open(loop, &req, "test_file_symlink", O_RDWR, 0, NULL); |
|
|
r = uv_fs_open(loop, &req, "test_file_symlink", O_RDWR, 0, NULL); |
|
|
ASSERT(r != -1); |
|
|
ASSERT(r >= 0); |
|
|
ASSERT(req.result != -1); |
|
|
ASSERT(req.result >= 0); |
|
|
link = req.result; |
|
|
link = req.result; |
|
|
uv_fs_req_cleanup(&req); |
|
|
uv_fs_req_cleanup(&req); |
|
|
|
|
|
|
|
|
memset(buf, 0, sizeof(buf)); |
|
|
memset(buf, 0, sizeof(buf)); |
|
|
r = uv_fs_read(loop, &req, link, buf, sizeof(buf), 0, NULL); |
|
|
r = uv_fs_read(loop, &req, link, buf, sizeof(buf), 0, NULL); |
|
|
ASSERT(r != -1); |
|
|
ASSERT(r >= 0); |
|
|
ASSERT(req.result != -1); |
|
|
ASSERT(req.result >= 0); |
|
|
ASSERT(strcmp(buf, test_buf) == 0); |
|
|
ASSERT(strcmp(buf, test_buf) == 0); |
|
|
|
|
|
|
|
|
close(link); |
|
|
close(link); |
|
|
|
|
|
|
|
|
r = uv_fs_symlink(loop, &req, "test_file_symlink", "test_file_symlink_symlink", 0, NULL); |
|
|
r = uv_fs_symlink(loop, &req, "test_file_symlink", "test_file_symlink_symlink", 0, NULL); |
|
|
ASSERT(r != -1); |
|
|
ASSERT(r == 0); |
|
|
uv_fs_req_cleanup(&req); |
|
|
uv_fs_req_cleanup(&req); |
|
|
|
|
|
|
|
|
r = uv_fs_readlink(loop, &req, "test_file_symlink_symlink", NULL); |
|
|
r = uv_fs_readlink(loop, &req, "test_file_symlink_symlink", NULL); |
|
|
ASSERT(r != -1); |
|
|
ASSERT(r == 0); |
|
|
ASSERT(strcmp(req.ptr, "test_file_symlink") == 0); |
|
|
ASSERT(strcmp(req.ptr, "test_file_symlink") == 0); |
|
|
uv_fs_req_cleanup(&req); |
|
|
uv_fs_req_cleanup(&req); |
|
|
|
|
|
|
|
@ -1340,25 +1349,25 @@ TEST_IMPL(fs_symlink) { |
|
|
ASSERT(symlink_cb_count == 1); |
|
|
ASSERT(symlink_cb_count == 1); |
|
|
|
|
|
|
|
|
r = uv_fs_open(loop, &req, "test_file_symlink2", O_RDWR, 0, NULL); |
|
|
r = uv_fs_open(loop, &req, "test_file_symlink2", O_RDWR, 0, NULL); |
|
|
ASSERT(r != -1); |
|
|
ASSERT(r >= 0); |
|
|
ASSERT(req.result != -1); |
|
|
ASSERT(req.result >= 0); |
|
|
link = req.result; |
|
|
link = req.result; |
|
|
uv_fs_req_cleanup(&req); |
|
|
uv_fs_req_cleanup(&req); |
|
|
|
|
|
|
|
|
memset(buf, 0, sizeof(buf)); |
|
|
memset(buf, 0, sizeof(buf)); |
|
|
r = uv_fs_read(loop, &req, link, buf, sizeof(buf), 0, NULL); |
|
|
r = uv_fs_read(loop, &req, link, buf, sizeof(buf), 0, NULL); |
|
|
ASSERT(r != -1); |
|
|
ASSERT(r >= 0); |
|
|
ASSERT(req.result != -1); |
|
|
ASSERT(req.result >= 0); |
|
|
ASSERT(strcmp(buf, test_buf) == 0); |
|
|
ASSERT(strcmp(buf, test_buf) == 0); |
|
|
|
|
|
|
|
|
close(link); |
|
|
close(link); |
|
|
|
|
|
|
|
|
r = uv_fs_symlink(loop, &req, "test_file_symlink2", "test_file_symlink2_symlink", 0, NULL); |
|
|
r = uv_fs_symlink(loop, &req, "test_file_symlink2", "test_file_symlink2_symlink", 0, NULL); |
|
|
ASSERT(r != -1); |
|
|
ASSERT(r == 0); |
|
|
uv_fs_req_cleanup(&req); |
|
|
uv_fs_req_cleanup(&req); |
|
|
|
|
|
|
|
|
r = uv_fs_readlink(loop, &req, "test_file_symlink2_symlink", readlink_cb); |
|
|
r = uv_fs_readlink(loop, &req, "test_file_symlink2_symlink", readlink_cb); |
|
|
ASSERT(r != -1); |
|
|
ASSERT(r == 0); |
|
|
uv_run(loop, UV_RUN_DEFAULT); |
|
|
uv_run(loop, UV_RUN_DEFAULT); |
|
|
ASSERT(readlink_cb_count == 1); |
|
|
ASSERT(readlink_cb_count == 1); |
|
|
|
|
|
|
|
@ -1440,7 +1449,7 @@ TEST_IMPL(fs_symlink_dir) { |
|
|
|
|
|
|
|
|
r = uv_fs_open(loop, &open_req1, "test_dir/file1", O_WRONLY | O_CREAT, |
|
|
r = uv_fs_open(loop, &open_req1, "test_dir/file1", O_WRONLY | O_CREAT, |
|
|
S_IWUSR | S_IRUSR, NULL); |
|
|
S_IWUSR | S_IRUSR, NULL); |
|
|
ASSERT(r != -1); |
|
|
ASSERT(r >= 0); |
|
|
uv_fs_req_cleanup(&open_req1); |
|
|
uv_fs_req_cleanup(&open_req1); |
|
|
r = uv_fs_close(loop, &close_req, open_req1.result, NULL); |
|
|
r = uv_fs_close(loop, &close_req, open_req1.result, NULL); |
|
|
ASSERT(r == 0); |
|
|
ASSERT(r == 0); |
|
@ -1448,7 +1457,7 @@ TEST_IMPL(fs_symlink_dir) { |
|
|
|
|
|
|
|
|
r = uv_fs_open(loop, &open_req1, "test_dir/file2", O_WRONLY | O_CREAT, |
|
|
r = uv_fs_open(loop, &open_req1, "test_dir/file2", O_WRONLY | O_CREAT, |
|
|
S_IWUSR | S_IRUSR, NULL); |
|
|
S_IWUSR | S_IRUSR, NULL); |
|
|
ASSERT(r != -1); |
|
|
ASSERT(r >= 0); |
|
|
uv_fs_req_cleanup(&open_req1); |
|
|
uv_fs_req_cleanup(&open_req1); |
|
|
r = uv_fs_close(loop, &close_req, open_req1.result, NULL); |
|
|
r = uv_fs_close(loop, &close_req, open_req1.result, NULL); |
|
|
ASSERT(r == 0); |
|
|
ASSERT(r == 0); |
|
@ -1469,7 +1478,7 @@ TEST_IMPL(fs_symlink_dir) { |
|
|
uv_fs_req_cleanup(&req); |
|
|
uv_fs_req_cleanup(&req); |
|
|
|
|
|
|
|
|
r = uv_fs_readdir(loop, &readdir_req, "test_dir_symlink", 0, NULL); |
|
|
r = uv_fs_readdir(loop, &readdir_req, "test_dir_symlink", 0, NULL); |
|
|
ASSERT(r == -1); |
|
|
ASSERT(r == UV_ENOENT); |
|
|
uv_fs_req_cleanup(&readdir_req); |
|
|
uv_fs_req_cleanup(&readdir_req); |
|
|
|
|
|
|
|
|
r = uv_fs_readdir(loop, &readdir_req, "test_dir", 0, NULL); |
|
|
r = uv_fs_readdir(loop, &readdir_req, "test_dir", 0, NULL); |
|
@ -1505,8 +1514,8 @@ TEST_IMPL(fs_utime) { |
|
|
unlink(path); |
|
|
unlink(path); |
|
|
r = uv_fs_open(loop, &req, path, O_RDWR | O_CREAT, |
|
|
r = uv_fs_open(loop, &req, path, O_RDWR | O_CREAT, |
|
|
S_IWUSR | S_IRUSR, NULL); |
|
|
S_IWUSR | S_IRUSR, NULL); |
|
|
ASSERT(r != -1); |
|
|
ASSERT(r >= 0); |
|
|
ASSERT(req.result != -1); |
|
|
ASSERT(req.result >= 0); |
|
|
uv_fs_req_cleanup(&req); |
|
|
uv_fs_req_cleanup(&req); |
|
|
close(r); |
|
|
close(r); |
|
|
|
|
|
|
|
@ -1590,16 +1599,16 @@ TEST_IMPL(fs_futime) { |
|
|
unlink(path); |
|
|
unlink(path); |
|
|
r = uv_fs_open(loop, &req, path, O_RDWR | O_CREAT, |
|
|
r = uv_fs_open(loop, &req, path, O_RDWR | O_CREAT, |
|
|
S_IWUSR | S_IRUSR, NULL); |
|
|
S_IWUSR | S_IRUSR, NULL); |
|
|
ASSERT(r != -1); |
|
|
ASSERT(r >= 0); |
|
|
ASSERT(req.result != -1); |
|
|
ASSERT(req.result >= 0); |
|
|
uv_fs_req_cleanup(&req); |
|
|
uv_fs_req_cleanup(&req); |
|
|
close(r); |
|
|
close(r); |
|
|
|
|
|
|
|
|
atime = mtime = 400497753; /* 1982-09-10 11:22:33 */ |
|
|
atime = mtime = 400497753; /* 1982-09-10 11:22:33 */ |
|
|
|
|
|
|
|
|
r = uv_fs_open(loop, &req, path, O_RDWR, 0, NULL); |
|
|
r = uv_fs_open(loop, &req, path, O_RDWR, 0, NULL); |
|
|
ASSERT(r != -1); |
|
|
ASSERT(r >= 0); |
|
|
ASSERT(req.result != -1); |
|
|
ASSERT(req.result >= 0); |
|
|
file = req.result; /* FIXME probably not how it's supposed to be used */ |
|
|
file = req.result; /* FIXME probably not how it's supposed to be used */ |
|
|
uv_fs_req_cleanup(&req); |
|
|
uv_fs_req_cleanup(&req); |
|
|
|
|
|
|
|
@ -1642,9 +1651,8 @@ TEST_IMPL(fs_stat_missing_path) { |
|
|
loop = uv_default_loop(); |
|
|
loop = uv_default_loop(); |
|
|
|
|
|
|
|
|
r = uv_fs_stat(loop, &req, "non_existent_file", NULL); |
|
|
r = uv_fs_stat(loop, &req, "non_existent_file", NULL); |
|
|
ASSERT(r == -1); |
|
|
ASSERT(r == UV_ENOENT); |
|
|
ASSERT(req.result == -1); |
|
|
ASSERT(req.result == UV_ENOENT); |
|
|
ASSERT(uv_last_error(loop).code == UV_ENOENT); |
|
|
|
|
|
uv_fs_req_cleanup(&req); |
|
|
uv_fs_req_cleanup(&req); |
|
|
|
|
|
|
|
|
MAKE_VALGRIND_HAPPY(); |
|
|
MAKE_VALGRIND_HAPPY(); |
|
@ -1692,8 +1700,7 @@ TEST_IMPL(fs_readdir_file) { |
|
|
loop = uv_default_loop(); |
|
|
loop = uv_default_loop(); |
|
|
|
|
|
|
|
|
r = uv_fs_readdir(loop, &readdir_req, path, 0, NULL); |
|
|
r = uv_fs_readdir(loop, &readdir_req, path, 0, NULL); |
|
|
ASSERT(r == -1); |
|
|
ASSERT(r == UV_ENOTDIR); |
|
|
ASSERT(uv_last_error(loop).code == UV_ENOTDIR); |
|
|
|
|
|
uv_fs_req_cleanup(&readdir_req); |
|
|
uv_fs_req_cleanup(&readdir_req); |
|
|
|
|
|
|
|
|
r = uv_fs_readdir(loop, &readdir_req, path, 0, file_readdir_cb); |
|
|
r = uv_fs_readdir(loop, &readdir_req, path, 0, file_readdir_cb); |
|
@ -1717,8 +1724,8 @@ TEST_IMPL(fs_open_dir) { |
|
|
loop = uv_default_loop(); |
|
|
loop = uv_default_loop(); |
|
|
|
|
|
|
|
|
r = uv_fs_open(loop, &req, path, O_RDONLY, 0, NULL); |
|
|
r = uv_fs_open(loop, &req, path, O_RDONLY, 0, NULL); |
|
|
ASSERT(r != -1); |
|
|
ASSERT(r >= 0); |
|
|
ASSERT(req.result != -1); |
|
|
ASSERT(req.result >= 0); |
|
|
ASSERT(req.ptr == NULL); |
|
|
ASSERT(req.ptr == NULL); |
|
|
file = r; |
|
|
file = r; |
|
|
uv_fs_req_cleanup(&req); |
|
|
uv_fs_req_cleanup(&req); |
|
@ -1748,40 +1755,40 @@ TEST_IMPL(fs_file_open_append) { |
|
|
|
|
|
|
|
|
r = uv_fs_open(loop, &open_req1, "test_file", O_WRONLY | O_CREAT, |
|
|
r = uv_fs_open(loop, &open_req1, "test_file", O_WRONLY | O_CREAT, |
|
|
S_IWUSR | S_IRUSR, NULL); |
|
|
S_IWUSR | S_IRUSR, NULL); |
|
|
ASSERT(r != -1); |
|
|
ASSERT(r >= 0); |
|
|
ASSERT(open_req1.result != -1); |
|
|
ASSERT(open_req1.result >= 0); |
|
|
uv_fs_req_cleanup(&open_req1); |
|
|
uv_fs_req_cleanup(&open_req1); |
|
|
|
|
|
|
|
|
r = uv_fs_write(loop, &write_req, open_req1.result, test_buf, |
|
|
r = uv_fs_write(loop, &write_req, open_req1.result, test_buf, |
|
|
sizeof(test_buf), -1, NULL); |
|
|
sizeof(test_buf), -1, NULL); |
|
|
ASSERT(r != -1); |
|
|
ASSERT(r >= 0); |
|
|
ASSERT(write_req.result != -1); |
|
|
ASSERT(write_req.result >= 0); |
|
|
uv_fs_req_cleanup(&write_req); |
|
|
uv_fs_req_cleanup(&write_req); |
|
|
|
|
|
|
|
|
r = uv_fs_close(loop, &close_req, open_req1.result, NULL); |
|
|
r = uv_fs_close(loop, &close_req, open_req1.result, NULL); |
|
|
ASSERT(r != -1); |
|
|
ASSERT(r == 0); |
|
|
ASSERT(close_req.result != -1); |
|
|
ASSERT(close_req.result == 0); |
|
|
uv_fs_req_cleanup(&close_req); |
|
|
uv_fs_req_cleanup(&close_req); |
|
|
|
|
|
|
|
|
r = uv_fs_open(loop, &open_req1, "test_file", O_RDWR | O_APPEND, 0, NULL); |
|
|
r = uv_fs_open(loop, &open_req1, "test_file", O_RDWR | O_APPEND, 0, NULL); |
|
|
ASSERT(r != -1); |
|
|
ASSERT(r >= 0); |
|
|
ASSERT(open_req1.result != -1); |
|
|
ASSERT(open_req1.result >= 0); |
|
|
uv_fs_req_cleanup(&open_req1); |
|
|
uv_fs_req_cleanup(&open_req1); |
|
|
|
|
|
|
|
|
r = uv_fs_write(loop, &write_req, open_req1.result, test_buf, |
|
|
r = uv_fs_write(loop, &write_req, open_req1.result, test_buf, |
|
|
sizeof(test_buf), -1, NULL); |
|
|
sizeof(test_buf), -1, NULL); |
|
|
ASSERT(r != -1); |
|
|
ASSERT(r >= 0); |
|
|
ASSERT(write_req.result != -1); |
|
|
ASSERT(write_req.result >= 0); |
|
|
uv_fs_req_cleanup(&write_req); |
|
|
uv_fs_req_cleanup(&write_req); |
|
|
|
|
|
|
|
|
r = uv_fs_close(loop, &close_req, open_req1.result, NULL); |
|
|
r = uv_fs_close(loop, &close_req, open_req1.result, NULL); |
|
|
ASSERT(r != -1); |
|
|
ASSERT(r == 0); |
|
|
ASSERT(close_req.result != -1); |
|
|
ASSERT(close_req.result == 0); |
|
|
uv_fs_req_cleanup(&close_req); |
|
|
uv_fs_req_cleanup(&close_req); |
|
|
|
|
|
|
|
|
r = uv_fs_open(loop, &open_req1, "test_file", O_RDONLY, S_IRUSR, NULL); |
|
|
r = uv_fs_open(loop, &open_req1, "test_file", O_RDONLY, S_IRUSR, NULL); |
|
|
ASSERT(r != -1); |
|
|
ASSERT(r >= 0); |
|
|
ASSERT(open_req1.result != -1); |
|
|
ASSERT(open_req1.result >= 0); |
|
|
uv_fs_req_cleanup(&open_req1); |
|
|
uv_fs_req_cleanup(&open_req1); |
|
|
|
|
|
|
|
|
r = uv_fs_read(loop, &read_req, open_req1.result, buf, sizeof(buf), -1, |
|
|
r = uv_fs_read(loop, &read_req, open_req1.result, buf, sizeof(buf), -1, |
|
@ -1795,8 +1802,8 @@ TEST_IMPL(fs_file_open_append) { |
|
|
uv_fs_req_cleanup(&read_req); |
|
|
uv_fs_req_cleanup(&read_req); |
|
|
|
|
|
|
|
|
r = uv_fs_close(loop, &close_req, open_req1.result, NULL); |
|
|
r = uv_fs_close(loop, &close_req, open_req1.result, NULL); |
|
|
ASSERT(r != -1); |
|
|
ASSERT(r == 0); |
|
|
ASSERT(close_req.result != -1); |
|
|
ASSERT(close_req.result == 0); |
|
|
uv_fs_req_cleanup(&close_req); |
|
|
uv_fs_req_cleanup(&close_req); |
|
|
|
|
|
|
|
|
/* Cleanup */ |
|
|
/* Cleanup */ |
|
@ -1818,53 +1825,53 @@ TEST_IMPL(fs_rename_to_existing_file) { |
|
|
|
|
|
|
|
|
r = uv_fs_open(loop, &open_req1, "test_file", O_WRONLY | O_CREAT, |
|
|
r = uv_fs_open(loop, &open_req1, "test_file", O_WRONLY | O_CREAT, |
|
|
S_IWUSR | S_IRUSR, NULL); |
|
|
S_IWUSR | S_IRUSR, NULL); |
|
|
ASSERT(r != -1); |
|
|
ASSERT(r >= 0); |
|
|
ASSERT(open_req1.result != -1); |
|
|
ASSERT(open_req1.result >= 0); |
|
|
uv_fs_req_cleanup(&open_req1); |
|
|
uv_fs_req_cleanup(&open_req1); |
|
|
|
|
|
|
|
|
r = uv_fs_write(loop, &write_req, open_req1.result, test_buf, |
|
|
r = uv_fs_write(loop, &write_req, open_req1.result, test_buf, |
|
|
sizeof(test_buf), -1, NULL); |
|
|
sizeof(test_buf), -1, NULL); |
|
|
ASSERT(r != -1); |
|
|
ASSERT(r >= 0); |
|
|
ASSERT(write_req.result != -1); |
|
|
ASSERT(write_req.result >= 0); |
|
|
uv_fs_req_cleanup(&write_req); |
|
|
uv_fs_req_cleanup(&write_req); |
|
|
|
|
|
|
|
|
r = uv_fs_close(loop, &close_req, open_req1.result, NULL); |
|
|
r = uv_fs_close(loop, &close_req, open_req1.result, NULL); |
|
|
ASSERT(r != -1); |
|
|
ASSERT(r == 0); |
|
|
ASSERT(close_req.result != -1); |
|
|
ASSERT(close_req.result == 0); |
|
|
uv_fs_req_cleanup(&close_req); |
|
|
uv_fs_req_cleanup(&close_req); |
|
|
|
|
|
|
|
|
r = uv_fs_open(loop, &open_req1, "test_file2", O_WRONLY | O_CREAT, |
|
|
r = uv_fs_open(loop, &open_req1, "test_file2", O_WRONLY | O_CREAT, |
|
|
S_IWUSR | S_IRUSR, NULL); |
|
|
S_IWUSR | S_IRUSR, NULL); |
|
|
ASSERT(r != -1); |
|
|
ASSERT(r >= 0); |
|
|
ASSERT(open_req1.result != -1); |
|
|
ASSERT(open_req1.result >= 0); |
|
|
uv_fs_req_cleanup(&open_req1); |
|
|
uv_fs_req_cleanup(&open_req1); |
|
|
|
|
|
|
|
|
r = uv_fs_close(loop, &close_req, open_req1.result, NULL); |
|
|
r = uv_fs_close(loop, &close_req, open_req1.result, NULL); |
|
|
ASSERT(r != -1); |
|
|
ASSERT(r == 0); |
|
|
ASSERT(close_req.result != -1); |
|
|
ASSERT(close_req.result == 0); |
|
|
uv_fs_req_cleanup(&close_req); |
|
|
uv_fs_req_cleanup(&close_req); |
|
|
|
|
|
|
|
|
r = uv_fs_rename(loop, &rename_req, "test_file", "test_file2", NULL); |
|
|
r = uv_fs_rename(loop, &rename_req, "test_file", "test_file2", NULL); |
|
|
ASSERT(r != -1); |
|
|
ASSERT(r == 0); |
|
|
ASSERT(rename_req.result != -1); |
|
|
ASSERT(rename_req.result == 0); |
|
|
uv_fs_req_cleanup(&rename_req); |
|
|
uv_fs_req_cleanup(&rename_req); |
|
|
|
|
|
|
|
|
r = uv_fs_open(loop, &open_req1, "test_file2", O_RDONLY, 0, NULL); |
|
|
r = uv_fs_open(loop, &open_req1, "test_file2", O_RDONLY, 0, NULL); |
|
|
ASSERT(r != -1); |
|
|
ASSERT(r >= 0); |
|
|
ASSERT(open_req1.result != -1); |
|
|
ASSERT(open_req1.result >= 0); |
|
|
uv_fs_req_cleanup(&open_req1); |
|
|
uv_fs_req_cleanup(&open_req1); |
|
|
|
|
|
|
|
|
memset(buf, 0, sizeof(buf)); |
|
|
memset(buf, 0, sizeof(buf)); |
|
|
r = uv_fs_read(loop, &read_req, open_req1.result, buf, sizeof(buf), -1, |
|
|
r = uv_fs_read(loop, &read_req, open_req1.result, buf, sizeof(buf), -1, |
|
|
NULL); |
|
|
NULL); |
|
|
ASSERT(r != -1); |
|
|
ASSERT(r >= 0); |
|
|
ASSERT(read_req.result != -1); |
|
|
ASSERT(read_req.result >= 0); |
|
|
ASSERT(strcmp(buf, test_buf) == 0); |
|
|
ASSERT(strcmp(buf, test_buf) == 0); |
|
|
uv_fs_req_cleanup(&read_req); |
|
|
uv_fs_req_cleanup(&read_req); |
|
|
|
|
|
|
|
|
r = uv_fs_close(loop, &close_req, open_req1.result, NULL); |
|
|
r = uv_fs_close(loop, &close_req, open_req1.result, NULL); |
|
|
ASSERT(r != -1); |
|
|
ASSERT(r == 0); |
|
|
ASSERT(close_req.result != -1); |
|
|
ASSERT(close_req.result == 0); |
|
|
uv_fs_req_cleanup(&close_req); |
|
|
uv_fs_req_cleanup(&close_req); |
|
|
|
|
|
|
|
|
/* Cleanup */ |
|
|
/* Cleanup */ |
|
@ -1886,31 +1893,31 @@ TEST_IMPL(fs_read_file_eof) { |
|
|
|
|
|
|
|
|
r = uv_fs_open(loop, &open_req1, "test_file", O_WRONLY | O_CREAT, |
|
|
r = uv_fs_open(loop, &open_req1, "test_file", O_WRONLY | O_CREAT, |
|
|
S_IWUSR | S_IRUSR, NULL); |
|
|
S_IWUSR | S_IRUSR, NULL); |
|
|
ASSERT(r != -1); |
|
|
ASSERT(r >= 0); |
|
|
ASSERT(open_req1.result != -1); |
|
|
ASSERT(open_req1.result >= 0); |
|
|
uv_fs_req_cleanup(&open_req1); |
|
|
uv_fs_req_cleanup(&open_req1); |
|
|
|
|
|
|
|
|
r = uv_fs_write(loop, &write_req, open_req1.result, test_buf, |
|
|
r = uv_fs_write(loop, &write_req, open_req1.result, test_buf, |
|
|
sizeof(test_buf), -1, NULL); |
|
|
sizeof(test_buf), -1, NULL); |
|
|
ASSERT(r != -1); |
|
|
ASSERT(r >= 0); |
|
|
ASSERT(write_req.result != -1); |
|
|
ASSERT(write_req.result >= 0); |
|
|
uv_fs_req_cleanup(&write_req); |
|
|
uv_fs_req_cleanup(&write_req); |
|
|
|
|
|
|
|
|
r = uv_fs_close(loop, &close_req, open_req1.result, NULL); |
|
|
r = uv_fs_close(loop, &close_req, open_req1.result, NULL); |
|
|
ASSERT(r != -1); |
|
|
ASSERT(r == 0); |
|
|
ASSERT(close_req.result != -1); |
|
|
ASSERT(close_req.result == 0); |
|
|
uv_fs_req_cleanup(&close_req); |
|
|
uv_fs_req_cleanup(&close_req); |
|
|
|
|
|
|
|
|
r = uv_fs_open(loop, &open_req1, "test_file", O_RDONLY, 0, NULL); |
|
|
r = uv_fs_open(loop, &open_req1, "test_file", O_RDONLY, 0, NULL); |
|
|
ASSERT(r != -1); |
|
|
ASSERT(r >= 0); |
|
|
ASSERT(open_req1.result != -1); |
|
|
ASSERT(open_req1.result >= 0); |
|
|
uv_fs_req_cleanup(&open_req1); |
|
|
uv_fs_req_cleanup(&open_req1); |
|
|
|
|
|
|
|
|
memset(buf, 0, sizeof(buf)); |
|
|
memset(buf, 0, sizeof(buf)); |
|
|
r = uv_fs_read(loop, &read_req, open_req1.result, buf, sizeof(buf), -1, |
|
|
r = uv_fs_read(loop, &read_req, open_req1.result, buf, sizeof(buf), -1, |
|
|
NULL); |
|
|
NULL); |
|
|
ASSERT(r != -1); |
|
|
ASSERT(r >= 0); |
|
|
ASSERT(read_req.result != -1); |
|
|
ASSERT(read_req.result >= 0); |
|
|
ASSERT(strcmp(buf, test_buf) == 0); |
|
|
ASSERT(strcmp(buf, test_buf) == 0); |
|
|
uv_fs_req_cleanup(&read_req); |
|
|
uv_fs_req_cleanup(&read_req); |
|
|
|
|
|
|
|
@ -1921,8 +1928,8 @@ TEST_IMPL(fs_read_file_eof) { |
|
|
uv_fs_req_cleanup(&read_req); |
|
|
uv_fs_req_cleanup(&read_req); |
|
|
|
|
|
|
|
|
r = uv_fs_close(loop, &close_req, open_req1.result, NULL); |
|
|
r = uv_fs_close(loop, &close_req, open_req1.result, NULL); |
|
|
ASSERT(r != -1); |
|
|
ASSERT(r == 0); |
|
|
ASSERT(close_req.result != -1); |
|
|
ASSERT(close_req.result == 0); |
|
|
uv_fs_req_cleanup(&close_req); |
|
|
uv_fs_req_cleanup(&close_req); |
|
|
|
|
|
|
|
|
/* Cleanup */ |
|
|
/* Cleanup */ |
|
|