svn commit: r274727 - head/usr.sbin/pw/tests

Brad Davis brd at FreeBSD.org
Wed Nov 19 23:07:48 UTC 2014


Author: brd (doc committer)
Date: Wed Nov 19 23:07:46 2014
New Revision: 274727
URL: https://svnweb.freebsd.org/changeset/base/274727

Log:
  Replace the pw(1) calls with a variable, to make it easier to to change across all the tests as needed.
  
  Reviewed by:	will

Modified:
  head/usr.sbin/pw/tests/helper_functions.shin
  head/usr.sbin/pw/tests/pw_delete.sh
  head/usr.sbin/pw/tests/pw_lock.sh
  head/usr.sbin/pw/tests/pw_modify.sh

Modified: head/usr.sbin/pw/tests/helper_functions.shin
==============================================================================
--- head/usr.sbin/pw/tests/helper_functions.shin	Wed Nov 19 22:17:22 2014	(r274726)
+++ head/usr.sbin/pw/tests/helper_functions.shin	Wed Nov 19 23:07:46 2014	(r274727)
@@ -1,5 +1,8 @@
 # $FreeBSD$
 
+# The pw command
+PW="pw -V ${HOME}"
+
 # Workdir to run tests in
 TESTDIR=$(atf_get_srcdir)
 

Modified: head/usr.sbin/pw/tests/pw_delete.sh
==============================================================================
--- head/usr.sbin/pw/tests/pw_delete.sh	Wed Nov 19 22:17:22 2014	(r274726)
+++ head/usr.sbin/pw/tests/pw_delete.sh	Wed Nov 19 23:07:46 2014	(r274727)
@@ -12,10 +12,10 @@ rmuser_seperate_group_head() {
 }
 rmuser_seperate_group_body() {
 	populate_etc_skel
-	pw -V ${HOME} useradd test || atf_fail "Creating test user"
-	pw -V ${HOME} groupmod test -M 'test,root' || \
+	${PW} useradd test || atf_fail "Creating test user"
+	${PW} groupmod test -M 'test,root' || \
 		atf_fail "Modifying the group"
-	pw -V ${HOME} userdel test || atf_fail "Delete the test user"
+	${PW} userdel test || atf_fail "Delete the test user"
 }
 
 atf_test_case group_do_not_delete_wheel_if_group_unknown
@@ -25,9 +25,9 @@ group_do_not_delete_wheel_if_group_unkno
 
 group_do_not_delete_wheel_if_group_unknown_body() {
 	populate_etc_skel
-	atf_check -s exit:0 -o inline:"wheel:*:0:root\n" -x pw -V ${HOME} groupshow wheel
-	atf_check -e inline:"pw: -g expects a number\n" -s exit:64 -x pw -V ${HOME} groupdel -g I_do_not_exist
-	atf_check -s exit:0 -o inline:"wheel:*:0:root\n" -x pw -V ${HOME} groupshow wheel
+	atf_check -s exit:0 -o inline:"wheel:*:0:root\n" -x ${PW} groupshow wheel
+	atf_check -e inline:"pw: -g expects a number\n" -s exit:64 -x ${PW} groupdel -g I_do_not_exist
+	atf_check -s exit:0 -o inline:"wheel:*:0:root\n" -x ${PW} groupshow wheel
 }
 
 atf_test_case user_do_not_try_to_delete_root_if_user_unknown
