2017-08-15 20:37:45 +05:30
|
|
|
(library
|
|
|
|
(thin-functional-tests)
|
|
|
|
|
|
|
|
(export register-thin-tests)
|
|
|
|
|
|
|
|
(import
|
|
|
|
(chezscheme)
|
2017-09-28 19:06:01 +05:30
|
|
|
(bcache block-manager)
|
2017-08-25 15:55:37 +05:30
|
|
|
(disk-units)
|
2017-08-15 20:37:45 +05:30
|
|
|
(fmt fmt)
|
|
|
|
(functional-tests)
|
2017-08-25 14:16:56 +05:30
|
|
|
(process)
|
2017-08-25 15:42:18 +05:30
|
|
|
(scenario-string-constants)
|
2017-08-23 15:18:33 +05:30
|
|
|
(temp-file)
|
2017-09-15 16:56:54 +05:30
|
|
|
(thin xml)
|
2017-09-14 20:39:43 +05:30
|
|
|
(srfi s8 receive))
|
2017-08-15 20:37:45 +05:30
|
|
|
|
|
|
|
(define-tool thin-check)
|
|
|
|
(define-tool thin-delta)
|
|
|
|
(define-tool thin-dump)
|
|
|
|
(define-tool thin-restore)
|
|
|
|
(define-tool thin-rmap)
|
2017-09-29 14:49:56 +05:30
|
|
|
(define-tool thin-repair)
|
2020-05-26 15:25:03 +05:30
|
|
|
(define-tool thin-metadata-pack)
|
|
|
|
(define-tool thin-metadata-unpack)
|
2017-08-15 20:37:45 +05:30
|
|
|
|
2017-08-24 18:33:07 +05:30
|
|
|
(define-syntax with-thin-xml
|
|
|
|
(syntax-rules ()
|
|
|
|
((_ (v) b1 b2 ...)
|
2017-08-29 19:16:59 +05:30
|
|
|
(with-temp-file-containing ((v "thin.xml" (fmt #f (generate-xml 10 1000))))
|
2017-08-24 18:33:07 +05:30
|
|
|
b1 b2 ...))))
|
2017-08-15 20:37:45 +05:30
|
|
|
|
|
|
|
(define-syntax with-valid-metadata
|
|
|
|
(syntax-rules ()
|
2017-08-25 15:42:18 +05:30
|
|
|
((_ (md) b1 b2 ...)
|
2017-08-29 19:16:59 +05:30
|
|
|
(with-temp-file-sized ((md "thin.bin" (meg 4)))
|
2017-08-25 15:42:18 +05:30
|
|
|
(with-thin-xml (xml)
|
2017-10-10 21:21:31 +05:30
|
|
|
(run-ok (thin-restore "-i" xml "-o" md))
|
2017-08-25 15:42:18 +05:30
|
|
|
b1 b2 ...)))))
|
2017-08-15 20:37:45 +05:30
|
|
|
|
|
|
|
;;; It would be nice if the metadata was at least similar to valid data.
|
2019-10-08 19:04:24 +05:30
|
|
|
;;; Here I'm just using the start of the ls binary as 'random' data.
|
2017-08-15 20:37:45 +05:30
|
|
|
(define-syntax with-corrupt-metadata
|
|
|
|
(syntax-rules ()
|
2017-08-25 15:42:18 +05:30
|
|
|
((_ (md) b1 b2 ...)
|
2017-08-29 19:16:59 +05:30
|
|
|
(with-temp-file-sized ((md "thin.bin" (meg 4)))
|
2019-10-08 19:04:24 +05:30
|
|
|
(system (fmt #f "dd if=/usr/bin/ls of=" md " bs=4096 > /dev/null 2>&1"))
|
2017-08-25 15:42:18 +05:30
|
|
|
b1 b2 ...))))
|
2017-08-15 20:37:45 +05:30
|
|
|
|
2017-08-29 19:25:48 +05:30
|
|
|
(define-syntax with-empty-metadata
|
|
|
|
(syntax-rules ()
|
|
|
|
((_ (md) b1 b2 ...)
|
|
|
|
(with-temp-file-sized ((md "thin.bin" (meg 4)))
|
|
|
|
b1 b2 ...))))
|
|
|
|
|
2019-10-25 15:02:56 +05:30
|
|
|
(define (damage-superblock md)
|
|
|
|
(system (string-append "dd if=/dev/zero of=" md " bs=4K count=1 conv=notrunc > /dev/null 2>&1")))
|
|
|
|
|
|
|
|
(define-syntax with-damaged-superblock
|
|
|
|
(syntax-rules ()
|
|
|
|
((_ (md) b1 b2 ...)
|
|
|
|
(with-valid-metadata (md)
|
|
|
|
(damage-superblock md)
|
|
|
|
b1 b2 ...))))
|
|
|
|
|
2017-08-15 20:37:45 +05:30
|
|
|
;; We have to export something that forces all the initialisation expressions
|
|
|
|
;; to run.
|
2017-08-17 16:00:28 +05:30
|
|
|
(define (register-thin-tests) #t)
|
2017-08-15 20:37:45 +05:30
|
|
|
|
2017-08-17 20:54:10 +05:30
|
|
|
;;;-----------------------------------------------------------
|
|
|
|
;;; thin_check scenarios
|
|
|
|
;;;-----------------------------------------------------------
|
|
|
|
|
2020-08-12 15:15:20 +05:30
|
|
|
(define-scenario (thin-check incompatible-options auto-repair)
|
2020-07-21 18:09:25 +05:30
|
|
|
"Incompatible options should cause failure"
|
|
|
|
(with-valid-metadata (md)
|
2020-08-12 15:15:20 +05:30
|
|
|
(run-fail (thin-check "--auto-repair" "-m" md))
|
|
|
|
(run-fail (thin-check "--auto-repair" "--override-mapping-root 123" md))
|
|
|
|
(run-fail (thin-check "--auto-repair" "--super-block-only" md))
|
|
|
|
(run-fail (thin-check "--auto-repair" "--skip-mappings" md))
|
|
|
|
(run-fail (thin-check "--auto-repair" "--ignore-non-fatal-errors" md))))
|
2020-07-21 18:09:25 +05:30
|
|
|
|
|
|
|
(define-scenario (thin-check incompatible-options clear-needs-check-flag)
|
|
|
|
"Incompatible options should cause failure"
|
|
|
|
(with-valid-metadata (md)
|
|
|
|
(run-fail (thin-check "--clear-needs-check-flag" "-m" md))
|
|
|
|
(run-fail (thin-check "--clear-needs-check-flag" "--override-mapping-root 123" md))
|
|
|
|
(run-fail (thin-check "--clear-needs-check-flag" "--super-block-only" md))
|
|
|
|
(run-fail (thin-check "--clear-needs-check-flag" "--skip-mappings" md))
|
|
|
|
(run-fail (thin-check "--clear-needs-check-flag" "--ignore-non-fatal-errors" md))))
|
|
|
|
|
2020-08-12 15:15:20 +05:30
|
|
|
(define-scenario (thin-check auto-repair)
|
|
|
|
"Accepts --auto-repair"
|
2020-07-21 20:17:59 +05:30
|
|
|
(with-valid-metadata (md)
|
2020-08-12 15:15:20 +05:30
|
|
|
(run-ok (thin-check "--auto-repair" md))))
|
2020-07-21 20:17:59 +05:30
|
|
|
|
2020-05-26 15:25:03 +05:30
|
|
|
)
|