[functional-tests] thin_delta tests

This commit is contained in:
Joe Thornber 2017-08-30 10:39:58 +01:00
parent e0bab67bd8
commit 8c251018c6
3 changed files with 56 additions and 63 deletions

View File

@ -1,62 +0,0 @@
Feature: thin_delta
Scenario: print version (-V flag)
When I run `thin_delta -V`
Then it should pass with version
Scenario: print version (--version flag)
When I run `thin_delta --version`
Then it should pass with version
Scenario: print help
When I run `thin_delta --help`
Then it should pass with:
"""
Usage: thin_delta [options] <device or file>
Options:
{--thin1, --snap1}
{--thin2, --snap2}
{-m, --metadata-snap} [block#]
{--verbose}
{-h|--help}
{-V|--version}
"""
Scenario: print help
When I run `thin_delta -h`
Then it should pass with:
"""
Usage: thin_delta [options] <device or file>
Options:
{--thin1, --snap1}
{--thin2, --snap2}
{-m, --metadata-snap} [block#]
{--verbose}
{-h|--help}
{-V|--version}
"""
Scenario: Unrecognised option should cause failure
When I run `thin_delta --unleash-the-hedeghogs`
Then it should fail
Scenario: --snap1 must be specified
When I run `thin_delta --snap2 45 foo`
Then it should fail with:
"""
--snap1 not specified.
"""
Scenario: --snap2 must be specified
When I run `thin_delta --snap1 45 foo`
Then it should fail with:
"""
--snap2 not specified.
"""
Scenario: device must be specified
When I run `thin_delta --snap1 45 --snap2 50`
Then it should fail with:
"""
No input device provided.
"""

View File

@ -5,6 +5,7 @@
thin-restore-outfile-too-small-text
thin-restore-help
thin-rmap-help
thin-delta-help
cache-check-help
cache-restore-help
@ -54,6 +55,16 @@ Where:
<block range> is of the form <begin>..<one-past-the-end>
for example 5..45 denotes blocks 5 to 44 inclusive, but not block 45")
(define thin-delta-help
"Usage: thin_delta [options] <device or file>
Options:
{--thin1, --snap1}
{--thin2, --snap2}
{-m, --metadata-snap} [block#]
{--verbose}
{-h|--help}
{-V|--version}")
(define cache-check-help
"Usage: cache_check [options] {device|file}
Options:
@ -105,4 +116,5 @@ Options:
These all relate to the size of the fast device (eg, SSD), rather
than the whole cached device.")
)

View File

@ -227,5 +227,48 @@
(define-scenario (thin-rmap multiple-regions-should-pass)
"thin_rmap should handle multiple regions."
(with-valid-metadata (md)
(thin-rmap "--region 1..23 --region 45..78" md))))
(thin-rmap "--region 1..23 --region 45..78" md)))
;;;-----------------------------------------------------------
;;; thin_delta scenarios
;;;-----------------------------------------------------------
(define-scenario (thin-delta v)
"thin_delta accepts -V"
(receive (stdout _) (thin-delta "-V")
(assert-equal tools-version stdout)))
(define-scenario (thin-delta version)
"thin_delta accepts --version"
(receive (stdout _) (thin-delta "--version")
(assert-equal tools-version stdout)))
(define-scenario (thin-delta h)
"thin_delta accepts -h"
(receive (stdout _) (thin-delta "-h")
(assert-equal thin-delta-help stdout)))
(define-scenario (thin-delta help)
"thin_delta accepts --help"
(receive (stdout _) (thin-delta "--help")
(assert-equal thin-delta-help stdout)))
(define-scenario (thin-delta unrecognised-option)
"Unrecognised option should cause failure"
(run-fail "thin_delta --unleash-the-hedgehogs"))
(define-scenario (thin-delta snap1-unspecified)
"Fails without --snap1 fails"
(receive (_ stderr) (run-fail "thin_delta --snap2 45 foo")
(assert-starts-with "--snap1 not specified." stderr)))
(define-scenario (thin-delta snap2-unspecified)
"Fails without --snap2 fails"
(receive (_ stderr) (run-fail "thin_delta --snap1 45 foo")
(assert-starts-with "--snap2 not specified." stderr)))
(define-scenario (thin-delta device-unspecified)
"Fails if no device given"
(receive (_ stderr) (run-fail "thin_delta --snap1 45 --snap2 46")
(assert-starts-with "No input device provided." stderr)))
)