* [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
* Re: [LTP] [PATCH] commands/df: Added new testcase to test df(1) command. 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> 0 siblings, 1 reply; 9+ messages in thread From: Cyril Hrubis @ 2015-04-28 16:33 UTC (permalink / raw) To: Zeng Linggang; +Cc: ltp-list Hi! > +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 Unless we set cleanup we need to do tst_rmdir here and below. > + 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 Hmm, we may need tst_acquire_device and tst_release_device for shell as well. Because as this is we cannot make use of the device passed to the runltp script. > + mkfs.ext2 ${device_name} >/dev/null 2>&1 > + if [ $? -ne 0 ];then If we end up here because, for example, mkfs.ext2 is not installed, the device will still be attached. We need either create a cleanup that is able to handle to cleanup interrupted setup or just detach the device and tst_rmdir() here and in the steps below. > + tst_brkm TBROK "mkfs.ext2 failed." > + fi > + > + mkdir mntpoint > + if [ $? -ne 0 ];then > + tst_brkm TBROK "mkdir testdir failed." > + fi This can be moved before the losetup when the only cleanup we need to do is tst_rmdir() > + mount ${device_name} mntpoint > + if [ $? -ne 0 ];then > + tst_brkm TBROK "mount failed." > + fi Can we use the ROD and ROD_SILENT here instead? :) > +} > + > +cleanup() > +{ > + umount -d mntpoint > + if [ $? -ne 0 ];then > + tst_resm TINFO "umount error." > + fi You need to detach the loop device here with losetup -d > + 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 -- Cyril Hrubis chrubis@suse.cz ------------------------------------------------------------------------------ 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 [flat|nested] 9+ messages in thread
[parent not found: <1431596608-27065-1-git-send-email-zenglg.jy@cn.fujitsu.com>]
* Re: [LTP] [PATCH v2 1/2] test.sh: Add tst_acquire_device() and tst_release_device() [not found] ` <1431596608-27065-1-git-send-email-zenglg.jy@cn.fujitsu.com> @ 2015-05-18 13:12 ` Cyril Hrubis [not found] ` <1432264251-27223-1-git-send-email-zenglg.jy@cn.fujitsu.com> 0 siblings, 1 reply; 9+ messages in thread From: Cyril Hrubis @ 2015-05-18 13:12 UTC (permalink / raw) To: Zeng Linggang; +Cc: ltp-list, Zhang Jin Hi! > Add two functions tst_acquire_device() and tst_release_device() > > Signed-off-by: Zhang Jin <jy_zhangjin@cn.fujitsu.com> > Signed-off-by: Zeng Linggang <zenglg.jy@cn.fujitsu.com> > --- > testcases/lib/test.sh | 44 ++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 44 insertions(+) > > diff --git a/testcases/lib/test.sh b/testcases/lib/test.sh > index 163c54b..3e6f742 100644 > --- a/testcases/lib/test.sh > +++ b/testcases/lib/test.sh > @@ -193,6 +193,50 @@ ROD() > fi > } > > +tst_acquire_device() > +{ > + local dd_size=$1 > + local testdevice=$2 > + local mntpoint=$3 > + > + ROD_SILENT dd if=/dev/zero of=testimg bs=1M count=${dd_size} > + > + ROD_SILENT losetup ${testdevice} testimg > + > + ROD_SILENT mkfs.ext2 ${testdevice} > + > + ROD_SILENT mkdir -p ${mntpoint} > + > + ROD_SILENT mount ${testdevice} ${mntpoint} Hmm, I would like to keep the formatting and mounting out of the library. Because if nothing else, user may want to use different fs than ext2. The second reason to do so is that we may want to do exactly same as the C function because anything else will be confusing. For that reason the free loop device should be also queried here (and stored in a global variable whose names starts with either tst_ or TST_). Moreover the C function will try LTP_DEV first and if it points to a valid block device, it will be used. > +} > + > +tst_release_device() > +{ > + local mntpoint=$1 > + > + grep -q ${mntpoint} /proc/self/mounts > + if [ $? -eq 0 ]; then > + umount ${mntpoint} > + if [ $? -ne 0 ];then > + tst_resm TWARN "'umount ${mntpoint}' failed" > + fi > + fi > + > + losetup -a | grep -q ${mntpoint} > + if [ $? -eq 0 ]; then > + losetup -d ${mntpoint} > + if [ $? -ne 0 ];then > + tst_resm TWARN "'losetup -d ${mntpoint}' failed" > + fi > + fi > + > + if [ -d ${mntpoint} ]; then > + rm -r ${mntpoint} > + fi > + > + rm testimg > +} > + > # Check that test name is set > if [ -z "$TCID" ]; then > tst_brkm TBROK "TCID is not defined" > -- > 1.9.3 > -- Cyril Hrubis chrubis@suse.cz ------------------------------------------------------------------------------ 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 [flat|nested] 9+ messages in thread
[parent not found: <1432264251-27223-1-git-send-email-zenglg.jy@cn.fujitsu.com>]
* Re: [LTP] [PATCH v3 1/2] test.sh: Add tst_acquire_device() and tst_release_device() [not found] ` <1432264251-27223-1-git-send-email-zenglg.jy@cn.fujitsu.com> @ 2015-05-27 14:40 ` Cyril Hrubis [not found] ` <1432264251-27223-2-git-send-email-zenglg.jy@cn.fujitsu.com> 1 sibling, 0 replies; 9+ messages in thread From: Cyril Hrubis @ 2015-05-27 14:40 UTC (permalink / raw) To: Zeng Linggang; +Cc: ltp-list, jy_zhangjin Hi! > +tst_acquire_device() > +{ We should check that tst_tmpdir() has been called here, i.e. that TST_TMPDIR is non-empty string. > + if [ -n "${LTP_DEV}" ]; then > + tst_resm TINFO "Using test device LTP_DEV='${LTP_DEV}'" > + stat ${LTP_DEV} | grep -q "block special file" [ -b "$LTP_DEV" ] ? > + if [ $? -ne 0 ]; then > + tst_brkm TBROK "${LTP_DEV} is not a block device" > + fi > + TST_DEVICE=${LTP_DEV} > + return > + fi > + > + ROD_SILENT dd if=/dev/zero of=test_dev.img bs=1024 count=20480 > + > + TST_DEVICE=$(losetup -f) > + if [ $? -ne 0 ]; then > + tst_brkm TBROK "Couldn't find free loop device" > + fi > + > + tst_resm TINFO "Found free device '${TST_DEVICE}'" > + > + ROD_SILENT losetup ${TST_DEVICE} test_dev.img > +} > + > +tst_release_device() > +{ > + losetup -a | grep -q ${TST_DEVICE} > + if [ $? -eq 0 ]; then > + losetup -d ${TST_DEVICE} > + if [ $? -ne 0 ];then > + tst_resm TWARN "'losetup -d ${TST_DEVICE}' failed" > + fi > + fi > + > + if [ -f "test_dev.img" ]; then > + rm test_dev.img > + fi We don't have to delete the file here, the tst_rmdir() will do that for us. > +} > + > # Check that test name is set > if [ -z "$TCID" ]; then > tst_brkm TBROK "TCID is not defined" Otherwise it looks fine. -- Cyril Hrubis chrubis@suse.cz ------------------------------------------------------------------------------ _______________________________________________ Ltp-list mailing list Ltp-list@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/ltp-list ^ permalink raw reply [flat|nested] 9+ messages in thread
[parent not found: <1432264251-27223-2-git-send-email-zenglg.jy@cn.fujitsu.com>]
* Re: [LTP] [PATCH v3 2/2] commands/df: Added new testcase to test df(1) command. [not found] ` <1432264251-27223-2-git-send-email-zenglg.jy@cn.fujitsu.com> @ 2015-05-27 14:53 ` Cyril Hrubis [not found] ` <1432809128.11403.53.camel@G08FNSTD140232> 0 siblings, 1 reply; 9+ messages in thread From: Cyril Hrubis @ 2015-05-27 14:53 UTC (permalink / raw) To: Zeng Linggang; +Cc: ltp-list, jy_zhangjin 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 ^ permalink raw reply [flat|nested] 9+ messages in thread
[parent not found: <1432809128.11403.53.camel@G08FNSTD140232>]
* Re: [LTP] [PATCH v3 2/2] commands/df: Added new testcase to test df(1) command. [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> 0 siblings, 1 reply; 9+ messages in thread From: Cyril Hrubis @ 2015-05-28 10:41 UTC (permalink / raw) To: Zeng Linggang; +Cc: ltp-list, jy_zhangjin Hi! > > Why can't we calculate the expected free space based on the size of > > the > > device? > > Hmm, I do not think it is suitable to calculate the size. 'df' report > file system disk space usage, which means it just only report the count > of all the data block. super block, group descriptor and others will not > include. > > ps: > ext2 file system: > +--------------+---------+---------+-----+---------+ > | boot section | group 0 | group 1 | ... | group n | > +--------------+---------+---------+-----+---------+ > group n: > +-------+------------+------------+--------+-------+-------+ > | super | group | data block | inode | inode | data | > | block | descriptor | bitmap | bitmap | table | block | > +-------+------------+------------+--------+-------+-------+ > > > > Does the space taken by the ext2 internal data structures > > vary unpredictedly? > > > > If we specify the block size, inode size and super block, we could get > the size of data block. BTW, mkfs use sparse_super as default option, > that means not every group has superblock backup copies. That make it > hard to calculate the size of data block. Quite complicated indeed. Another idea may be to measure the difference in free space before and after we create a file. 1. create an empty file 1. get free space 2. fill the file with well defined amount of data 3. get free space, check that the difference matches the expectation -- Cyril Hrubis chrubis@suse.cz ------------------------------------------------------------------------------ _______________________________________________ Ltp-list mailing list Ltp-list@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/ltp-list ^ permalink raw reply [flat|nested] 9+ messages in thread
[parent not found: <1433151743-30219-1-git-send-email-zenglg.jy@cn.fujitsu.com>]
[parent not found: <1433151743-30219-2-git-send-email-zenglg.jy@cn.fujitsu.com>]
* Re: [LTP] [PATCH v4 2/2] commands/df: Added new testcase to test df(1) command. [not found] ` <1433151743-30219-2-git-send-email-zenglg.jy@cn.fujitsu.com> @ 2015-06-03 14:27 ` Cyril Hrubis [not found] ` <1433754901.2651.50.camel@G08FNSTD140232.g08.fujitsu.local> 0 siblings, 1 reply; 9+ messages in thread From: Cyril Hrubis @ 2015-06-03 14:27 UTC (permalink / raw) To: Zeng Linggang; +Cc: ltp-list, jy_zhangjin Hi! > +sub() > +{ > + minuend=$(echo $1 | sed -r 's/([[:digit:]]{1,}).*/\1/') > + if echo $1 | grep -q -E "m|M"; then > + minuend=$((minuend*1024*1024)) > + flag=m > + elif echo $1 | grep -q -E "k|K"; then > + minuend=$((minuend*1024)) > + flag=k > + else > + flag=0 > + fi > + > + subtrahend=$(echo $2 | sed -r 's/([[:digit:]]{1,}).*/\1/') > + if echo $2 | grep -q -E "m|M"; then > + subtrahend=$((subtrahend*1024*1024)) > + elif echo $2 | grep -q -E "k|K"; then > + subtrahend=$((subtrahend*1024)) > + fi > + > + rest=$((minuend - subtrahend)) > + if [ $flag == m ]; then > + echo $((rest/1024/1024)) > + elif [ $flag == k ]; then > + echo $((rest/1024)) > + else > + echo $rest > + fi I don't get why we multiply the numbers, substract them and then divide them again. Can't we just substract them? Also does this work for other filesystems than ext2? It may be a good idea to run the test for a few more filesystems as well. We may add a parameter which fs to use and add entries as: df01 -f ext2 df01 -f ext3 ... to the runtest file. Otherwise it looks good. -- Cyril Hrubis chrubis@suse.cz ------------------------------------------------------------------------------ _______________________________________________ Ltp-list mailing list Ltp-list@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/ltp-list ^ permalink raw reply [flat|nested] 9+ messages in thread
[parent not found: <1433754901.2651.50.camel@G08FNSTD140232.g08.fujitsu.local>]
* Re: [LTP] [PATCH v4 2/2] commands/df: Added new testcase to test df(1) command. [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> 0 siblings, 1 reply; 9+ messages in thread From: Cyril Hrubis @ 2015-06-08 13:57 UTC (permalink / raw) To: Zeng Linggang; +Cc: ltp-list, jy_zhangjin Hi! > > I don't get why we multiply the numbers, substract them and then divide > > them again. Can't we just substract them? > > This is for the conversion of measurement units. > For example: > We may get the output from 'df', 172k as subtrahend and 11M as minuend. > If we want to do subtract. We should convert them to the same unit > first. Does that actually happen? Looking at the code the sub() is called from df_verify() that calls df always with exactly same parameters twice so we always end up with matching units or am I mistaken? > > Also does this work for other filesystems than ext2? It may be a good > > idea to run the test for a few more filesystems as well. We may add a > > parameter which fs to use and add entries as: > > > > Hmm, this is a good idea. > Nowadays, I am thinking about ext3 and ext4, but I know very few about > other filesystems. Are you OK that I send you the new patches about > them(ext2, ext3 and ext4)? Sounds as a good start. If you add an parameter to specify fs to test we can easily extend it for any other fs as well later on. -- Cyril Hrubis chrubis@suse.cz ------------------------------------------------------------------------------ _______________________________________________ Ltp-list mailing list Ltp-list@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/ltp-list ^ permalink raw reply [flat|nested] 9+ messages in thread
[parent not found: <1434095739-19883-1-git-send-email-zenglg.jy@cn.fujitsu.com>]
[parent not found: <1434095739-19883-2-git-send-email-zenglg.jy@cn.fujitsu.com>]
* Re: [LTP] [PATCH v5 2/2] commands/df: Added new testcase to test df(1) command. [not found] ` <1434095739-19883-2-git-send-email-zenglg.jy@cn.fujitsu.com> @ 2015-06-16 19:51 ` Cyril Hrubis 0 siblings, 0 replies; 9+ messages in thread From: Cyril Hrubis @ 2015-06-16 19:51 UTC (permalink / raw) To: Zeng Linggang; +Cc: ltp-list Hi! I've changed the test to work with other filesystems as well, fixed a few typos, etc. and pushed, thanks. -- Cyril Hrubis chrubis@suse.cz ------------------------------------------------------------------------------ _______________________________________________ Ltp-list mailing list Ltp-list@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/ltp-list ^ permalink raw reply [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