summaryrefslogtreecommitdiffstats
path: root/pw/tests/pw_usernext.sh
diff options
context:
space:
mode:
authorSimon J. Gerraty <sjg@FreeBSD.org>2015-05-27 01:19:58 +0000
committerSimon J. Gerraty <sjg@FreeBSD.org>2015-05-27 01:19:58 +0000
commitd8b9e0faa3460c476b2e30e33f85d3c45d75832b (patch)
tree718a4865bc637195eba03ee314533bf4505046c9 /pw/tests/pw_usernext.sh
parent07f6546979612511fa7f69bea50fe257e8ae562a (diff)
parent31af648934ea1701d783359919da4009225e7477 (diff)
downloadpw-darwin-d8b9e0faa3460c476b2e30e33f85d3c45d75832b.tar.gz
pw-darwin-d8b9e0faa3460c476b2e30e33f85d3c45d75832b.zip
Merge sync of head
Diffstat (limited to 'pw/tests/pw_usernext.sh')
-rwxr-xr-xpw/tests/pw_usernext.sh45
1 files changed, 45 insertions, 0 deletions
diff --git a/pw/tests/pw_usernext.sh b/pw/tests/pw_usernext.sh
new file mode 100755
index 0000000..89f938e
--- /dev/null
+++ b/pw/tests/pw_usernext.sh
@@ -0,0 +1,45 @@
+# $FreeBSD$
+
+# Import helper functions
+. $(atf_get_srcdir)/helper_functions.shin
+
+# Test usernext after adding a random number of new users.
+atf_test_case usernext
+usernext_body() {
+ populate_etc_skel
+
+ CURRENT=`${PW} usernext | sed -e 's/:.*//'`
+ RANDOM=`jot -r 1 1 150`
+ MAX=`expr ${CURRENT} + ${RANDOM}`
+ while [ "${CURRENT}" -lt "${MAX}" ]
+ do
+ atf_check -s exit:0 ${PW} useradd test${CURRENT}
+ CURRENT=`expr ${CURRENT} + 1`
+ done
+ atf_check -s exit:0 -o match:"${CURRENT}:${CURRENT}" \
+ ${PW} usernext
+}
+
+# Test usernext when multiple users are added to the same group so
+# that group id doesn't increment at the same pace as new users.
+atf_test_case usernext_assigned_group
+usernext_assigned_group_body() {
+ populate_etc_skel
+
+ CURRENT=`${PW} usernext | sed -e 's/:.*//'`
+ CURRENTGID=`${PW} groupnext`
+ RANDOM=`jot -r 1 1 150`
+ MAX=`expr ${CURRENT} + ${RANDOM}`
+ while [ "${CURRENT}" -lt "${MAX}" ]
+ do
+ atf_check -s exit:0 ${PW} useradd -n test${CURRENT} -g 0
+ CURRENT=`expr ${CURRENT} + 1`
+ done
+ atf_check -s exit:0 -o match:"${CURRENT}:${CURRENTGID}" \
+ ${PW} usernext
+}
+
+atf_init_test_cases() {
+ atf_add_test_case usernext
+ atf_add_test_case usernext_assigned_group
+}