Zeng Linggang <zenglg...@cn.fujitsu.com> wrote on 11/17/2014 06:08:12 PM:
> Zeng Linggang <zenglg...@cn.fujitsu.com>
> 11/17/2014 06:08 PM
>
> To
>
> ltp-list <ltp-list@lists.sourceforge.net>
>
> cc
>
> Subject
>
> [LTP] [PATCH 1/5] ima_setup.sh: Some cleanup
>
> * 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...@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, zo...@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
>
>
>
This patch looks fine
>
>
------------------------------------------------------------------------------
> 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
>
------------------------------------------------------------------------------
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