[functional-tests] Check *_restore doesn't touch the metadata if the xml doesn't exists, or isn't xml.

This commit is contained in:
Joe Thornber
2017-09-28 14:36:01 +01:00
parent 7796b4eecb
commit f018e6ecf7
5 changed files with 51 additions and 4 deletions

View File

@ -20,10 +20,12 @@
assert-equal
assert-eof
assert-starts-with
assert-matches)
assert-matches
assert-superblock-untouched)
(import
(chezscheme)
(bcache block-manager)
(fmt fmt)
(list-utils)
(logging)
@ -221,5 +223,20 @@
(unless ((regex pattern) str)
(fail (fmt #f "string should match: " pattern ", " str))))
(define (all-zeroes? ptr count)
(let ((u8-ptr (make-ftype-pointer unsigned-8 ptr)))
(let loop ((i 0))
(if (= count i)
#t
(if (zero? (ftype-ref unsigned-8 () u8-ptr i))
(loop (+ i 1))
#f)))))
(define (assert-superblock-untouched md)
(with-bcache (cache md 1)
(with-block (b cache 0 (get-flags))
(unless (all-zeroes? (block-data b) 4096)
(fail "superblock contains non-zero data")))))
)