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
chru...@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

Reply via email to