test: fix fs_chown when running as root

chown(2) to root is expected to fail - unless you're root, of course.
This commit is contained in:
Ben Noordhuis 2013-07-02 13:39:24 +02:00
parent d4f6165346
commit d0be852cb1

View File

@ -196,9 +196,16 @@ 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 == -1);
ASSERT(req->errorno == UV_EPERM);
}
#endif #endif
chown_cb_count++; chown_cb_count++;
uv_fs_req_cleanup(req); uv_fs_req_cleanup(req);