public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH 1/5] ima_setup.sh: Some cleanup
@ 2014-11-17 12:38 Zeng Linggang
  2014-11-17 12:39 ` [LTP] [PATCH 2/5] ima_measurements.sh: " Zeng Linggang
                   ` (5 more replies)
  0 siblings, 6 replies; 11+ messages in thread
From: Zeng Linggang @ 2014-11-17 12:38 UTC (permalink / raw)
  To: ltp-list

* Use 'test.sh'.

* Use 'test_brkm' instead of 'tst_resm TBROK'.

* Use 'tst_tmpdir' and 'tst_rmdir'.

* Delete some unuseful comments.

* Some cleanup.

Signed-off-by: Zeng Linggang <zenglg.jy@cn.fujitsu.com>
---
 .../security/integrity/ima/tests/ima_setup.sh      | 85 +++-------------------
 1 file changed, 12 insertions(+), 73 deletions(-)

diff --git a/testcases/kernel/security/integrity/ima/tests/ima_setup.sh b/testcases/kernel/security/integrity/ima/tests/ima_setup.sh
index 4013e1f..0ff38d2 100755
--- a/testcases/kernel/security/integrity/ima/tests/ima_setup.sh
+++ b/testcases/kernel/security/integrity/ima/tests/ima_setup.sh
@@ -14,8 +14,8 @@
 ## for more details.                                                          ##
 ##                                                                            ##
 ## You should have received a copy of the GNU General Public License          ##
-## along with this program;  if not, write to the Free Software               ##
-## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA    ##
+## along with this program;  if not, write to the Free Software Foundation,   ##
+## Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA           ##
 ##                                                                            ##
 ################################################################################
 #
@@ -24,13 +24,10 @@
 # Description:  setup/cleanup routines for the integrity tests.
 #
 # Author:       Mimi Zohar, zohar@ibm.vnet.ibm.com
-#
-# Return        - zero on success
-#               - non zero on failure. return value from commands ($RC)
 ################################################################################
+. test.sh
 mount_sysfs()
 {
-
 	SYSFS=$(mount 2>/dev/null | awk '$5 == "sysfs" { print $3 }')
 	if [ "x$SYSFS" = x ] ; then
 
@@ -38,22 +35,17 @@ mount_sysfs()
 
 		test -d $SYSFS || mkdir -p $SYSFS 2>/dev/null
 		if [ $? -ne 0 ] ; then
-			tst_resm TBROK "Failed to mkdir $SYSFS"
-			return 1
+			tst_brkm TBROK "Failed to mkdir $SYSFS"
 		fi
 		if ! mount -t sysfs sysfs $SYSFS 2>/dev/null ; then
-			tst_resm TBROK "Failed to mount $SYSFS"
-			return 1
+			tst_brkm TBROK "Failed to mount $SYSFS"
 		fi
 
 	fi
-
-	return 0
 }
 
 mount_securityfs()
 {
-
 	SECURITYFS=$(mount 2>/dev/null | awk '$5 == "securityfs" { print $3 }')
 	if [ "x$SECURITYFS" = x ] ; then
 
@@ -61,87 +53,34 @@ mount_securityfs()
 
 		test -d $SECURITYFS || mkdir -p $SECURITYFS 2>/dev/null
 		if [ $? -ne 0 ] ; then
-			tst_resm TBROK "Failed to mkdir $SECURITYFS"
-			return 1
+			tst_brkm TBROK "Failed to mkdir $SECURITYFS"
 		fi
 		if ! mount -t securityfs securityfs $SECURITYFS 2>/dev/null ; then
-			tst_resm TBROK "Failed to mount $SECURITYFS"
-			return 1
+			tst_brkm TBROK "Failed to mount $SECURITYFS"
 		fi
 
 	fi
-
-	return 0
-
 }
 
 setup()
 {
-	export TST_TOTAL=1
-	export TCID="setup"
-        export TST_COUNT=0
-
-	LTPBIN=
-	LTPIMA=
-
-	trap "cleanup" 0
-	if [ -z "$TMPDIR" ]; then
-		LTPTMP=/tmp
-	else
-		LTPTMP=${TMPDIR}
-	fi
-	if [ -z "$LTPBIN" ]; then
-		LTPBIN=../../../../../bin
-		PATH=$PATH:$LTPBIN
-	fi
-
 	tst_require_root
 
-	# create the temporary directory used by this testcase
-	LTPIMA=$LTPTMP/ima
-	umask 077
-	mkdir $LTPIMA > /dev/null 2>&1 || RC=$?
-	if [ $RC -ne 0 ]; then
-		tst_resm TBROK "Unable to create temporary directory"
-		return $RC
-	fi
+	tst_tmpdir
 
-	# mount sysfs if it is not already mounted
-	mount_sysfs || RC=$?
-	if [ $RC -ne 0 ]; then
-		tst_resm TBROK "Cannot mount sysfs"
-		return $RC
-	fi
+	mount_sysfs
 
 	# mount securityfs if it is not already mounted
-	mount_securityfs || RC=$?
-	if [ $RC -ne 0 ]; then
-		tst_resm TBROK "Cannot mount securityfs"
-		return $RC
-	fi
-
-	mount
+	mount_securityfs
 
 	# IMA must be configured in the kernel
 	IMA_DIR=$SECURITYFS/ima
 	if [ ! -d "$IMA_DIR" ]; then
-		tst_resm TCONF "IMA not enabled in kernel"
-		RC=1
+		tst_brkm TCONF "IMA not enabled in kernel"
 	fi
-	return $RC
 }
 
-# Function:     cleanup
-#
-# Description   - remove temporary files and directories.
-#
-# Return        - zero on success
-#               - non zero on failure. return value from commands ($RC)
 cleanup()
 {
-	tst_resm TINFO "CLEAN: removing $LTPIMA"
-	rm -rf "$LTPIMA" || RC=$?
-	return $RC
+	tst_rmdir
 }
-
-. cmdlib.sh
-- 
1.8.3.1




------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

end of thread, other threads:[~2014-12-03 12:45 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-17 12:38 [LTP] [PATCH 1/5] ima_setup.sh: Some cleanup Zeng Linggang
2014-11-17 12:39 ` [LTP] [PATCH 2/5] ima_measurements.sh: " Zeng Linggang
2014-11-17 16:39   ` Poornima Nayak
2014-11-18  2:05     ` Zeng Linggang
2014-12-02 13:42     ` Cyril Hrubis
2014-12-03 12:44   ` Cyril Hrubis
2014-11-17 12:40 ` [LTP] [PATCH 3/5] ima_policy.sh: " Zeng Linggang
2014-11-17 12:40 ` [LTP] [PATCH 4/5] ima_tpm.sh: " Zeng Linggang
2014-11-17 12:41 ` [LTP] [PATCH 5/5] ima_violations.sh: " Zeng Linggang
2014-11-17 16:33 ` [LTP] [PATCH 1/5] ima_setup.sh: " Poornima Nayak
2014-12-03 12:29 ` Cyril Hrubis

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