Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'deps/uv/test/test-get-passwd.c')
-rw-r--r--deps/uv/test/test-get-passwd.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/deps/uv/test/test-get-passwd.c b/deps/uv/test/test-get-passwd.c
index 865c07d6515..d2c7431fe7f 100644
--- a/deps/uv/test/test-get-passwd.c
+++ b/deps/uv/test/test-get-passwd.c
@@ -22,6 +22,10 @@
#include "uv.h"
#include "task.h"
#include <string.h>
+#ifndef _WIN32
+#include <unistd.h>
+#include <sys/types.h>
+#endif
TEST_IMPL(get_passwd) {
/* TODO(gengjiawen): Fix test on QEMU. */
@@ -64,11 +68,15 @@ TEST_IMPL(get_passwd) {
#endif
#ifdef _WIN32
- ASSERT(pwd.uid == -1);
- ASSERT(pwd.gid == -1);
+ ASSERT_EQ(pwd.uid, (unsigned)-1);
+ ASSERT_EQ(pwd.gid, (unsigned)-1);
#else
- ASSERT(pwd.uid >= 0);
- ASSERT(pwd.gid >= 0);
+ ASSERT_NE(pwd.uid, (unsigned)-1);
+ ASSERT_NE(pwd.gid, (unsigned)-1);
+ ASSERT_EQ(pwd.uid, geteuid());
+ if (pwd.uid != 0 && pwd.gid != getgid())
+ /* This will be likely true, as only root could have changed it. */
+ ASSERT_EQ(pwd.gid, getegid());
#endif
/* Test uv_os_free_passwd() */