2017-08-17 16:26:15 +01:00
|
|
|
(library
|
|
|
|
(cache-functional-tests)
|
|
|
|
(export register-cache-tests)
|
|
|
|
(import (chezscheme)
|
2017-08-25 11:26:09 +01:00
|
|
|
(disk-units)
|
2017-08-17 16:26:15 +01:00
|
|
|
(functional-tests)
|
|
|
|
(cache-xml)
|
|
|
|
(fmt fmt)
|
2017-08-25 09:46:56 +01:00
|
|
|
(process)
|
2017-08-25 11:26:09 +01:00
|
|
|
(scenario-string-constants)
|
2017-08-23 10:48:33 +01:00
|
|
|
(temp-file)
|
2017-08-17 16:26:15 +01:00
|
|
|
(srfi s8 receive))
|
|
|
|
|
|
|
|
(define-tool cache-check)
|
|
|
|
(define-tool cache-dump)
|
|
|
|
(define-tool cache-restore)
|
|
|
|
(define-tool cache-metadata-size)
|
2019-10-08 14:34:24 +01:00
|
|
|
(define-tool cache-repair)
|
2017-08-17 16:26:15 +01:00
|
|
|
|
2017-08-24 14:03:07 +01:00
|
|
|
(define-syntax with-cache-xml
|
|
|
|
(syntax-rules ()
|
|
|
|
((_ (v) b1 b2 ...)
|
2017-08-29 14:46:59 +01:00
|
|
|
(with-temp-file-containing ((v "cache.xml" (fmt #f (generate-xml 512 1024 128))))
|
2017-08-24 14:03:07 +01:00
|
|
|
b1 b2 ...))))
|
2017-08-17 16:26:15 +01:00
|
|
|
|
|
|
|
(define-syntax with-valid-metadata
|
|
|
|
(syntax-rules ()
|
2017-08-25 11:26:09 +01:00
|
|
|
((_ (md) b1 b2 ...)
|
2017-12-12 15:27:20 +00:00
|
|
|
(with-temp-file-sized ((md "cache.bin" (to-bytes (meg 4))))
|
2017-08-25 11:26:09 +01:00
|
|
|
(with-cache-xml (xml)
|
2017-10-10 16:51:31 +01:00
|
|
|
(run-ok (cache-restore "-i" xml "-o" md))
|
2017-08-25 11:26:09 +01:00
|
|
|
b1 b2 ...)))))
|
2017-08-17 16:26:15 +01:00
|
|
|
|
|
|
|
;;; It would be nice if the metadata was at least similar to valid data.
|
|
|
|
(define-syntax with-corrupt-metadata
|
|
|
|
(syntax-rules ()
|
2017-08-25 11:26:09 +01:00
|
|
|
((_ (md) b1 b2 ...)
|
2017-12-12 15:27:20 +00:00
|
|
|
(with-temp-file-sized ((md "cache.bin" (to-bytes (meg 4))))
|
2019-10-08 14:34:24 +01:00
|
|
|
(system (fmt #f "dd if=/usr/bin/ls of=" md " bs=4096 > /dev/null 2>&1"))
|
|
|
|
b1 b2 ...))))
|
2017-08-17 16:26:15 +01:00
|
|
|
|
2017-08-25 15:03:50 +01:00
|
|
|
(define-syntax with-empty-metadata
|
|
|
|
(syntax-rules ()
|
|
|
|
((_ (md) b1 b2 ...)
|
2017-12-12 15:27:20 +00:00
|
|
|
(with-temp-file-sized ((md "cache.bin" (to-bytes (meg 4))))
|
2017-08-25 15:03:50 +01:00
|
|
|
b1 b2 ...))))
|
|
|
|
|
2017-08-17 16:26:15 +01:00
|
|
|
;; We have to export something that forces all the initialisation expressions
|
|
|
|
;; to run.
|
|
|
|
(define (register-cache-tests) #t)
|
|
|
|
|
2017-08-25 15:03:50 +01:00
|
|
|
;;;-----------------------------------------------------------
|
|
|
|
;;; cache_dump scenarios
|
|
|
|
;;;-----------------------------------------------------------
|
|
|
|
|
2017-09-21 10:22:38 +01:00
|
|
|
(define-scenario (cache-dump small-input-file)
|
|
|
|
"Fails with small input file"
|
|
|
|
(with-temp-file-sized ((md "cache.bin" 512))
|
2017-10-10 16:51:31 +01:00
|
|
|
(run-fail
|
|
|
|
(cache-dump md))))
|
2017-09-15 12:26:54 +01:00
|
|
|
)
|