]> CyberLeo.Net >> Repos - FreeBSD/releng/10.2.git/blob - usr.sbin/pw/tests/pw_usernext.sh
- Copy stable/10@285827 to releng/10.2 in preparation for 10.2-RC1
[FreeBSD/releng/10.2.git] / usr.sbin / pw / tests / pw_usernext.sh
1 # $FreeBSD$
2
3 # Import helper functions
4 . $(atf_get_srcdir)/helper_functions.shin
5
6 # Test usernext after adding a random number of new users.
7 atf_test_case usernext
8 usernext_body() {
9         populate_etc_skel
10
11         CURRENT=`${PW} usernext | sed -e 's/:.*//'`
12         RANDOM=`jot -r 1 1 150`
13         MAX=`expr ${CURRENT} + ${RANDOM}`
14         while [ "${CURRENT}" -lt "${MAX}" ]
15         do
16                 atf_check -s exit:0 ${PW} useradd test${CURRENT}
17                 CURRENT=`expr ${CURRENT} + 1`
18         done
19         atf_check -s exit:0 -o match:"${CURRENT}:${CURRENT}" \
20                 ${PW} usernext
21 }
22
23 # Test usernext when multiple users are added to the same group so 
24 # that group id doesn't increment at the same pace as new users.
25 atf_test_case usernext_assigned_group
26 usernext_assigned_group_body() {
27         populate_etc_skel
28
29         CURRENT=`${PW} usernext | sed -e 's/:.*//'`
30         CURRENTGID=`${PW} groupnext`
31         RANDOM=`jot -r 1 1 150`
32         MAX=`expr ${CURRENT} + ${RANDOM}`
33         while [ "${CURRENT}" -lt "${MAX}" ]
34         do
35                 atf_check -s exit:0 ${PW} useradd -n test${CURRENT} -g 0
36                 CURRENT=`expr ${CURRENT} + 1`
37         done
38         atf_check -s exit:0 -o match:"${CURRENT}:${CURRENTGID}" \
39                 ${PW} usernext
40 }
41
42 atf_init_test_cases() {
43         atf_add_test_case usernext
44         atf_add_test_case usernext_assigned_group
45 }