From: Cyril Hrubis <chrubis@suse.cz>
To: Zeng Linggang <zenglg.jy@cn.fujitsu.com>
Cc: ltp-list@lists.sourceforge.net, jy_zhangjin@cn.fujitsu.com
Subject: Re: [LTP] [PATCH v3 2/2] commands/df: Added new testcase to test df(1) command.
Date: Wed, 27 May 2015 16:53:30 +0200 [thread overview]
Message-ID: <20150527145330.GC13878@rei.suse.de> (raw)
In-Reply-To: <1432264251-27223-2-git-send-email-zenglg.jy@cn.fujitsu.com>
Hi!
> + local get_size=$(blockdev --getsize64 ${TST_DEVICE})
> + # 20971520 = 20 * 1024 * 1024 = 20M
> + if [ ${get_size} != "20971520" ]; then
> + tst_brkm TCONF "${TST_DEVICE} size is ${get_size}, excepted 20M"
> + fi
Why can't we calculate the expected free space based on the size of the
device? Does the space taken by the ext2 internal data structures
vary unpredictedly?
> + ROD_SILENT mkfs.ext2 ${TST_DEVICE}
> +
> + ROD_SILENT mkdir -p mntpoint
> +
> + ROD_SILENT mount ${TST_DEVICE} mntpoint
> +}
> +
> +cleanup()
> +{
> + grep -q mntpoint /proc/self/mounts
> + if [ $? -eq 0 ]; then
> + umount mntpoint
> + if [ $? -ne 0 ];then
> + tst_resm TWARN "'umount mntpoint' failed"
> + fi
> + else
> + tst_resm TINFO "mntpoint is not mounted"
> + fi
> +
> + tst_release_device
> +
> + tst_rmdir
> +}
> +
> +df_test()
> +{
> + $1 >${TCID}.temp 2>&1
You do tst_tmpdir in the setup, which creates unique directory for the
testcase. There is no need to construct complicated names for temporary
files. Simple $1 > out 2>&1 should be fine.
> + 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 ${TST_DEVICE} ${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 ${TST_DEVICE} ${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
>
--
Cyril Hrubis
chrubis@suse.cz
------------------------------------------------------------------------------
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
next prev parent reply other threads:[~2015-05-27 14:54 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` Cyril Hrubis [this message]
[not found] ` <1432809128.11403.53.camel@G08FNSTD140232>
2015-05-28 10:41 ` [LTP] [PATCH v3 2/2] commands/df: Added new testcase to test df(1) command 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150527145330.GC13878@rei.suse.de \
--to=chrubis@suse.cz \
--cc=jy_zhangjin@cn.fujitsu.com \
--cc=ltp-list@lists.sourceforge.net \
--cc=zenglg.jy@cn.fujitsu.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox