From: chrubis@suse.cz
To: Stanislav Kholmanskikh <stanislav.kholmanskikh@oracle.com>
Cc: ltp-list@lists.sourceforge.net
Subject: Re: [LTP] [PATCH] syscalls/swapon: fix for variable page size
Date: Mon, 24 Jun 2013 18:23:28 +0200 [thread overview]
Message-ID: <20130624162328.GC3492@rei> (raw)
In-Reply-To: <1372066195-18166-1-git-send-email-stanislav.kholmanskikh@oracle.com>
Hi!
> testcases/kernel/syscalls/swapon/swapon01.c | 19 +++++-
> testcases/kernel/syscalls/swapon/swapon02.c | 84 ++++++++++++---------------
> testcases/kernel/syscalls/swapon/swapon03.c | 17 +-----
> 3 files changed, 55 insertions(+), 65 deletions(-)
>
> diff --git a/testcases/kernel/syscalls/swapon/swapon01.c b/testcases/kernel/syscalls/swapon/swapon01.c
> index 11a49f9..05f1579 100644
> --- a/testcases/kernel/syscalls/swapon/swapon01.c
> +++ b/testcases/kernel/syscalls/swapon/swapon01.c
> @@ -132,6 +132,10 @@ int main(int ac, char **av)
> /* setup() - performs all ONE TIME setup for this test */
> void setup()
> {
> + char cmd_buffer[256];
> +
> + long bs = sysconf(_SC_PAGESIZE);
> + int count = 10;
>
> tst_sig(FORK, DEF_HANDLER, cleanup);
>
> @@ -154,15 +158,22 @@ void setup()
> "Cannot do swapon on a file located on a nfs filesystem");
> }
>
> - if (!tst_cwd_has_free(65536)) {
> + if (!tst_cwd_has_free(bs*count)) {
> tst_brkm(TBROK, cleanup,
> "Insufficient disk space to create swap file");
> }
>
> /*create file */
> - if (system("dd if=/dev/zero of=swapfile01 bs=1024 count=65536 >"
> - " tmpfile 2>&1") != 0) {
> - tst_brkm(TBROK, cleanup, "Failed to create file for swap");
> + if (snprintf(cmd_buffer, sizeof(cmd_buffer),
> + "dd if=/dev/zero of=swapfile01 bs=%li "
> + "count=%i > /tmp/file 2>&1", bs, count) < 0) {
> + tst_brkm(TBROK, cleanup,
> + "sprintf() failed to create command string");
> + }
> +
> + if (system(cmd_buffer) != 0) {
> + tst_brkm(TBROK, cleanup, "dd command failed to create file via "
> + "command: %s", cmd_buffer);
This part of the code seems to be repeated several times. What about
making it into library code in lib/tst_fill_file.c instead?
Something like:
tst_fill_file(const char *path, char pattern, size_t bs, size_t count);
And I would open the and write the file directly rather than doing
system("dd ...");
--
Cyril Hrubis
chrubis@suse.cz
------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:
Build for Windows Store.
http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
next prev parent reply other threads:[~2013-06-24 16:22 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-24 9:29 [LTP] [PATCH] syscalls/swapon: fix for variable page size Stanislav Kholmanskikh
2013-06-24 16:23 ` chrubis [this message]
[not found] ` <51C932ED.6060309@oracle.com>
2013-06-25 12:48 ` chrubis
2013-07-16 14:06 ` [LTP] [PATCH V2] " Stanislav Kholmanskikh
2013-07-17 13:05 ` chrubis
2013-07-25 11:43 ` [LTP] [PATCH V3 1/2] lib/tst_fill_file.c: added tst_fill_file function Stanislav Kholmanskikh
2013-07-25 11:43 ` [LTP] [PATCH V3 2/2] syscalls/swapon: fix for variable page size Stanislav Kholmanskikh
2013-08-12 12:49 ` [LTP] [PATCH V4] " Stanislav Kholmanskikh
2013-08-12 12:49 ` [LTP] [PATCH V4 1/2] Implemented tst_fill_file function Stanislav Kholmanskikh
2013-08-13 14:59 ` chrubis
2013-08-12 12:49 ` [LTP] [PATCH V4 2/2] syscalls/swapon: fix for variable page size Stanislav Kholmanskikh
2013-08-13 15:01 ` chrubis
2013-08-14 6:01 ` [LTP] [PATCH V5 1/2] Implemented tst_fill_file function Stanislav Kholmanskikh
2013-08-14 6:01 ` [LTP] [PATCH V5 2/2] syscalls/swapon: fix for variable page size Stanislav Kholmanskikh
2013-08-14 9:57 ` 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=20130624162328.GC3492@rei \
--to=chrubis@suse.cz \
--cc=ltp-list@lists.sourceforge.net \
--cc=stanislav.kholmanskikh@oracle.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