summaryrefslogtreecommitdiff
path: root/tests/grp_pwd_test.cpp
diff options
context:
space:
mode:
authorJustin DeMartino <jjdemartino@google.com>2020-09-21 13:23:58 -0700
committerJustin DeMartino <jjdemartino@google.com>2020-09-21 13:23:58 -0700
commit7e4fe6a28b718ab97c08811566238af2893ca65b (patch)
tree5413a5ec890b5a1ac4fbbe4548b5014e41a2591b /tests/grp_pwd_test.cpp
parentdcdcb3fa15004669823a3a118189d9d72ff30852 (diff)
parentab08b955a34423d53b28a6210e7530e67241af4a (diff)
Merge SP1A.200921.001
Change-Id: Id2ab019914bb555dadf52c46b8403c0d5fb3c20a
Diffstat (limited to 'tests/grp_pwd_test.cpp')
-rw-r--r--tests/grp_pwd_test.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/grp_pwd_test.cpp b/tests/grp_pwd_test.cpp
index 99117e45b..bf65720f9 100644
--- a/tests/grp_pwd_test.cpp
+++ b/tests/grp_pwd_test.cpp
@@ -820,6 +820,24 @@ TEST(grp, getgrent_iterate) {
#endif
}
+TEST(grp, getgrouplist) {
+#if defined(__BIONIC__)
+ // Query the number of groups.
+ int ngroups = 0;
+ ASSERT_EQ(-1, getgrouplist("root", 123, nullptr, &ngroups));
+ ASSERT_EQ(1, ngroups);
+
+ // Query the specific groups (just the one you pass in on Android).
+ ngroups = 8;
+ gid_t groups[ngroups];
+ ASSERT_EQ(1, getgrouplist("root", 123, groups, &ngroups));
+ ASSERT_EQ(1, ngroups);
+ ASSERT_EQ(123u, groups[0]);
+#else
+ GTEST_SKIP() << "bionic-only test (groups too unpredictable)";
+#endif
+}
+
#if defined(__BIONIC__)
static void TestAidNamePrefix(const std::string& file_path) {
std::string file_contents;