public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH 1/5] acl_test01: Fixes
@ 2015-06-09  9:49 Stanislav Kholmanskikh
  2015-06-09  9:49 ` [LTP] [PATCH 2/5] acl_test01: Verify the exit code of the second test case Stanislav Kholmanskikh
  2015-06-09 10:00 ` [LTP] [PATCH 1/5] acl_test01: Fixes Cyril Hrubis
  0 siblings, 2 replies; 14+ messages in thread
From: Stanislav Kholmanskikh @ 2015-06-09  9:49 UTC (permalink / raw)
  To: ltp-list; +Cc: vasily.isaenko

Converted the test case to use tst_tmpdir instead of local juggling
with $TMP.

When we execute LTP, $PATH includes $LTPROOT/testcases/bin, so there
is no reason to set $TCbin explicitly. Therefore, removed $TCbin.

Signed-off-by: Stanislav Kholmanskikh <stanislav.kholmanskikh@oracle.com>
---
 runtest/admin_tools                 |    2 +-
 testcases/kernel/fs/acls/acl_test01 |   56 ++++++++++++++--------------------
 2 files changed, 24 insertions(+), 34 deletions(-)

diff --git a/runtest/admin_tools b/runtest/admin_tools
index 559757e..0a46468 100644
--- a/runtest/admin_tools
+++ b/runtest/admin_tools
@@ -6,4 +6,4 @@ cron_allow01 cron_allow01
 cron_dirs_checks01 cron_dirs_checks01
 at_deny01 at_deny01
 at_allow01 at_allow01
-acl_test01 export TCbin=$LTPROOT/testcases/bin;acl_test01
+acl_test01 acl_test01
diff --git a/testcases/kernel/fs/acls/acl_test01 b/testcases/kernel/fs/acls/acl_test01
index 328ff74..be88aa8 100755
--- a/testcases/kernel/fs/acls/acl_test01
+++ b/testcases/kernel/fs/acls/acl_test01
@@ -43,16 +43,13 @@ export TST_COUNT=1
 
 . test.sh
 
-TMP=${TMP:=/tmp}
-
 TEST_USER1="acltest1"
 TEST_USER1_GROUP="users"
 TEST_USER1_PASSWD="ltp_test_pass1"
-TEST_USER1_HOMEDIR="$TMP/tacl/mount-ext3/$TEST_USER1"
+TEST_USER1_HOMEDIR="mount-ext3/$TEST_USER1"
 
-FILE_ACL="$TMP/tacl/mount-ext3/test_file"
-FILE_ACL_LINK="$TMP/tacl/mount-ext3/test_file_link"
-TCbin=`pwd`
+FILE_ACL="mount-ext3/test_file"
+FILE_ACL_LINK="mount-ext3/test_file_link"
 
 COMMAND=$(command -v "getenforce" "setenforce" |wc -l)
 if [ $COMMAND -eq 2 ]; then
