All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cyril Hrubis <chrubis@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v3 1/2] test.sh: make the loop device size can be increased
Date: Tue, 30 Aug 2016 15:34:44 +0200	[thread overview]
Message-ID: <20160830133443.GB23854@rei.lan> (raw)
In-Reply-To: <CAEemH2eD2L49XGtPJd72FbyOg9RbgQwzNFyBYJPSpY3zyAZJrg@mail.gmail.com>

Hi!
> I'm now hesitating whether we should keep tst_device.c as same as the
> shell? although we don't need it for a while.

I do not care that much either way.

> Which something like:
> 
> const char *tst_acquire_device(void (cleanup_fn)(void), int size)
> {
>     int acq_dev_size;
>     long long ltp_dev_size;
>     char *dev;
>     struct stat st;
> 
>     if (size > 0)
>         acq_dev_size = size;
>     else
>         acq_dev_size = 150;

size = size > 0 ? size : 150;

is a bit shorter.

>     if (device_acquired)
>         tst_brkm(TBROK, cleanup_fn, "Device allready acquired");
> 
>     if (!tst_tmpdir_created()) {
>         tst_brkm(TBROK, cleanup_fn,
>                  "Cannot acquire device without tmpdir() created");
>     }
> 
>     dev = getenv("LTP_DEV");
> 
>     if (dev) {
>         tst_resm(TINFO, "Using test device LTP_DEV='%s'", dev);
>
>         SAFE_STAT(cleanup_fn, dev, &st);
> 
>         if (!S_ISBLK(st.st_mode)) {
>             tst_brkm(TBROK, cleanup_fn,
>                     "%s is not a block device", dev);
>         }
> 
>         ltp_dev_size = (int)st.st_size/1024/1024;
> 
>         if (acq_dev_size <= ltp_dev_size) {
>             if (tst_fill_file(dev, 0, 1024, 512)) {
>                 tst_brkm(TBROK | TERRNO, cleanup_fn,
>                     "Failed to clear the first 512k of %s", dev);
>             }
> 
>             return dev;
>         }

	We should print here that the LTP_DEV was skipped
	because it was too small. Something as:

	tst_resm(TINFO, "Skipping $LTP_DEV size %dMB, requested size %dMB",
	         ltp_dev_size, size);

	Otherwise it would look like the $LTP_DEV was used from the test
	log.

>     }
> 
>     if (tst_fill_file(DEV_FILE, 0, 1024, 1024 * acq_dev_size)) {
>         tst_brkm(TBROK | TERRNO, cleanup_fn,
>                  "Failed to create " DEV_FILE);
> 
>     }
> 
>     if (find_free_loopdev())
>         return NULL;
> 
>     attach_device(cleanup_fn, dev_path, DEV_FILE);
> 
>     device_acquired = 1;
> 
>     return dev_path;
> }

Otherwise this looks fine.

-- 
Cyril Hrubis
chrubis@suse.cz

  reply	other threads:[~2016-08-30 13:34 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-18 13:09 [LTP] [PATCH v3 1/2] test.sh: make the loop device size can be increased Li Wang
2016-08-22 17:18 ` Cyril Hrubis
2016-08-23 11:03   ` Li Wang
2016-08-30 13:34     ` Cyril Hrubis [this message]
2016-08-31  9:12       ` Li Wang

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=20160830133443.GB23854@rei.lan \
    --to=chrubis@suse.cz \
    --cc=ltp@lists.linux.it \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.