Author: bapt
Date: Sun Jul 12 09:42:10 2015
New Revision: 285418
URL: https://svnweb.freebsd.org/changeset/base/285418

Log:
  Add minimum regression tests for pw -R

Modified:
  head/usr.sbin/pw/tests/helper_functions.shin
  head/usr.sbin/pw/tests/pw_useradd.sh

Modified: head/usr.sbin/pw/tests/helper_functions.shin
==============================================================================
--- head/usr.sbin/pw/tests/helper_functions.shin        Sun Jul 12 03:39:36 
2015        (r285417)
+++ head/usr.sbin/pw/tests/helper_functions.shin        Sun Jul 12 09:42:10 
2015        (r285418)
@@ -2,11 +2,12 @@
 
 # The pw command
 PW="pw -V ${HOME}"
+RPW="pw -R ${HOME}"
 
 # Workdir to run tests in
 TESTDIR=$(atf_get_srcdir)
 
-# Populate the files pw needs to use into $HOME/etc
+# Populate the files pw needs to use into $HOME
 populate_etc_skel() {
        cp ${TESTDIR}/master.passwd ${HOME} || \
                atf_fail "Populating master.passwd in ${HOME}"
@@ -16,3 +17,16 @@ populate_etc_skel() {
        pwd_mkdb -p -d ${HOME} ${HOME}/master.passwd || \
                atf_fail "generate passwd from master.passwd"
 }
+
+# Populate the files pw needs to use into $HOME/etc
+populate_root_etc_skel() {
+       mkdir ${HOME}/etc
+       cp ${TESTDIR}/master.passwd ${HOME}/etc || \
+               atf_fail "Populating master.passwd in ${HOME}/etc"
+       cp ${TESTDIR}/group ${HOME}/etc || \
+               atf_fail "Populating group in ${HOME}/etc"
+
+       # Generate the passwd file
+       pwd_mkdb -p -d ${HOME}/etc ${HOME}//etc/master.passwd || \
+               atf_fail "generate passwd from master.passwd"
+}

Modified: head/usr.sbin/pw/tests/pw_useradd.sh
==============================================================================
--- head/usr.sbin/pw/tests/pw_useradd.sh        Sun Jul 12 03:39:36 2015        
(r285417)
+++ head/usr.sbin/pw/tests/pw_useradd.sh        Sun Jul 12 09:42:10 2015        
(r285418)
@@ -240,6 +240,21 @@ user_add_password_from_h_body() {
        EOF
 }
 
+atf_test_case user_add_R
+user_add_R_body() {
+       populate_root_etc_skel
+
+       atf_check -s exit:0 ${RPW} useradd foo
+       mkdir -p ${HOME}/home
+       atf_check -s exit:0 ${RPW} useradd bar -m
+       test -d ${HOME}/home/bar || atf_fail "Directory not created"
+       atf_check -s exit:0 ${RPW} userdel bar
+       test -d ${HOME}/home/bar || atf_fail "Directory removed"
+#      atf_check -s exit:0 ${RPW} useradd bar
+#      atf_check -s exit:0 ${RPW} userdel bar -r
+#      test -d ${HOME}/home/bar && atf_fail "Directory not removed"
+}
+
 atf_init_test_cases() {
        atf_add_test_case user_add
        atf_add_test_case user_add_noupdate
@@ -261,4 +276,5 @@ atf_init_test_cases() {
        atf_add_test_case user_add_invalid_user_entry
        atf_add_test_case user_add_invalid_group_entry
        atf_add_test_case user_add_password_from_h
+       atf_add_test_case user_add_R
 }
_______________________________________________
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