public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH] commands/df: Added new testcase to test df(1) command.
@ 2015-04-28 11:10 Zeng Linggang
  2015-04-28 16:33 ` Cyril Hrubis
  0 siblings, 1 reply; 9+ messages in thread
From: Zeng Linggang @ 2015-04-28 11:10 UTC (permalink / raw)
  To: ltp-list

Test df(1) command with some basic options.

Signed-off-by: Zhang Jin <jy_zhangjin@cn.fujitsu.com>
---
 runtest/commands               |   1 +
 testcases/commands/df/Makefile |  28 ++++++
 testcases/commands/df/df01.sh  | 191 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 220 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 b711294..da8d92c 100644
--- a/runtest/commands
+++ b/runtest/commands
@@ -20,3 +20,4 @@ size01 size01
 sssd01 sssd01
 sssd02 sssd02
 sssd03 sssd03
+df01 df01.sh
diff --git a/testcases/commands/df/Makefile b/testcases/commands/df/Makefile
new file mode 100644
index 0000000..6d3c7fd
--- /dev/null
+++ b/testcases/commands/df/Makefile
@@ -0,0 +1,28 @@
+#
+#    commands/df testcases Makefile.
+#
+#    Copyright (C) 2015 Fujitsu Ltd.
+#    Author:Zhang Jin <jy_zhangjin@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..b3b592f
--- /dev/null
+++ b/testcases/commands/df/df01.sh
@@ -0,0 +1,191 @@
+#!/bin/bash
+#
+# Copyright (c) 2015 Fujitsu Ltd.
+# Author: Zhang Jin <jy_zhangjin@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
+
+	tst_tmpdir
+
+	dd if=/dev/zero of=test.img bs=1M count=20 >/dev/null 2>&1
+	if [ $? -ne 0 ];then
+		tst_brkm TBROK "dd failed."
+	fi
+
+	device_name=$(/sbin/losetup -f)
+	if [ $? -ne 0 ];then
+		tst_brkm TBROK "device_name failed."
+	fi
+
+	losetup ${device_name} test.img
+	if [ $? -ne 0 ];then
+		tst_brkm TBROK "losetup failed."
+	fi
+
+	mkfs.ext2 ${device_name} >/dev/null 2>&1
+	if [ $? -ne 0 ];then
+		tst_brkm TBROK "mkfs.ext2 failed."
+	fi
+
+	mkdir mntpoint
+	if [ $? -ne 0 ];then
+		tst_brkm TBROK "mkdir testdir failed."
+	fi
+
+	mount ${device_name} mntpoint
+	if [ $? -ne 0 ];then
+		tst_brkm TBROK "mount failed."
+	fi
+}
+
+cleanup()
+{
+	umount -d mntpoint
+	if [ $? -ne 0 ];then
+		tst_resm TINFO "umount error."
+	fi
+
+	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
+}
+
+setup
+TST_CLEANUP="cleanup"
+
+for i in $(seq 1 ${TST_TOTAL})
+do
+	test$i
+done
+
+tst_exit
-- 
2.4.0-rc1




------------------------------------------------------------------------------
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

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

end of thread, other threads:[~2015-06-16 19:53 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-04-28 11:10 [LTP] [PATCH] commands/df: Added new testcase to test df(1) command Zeng Linggang
2015-04-28 16:33 ` Cyril Hrubis
     [not found]   ` <1431596608-27065-1-git-send-email-zenglg.jy@cn.fujitsu.com>
2015-05-18 13:12     ` [LTP] [PATCH v2 1/2] test.sh: Add tst_acquire_device() and tst_release_device() Cyril Hrubis
     [not found]       ` <1432264251-27223-1-git-send-email-zenglg.jy@cn.fujitsu.com>
2015-05-27 14:40         ` [LTP] [PATCH v3 " Cyril Hrubis
     [not found]         ` <1432264251-27223-2-git-send-email-zenglg.jy@cn.fujitsu.com>
2015-05-27 14:53           ` [LTP] [PATCH v3 2/2] commands/df: Added new testcase to test df(1) command Cyril Hrubis
     [not found]             ` <1432809128.11403.53.camel@G08FNSTD140232>
2015-05-28 10:41               ` Cyril Hrubis
     [not found]                 ` <1433151743-30219-1-git-send-email-zenglg.jy@cn.fujitsu.com>
     [not found]                   ` <1433151743-30219-2-git-send-email-zenglg.jy@cn.fujitsu.com>
2015-06-03 14:27                     ` [LTP] [PATCH v4 " Cyril Hrubis
     [not found]                       ` <1433754901.2651.50.camel@G08FNSTD140232.g08.fujitsu.local>
2015-06-08 13:57                         ` Cyril Hrubis
     [not found]                           ` <1434095739-19883-1-git-send-email-zenglg.jy@cn.fujitsu.com>
     [not found]                             ` <1434095739-19883-2-git-send-email-zenglg.jy@cn.fujitsu.com>
2015-06-16 19:51                               ` [LTP] [PATCH v5 " Cyril Hrubis

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