[functional-tests/cache] use a temp file for metadata
This commit is contained in:
parent
78cb2570a3
commit
de2e243408
@ -2,10 +2,12 @@
|
|||||||
(cache-functional-tests)
|
(cache-functional-tests)
|
||||||
(export register-cache-tests)
|
(export register-cache-tests)
|
||||||
(import (chezscheme)
|
(import (chezscheme)
|
||||||
|
(disk-units)
|
||||||
(functional-tests)
|
(functional-tests)
|
||||||
(cache-xml)
|
(cache-xml)
|
||||||
(fmt fmt)
|
(fmt fmt)
|
||||||
(process)
|
(process)
|
||||||
|
(scenario-string-constants)
|
||||||
(temp-file)
|
(temp-file)
|
||||||
(srfi s8 receive))
|
(srfi s8 receive))
|
||||||
|
|
||||||
@ -14,52 +16,31 @@
|
|||||||
(define-tool cache-restore)
|
(define-tool cache-restore)
|
||||||
(define-tool cache-metadata-size)
|
(define-tool cache-metadata-size)
|
||||||
|
|
||||||
(define (current-metadata) "metadata.bin")
|
|
||||||
|
|
||||||
(define cwd "/tmp")
|
|
||||||
|
|
||||||
(define-syntax with-cache-xml
|
(define-syntax with-cache-xml
|
||||||
(syntax-rules ()
|
(syntax-rules ()
|
||||||
((_ (v) b1 b2 ...)
|
((_ (v) b1 b2 ...)
|
||||||
(with-temp-file-containing ((v (fmt #f (generate-xml 512 1024 128))))
|
(with-temp-file-containing ((v (fmt #f (generate-xml 512 1024 128))))
|
||||||
b1 b2 ...))))
|
b1 b2 ...))))
|
||||||
|
|
||||||
(define (%with-valid-metadata thunk)
|
|
||||||
(with-cache-xml (xml)
|
|
||||||
(cache-restore "-i" xml "-o" (current-metadata))
|
|
||||||
(thunk)))
|
|
||||||
|
|
||||||
(define-syntax with-valid-metadata
|
(define-syntax with-valid-metadata
|
||||||
(syntax-rules ()
|
(syntax-rules ()
|
||||||
((_ body ...)
|
((_ (md) b1 b2 ...)
|
||||||
(%with-valid-metadata (lambda () body ...)))))
|
(with-temp-file-sized ((md (meg 4)))
|
||||||
|
(with-cache-xml (xml)
|
||||||
|
(cache-restore "-i" xml "-o" md)
|
||||||
|
b1 b2 ...)))))
|
||||||
|
|
||||||
;;; It would be nice if the metadata was at least similar to valid data.
|
;;; It would be nice if the metadata was at least similar to valid data.
|
||||||
(define (%with-corrupt-metadata thunk)
|
|
||||||
(run-ok "dd if=/dev/zero" (fmt #f "of=" (current-metadata)) "bs=64M count=1")
|
|
||||||
(thunk))
|
|
||||||
|
|
||||||
(define-syntax with-corrupt-metadata
|
(define-syntax with-corrupt-metadata
|
||||||
(syntax-rules ()
|
(syntax-rules ()
|
||||||
((_ body ...) (%with-corrupt-metadata (lambda () body ...)))))
|
((_ (md) b1 b2 ...)
|
||||||
|
(with-temp-file-sized ((md (meg 4)))
|
||||||
|
b1 b2 ...))))
|
||||||
|
|
||||||
;; We have to export something that forces all the initialisation expressions
|
;; We have to export something that forces all the initialisation expressions
|
||||||
;; to run.
|
;; to run.
|
||||||
(define (register-cache-tests) #t)
|
(define (register-cache-tests) #t)
|
||||||
|
|
||||||
(define cache-check-help
|
|
||||||
"Usage: cache_check [options] {device|file}
|
|
||||||
Options:
|
|
||||||
{-q|--quiet}
|
|
||||||
{-h|--help}
|
|
||||||
{-V|--version}
|
|
||||||
{--clear-needs-check-flag}
|
|
||||||
{--super-block-only}
|
|
||||||
{--skip-mappings}
|
|
||||||
{--skip-hints}
|
|
||||||
{--skip-discards}")
|
|
||||||
|
|
||||||
;;;-----------------------------------------------------------
|
;;;-----------------------------------------------------------
|
||||||
;;; cache_check scenarios
|
;;; cache_check scenarios
|
||||||
;;;-----------------------------------------------------------
|
;;;-----------------------------------------------------------
|
||||||
@ -119,27 +100,27 @@ Options:
|
|||||||
|
|
||||||
(define-scenario (cache-check fails-with-corrupt-metadata)
|
(define-scenario (cache-check fails-with-corrupt-metadata)
|
||||||
"Fail with corrupt superblock"
|
"Fail with corrupt superblock"
|
||||||
(with-corrupt-metadata
|
(with-corrupt-metadata (md)
|
||||||
(run-fail "cache_check" (current-metadata))))
|
(run-fail "cache_check" md)))
|
||||||
|
|
||||||
(define-scenario (cache-check failing-q)
|
(define-scenario (cache-check failing-q)
|
||||||
"Fail quietly with -q"
|
"Fail quietly with -q"
|
||||||
(with-corrupt-metadata
|
(with-corrupt-metadata (md)
|
||||||
(receive (stdout stderr) (run-fail "cache_check" "-q" (current-metadata))
|
(receive (stdout stderr) (run-fail "cache_check" "-q" md)
|
||||||
(assert-eof stdout)
|
(assert-eof stdout)
|
||||||
(assert-eof stderr))))
|
(assert-eof stderr))))
|
||||||
|
|
||||||
(define-scenario (cache-check failing-quiet)
|
(define-scenario (cache-check failing-quiet)
|
||||||
"Fail quietly with --quiet"
|
"Fail quietly with --quiet"
|
||||||
(with-corrupt-metadata
|
(with-corrupt-metadata (md)
|
||||||
(receive (stdout stderr) (run-fail "cache_check" "--quiet" (current-metadata))
|
(receive (stdout stderr) (run-fail "cache_check" "--quiet" md)
|
||||||
(assert-eof stdout)
|
(assert-eof stdout)
|
||||||
(assert-eof stderr))))
|
(assert-eof stderr))))
|
||||||
|
|
||||||
(define-scenario (cache-check valid-metadata-passes)
|
(define-scenario (cache-check valid-metadata-passes)
|
||||||
"A valid metadata area passes"
|
"A valid metadata area passes"
|
||||||
(with-valid-metadata
|
(with-valid-metadata (md)
|
||||||
(cache-check (current-metadata))))
|
(cache-check md)))
|
||||||
|
|
||||||
(define-scenario (cache-check deliberately-fail)
|
(define-scenario (cache-check deliberately-fail)
|
||||||
"remove me"
|
"remove me"
|
||||||
@ -148,7 +129,7 @@ Options:
|
|||||||
(define-scenario (cache-check bad-metadata-version)
|
(define-scenario (cache-check bad-metadata-version)
|
||||||
"Invalid metadata version fails"
|
"Invalid metadata version fails"
|
||||||
(with-cache-xml (xml)
|
(with-cache-xml (xml)
|
||||||
(cache-restore "-i" xml "-o" (current-metadata)
|
(with-temp-file-sized ((md (meg 4)))
|
||||||
"--debug-override-metadata-version" "12345")
|
(cache-restore "-i" xml "-o" md "--debug-override-metadata-version" "12345")
|
||||||
(run-fail "cache_check" (current-metadata))))
|
(run-fail "cache_check" md))))
|
||||||
)
|
)
|
||||||
|
@ -4,7 +4,10 @@
|
|||||||
(export thin-check-help
|
(export thin-check-help
|
||||||
thin-restore-outfile-too-small-text
|
thin-restore-outfile-too-small-text
|
||||||
thin-restore-help
|
thin-restore-help
|
||||||
thin-rmap-help)
|
thin-rmap-help
|
||||||
|
|
||||||
|
cache-check-help
|
||||||
|
)
|
||||||
|
|
||||||
(import (rnrs))
|
(import (rnrs))
|
||||||
|
|
||||||
@ -46,4 +49,17 @@ Options:
|
|||||||
Where:
|
Where:
|
||||||
<block range> is of the form <begin>..<one-past-the-end>
|
<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")
|
for example 5..45 denotes blocks 5 to 44 inclusive, but not block 45")
|
||||||
|
|
||||||
|
(define cache-check-help
|
||||||
|
"Usage: cache_check [options] {device|file}
|
||||||
|
Options:
|
||||||
|
{-q|--quiet}
|
||||||
|
{-h|--help}
|
||||||
|
{-V|--version}
|
||||||
|
{--clear-needs-check-flag}
|
||||||
|
{--super-block-only}
|
||||||
|
{--skip-mappings}
|
||||||
|
{--skip-hints}
|
||||||
|
{--skip-discards}")
|
||||||
|
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user