Home | History | Annotate | Download | only in tests

Lines Matching refs:pwd

21 #include <pwd.h>
47 static void check_passwd(const passwd* pwd, const char* username, uid_t uid, uid_type_t uid_type,
49 ASSERT_TRUE(pwd != NULL);
51 EXPECT_STREQ(username, pwd->pw_name);
53 EXPECT_EQ(uid, pwd->pw_uid);
54 EXPECT_EQ(uid, pwd->pw_gid);
55 EXPECT_EQ(NULL, pwd->pw_passwd);
57 EXPECT_EQ(NULL, pwd->pw_gecos);
61 EXPECT_STREQ("/", pwd->pw_dir);
63 EXPECT_STREQ("/data", pwd->pw_dir);
65 EXPECT_STREQ("/system/bin/sh", pwd->pw_shell);
71 passwd* pwd = getpwuid(uid);
74 check_passwd(pwd, username, uid, uid_type, check_username);
80 passwd* pwd = getpwnam(username);
83 check_passwd(pwd, username, uid, uid_type, check_username);
93 passwd* pwd = NULL;
94 result = getpwuid_r(uid, &pwd_storage, buf, sizeof(buf), &pwd);
98 check_passwd(pwd, username, uid, uid_type, check_username);
108 passwd* pwd = NULL;
109 result = getpwnam_r(username, &pwd_storage, buf, sizeof(buf), &pwd);
113 check_passwd(pwd, username, uid, uid_type, check_username);
141 TEST(pwd, getpwnam_system_id_root) {
145 TEST(pwd, getpwnam_system_id_system) {
149 TEST(pwd, getpwnam_app_id_radio) {
153 TEST(pwd, getpwnam_oem_id_5000) {
157 TEST(pwd, getpwnam_oem_id_5999) {
161 TEST(pwd, getpwnam_oem_id_2900) {
165 TEST(pwd, getpwnam_oem_id_2999) {
169 TEST(pwd, getpwnam_app_id_nobody) {
173 TEST(pwd, getpwnam_app_id_u0_a0) {
177 TEST(pwd, getpwnam_app_id_u0_a1234) {
182 TEST(pwd, getpwnam_app_id_u0_a49999) {
186 TEST(pwd, getpwnam_app_id_u0_i1) {
190 TEST(pwd, getpwnam_app_id_u1_root) {
194 TEST(pwd, getpwnam_app_id_u1_radio) {
198 TEST(pwd, getpwnam_app_id_u1_a0) {
202 TEST(pwd, getpwnam_app_id_u1_a40000) {
206 TEST(pwd, getpwnam_app_id_u1_i0) {
257 TEST(pwd, getpwent_iterate) {
259 passwd* pwd;
263 while ((pwd = getpwent()) != NULL) {
264 ASSERT_TRUE(NULL != pwd->pw_name);
266 EXPECT_EQ(pwd->pw_gid, pwd->pw_uid) << "pwd->pw_uid: " << pwd->pw_uid;
267 EXPECT_EQ(NULL, pwd->pw_passwd) << "pwd->pw_uid: " << pwd->pw_uid;
269 EXPECT_TRUE(NULL == pwd->pw_gecos) << "pwd->pw_uid: " << pwd->pw_uid;
271 EXPECT_TRUE(NULL != pwd->pw_shell);
272 if (pwd->pw_uid < AID_APP_START || pwd->pw_uid == AID_OVERFLOWUID) {
273 EXPECT_STREQ("/", pwd->pw_dir) << "pwd->pw_uid: " << pwd->pw_uid;
275 EXPECT_STREQ("/data", pwd->pw_dir) << "pwd->pw_uid: " << pwd->pw_uid;
278 EXPECT_EQ(0U, uids.count(pwd->pw_uid)) << "pwd->pw_uid: " << pwd->pw_uid;
279 uids.emplace(pwd->pw_uid);