whitespace

This commit is contained in:
Joe Thornber 2017-08-31 10:09:58 +01:00
parent 9e096fa982
commit fe1f46ae07
3 changed files with 440 additions and 440 deletions

View File

@ -52,86 +52,86 @@
;;;-----------------------------------------------------------
(define-scenario (cache-check v)
"cache_check -V"
(receive (stdout _) (cache-check "-V")
(assert-equal tools-version stdout)))
"cache_check -V"
(receive (stdout _) (cache-check "-V")
(assert-equal tools-version stdout)))
(define-scenario (cache-check version)
"cache_check --version"
(receive (stdout _) (cache-check "--version")
(assert-equal tools-version stdout)))
"cache_check --version"
(receive (stdout _) (cache-check "--version")
(assert-equal tools-version stdout)))
(define-scenario (cache-check h)
"cache_check -h"
(receive (stdout _) (cache-check "-h")
(assert-equal cache-check-help stdout)))
"cache_check -h"
(receive (stdout _) (cache-check "-h")
(assert-equal cache-check-help stdout)))
(define-scenario (cache-check help)
"cache_check --help"
(receive (stdout _) (cache-check "--help")
(assert-equal cache-check-help stdout)))
"cache_check --help"
(receive (stdout _) (cache-check "--help")
(assert-equal cache-check-help stdout)))
(define-scenario (cache-check must-specify-metadata)
"Metadata file must be specified"
(receive (_ stderr) (run-fail "cache_check")
(assert-equal
(string-append "No input file provided.\n"
cache-check-help)
stderr)))
"Metadata file must be specified"
(receive (_ stderr) (run-fail "cache_check")
(assert-equal
(string-append "No input file provided.\n"
cache-check-help)
stderr)))
(define-scenario (cache-check no-such-metadata)
"Metadata file doesn't exist."
(let ((bad-path "/arbitrary/filename"))
(receive (_ stderr) (run-fail "cache_check" bad-path)
(assert-starts-with
(string-append bad-path ": No such file or directory")
stderr))))
"Metadata file doesn't exist."
(let ((bad-path "/arbitrary/filename"))
(receive (_ stderr) (run-fail "cache_check" bad-path)
(assert-starts-with
(string-append bad-path ": No such file or directory")
stderr))))
(define-scenario (cache-check metadata-file-cannot-be-a-directory)
"Metadata file must not be a directory"
(let ((bad-path "/tmp"))
(receive (_ stderr) (run-fail "cache_check" bad-path)
(assert-starts-with
(string-append bad-path ": Not a block device or regular file")
stderr))))
"Metadata file must not be a directory"
(let ((bad-path "/tmp"))
(receive (_ stderr) (run-fail "cache_check" bad-path)
(assert-starts-with
(string-append bad-path ": Not a block device or regular file")
stderr))))
(define-scenario (cache-check unreadable-metadata)
"Metadata file exists, but is unreadable."
(with-valid-metadata (md)
(run-ok "chmod" "-r" md)
(receive (_ stderr) (run-fail "cache_check" md)
(assert-starts-with "syscall 'open' failed: Permission denied" stderr))))
"Metadata file exists, but is unreadable."
(with-valid-metadata (md)
(run-ok "chmod" "-r" md)
(receive (_ stderr) (run-fail "cache_check" md)
(assert-starts-with "syscall 'open' failed: Permission denied" stderr))))
(define-scenario (cache-check fails-with-corrupt-metadata)
"Fail with corrupt superblock"
(with-corrupt-metadata (md)
(run-fail "cache_check" md)))
"Fail with corrupt superblock"
(with-corrupt-metadata (md)
(run-fail "cache_check" md)))
(define-scenario (cache-check failing-q)
"Fail quietly with -q"
(with-corrupt-metadata (md)
(receive (stdout stderr) (run-fail "cache_check" "-q" md)
(assert-eof stdout)
(assert-eof stderr))))
"Fail quietly with -q"
(with-corrupt-metadata (md)
(receive (stdout stderr) (run-fail "cache_check" "-q" md)
(assert-eof stdout)
(assert-eof stderr))))
(define-scenario (cache-check failing-quiet)
"Fail quietly with --quiet"
(with-corrupt-metadata (md)
(receive (stdout stderr) (run-fail "cache_check" "--quiet" md)
(assert-eof stdout)
(assert-eof stderr))))
"Fail quietly with --quiet"
(with-corrupt-metadata (md)
(receive (stdout stderr) (run-fail "cache_check" "--quiet" md)
(assert-eof stdout)
(assert-eof stderr))))
(define-scenario (cache-check valid-metadata-passes)
"A valid metadata area passes"
(with-valid-metadata (md)
(cache-check md)))
"A valid metadata area passes"
(with-valid-metadata (md)
(cache-check md)))
(define-scenario (cache-check bad-metadata-version)
"Invalid metadata version fails"
(with-cache-xml (xml)
(with-empty-metadata (md)
(cache-restore "-i" xml "-o" md "--debug-override-metadata-version" "12345")
(run-fail "cache_check" md))))
"Invalid metadata version fails"
(with-cache-xml (xml)
(with-empty-metadata (md)
(cache-restore "-i" xml "-o" md "--debug-override-metadata-version" "12345")
(run-fail "cache_check" md))))
;;;-----------------------------------------------------------
;;; cache_restore scenarios
@ -148,74 +148,74 @@
(assert-equal tools-version stdout)))
(define-scenario (cache-restore h)
"cache_restore -h"
(receive (stdout _) (cache-restore "-h")
(assert-equal cache-restore-help stdout)))
"cache_restore -h"
(receive (stdout _) (cache-restore "-h")
(assert-equal cache-restore-help stdout)))
(define-scenario (cache-restore help)
"cache_restore --help"
(receive (stdout _) (cache-restore "--help")
(assert-equal cache-restore-help stdout)))
"cache_restore --help"
(receive (stdout _) (cache-restore "--help")
(assert-equal cache-restore-help stdout)))
(define-scenario (cache-restore no-input-file)
"forget to specify an input file"
(with-empty-metadata (md)
(receive (_ stderr) (run-fail "cache_restore" "-o" md)
(assert-starts-with "No input file provided." stderr))))
(define-scenario (cache-restore no-input-file)
"forget to specify an input file"
(with-empty-metadata (md)
(receive (_ stderr) (run-fail "cache_restore" "-o" md)
(assert-starts-with "No input file provided." stderr))))
(define-scenario (cache-restore missing-input-file)
"the input file can't be found"
(with-empty-metadata (md)
(receive (_ stderr) (run-fail "cache_restore -i no-such-file -o" md)
(assert-starts-with "Couldn't stat file" stderr))))
(define-scenario (cache-restore missing-input-file)
"the input file can't be found"
(with-empty-metadata (md)
(receive (_ stderr) (run-fail "cache_restore -i no-such-file -o" md)
(assert-starts-with "Couldn't stat file" stderr))))
(define-scenario (cache-restore missing-output-file)
"the output file can't be found"
(with-cache-xml (xml)
(receive (_ stderr) (run-fail "cache_restore -i " xml)
(assert-starts-with "No output file provided." stderr))))
(define-scenario (cache-restore missing-output-file)
"the output file can't be found"
(with-cache-xml (xml)
(receive (_ stderr) (run-fail "cache_restore -i " xml)
(assert-starts-with "No output file provided." stderr))))
(define-scenario (cache-restore tiny-output-file)
"Fails if the output file is too small."
(with-temp-file-sized ((md "cache.bin" (* 1024 4)))
(with-cache-xml (xml)
(receive (_ stderr) (run-fail "cache_restore" "-i" xml "-o" md)
(assert-starts-with cache-restore-outfile-too-small-text stderr)))))
(define-scenario (cache-restore tiny-output-file)
"Fails if the output file is too small."
(with-temp-file-sized ((md "cache.bin" (* 1024 4)))
(with-cache-xml (xml)
(receive (_ stderr) (run-fail "cache_restore" "-i" xml "-o" md)
(assert-starts-with cache-restore-outfile-too-small-text stderr)))))
(define-scenario (cache-restore successfully-restores)
"Restore succeeds."
(with-empty-metadata (md)
(with-cache-xml (xml)
(cache-restore "-i" xml "-o" md))))
(define-scenario (cache-restore successfully-restores)
"Restore succeeds."
(with-empty-metadata (md)
(with-cache-xml (xml)
(cache-restore "-i" xml "-o" md))))
(define-scenario (cache-restore q)
"cache_restore accepts -q"
(with-empty-metadata (md)
(with-cache-xml (xml)
(receive (stdout stderr) (cache-restore "-i" xml "-o" md "-q")
(assert-eof stdout)
(assert-eof stderr)))))
(define-scenario (cache-restore q)
"cache_restore accepts -q"
(with-empty-metadata (md)
(with-cache-xml (xml)
(receive (stdout stderr) (cache-restore "-i" xml "-o" md "-q")
(assert-eof stdout)
(assert-eof stderr)))))
(define-scenario (cache-restore quiet)
"cache_restore accepts --quiet"
(with-empty-metadata (md)
(with-cache-xml (xml)
(receive (stdout stderr) (cache-restore "-i" xml "-o" md "--quiet")
(assert-eof stdout)
(assert-eof stderr)))))
(define-scenario (cache-restore quiet)
"cache_restore accepts --quiet"
(with-empty-metadata (md)
(with-cache-xml (xml)
(receive (stdout stderr) (cache-restore "-i" xml "-o" md "--quiet")
(assert-eof stdout)
(assert-eof stderr)))))
;; Failing due to a genuine bug in cache_restore
(define-scenario (cache-restore override-metadata-version)
"we can set any metadata version"
(with-empty-metadata (md)
(with-cache-xml (xml)
(cache-restore "-i" xml "-o" md "--debug-override-metadata-version 10298"))))
;; Failing due to a genuine bug in cache_restore
(define-scenario (cache-restore override-metadata-version)
"we can set any metadata version"
(with-empty-metadata (md)
(with-cache-xml (xml)
(cache-restore "-i" xml "-o" md "--debug-override-metadata-version 10298"))))
(define-scenario (cache-restore omit-clean-shutdown)
"accepts --omit-clean-shutdown"
(with-empty-metadata (md)
(with-cache-xml (xml)
(cache-restore "-i" xml "-o" md "--omit-clean-shutdown"))))
(define-scenario (cache-restore omit-clean-shutdown)
"accepts --omit-clean-shutdown"
(with-empty-metadata (md)
(with-cache-xml (xml)
(cache-restore "-i" xml "-o" md "--omit-clean-shutdown"))))
;;;-----------------------------------------------------------
;;; cache_dump scenarios
@ -232,14 +232,14 @@
(assert-equal tools-version stdout)))
(define-scenario (cache-dump h)
"cache_dump -h"
(receive (stdout _) (cache-dump "-h")
(assert-equal cache-dump-help stdout)))
"cache_dump -h"
(receive (stdout _) (cache-dump "-h")
(assert-equal cache-dump-help stdout)))
(define-scenario (cache-dump help)
"cache_dump --help"
(receive (stdout _) (cache-dump "--help")
(assert-equal cache-dump-help stdout)))
"cache_dump --help"
(receive (stdout _) (cache-dump "--help")
(assert-equal cache-dump-help stdout)))
(define-scenario (cache-dump missing-input-file)
"Fails with missing input file."
@ -247,84 +247,84 @@
(assert-starts-with "No input file provided." stderr)))
(define-scenario (cache-dump restore-is-noop)
"cache_dump followed by cache_restore is a noop."
(with-valid-metadata (md)
(receive (d1-stdout _) (cache-dump md)
(with-temp-file-containing ((xml "cache.xml" d1-stdout))
(cache-restore "-i" xml "-o" md)
(receive (d2-stdout _) (cache-dump md)
(assert-equal d1-stdout d2-stdout))))))
"cache_dump followed by cache_restore is a noop."
(with-valid-metadata (md)
(receive (d1-stdout _) (cache-dump md)
(with-temp-file-containing ((xml "cache.xml" d1-stdout))
(cache-restore "-i" xml "-o" md)
(receive (d2-stdout _) (cache-dump md)
(assert-equal d1-stdout d2-stdout))))))
;;;-----------------------------------------------------------
;;; cache_metadata_size scenarios
;;;-----------------------------------------------------------
(define-scenario (cache-metadata-size v)
"cache_metadata_size -V"
(receive (stdout _) (cache-metadata-size "-V")
(assert-equal tools-version stdout)))
"cache_metadata_size -V"
(receive (stdout _) (cache-metadata-size "-V")
(assert-equal tools-version stdout)))
(define-scenario (cache-metadata-size version)
"cache_metadata_size --version"
(receive (stdout _) (cache-metadata-size "--version")
(assert-equal tools-version stdout)))
"cache_metadata_size --version"
(receive (stdout _) (cache-metadata-size "--version")
(assert-equal tools-version stdout)))
(define-scenario (cache-metadata-size h)
"cache_metadata_size -h"
(receive (stdout _) (cache-metadata-size "-h")
(assert-equal cache-metadata-size-help stdout)))
"cache_metadata_size -h"
(receive (stdout _) (cache-metadata-size "-h")
(assert-equal cache-metadata-size-help stdout)))
(define-scenario (cache-metadata-size help)
"cache_metadata_size --help"
(receive (stdout _) (cache-metadata-size "--help")
(assert-equal cache-metadata-size-help stdout)))
"cache_metadata_size --help"
(receive (stdout _) (cache-metadata-size "--help")
(assert-equal cache-metadata-size-help stdout)))
(define-scenario (cache-metadata-size no-args)
"No arguments specified causes fail"
(receive (_ stderr) (run-fail "cache_metadata_size")
(assert-equal "Please specify either --device-size and --block-size, or --nr-blocks."
stderr)))
"No arguments specified causes fail"
(receive (_ stderr) (run-fail "cache_metadata_size")
(assert-equal "Please specify either --device-size and --block-size, or --nr-blocks."
stderr)))
(define-scenario (cache-metadata-size device-size-only)
"Just --device-size causes fail"
(receive (_ stderr) (run-fail "cache_metadata_size --device-size" (meg 100))
(assert-equal "If you specify --device-size you must also give --block-size."
stderr)))
"Just --device-size causes fail"
(receive (_ stderr) (run-fail "cache_metadata_size --device-size" (meg 100))
(assert-equal "If you specify --device-size you must also give --block-size."
stderr)))
(define-scenario (cache-metadata-size block-size-only)
"Just --block-size causes fail"
(receive (_ stderr) (run-fail "cache_metadata_size --block-size" 128)
(assert-equal "If you specify --block-size you must also give --device-size."
stderr)))
"Just --block-size causes fail"
(receive (_ stderr) (run-fail "cache_metadata_size --block-size" 128)
(assert-equal "If you specify --block-size you must also give --device-size."
stderr)))
(define-scenario (cache-metadata-size conradictory-info-fails)
"Contradictory info causes fail"
(receive (_ stderr) (run-fail "cache_metadata_size --device-size 102400 --block-size 1000 --nr-blocks 6")
(assert-equal "Contradictory arguments given, --nr-blocks doesn't match the --device-size and --block-size."
stderr)))
"Contradictory info causes fail"
(receive (_ stderr) (run-fail "cache_metadata_size --device-size 102400 --block-size 1000 --nr-blocks 6")
(assert-equal "Contradictory arguments given, --nr-blocks doesn't match the --device-size and --block-size."
stderr)))
(define-scenario (cache-metadata-size all-args-agree)
"All args agreeing succeeds"
(receive (stdout stderr) (cache-metadata-size "--device-size" 102400 "--block-size" 100 "--nr-blocks" 1024)
(assert-equal "8248 sectors" stdout)
(assert-eof stderr)))
"All args agreeing succeeds"
(receive (stdout stderr) (cache-metadata-size "--device-size" 102400 "--block-size" 100 "--nr-blocks" 1024)
(assert-equal "8248 sectors" stdout)
(assert-eof stderr)))
(define-scenario (cache-metadata-size nr-blocks-alone)
"Just --nr-blocks succeeds"
(receive (stdout stderr) (cache-metadata-size "--nr-blocks" 1024)
(assert-equal "8248 sectors" stdout)
(assert-eof stderr)))
"Just --nr-blocks succeeds"
(receive (stdout stderr) (cache-metadata-size "--nr-blocks" 1024)
(assert-equal "8248 sectors" stdout)
(assert-eof stderr)))
(define-scenario (cache-metadata-size dev-size-and-block-size-succeeds)
"Specifying --device-size with --block-size succeeds"
(receive (stdout stderr) (cache-metadata-size "--device-size" 102400 "--block-size" 100)
(assert-equal "8248 sectors" stdout)
(assert-eof stderr)))
"Specifying --device-size with --block-size succeeds"
(receive (stdout stderr) (cache-metadata-size "--device-size" 102400 "--block-size" 100)
(assert-equal "8248 sectors" stdout)
(assert-eof stderr)))
(define-scenario (cache-metadata-size big-config)
"A big configuration succeeds"
(receive (stdout stderr) (cache-metadata-size "--nr-blocks 67108864")
(assert-equal "3678208 sectors" stdout)
(assert-eof stderr)))
"A big configuration succeeds"
(receive (stdout stderr) (cache-metadata-size "--nr-blocks 67108864")
(assert-equal "3678208 sectors" stdout)
(assert-eof stderr)))
)

