From: Zhang Jin <jy_zhang...@cn.fujitsu.com> Test df(1) command with some basic options.
Signed-off-by: Zhang Jin <jy_zhang...@cn.fujitsu.com> Signed-off-by: Zeng Linggang <zenglg...@cn.fujitsu.com> --- runtest/commands | 1 + testcases/commands/df/Makefile | 28 +++++++ testcases/commands/df/df01.sh | 165 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 194 insertions(+) create mode 100644 testcases/commands/df/Makefile create mode 100755 testcases/commands/df/df01.sh diff --git a/runtest/commands b/runtest/commands index 06291f0..a6208b3 100644 --- a/runtest/commands +++ b/runtest/commands @@ -21,3 +21,4 @@ sssd01 sssd01 sssd02 sssd02 sssd03 sssd03 du01 du01.sh +df01 df01.sh diff --git a/testcases/commands/df/Makefile b/testcases/commands/df/Makefile new file mode 100644 index 0000000..e1a38c8 --- /dev/null +++ b/testcases/commands/df/Makefile @@ -0,0 +1,28 @@ +# +# commands/df testcases Makefile. +# +# Copyright (c) 2015 Fujitsu Ltd. +# Author:Zhang Jin <jy_zhang...@cn.fujitsu.com> +# +# 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. +# + +top_srcdir ?= ../../.. + +include $(top_srcdir)/include/mk/env_pre.mk + +INSTALL_TARGETS := df01.sh + +include $(top_srcdir)/include/mk/generic_leaf_target.mk diff --git a/testcases/commands/df/df01.sh b/testcases/commands/df/df01.sh new file mode 100755 index 0000000..be44aaa --- /dev/null +++ b/testcases/commands/df/df01.sh @@ -0,0 +1,165 @@ +#!/bin/sh +# +# Copyright (c) 2015 Fujitsu Ltd. +# Author: Zhang Jin <jy_zhang...@cn.fujitsu.com> +# +# 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. +# +# Test df command with some basic options. +# + +TCID=df01 +TST_TOTAL=12 +. test.sh + +setup() +{ + tst_require_root + + tst_check_cmds df mkfs.ext2 + + tst_tmpdir + + device_name=$(/sbin/losetup -f) + if [ $? -ne 0 ]; then + tst_brkm TBROK "get device_name failed." + fi + + tst_acquire_device 20 ${device_name} mntpoint +} + +cleanup() +{ + tst_release_device ${device_name} + + tst_rmdir +} + +df_test() +{ + $1 >${TCID}.temp 2>&1 + if [ $? -ne 0 ]; then + grep -q -E "unrecognized option | invalid option" ${TCID}.temp + if [ $? -eq 0 ]; then + tst_resm TCONF "'$1' not supported." + return + else + tst_resm TFAIL "'$1' failed." + return + fi + fi + + grep ${device_name} ${TCID}.temp | grep mntpoint | grep -q $2 + if [ $? -eq 0 ]; then + tst_resm TPASS "'$1' passed." + else + tst_resm TFAIL "'$1' failed." + fi +} + +test1() +{ + df_test "df" "19827" +} + +test2() +{ + df_test "df -a" "19827" +} + +test3() +{ + df_test "df -h" "20M" +} + +test4() +{ + df_test "df -H" "21M" +} + +test5() +{ + df_test "df -i" "5136" +} + +test6() +{ + df_test "df -k" "19827" +} + +test7() +{ + df_test "df -m" "20" +} + +test8() +{ + df_test "df -t ext2" "19827" +} + +test9() +{ + df_test "df -T" "19827" +} + +test10() +{ + df_test "df -v mntpoint" "19827" +} + +test11() +{ + df -x ext2 >${TCID}.temp 2>&1 + if [ $? -ne 0 ]; then + grep -q -E "unrecognized option | invalid option" ${TCID}.temp + if [ $? -eq 0 ]; then + tst_resm TCONF "'df -x ext2' not supported." + return + else + tst_resm TFAIL "'df -x ext2' failed." + return + fi + fi + + grep ${device_name} ${TCID}.temp | grep -q mntpoint + if [ $? -ne 0 ]; then + tst_resm TPASS "'df -x ext2' passed." + else + tst_resm TFAIL "'df -x ext2' failed." + fi +} + +test12() +{ + df --version >${TCID}.temp 2>&1 + if [ $? -ne 0 ]; then + grep -q -E "unrecognized option | invalid option" ${TCID}.temp + if [ $? -eq 0 ]; then + tst_resm TCONF "'df --version' not supported." + return + else + tst_resm TFAIL "'df --version' failed." + return + fi + else + tst_resm TPASS "'df --version' passed." + fi +} + +TST_CLEANUP="cleanup" +setup + +for i in $(seq 1 ${TST_TOTAL}) +do + test$i +done + +tst_exit -- 1.9.3 ------------------------------------------------------------------------------ One dashboard for servers and applications across Physical-Virtual-Cloud Widest out-of-the-box monitoring support with 50+ applications Performance metrics, stats and reports that give you Actionable Insights Deep dive visibility with transaction tracing using APM Insight. http://ad.doubleclick.net/ddm/clk/290420510;117567292;y _______________________________________________ Ltp-list mailing list Ltp-list@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/ltp-list