@@ -37,7 +37,7 @@ user_do_not_try_to_delete_root_if_user_u
 
 user_do_not_try_to_delete_root_if_user_unknown_body() {
 	populate_etc_skel
-	atf_check -e inline:"pw: -u expects a number\n" -s exit:64 -x pw -V ${HOME} userdel -u plop
+	atf_check -e inline:"pw: -u expects a number\n" -s exit:64 -x ${PW} userdel -u plop
 }
 
 atf_init_test_cases() {

Modified: head/usr.sbin/pw/tests/pw_lock.sh
==============================================================================
--- head/usr.sbin/pw/tests/pw_lock.sh	Wed Nov 19 22:17:22 2014	(r274726)
+++ head/usr.sbin/pw/tests/pw_lock.sh	Wed Nov 19 23:07:46 2014	(r274727)
@@ -7,11 +7,11 @@
 atf_test_case user_locking cleanup
 user_locking_body() {
 	populate_etc_skel
-	pw -V ${HOME} useradd test || atf_fail "Creating test user"
-	pw -V ${HOME} lock test || atf_fail "Locking the user"
+	${PW} useradd test || atf_fail "Creating test user"
+	${PW} lock test || atf_fail "Locking the user"
 	atf_check -s exit:0 -o match:"^test:\*LOCKED\*\*:1001:" \
 		grep "^test:\*LOCKED\*\*:1001:" $HOME/master.passwd
-	pw -V ${HOME} unlock test || atf_fail "Locking the user"
+	${PW} unlock test || atf_fail "Locking the user"
 	atf_check -s exit:0 -o match:"^test:\*:1001:" \
 		grep "^test:\*:1001:" $HOME/master.passwd
 }

Modified: head/usr.sbin/pw/tests/pw_modify.sh
==============================================================================
--- head/usr.sbin/pw/tests/pw_modify.sh	Wed Nov 19 22:17:22 2014	(r274726)
+++ head/usr.sbin/pw/tests/pw_modify.sh	Wed Nov 19 23:07:46 2014	(r274727)
@@ -8,11 +8,11 @@
 atf_test_case groupmod_user
 groupmod_user_body() {
 	populate_etc_skel
-	atf_check -s exit:0 pw -V ${HOME} addgroup test
-	atf_check -s exit:0 pw -V ${HOME} groupmod test -m root
+	atf_check -s exit:0 ${PW} addgroup test
+	atf_check -s exit:0 ${PW} groupmod test -m root
 	atf_check -s exit:0 -o match:"^test:\*:1001:root$" \
 		grep "^test:\*:.*:root$" $HOME/group
-	atf_check -s exit:0 pw -V ${HOME} groupmod test -d root
+	atf_check -s exit:0 ${PW} groupmod test -d root
 	atf_check -s exit:0 -o match:"^test:\*:1001:$" \
 		grep "^test:\*:.*:$" $HOME/group
 }
@@ -22,9 +22,9 @@ groupmod_user_body() {
 atf_test_case groupmod_invalid_user
 groupmod_invalid_user_body() {
 	populate_etc_skel
-	atf_check -s exit:0 pw -V ${HOME} addgroup test
-	atf_check -s exit:67 -e match:"does not exist" pw -V ${HOME} groupmod test -m foo
-	atf_check -s exit:0  pw -V ${HOME} groupmod test -d foo
+	atf_check -s exit:0 ${PW} addgroup test
+	atf_check -s exit:67 -e match:"does not exist" ${PW} groupmod test -m foo
+	atf_check -s exit:0  ${PW} groupmod test -d foo
 }
 
 atf_test_case groupmod_bug_193704
@@ -33,9 +33,9 @@ groupmod_bug_193704_head() {
 }
 groupmod_bug_193704_body() {
 	populate_etc_skel
-	atf_check -s exit:0 -x pw -V ${HOME} groupadd test
-	atf_check -s exit:0 -x pw -V ${HOME} groupmod test -l newgroupname
-	atf_check -s exit:65 -e match:"^pw: unknown group" -x pw -V ${HOME} groupshow test
+	atf_check -s exit:0 -x ${PW} groupadd test
+	atf_check -s exit:0 -x ${PW} groupmod test -l newgroupname
+	atf_check -s exit:65 -e match:"^pw: unknown group" -x ${PW} groupshow test
 }
 
 atf_test_case usermod_bug_185666
@@ -45,17 +45,17 @@ usermod_bug_185666_head() {
 
 usermod_bug_185666_body() {
 	populate_etc_skel
-	atf_check -s exit:0 -x pw -V ${HOME} useradd testuser
-	atf_check -s exit:0 -x pw -V ${HOME} groupadd testgroup
-	atf_check -s exit:0 -x pw -V ${HOME} groupadd testgroup2
-	atf_check -s exit:0 -x pw -V ${HOME} usermod testuser -G testgroup
-	atf_check -o inline:"testuser:*:1001:\n" -x pw -V${HOME} groupshow testuser
-	atf_check -o inline:"testgroup:*:1002:testuser\n" -x pw -V ${HOME} groupshow testgroup
-	atf_check -o inline:"testgroup2:*:1003:\n" -x pw -V${HOME} groupshow testgroup2
-	atf_check -s exit:0 -x pw -V ${HOME} usermod testuser -G testgroup2
-	atf_check -o inline:"testuser:*:1001:\n" -x pw -V ${HOME} groupshow testuser
-	atf_check -o inline:"testgroup:*:1002:\n" -x pw -V ${HOME} groupshow testgroup
-	atf_check -o inline:"testgroup2:*:1003:testuser\n" -x pw -V ${HOME} groupshow testgroup2
+	atf_check -s exit:0 -x ${PW} useradd testuser
+	atf_check -s exit:0 -x ${PW} groupadd testgroup
+	atf_check -s exit:0 -x ${PW} groupadd testgroup2
+	atf_check -s exit:0 -x ${PW} usermod testuser -G testgroup
+	atf_check -o inline:"testuser:*:1001:\n" -x ${PW} groupshow testuser
+	atf_check -o inline:"testgroup:*:1002:testuser\n" -x ${PW} groupshow testgroup
+	atf_check -o inline:"testgroup2:*:1003:\n" -x ${PW} groupshow testgroup2
+	atf_check -s exit:0 -x ${PW} usermod testuser -G testgroup2
+	atf_check -o inline:"testuser:*:1001:\n" -x ${PW} groupshow testuser
+	atf_check -o inline:"testgroup:*:1002:\n" -x ${PW} groupshow testgroup
+	atf_check -o inline:"testgroup2:*:1003:testuser\n" -x ${PW} groupshow testgroup2
 }
 
 atf_test_case do_not_duplicate_group_on_gid_change
@@ -65,8 +65,8 @@ do_not_duplicate_group_on_gid_change_hea
 
 do_not_duplicate_group_on_gid_change_body() {
 	populate_etc_skel
-	atf_check -s exit:0 -x pw -V ${HOME} groupadd testgroup
-	atf_check -s exit:0 -x pw -V ${HOME} groupmod testgroup -g 12345
+	atf_check -s exit:0 -x ${PW} groupadd testgroup
+	atf_check -s exit:0 -x ${PW} groupmod testgroup -g 12345
 	# use grep to see if the entry has not be duplicated
 	atf_check -o inline:"testgroup:*:12345:\n" -s exit:0 -x grep "^testgroup" ${HOME}/group
 }


More information about the svn-src-head mailing list