View File

@ -47,145 +47,145 @@
;;; era_check scenarios
;;;-----------------------------------------------------------
(define-scenario (era-check v)
"era_check -V"
(receive (stdout _) (era-check "-V")
(assert-equal tools-version stdout)))
"era_check -V"
(receive (stdout _) (era-check "-V")
(assert-equal tools-version stdout)))
(define-scenario (era-check version)
"era_check --version"
(receive (stdout _) (era-check "--version")
(assert-equal tools-version stdout)))
"era_check --version"
(receive (stdout _) (era-check "--version")
(assert-equal tools-version stdout)))
(define-scenario (era-check h)
"era_check -h"
(receive (stdout _) (era-check "-h")
(assert-equal era-check-help stdout)))
"era_check -h"
(receive (stdout _) (era-check "-h")
(assert-equal era-check-help stdout)))
(define-scenario (era-check help)
"era_check --help"
(receive (stdout _) (era-check "--help")
(assert-equal era-check-help stdout)))
"era_check --help"
(receive (stdout _) (era-check "--help")
(assert-equal era-check-help stdout)))
(define-scenario (era-check no-device-specified)
"Fail if no device specified"
(receive (_ stderr) (run-fail "era_check")
(assert-starts-with "No input file provided." stderr)))
"Fail if no device specified"
(receive (_ stderr) (run-fail "era_check")
(assert-starts-with "No input file provided." stderr)))
(define-scenario (era-check dev-not-exist)
"Fail if specified device doesn't exist"
(receive (_ stderr) (run-fail "era_check /dev/unlikely")
(assert-starts-with "/dev/unlikely: No such file or directory" stderr)))
"Fail if specified device doesn't exist"
(receive (_ stderr) (run-fail "era_check /dev/unlikely")
(assert-starts-with "/dev/unlikely: No such file or directory" stderr)))
(define-scenario (era-check dev-is-a-directory)
"Fail if given a directory instead of a file or device"
(receive (_ stderr) (run-fail "era_check /tmp")
(assert-starts-with "/tmp: Not a block device or regular file" stderr)))
"Fail if given a directory instead of a file or device"
(receive (_ stderr) (run-fail "era_check /tmp")
(assert-starts-with "/tmp: Not a block device or regular file" stderr)))
(define-scenario (era-check bad-permissions)
"Fail if given a device with inadequate access permissions"
(with-temp-file-sized ((md "era.bin" (meg 4)))
(run-ok "chmod -r" md)
(receive (_ stderr) (run-fail "era_check" md)
(assert-starts-with "syscall 'open' failed: Permission denied" stderr))))
"Fail if given a device with inadequate access permissions"
(with-temp-file-sized ((md "era.bin" (meg 4)))
(run-ok "chmod -r" md)
(receive (_ stderr) (run-fail "era_check" md)
(assert-starts-with "syscall 'open' failed: Permission denied" stderr))))
(define-scenario (era-check empty-dev)
"Fail if given a file of zeroes"
(with-empty-metadata (md)
(run-fail "era_check" md)))
"Fail if given a file of zeroes"
(with-empty-metadata (md)
(run-fail "era_check" md)))
(define-scenario (era-check quiet)
"Fail should give no output if --quiet"
(with-empty-metadata (md)
(receive (stdout stderr) (run-fail "era_check --quiet" md)
(assert-eof stdout)
(assert-eof stderr))))
"Fail should give no output if --quiet"
(with-empty-metadata (md)
(receive (stdout stderr) (run-fail "era_check --quiet" md)
(assert-eof stdout)
(assert-eof stderr))))
(define-scenario (era-check q)
"Fail should give no output if -q"
(with-empty-metadata (md)
(receive (stdout stderr) (run-fail "era_check -q" md)
(assert-eof stdout)
(assert-eof stderr))))
"Fail should give no output if -q"
(with-empty-metadata (md)
(receive (stdout stderr) (run-fail "era_check -q" md)
(assert-eof stdout)
(assert-eof stderr))))
;;;-----------------------------------------------------------
;;; era_restore scenarios
;;;-----------------------------------------------------------
(define-scenario (era-restore v)
"era_restore -V"
(receive (stdout _) (era-restore "-V")
(assert-equal tools-version stdout)))
"era_restore -V"
(receive (stdout _) (era-restore "-V")
(assert-equal tools-version stdout)))
(define-scenario (era-restore version)
"era_restore --version"
(receive (stdout _) (era-restore "--version")
(assert-equal tools-version stdout)))
"era_restore --version"
(receive (stdout _) (era-restore "--version")
(assert-equal tools-version stdout)))
(define-scenario (era-restore h)
"era_restore -h"
(receive (stdout _) (era-restore "-h")
(assert-equal era-restore-help stdout)))
"era_restore -h"
(receive (stdout _) (era-restore "-h")
(assert-equal era-restore-help stdout)))
(define-scenario (era-restore help)
"era_restore --help"
(receive (stdout _) (era-restore "--help")
(assert-equal era-restore-help stdout)))
"era_restore --help"
(receive (stdout _) (era-restore "--help")
(assert-equal era-restore-help stdout)))
(define-scenario (era-restore input-unspecified)
"Fails if no xml specified"
(with-empty-metadata (md)
(receive (_ stderr) (run-fail "era_restore" "-o" md)
(assert-starts-with "No input file provided." stderr))))
"Fails if no xml specified"
(with-empty-metadata (md)
(receive (_ stderr) (run-fail "era_restore" "-o" md)
(assert-starts-with "No input file provided." stderr))))
(define-scenario (era-restore output-unspecified)
"Fails if no metadata dev specified"
(with-era-xml (xml)
(receive (_ stderr) (run-fail "era_restore" "-i" xml)
(assert-starts-with "No output file provided." stderr))))
"Fails if no metadata dev specified"
(with-era-xml (xml)
(receive (_ stderr) (run-fail "era_restore" "-i" xml)
(assert-starts-with "No output file provided." stderr))))
(define-scenario (era-restore success)
"Succeeds with xml and metadata"
(with-era-xml (xml)
(with-empty-metadata (md)
(era-restore "-i" xml "-o" md))))
"Succeeds with xml and metadata"
(with-era-xml (xml)
(with-empty-metadata (md)
(era-restore "-i" xml "-o" md))))
(define-scenario (era-restore quiet)
"No output with --quiet (succeeding)"
(with-era-xml (xml)
(with-empty-metadata (md)
(receive (stdout stderr) (era-restore "--quiet" "-i" xml "-o" md)
(assert-eof stdout)
(assert-eof stderr)))))
"No output with --quiet (succeeding)"
(with-era-xml (xml)
(with-empty-metadata (md)
(receive (stdout stderr) (era-restore "--quiet" "-i" xml "-o" md)
(assert-eof stdout)
(assert-eof stderr)))))
(define-scenario (era-restore q)
"No output with -q (succeeding)"
(with-era-xml (xml)
(with-empty-metadata (md)
(receive (stdout stderr) (era-restore "-q" "-i" xml "-o" md)
(assert-eof stdout)
(assert-eof stderr)))))
"No output with -q (succeeding)"
(with-era-xml (xml)
(with-empty-metadata (md)
(receive (stdout stderr) (era-restore "-q" "-i" xml "-o" md)
(assert-eof stdout)
(assert-eof stderr)))))
(define-scenario (era-restore quiet-fail)
"No output with --quiet (failing)"
(with-temp-file ((bad-xml "era.xml"))
(with-empty-metadata (md)
(receive (stdout stderr) (run-fail "era_restore" "--quiet" "-i" bad-xml "-o" md)
(assert-eof stdout)
(assert-eof stderr)))))
"No output with --quiet (failing)"
(with-temp-file ((bad-xml "era.xml"))
(with-empty-metadata (md)
(receive (stdout stderr) (run-fail "era_restore" "--quiet" "-i" bad-xml "-o" md)
(assert-eof stdout)
(assert-eof stderr)))))
(define-scenario (era-restore q-fail)
"No output with --q(failing)"
(with-temp-file ((bad-xml "era.xml"))
(with-empty-metadata (md)
(receive (stdout stderr) (run-fail "era_restore" "-q" "-i" bad-xml "-o" md)
(assert-eof stdout)
(assert-eof stderr)))))
"No output with --q(failing)"
(with-temp-file ((bad-xml "era.xml"))
(with-empty-metadata (md)
(receive (stdout stderr) (run-fail "era_restore" "-q" "-i" bad-xml "-o" md)
(assert-eof stdout)
(assert-eof stderr)))))
(define-scenario (era-dump restore-is-noop)
"era_dump followed by era_restore is a noop."
(with-valid-metadata (md)
(receive (d1-stdout _) (era-dump md)
(with-temp-file-containing ((xml "era.xml" d1-stdout))
(era-restore "-i" xml "-o" md)
(receive (d2-stdout _) (era-dump md)
(assert-equal d1-stdout d2-stdout))))))
(define-scenario (era-dump restore-is-noop)
"era_dump followed by era_restore is a noop."
(with-valid-metadata (md)
(receive (d1-stdout _) (era-dump md)
(with-temp-file-containing ((xml "era.xml" d1-stdout))
(era-restore "-i" xml "-o" md)
(receive (d2-stdout _) (era-dump md)
(assert-equal d1-stdout d2-stdout))))))
)

