Ping :-)

Regards,
Xiaoguang Wang

On 03/21/2014 07:44 PM, Xiaoguang Wang wrote:
> Create misc.sh to place miscellaneous functions, which will be
> useful for tests written in shell but do not have a proper place
> to place.
>
> Currenly add tst_fs_has_free(), which will check if the mounted
> file system has enough free space.
>
> Signed-off-by: Xiaoguang Wang <wangxg.f...@cn.fujitsu.com>
> ---
>  testcases/lib/misc.sh | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 48 insertions(+)
>  create mode 100644 testcases/lib/misc.sh
>
> diff --git a/testcases/lib/misc.sh b/testcases/lib/misc.sh
> new file mode 100644
> index 0000000..f6b97ba
> --- /dev/null
> +++ b/testcases/lib/misc.sh
> @@ -0,0 +1,48 @@
> +#!/bin/sh
> +#
> +# Copyright (c) Linux Test Project, 2014
> +#
> +# This program is free software; you can redistribute it and/or modify
> +# it under the terms of the GNU General Public License as published by
> +# the Free Software Foundation; either version 2 of the License, or
> +# (at your option) any later version.
> +#
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +# GNU General Public License 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.
> +#
> +# This is a LTP shell test library for miscellaneous functions.
> +#
> +
> +. test.sh
> +
> +# check if the mounted file system has enough free space,
> +# if it is, tst_fs_has_free() returns 1, otherwise 0.
> +# NOTE: filesystem free space counts in KB
> +tst_fs_has_free()
> +{
> +     local free_space=0
> +     local abs_mntpoint=$(cd $1; pwd)
> +     local required_space=$2
> +
> +     if [ -z "$abs_mntpoint" ]; then
> +             tst_brkm TBROK "$1: not a valid path"
> +     fi
> +
> +     free_space=$(df | grep $abs_mntpoint | awk '{print $4}')
> +
> +     if [ -z "$free_space" ]; then
> +             tst_brkm TBROK "$1: not a valid mount point"
> +     fi
> +
> +     if [ $free_space -ge $required_space ]; then
> +             return 1;
> +     else
> +             return 0;
> +     fi
> +}


------------------------------------------------------------------------------
Put Bad Developers to Shame
Dominate Development with Jenkins Continuous Integration
Continuously Automate Build, Test & Deployment 
Start a new project now. Try Jenkins in the cloud.
http://p.sf.net/sfu/13600_Cloudbees
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to