(library
(thin-functional-tests)
(export register-thin-tests)
(import
(chezscheme)
(fmt fmt)
(functional-tests)
(temp-file)
(thin-xml)
(srfi s8 receive)
(only (srfi s1 lists) drop-while))
(define-tool thin-check)
(define-tool thin-delta)
(define-tool thin-dump)
(define-tool thin-restore)
(define-tool thin-rmap)
;; FIXME: use a temp file
(define (current-metadata) "metadata.bin")
;; FIXME: remove
(define cwd "/tmp")
(define-syntax with-thin-xml
(syntax-rules ()
((_ (v) b1 b2 ...)
(with-temp-file-containing ((v (fmt #f (generate-xml 10 1000))))
b1 b2 ...))))
(define-syntax with-valid-metadata
(syntax-rules ()
((_ b1 b2 ...)
(with-thin-xml (xml)
(thin-restore "-i" xml "-o" (current-metadata))
b1 b2 ...))))
;;; 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
(syntax-rules ()
((_ body ...) (%with-corrupt-metadata (lambda () body ...)))))
;; We have to export something that forces all the initialisation expressions
;; to run.
(define (register-thin-tests) #t)
(define thin-check-help
"Usage: thin_check [options] {device|file}
Options:
{-q|--quiet}
{-h|--help}
{-V|--version}
{--clear-needs-check-flag}
{--ignore-non-fatal-errors}
{--skip-mappings}
{--super-block-only}")
(define thin-restore-outfile-too-small-text
"Output file too small.
The output file should either be a block device,
or an existing file. The file needs to be large
enough to hold the metadata.")
(define thin-restore-help
"Usage: thin_restore [options]
Options:
{-h|--help}
{-i|--input}
{-o|--output}