Skip to contentSkip to conversation

test/t1000-lvcreate-usage.sh: exercise lvcreate

PATCH Jim Meyering 2 participants 4 messages Sep 17, 2007

lore
Share & tools
lore
#0 lore raw

Dave and I were talking last week about the lack of integration tests, and since he was working on lvcreate and I'd just created this test framework, he sent me a bunch of commands he'd been using to test lvcreate; Today I made them work with the new framework.

When I run the new test by itself, it does this:

    # cd test && ./t1000-lvcreate-usage.sh
    *   ok 1: set up temp files, loopback devices, PVs, and a VG
    *   ok 2: lvcreate w/negative stripesize must fail
    *   ok 3: lvcreate w/too-large stripesize must fail
    *   ok 4: lvcreate w/single stripe succeeds with diagnostics to stdout
    *   ok 5: lvcreate w/no stripe size succeeds with diagnostics to stdout
    *   ok 6: lvcreate w/invalid number of stripes must fail
    *   ok 7: lvcreate w/invalid stripe size must fail
    * passed all 7 test(s)

[Remember, I'm new to LVM, so if there are better/cleaner ways to test
these things, please let me know, soon. Otherwise, anything that's ugly or plain wrong in this test may end up being copy/pasted into new tests. Of course, if there's too much commonality, things will be factored out into shell functions that are shared, but still... ]

Here's the patch:

Test how lvcreate handles its command-line options.

* test/t1000-lvcreate-usage.sh: New tests.
* test/Makefile.in (T): Add it. Derived from test cases by Dave Wysochanski.

---
 test/Makefile.in             |    1 +
 test/t1000-lvcreate-usage.sh |   70 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 71 insertions(+), 0 deletions(-)
 create mode 100755 test/t1000-lvcreate-usage.sh
test/Makefile.in +1 -0
index a7f2876..b54560f 100644
@@ -32,6 +32,7 @@ SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
 # T = $(wildcard t[0-9][0-9][0-9][0-9]-*.sh)
 T = \
   t0000-basic.sh \
+  t1000-lvcreate-usage.sh \
   t3000-lvcreate-pvtags.sh \
   t4000-pv-range-overflow.sh
 
test/t1000-lvcreate-usage.sh new file +70 -0

70 lines not on this page · raw message

--
1.5.3.1.19.gb5ef6-dirty

#1 lore raw
Quoted 10 lines · Jim Meyering

When I run the new test by itself, it does this:

    # cd test && ./t1000-lvcreate-usage.sh
    *   ok 1: set up temp files, loopback devices, PVs, and a VG
    *   ok 2: lvcreate w/negative stripesize must fail
    *   ok 3: lvcreate w/too-large stripesize must fail
    *   ok 4: lvcreate w/single stripe succeeds with diagnostics to stdout
    *   ok 5: lvcreate w/no stripe size succeeds with diagnostics to stdout
    *   ok 6: lvcreate w/invalid number of stripes must fail
    *   ok 7: lvcreate w/invalid stripe size must fail
    * passed all 7 test(s)

Can you make that easier to parse?
Should every test have a reference number (perhaps derived from its filename?) that is not going to change and appears on the output line? Should each test belong to a defined category, e.g. 'lvcreate' above. What role do the *s serve? Would a wider range of characters make the output more readable?
Can the version of the test also appear in the test logs along with complete command output? [I noticed a '>/dev/null' earlier that ought to disappear:-) ]

'ok' with 'must fail' is misleading - try inverting the descriptions e.g. 'rejects negative stripesizes' (plural as I'd assume a range of values are being tested each time)

Alasdair

Signature · 1 line
agk at redhat.com
#2 lore raw
Quoted 12 lines · Alasdair G Kergon
Quoted 10 lines · Jim Meyering

When I run the new test by itself, it does this:

    # cd test && ./t1000-lvcreate-usage.sh
    *   ok 1: set up temp files, loopback devices, PVs, and a VG
    *   ok 2: lvcreate w/negative stripesize must fail
    *   ok 3: lvcreate w/too-large stripesize must fail
    *   ok 4: lvcreate w/single stripe succeeds with diagnostics to stdout
    *   ok 5: lvcreate w/no stripe size succeeds with diagnostics to stdout
    *   ok 6: lvcreate w/invalid number of stripes must fail
    *   ok 7: lvcreate w/invalid stripe size must fail
    * passed all 7 test(s)
Quoted 1 line

Can you make that easier to parse?

The idea is that you don't bother to parse it unless something fails :) But see proposed rewordings below.

Quoted 1 line

Should every test have a reference number (perhaps derived from its

All of those tests come from the same file: t1000-lvcreate-usage. Currently, I have these files:

  $ ls -1 t[0-9]*.sh
  t0000-basic.sh*
  t1000-lvcreate-usage.sh*
  t3000-lvcreate-pvtags.sh*
  t4000-pv-range-overflow.sh*

The numbers are pretty arbitrary, now.
Ideally, you'd put simplest tests early and ones that rely on more and more functionality/tools later.

Quoted 1 line

filename?) that is not going to change and appears on the output line?

IMHO, the combination of the file name, t1000-lvcreate-usage, and the textual "title" of each test within that file is sufficient to identify it.

Quoted 3 lines

Should each test belong to a defined category, e.g. 'lvcreate' above. What role do the *s serve? Would a wider range of characters make the output more readable?

The output format is from that of git's tests.

Quoted 2 lines

Can the version of the test also appear in the test logs along with complete command output?

If you want more output, you can run the test with --debug --verbose. Or set those options in test/Makefile.in. This is the first line of that file:

    #TEST_OPTS=--verbose --debug
Quoted 2 lines

[I noticed a '>/dev/null' earlier that ought
to disappear:-) ]

If you mean the one in t1000*'s cleanup_ function, then I'd rather not remove it. Otherwise, currently you'd see this at the end of the test:

0 logical volume(s) in volume group "t1000-test-vg-11070" now active Volume group "t1000-test-vg-11070" successfully removed

Quoted 3 lines

'ok' with 'must fail' is misleading - try inverting the descriptions e.g. 'rejects negative stripesizes' (plural as I'd assume a range of values are being tested each time)

How about these rewordings:

./t1000-lvcreate-usage.sh
* ok 1: set up temp files, loopback devices, PVs, and a VG
* ok 2: lvcreate rejects a negative stripesize
* ok 3: lvcreate rejects a too-large stripesize
* ok 4: lvcreate w/single stripe succeeds with diagnostics to stdout
* ok 5: lvcreate w/no stripe size succeeds with diagnostics to stdout
* ok 6: lvcreate rejects an invalid number of stripes
* ok 7: lvcreate rejects an invalid stripe size

#3 lore raw
Quoted 4 lines
Quoted 2 lines

[I noticed a '>/dev/null' earlier that ought
to disappear:-) ]

If you mean the one in t1000*'s cleanup_ function, then I'd rather not remove it.

What I mean is no output should be discarded anywhere. It should all be captured into log files in case someone wants to refer to it.

Alasdair

Signature · 1 line
agk at redhat.com