Skip to content

Commit

Permalink
p_shadow-utils: use next guid for group tests
Browse files Browse the repository at this point in the history
There is a possibility that the guid 1010 is in used during the test and
could make it fail. Picking the next available guid works around that
possibility, while letting the test still test the same scenario.
  • Loading branch information
carlosrodfern committed Oct 30, 2024
1 parent 19551e9 commit 17f84b7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
3 changes: 2 additions & 1 deletion tests/p_shadow-utils/30-groupadd_tests
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ t_Log "Running $0 group add tests"
sed -i /testgroup/d /etc/group

echo "Create a new group"
groupadd -g 1010 testgroup
next_guid=$((10+$(awk -F: '{print $3}' /etc/group | sort | tail -1)))
groupadd -g $next_guid testgroup
t_CheckExitStatus $?
7 changes: 4 additions & 3 deletions tests/p_shadow-utils/34-groupmod_tests
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
t_Log "Running $0"

# Check that the testgroup exists with GID 1010
grep -q "testgroup:x:1010:testshadow" /etc/group || { t_Log "FAIL Test group doesn't exist"; exit $FAIL; }
grep -q "^testgroup:" /etc/group || { t_Log "FAIL Test group doesn't exist"; exit $FAIL; }

echo "Changing GID for group testgroup to 1011"
groupmod -g 1011 testgroup
next_guid=$((10+$(awk -F: '{print $3}' /etc/group | sort | tail -1)))
echo "Changing GID for group testgroup to $next_guid"
groupmod -g $next_guid testgroup
t_CheckExitStatus $?

0 comments on commit 17f84b7

Please sign in to comment.