Skip to content

Commit

Permalink
test: initgroups: compare result group lists without order (#2385)
Browse files Browse the repository at this point in the history
Fixes issue #2384
  • Loading branch information
TheJonny authored Apr 23, 2024
1 parent f129095 commit e046897
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions test/test_unistd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,12 +313,15 @@ fn test_initgroups() {
// groups that the user belongs to are also set.
let user = CString::new("root").unwrap();
let group = Gid::from_raw(123);
let group_list = getgrouplist(&user, group).unwrap();
let mut group_list = getgrouplist(&user, group).unwrap();
assert!(group_list.contains(&group));

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

let new_groups = getgroups().unwrap();
let mut new_groups = getgroups().unwrap();

new_groups.sort_by_key(|gid| gid.as_raw());
group_list.sort_by_key(|gid| gid.as_raw());
assert_eq!(new_groups, group_list);

// Revert back to the old groups
Expand Down

0 comments on commit e046897

Please sign in to comment.