Skip to content

Commit e046897

Browse files
authored
test: initgroups: compare result group lists without order (#2385)
Fixes issue #2384
1 parent f129095 commit e046897

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

test/test_unistd.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,12 +313,15 @@ fn test_initgroups() {
313313
// groups that the user belongs to are also set.
314314
let user = CString::new("root").unwrap();
315315
let group = Gid::from_raw(123);
316-
let group_list = getgrouplist(&user, group).unwrap();
316+
let mut group_list = getgrouplist(&user, group).unwrap();
317317
assert!(group_list.contains(&group));
318318

319319
initgroups(&user, group).unwrap();
320320

321-
let new_groups = getgroups().unwrap();
321+
let mut new_groups = getgroups().unwrap();
322+
323+
new_groups.sort_by_key(|gid| gid.as_raw());
324+
group_list.sort_by_key(|gid| gid.as_raw());
322325
assert_eq!(new_groups, group_list);
323326

324327
// Revert back to the old groups

0 commit comments

Comments
 (0)