View File

@ -57,218 +57,218 @@
;;;-----------------------------------------------------------
(define-scenario (thin-check v)
"thin_check -V"
(receive (stdout _) (thin-check "-V")
(assert-equal tools-version stdout)))
"thin_check -V"
(receive (stdout _) (thin-check "-V")
(assert-equal tools-version stdout)))
(define-scenario (thin-check version)
"thin_check --version"
(receive (stdout _) (thin-check "--version")
(assert-equal tools-version stdout)))
(define-scenario (thin-check version)
"thin_check --version"
(receive (stdout _) (thin-check "--version")
(assert-equal tools-version stdout)))
(define-scenario (thin-check h)
"print help (-h)"
(receive (stdout _) (thin-check "-h")
(assert-equal thin-check-help stdout)))
(define-scenario (thin-check h)
"print help (-h)"
(receive (stdout _) (thin-check "-h")
(assert-equal thin-check-help stdout)))
(define-scenario (thin-check help)
"print help (--help)"
(receive (stdout _) (thin-check "--help")
(assert-equal thin-check-help stdout)))
(define-scenario (thin-check help)
"print help (--help)"
(receive (stdout _) (thin-check "--help")
(assert-equal thin-check-help stdout)))
(define-scenario (thin-check bad-option)
"Unrecognised option should cause failure"
(run-fail "thin_check --hedgehogs-only"))
(define-scenario (thin-check bad-option)
"Unrecognised option should cause failure"
(run-fail "thin_check --hedgehogs-only"))
(define-scenario (thin-check superblock-only-valid)
"--super-block-only check passes on valid metadata"
(with-valid-metadata (md)
(thin-check "--super-block-only" md)))
(define-scenario (thin-check superblock-only-valid)
"--super-block-only check passes on valid metadata"
(with-valid-metadata (md)
(thin-check "--super-block-only" md)))
(define-scenario (thin-check superblock-only-invalid)
"--super-block-only check fails with corrupt metadata"
(with-corrupt-metadata (md)
(run-fail "thin_check --super-block-only" md)))
(define-scenario (thin-check superblock-only-invalid)
"--super-block-only check fails with corrupt metadata"
(with-corrupt-metadata (md)
(run-fail "thin_check --super-block-only" md)))
(define-scenario (thin-check skip-mappings-valid)
"--skip-mappings check passes on valid metadata"
(with-valid-metadata (md)
(thin-check "--skip-mappings" md)))
(define-scenario (thin-check skip-mappings-valid)
"--skip-mappings check passes on valid metadata"
(with-valid-metadata (md)
(thin-check "--skip-mappings" md)))
(define-scenario (thin-check ignore-non-fatal-errors)
"--ignore-non-fatal-errors check passes on valid metadata"
(with-valid-metadata (md)
(thin-check "--ignore-non-fatal-errors" md)))
(define-scenario (thin-check ignore-non-fatal-errors)
"--ignore-non-fatal-errors check passes on valid metadata"
(with-valid-metadata (md)
(thin-check "--ignore-non-fatal-errors" md)))
(define-scenario (thin-check quiet)
"--quiet should give no output"
(with-valid-metadata (md)
(receive (stdout stderr) (thin-check "--quiet" md)
(assert-eof stdout)
(assert-eof stderr))))
(define-scenario (thin-check quiet)
"--quiet should give no output"
(with-valid-metadata (md)
(receive (stdout stderr) (thin-check "--quiet" md)
(assert-eof stdout)
(assert-eof stderr))))
(define-scenario (thin-check clear-needs-check-flag)
"Accepts --clear-needs-check-flag"
(with-valid-metadata (md)
(thin-check "--clear-needs-check-flag" md)))
(define-scenario (thin-check clear-needs-check-flag)
"Accepts --clear-needs-check-flag"
(with-valid-metadata (md)
(thin-check "--clear-needs-check-flag" md)))
;;;-----------------------------------------------------------
;;; thin_restore scenarios
;;;-----------------------------------------------------------
;;;-----------------------------------------------------------
;;; thin_restore scenarios
;;;-----------------------------------------------------------
(define-scenario (thin-restore print-version-v)
"print help (-V)"
(receive (stdout _) (thin-restore "-V")
(assert-equal tools-version stdout)))
(define-scenario (thin-restore print-version-v)
"print help (-V)"
(receive (stdout _) (thin-restore "-V")
(assert-equal tools-version stdout)))
(define-scenario (thin-restore print-version-long)
"print help (--version)"
(receive (stdout _) (thin-restore "--version")
(assert-equal tools-version stdout)))
(define-scenario (thin-restore print-version-long)
"print help (--version)"
(receive (stdout _) (thin-restore "--version")
(assert-equal tools-version stdout)))
(define-scenario (thin-restore h)
"print help (-h)"
(receive (stdout _) (thin-restore "-h")
(assert-equal thin-restore-help stdout)))
(define-scenario (thin-restore h)
"print help (-h)"
(receive (stdout _) (thin-restore "-h")
(assert-equal thin-restore-help stdout)))
(define-scenario (thin-restore help)
"print help (-h)"
(receive (stdout _) (thin-restore "--help")
(assert-equal thin-restore-help stdout)))
(define-scenario (thin-restore help)
"print help (-h)"
(receive (stdout _) (thin-restore "--help")
(assert-equal thin-restore-help stdout)))
(define-scenario (thin-restore no-input-file)
"forget to specify an input file"
(with-empty-metadata (md)
(receive (_ stderr) (run-fail "thin_restore" "-o" md)
(assert-starts-with "No input file provided." stderr))))
(define-scenario (thin-restore no-input-file)
"forget to specify an input file"
(with-empty-metadata (md)
(receive (_ stderr) (run-fail "thin_restore" "-o" md)
(assert-starts-with "No input file provided." stderr))))
(define-scenario (thin-restore missing-input-file)
"the input file can't be found"
(with-empty-metadata (md)
(receive (_ stderr) (run-fail "thin_restore -i no-such-file -o" md)
(assert-starts-with "Couldn't stat file" stderr))))
(define-scenario (thin-restore missing-input-file)
"the input file can't be found"
(with-empty-metadata (md)
(receive (_ stderr) (run-fail "thin_restore -i no-such-file -o" md)
(assert-starts-with "Couldn't stat file" stderr))))
(define-scenario (thin-restore missing-output-file)
"the output file can't be found"
(with-thin-xml (xml)
(receive (_ stderr) (run-fail "thin_restore -i " xml)
(assert-starts-with "No output file provided." stderr))))
(define-scenario (thin-restore missing-output-file)
"the output file can't be found"
(with-thin-xml (xml)
(receive (_ stderr) (run-fail "thin_restore -i " xml)
(assert-starts-with "No output file provided." stderr))))
(define-scenario (thin-restore tiny-output-file)
"Fails if the output file is too small."
(with-temp-file-sized ((md "thin.bin" 4096))
(with-thin-xml (xml)
(receive (_ stderr) (run-fail "thin_restore" "-i" xml "-o" md)
(assert-starts-with thin-restore-outfile-too-small-text stderr)))))
(define-scenario (thin-restore tiny-output-file)
"Fails if the output file is too small."
(with-temp-file-sized ((md "thin.bin" 4096))
(with-thin-xml (xml)
(receive (_ stderr) (run-fail "thin_restore" "-i" xml "-o" md)
(assert-starts-with thin-restore-outfile-too-small-text stderr)))))
(define-scenario (thin-restore q)
"thin_restore accepts -q"
(with-empty-metadata (md)
(with-thin-xml (xml)
(receive (stdout _) (thin-restore "-i" xml "-o" md "-q")
(assert-eof stdout)))))
(define-scenario (thin-restore q)
"thin_restore accepts -q"
(with-empty-metadata (md)
(with-thin-xml (xml)
(receive (stdout _) (thin-restore "-i" xml "-o" md "-q")
(assert-eof stdout)))))
(define-scenario (thin-restore quiet)
"thin_restore accepts --quiet"
(with-empty-metadata (md)
(with-thin-xml (xml)
(receive (stdout _) (thin-restore "-i" xml "-o" md "--quiet")
(assert-eof stdout)))))
(define-scenario (thin-restore quiet)
"thin_restore accepts --quiet"
(with-empty-metadata (md)
(with-thin-xml (xml)
(receive (stdout _) (thin-restore "-i" xml "-o" md "--quiet")
(assert-eof stdout)))))
(define-scenario (thin-dump restore-is-noop)
"thin_dump followed by thin_restore is a noop."
(with-valid-metadata (md)
(receive (d1-stdout _) (thin-dump md)
(with-temp-file-containing ((xml "thin.xml" d1-stdout))
(thin-restore "-i" xml "-o" md)
(receive (d2-stdout _) (thin-dump md)
(assert-equal d1-stdout d2-stdout))))))
(define-scenario (thin-dump restore-is-noop)
"thin_dump followed by thin_restore is a noop."
(with-valid-metadata (md)
(receive (d1-stdout _) (thin-dump md)
(with-temp-file-containing ((xml "thin.xml" d1-stdout))
(thin-restore "-i" xml "-o" md)
(receive (d2-stdout _) (thin-dump md)
(assert-equal d1-stdout d2-stdout))))))
;;;-----------------------------------------------------------
;;; thin_rmap scenarios
;;;-----------------------------------------------------------
;;;-----------------------------------------------------------
;;; thin_rmap scenarios
;;;-----------------------------------------------------------
(define-scenario (thin-rmap v)
"thin_rmap accepts -V"
(receive (stdout _) (thin-rmap "-V")
(assert-equal tools-version stdout)))
(define-scenario (thin-rmap v)
"thin_rmap accepts -V"
(receive (stdout _) (thin-rmap "-V")
(assert-equal tools-version stdout)))
(define-scenario (thin-rmap version)
"thin_rmap accepts --version"
(receive (stdout _) (thin-rmap "--version")
(assert-equal tools-version stdout)))
(define-scenario (thin-rmap version)
"thin_rmap accepts --version"
(receive (stdout _) (thin-rmap "--version")
(assert-equal tools-version stdout)))
(define-scenario (thin-rmap h)
"thin_rmap accepts -h"
(receive (stdout _) (thin-rmap "-h")
(assert-equal thin-rmap-help stdout)))
(define-scenario (thin-rmap h)
"thin_rmap accepts -h"
(receive (stdout _) (thin-rmap "-h")
(assert-equal thin-rmap-help stdout)))
(define-scenario (thin-rmap help)
"thin_rmap accepts --help"
(receive (stdout _) (thin-rmap "--help")
(assert-equal thin-rmap-help stdout)))
(define-scenario (thin-rmap help)
"thin_rmap accepts --help"
(receive (stdout _) (thin-rmap "--help")
(assert-equal thin-rmap-help stdout)))
(define-scenario (thin-rmap unrecognised-flag)
"thin_rmap complains with bad flags."
(run-fail "thin_rmap --unleash-the-hedgehogs"))
(define-scenario (thin-rmap unrecognised-flag)
"thin_rmap complains with bad flags."
(run-fail "thin_rmap --unleash-the-hedgehogs"))
(define-scenario (thin-rmap valid-region-format-should-pass)
"thin_rmap with a valid region format should pass."
(with-valid-metadata (md)
(thin-rmap "--region 23..7890" md)))
(define-scenario (thin-rmap valid-region-format-should-pass)
"thin_rmap with a valid region format should pass."
(with-valid-metadata (md)
(thin-rmap "--region 23..7890" md)))
(define-scenario (thin-rmap invalid-region-should-fail)
"thin_rmap with an invalid region format should fail."
(for-each (lambda (pattern)
(with-valid-metadata (md)
(run-fail "thin_rmap --region" pattern md)))
'("23,7890" "23..six" "found..7890" "89..88" "89..89" "89.." "" "89...99")))
(define-scenario (thin-rmap invalid-region-should-fail)
"thin_rmap with an invalid region format should fail."
(for-each (lambda (pattern)
(with-valid-metadata (md)
(run-fail "thin_rmap --region" pattern md)))
'("23,7890" "23..six" "found..7890" "89..88" "89..89" "89.." "" "89...99")))
(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)))
(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_delta scenarios
;;;-----------------------------------------------------------
(define-scenario (thin-delta v)
"thin_delta accepts -V"
(receive (stdout _) (thin-delta "-V")
(assert-equal tools-version stdout)))
;;;-----------------------------------------------------------
;;; 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 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 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 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 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 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 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)))
(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)))
)
)