Author: brd (doc committer)
Date: Mon Feb  9 21:15:52 2015
New Revision: 278475
URL: https://svnweb.freebsd.org/changeset/base/278475

Log:
  Add tests for `pw usernext'.
  
  PR:           197120
  Submitted by: Robert O'Neil <oneil...@gmail.com>
  Approved by:  will

Added:
  head/usr.sbin/pw/tests/pw_usernext.sh   (contents, props changed)
Modified:
  head/usr.sbin/pw/tests/Makefile

Modified: head/usr.sbin/pw/tests/Makefile
==============================================================================
--- head/usr.sbin/pw/tests/Makefile     Mon Feb  9 21:03:23 2015        
(r278474)
+++ head/usr.sbin/pw/tests/Makefile     Mon Feb  9 21:15:52 2015        
(r278475)
@@ -11,7 +11,8 @@ ATF_TESTS_SH= pw_etcdir \
                pw_groupmod \
                pw_useradd \
                pw_userdel \
-               pw_usermod
+               pw_usermod \
+               pw_usernext
 
 .for tp in ${ATF_TESTS_SH}
 TEST_METADATA.${tp}+=  required_user="root"

Added: head/usr.sbin/pw/tests/pw_usernext.sh
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/usr.sbin/pw/tests/pw_usernext.sh       Mon Feb  9 21:15:52 2015        
(r278475)
@@ -0,0 +1,42 @@
+# $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
+
+       var0=1
+       LIMIT=`jot -r 1 2 10`
+       while [ "$var0" -lt "$LIMIT" ]
+       do
+               atf_check -s exit:0 ${PW} useradd test$var0
+               var0=`expr $var0 + 1`
+       done
+       atf_check -s exit:0 -o match:"100${LIMIT}:100${LIMIT}" \
+               ${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
+
+       var0=1
+       LIMIT=`jot -r 1 2 10`
+       while [ "$var0" -lt "$LIMIT" ]
+       do
+               atf_check -s exit:0 ${PW} useradd -n test$var0 -g 0
+               var0=`expr $var0 + 1`
+       done
+       atf_check -s exit:0 -o match:"100${LIMIT}:1001}" \
+               ${PW} usernext
+}
+
+atf_init_test_cases() {
+       atf_add_test_case usernext
+       atf_add_test_case usernext_assigned_group
+}
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to