From: chrubis@suse.cz
To: Xiaoguang Wang <wangxg.fnst@cn.fujitsu.com>
Cc: ltp-list@lists.sourceforge.net
Subject: Re: [LTP] [PATCH v3 1/2] lib/tst_fs_has_free.c: add tst_fs_has_free() to determine filesystem's free space
Date: Wed, 7 May 2014 15:56:15 +0200 [thread overview]
Message-ID: <20140507135615.GA21868@rei> (raw)
In-Reply-To: <1398391328-13711-1-git-send-email-wangxg.fnst@cn.fujitsu.com>
Hi!
> The existing lib/tst_cwd_has_free.c only determines the filesystem, which
> the current directory is in. And I think tst_cwd_has_free() is not entirely
> correct. See this code in tst_cwd_has_free():
> return ((float)sf.f_bfree) / (1024 / sf.f_bsize) >=
> required_kib ? 1 : 0;
> if sf.f_bsize is greater than 1024, this code is wrong.
>
> I choose to remove tst_cwd_has_free.c and add lib/tst_fs_has_free.c.
> The prototype is below:
> int tst_fs_has_free(void (*cleanup)(void), const char *path,
> unsigned int size, unsigned int mult);
>
> User can specify the path to determine the corresponding filesystem.
Pushed with a small fixes, thanks.
> +enum {
> + TST_KB = 1024,
> + TST_MB = 1048576,
> + TST_GB = 1073741824,
> +};
I've added TST_BYTES = 1 here so that we don't have to divide the 10 *
pagesize in the last case.
> diff --git a/testcases/kernel/syscalls/swapoff/swapoff01.c b/testcases/kernel/syscalls/swapoff/swapoff01.c
> index b4d19de..96b52ae 100644
> --- a/testcases/kernel/syscalls/swapoff/swapoff01.c
> +++ b/testcases/kernel/syscalls/swapoff/swapoff01.c
> @@ -99,7 +99,7 @@ static void setup(void)
> break;
> }
>
> - if (!tst_cwd_has_free(65536)) {
> + if (!tst_fs_has_free(NULL, ".", 64, TST_KB)) {
> tst_brkm(TBROK, cleanup,
> "Insufficient disk space to create swap file");
> }
And changes this to:
if (!tst_fs_has_free(NULL, ".", 64, TST_MB)) {
Because as far as I can tell, the test creates 64 megabytes files.
PS: We should document the function in Test Writing Guidelines. Will you
send a patch or should I write it?
--
Cyril Hrubis
chrubis@suse.cz
------------------------------------------------------------------------------
Is your legacy SCM system holding you back? Join Perforce May 7 to find out:
• 3 signs your SCM is hindering your productivity
• Requirements for releasing software faster
• Expert tips and advice for migrating your SCM now
http://p.sf.net/sfu/perforce
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
next prev parent reply other threads:[~2014-05-07 13:57 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-25 2:02 [LTP] [PATCH v3 1/2] lib/tst_fs_has_free.c: add tst_fs_has_free() to determine filesystem's free space Xiaoguang Wang
2014-04-25 2:02 ` [LTP] [PATCH v3 2/2] tools/apicmd: add tst_fs_has_free Xiaoguang Wang
2014-05-07 17:03 ` chrubis
2014-05-07 13:56 ` chrubis [this message]
2014-05-07 17:07 ` [LTP] [PATCH v3 1/2] lib/tst_fs_has_free.c: add tst_fs_has_free() to determine filesystem's free space chrubis
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=20140507135615.GA21868@rei \
--to=chrubis@suse.cz \
--cc=ltp-list@lists.sourceforge.net \
--cc=wangxg.fnst@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