From 1067b6cb2c8fd43f95b39217c34c2003a2f0f0e3 Mon Sep 17 00:00:00 2001 From: Jonathan Krebs Date: Mon, 22 Apr 2024 20:56:25 +0200 Subject: [PATCH] test: initgroups: compare result group lists without order Fixes issue #2384 --- test/test_unistd.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/test/test_unistd.rs b/test/test_unistd.rs index aa2e5e56d7..6ccf59fb05 100644 --- a/test/test_unistd.rs +++ b/test/test_unistd.rs @@ -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