@@ -66,9 +63,6 @@ fi
 #-----------------------------------------------------------------------
 
 do_setup(){
-
-	tst_require_root
-
 	rm -f $FILE_ACL
 	rm -f $FILE_ACL_LINK
 
@@ -87,12 +81,12 @@ do_setup(){
 	rm -rf $TEST_USER1_HOMEDIR
 	userdel $TEST_USER1 > /dev/null 2>&1
 	sleep 1
-	useradd -d $TEST_USER1_HOMEDIR -m -g $TEST_USER1_GROUP $TEST_USER1 -s /bin/sh
+	useradd -d $(readlink -f $TEST_USER1_HOMEDIR) -m \
+	    -g $TEST_USER1_GROUP $TEST_USER1 -s /bin/sh
 
 	if [ $? -ne 0 ]; then
 		tst_brkm TBROK "Could not add test user $TEST_USER1."
 	fi
-
 }
 
 #-----------------------------------------------------------------------
@@ -100,13 +94,13 @@ do_setup(){
 #-----------------------------------------------------------------------
 
 do_cleanup() {
-	rm -rf $TEST_USER1_HOMEDIR
 	userdel $TEST_USER1 > /dev/null 2>&1
-	rm -f $FILE_ACL > /dev/null 2>&1
-	rm -f $FILE_ACL_LINK > /dev/null 2>&1
-	mount | grep "$TMP/tacl/mount-ext3" && umount -d $TMP/tacl/mount-ext3
+
+	MOUNT_POINT=$(readlink -f "mount-ext3")
+	mount | grep $MOUNT_POINT && umount -d $MOUNT_POINT
 	[ "x$LOOP_DEV" != x ] && losetup -d $LOOP_DEV
-	rm -rf $TMP/tacl
+
+	tst_rmdir
 
 	# We set it back to Enforcing.
 	if [ "$SELINUX" = "Enforcing" ]; then
@@ -126,18 +120,15 @@ then
 else
 	tst_require_root
 
-	if ! ( test -d $TMP/tacl || mkdir -m 777 $TMP/tacl) ; then
-		tst_brkm TBROK "Failed to create $TMP/tacl directory."
-	fi
-
-	trap do_cleanup EXIT
+	tst_tmpdir
+	TST_CLEANUP=do_cleanup
 
 	#	The  following  commands  can  be  used as an example of using
 	#	a loopback device.
 
-	dd if=/dev/zero of=$TMP/tacl/blkext3 bs=1k count=10240 && chmod 777 $TMP/tacl/blkext3
+	dd if=/dev/zero of=blkext3 bs=1k count=10240 && chmod 777 blkext3
 	if [ $? -ne 0 ] ; then
-		tst_brkm TBROK "Failed to create $TMP/tacl/blkext3"
+		tst_brkm TBROK "Failed to create blkext3"
 	fi
 
 	# Avoid hardcoded loopback device values (-f tries to find the first
@@ -146,7 +137,7 @@ else
 		tst_brkm TCONF "[ losetup.1 ] Failed to find an available loopback device -- is the required support compiled in your kernel?"
 	fi
 
-	if ! losetup $LOOP_DEV $TMP/tacl/blkext3 2>&1 > /dev/null; then
+	if ! losetup $LOOP_DEV blkext3 2>&1 > /dev/null; then
 		echo ""
 		tst_brkm TCONF "[ losetup.2 ] Failed to setup the device."
 	fi
@@ -154,8 +145,8 @@ else
 	mount | grep ext2
 	if [ $? -ne 0 ]; then
 		mkfs -t ext3 $LOOP_DEV #> /dev/null 2>&1
-		mkdir  -m 777 $TMP/tacl/mount-ext3
-		mount -t ext3 -o defaults,acl,user_xattr $LOOP_DEV $TMP/tacl/mount-ext3
+		mkdir -m 777 mount-ext3
+		mount -t ext3 -o defaults,acl,user_xattr $LOOP_DEV mount-ext3
 		if [ $? -ne 0 ]
 		then
 			tst_resm TCONF "[ mount ] Make sure that ACL (Access Control List)"
@@ -165,8 +156,8 @@ else
 	else
 
 		mkfs -t ext2 $LOOP_DEV
-		mkdir  -m 777 $TMP/tacl/mount-ext3
-		mount -t ext2 -o defaults,acl,user_xattr $LOOP_DEV $TMP/tacl/mount-ext3
+		mkdir -m 777 mount-ext3
+		mount -t ext2 -o defaults,acl,user_xattr $LOOP_DEV mount-ext3
 		if [ $? -ne 0 ]
 		then
 			tst_resm TCONF "FAILED: [ mount ] Make sure that ACL (Access Control List)"
@@ -188,7 +179,7 @@ then
 	setfacl -m u:$TEST_USER1:r $FILE_ACL
 
 	echo "Trying extended acls for files"
-	${TCbin}/acl_file_test $FILE_ACL
+	acl_file_test $FILE_ACL
 	if [ $? -ne 0 ]
 	then
 		tst_resm TFAIL "Extended acls for files."
@@ -197,7 +188,7 @@ then
 	fi
 
 	echo "Trying extended acls for file links"
-	${TCbin}/acl_link_test $FILE_ACL_LINK
+	acl_link_test $FILE_ACL_LINK
 	if [ $? -ne 0 ]
 	then
 		tst_resm TFAIL "Extended acls for links."
@@ -217,7 +208,7 @@ else
 	setfacl -mu:root:r $FILE_ACL
 
 	echo "Trying extended acls for files"
-	${TCbin}/acl_file_test $FILE_ACL
+	acl_file_test $FILE_ACL
 	if [ $? -ne 0 ]
 	then
 		tst_resm TFAIL "Extended acls for files."
@@ -226,7 +217,7 @@ else
 	fi
 
 	echo "Trying extended acls for file links"
-	${TCbin}/acl_link_test $FILE_ACL_LINK
+	acl_link_test $FILE_ACL_LINK
 	if [ $? -ne 0 ]
 	then
 		tst_resm TFAIL "Extended acls for links."
@@ -239,7 +230,6 @@ else
 
 	su $TEST_USER1 -c "$0"
 	echo ""
-	do_cleanup
 fi
 
 tst_exit
-- 
1.7.1


------------------------------------------------------------------------------
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2015-06-09 12:51 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-09  9:49 [LTP] [PATCH 1/5] acl_test01: Fixes Stanislav Kholmanskikh
2015-06-09  9:49 ` [LTP] [PATCH 2/5] acl_test01: Verify the exit code of the second test case Stanislav Kholmanskikh
2015-06-09  9:49   ` [LTP] [PATCH 3/5] acl_test01: Hide unnecessary output Stanislav Kholmanskikh
2015-06-09  9:49     ` [LTP] [PATCH 4/5] tools/apicmd: Add tst_fs_type Stanislav Kholmanskikh
2015-06-09  9:49       ` [LTP] [RFC PATCH 5/5] acl_test01: Wait until the loop device is detached Stanislav Kholmanskikh
2015-06-09 10:10         ` Cyril Hrubis
2015-06-09 10:11           ` Cyril Hrubis
     [not found]           ` <5576D352.4040004@oracle.com>
2015-06-09 12:50             ` Cyril Hrubis
2015-06-09 10:01       ` [LTP] [PATCH 4/5] tools/apicmd: Add tst_fs_type Cyril Hrubis
2015-06-09 10:04     ` [LTP] [PATCH 3/5] acl_test01: Hide unnecessary output Cyril Hrubis
2015-06-09 10:54   ` [LTP] [PATCH 2/5] acl_test01: Verify the exit code of the second test case Cyril Hrubis
     [not found]     ` <5576D3E3.5020600@oracle.com>
2015-06-09 12:03       ` Cyril Hrubis
2015-06-09 10:00 ` [LTP] [PATCH 1/5] acl_test01: Fixes Cyril Hrubis
     [not found]   ` <5576BB8A.2030809@oracle.com>
2015-06-09 10:17     ` Cyril Hrubis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox