Changeset 22446 in project for release/4/ugarit/trunk


Ignore:
Timestamp:
01/16/11 18:42:29 (11 years ago)
Author:
Alaric Snell-Pym
Message:

ugarit: Starting to test the sexpr-stream engine

File:
1 edited

Legend:

Unmodified
Added
Removed
  • release/4/ugarit/trunk/test/run.scm

    r22219 r22446  
    106106                   (check-dir-is-empty store-path)))
    107107
    108    (test-group "Testing 0-element key stream"
     108   (test-group "0-element key stream"
    109109               (define test-list (list 1 2 3 4 5 6))
    110110               (define test-data (list->u8vector test-list))
     
    121121                     (check-dir-is-empty store-path))))
    122122
    123    (test-group "Testing 1-element key stream...\n"
     123   (test-group "1-element key stream...\n"
    124124               (define test-list (list 1 2 3 4 5 6 7))
    125125               (define test-data (list->u8vector test-list))
     
    143143                     (check-dir-is-empty store-path))))
    144144
    145    (test-group "Testing 2-element key stream...\n"
     145   (test-group "2-element key stream...\n"
    146146               (define test-list (list 1 2 3 4 5 6 7 8))
    147147               (define test-data (list->u8vector test-list))
     
    169169
    170170   (define iterations 1024)
    171    (test-group (sprintf "Testing ~a-element key stream..." iterations)
     171   (test-group (sprintf "~a-element key stream..." iterations)
    172172               (define test-list (list 1 2 3 4 5 6 7 8 9))
    173173               (define test-data (list->u8vector test-list))
     
    200200                     (test-assert "Unlink final block" (archive-unlink! a test-key))
    201201                     (check-dir-is-empty store-path))))
     202
     203   (test-group "0-element sexpr stream"
     204               (test-define "Create sexpr-stream writer" ssw (make-sexpr-stream-writer* a 't 'ti))
     205               (test-define-values "Close sexpr-stream writer" (ss-hash ss-reused?) ((sexpr-stream-writer-finish! ssw)))
     206               (test-assert "Sexpr stream did not already exist" (not ss-reused?))
     207               (test "Correct hash"  "3293ac630c13f0245f92bbb1766e16167a4e58492dde73f3t" ss-hash)
     208               (test "Sexpr stream reads back OK" '() (fold-sexpr-stream a ss-hash 't 'ti cons '()))
     209
     210               (if (archive-unlinkable? a)
     211                   (begin
     212                     (test-assert (archive-unlink! a ss-hash))
     213                     (check-dir-is-empty store-path))))
     214
     215   (test-group "1-element sexpr stream"
     216               (define test-list (list 1 2 3 4 5 6 7 8 9 10 11))
     217               (define test-data (list->u8vector test-list))
     218               (test-define "Archive hash" test-key ((archive-hash a) test-data 'test))
     219               (test-define "Create sexpr-stream writer" ssw (make-sexpr-stream-writer* a 't 'ti))
     220               (test "Write to sexpr stream" (void)
     221                     ((sexpr-stream-writer-write! ssw) `(foo ,test-key) (list (cons test-key #f))))
     222               (test-define-values "Close sexpr-stream writer" (ss-hash ss-reused?) ((sexpr-stream-writer-finish! ssw)))
     223               (test-assert "Sexpr stream did not already exist" (not ss-reused?))
     224               (test "Sexpr stream reads back OK"
     225                     `((foo ,test-key))
     226                     (fold-sexpr-stream a ss-hash 't 'ti cons '()))
     227
     228               (if (archive-unlinkable? a)
     229                   (begin
     230                     (test "Unlink sexpr stream" (void)
     231                           (unlink-sexpr-stream! a ss-hash 't 'ti
     232                                                 (lambda (sexpr)
     233                                                   (test "Correct entry read back" `(foo ,test-key) (identity sexpr))
     234                                                   (test "Unlink entry" #f (archive-unlink! a test-key)))))
     235                     (test-assert "Sexpr stream is gone" (not (archive-exists? a ss-hash)))
     236                     (test-assert "Test block is gone" (not (archive-exists? a test-key)))
     237                     (check-dir-is-empty store-path))))
     238
    202239#|
    203    (printf "Testing 0-element sexpr stream...\n")
    204    (define test-list (list 1 2 3 4 5 6 7 8 9 10))
    205    (define test-data (list->u8vector test-list))
    206    (define test-key ((archive-hash a) test-data 'test))
    207    (define ssw (make-sexpr-stream-writer* a 't 'ti))
    208    (define-values (ss-hash ss-reused?) ((sexpr-stream-writer-finish! ssw)))
    209    (assert (not ss-reused?))
    210    (assert (string=? ss-hash "3293ac630c13f0245f92bbb1766e16167a4e58492dde73f3t"))
    211    (assert (equal? (fold-sexpr-stream archive ss-hash 't 'ti cons '()) '()))
    212    (if (archive-unlinkable? a)
    213       (begin
    214          (assert (archive-unlink! a ss-hash))
    215          (check-dir-is-empty store-path)))
    216 
    217    (printf "Testing 1-element sexpr stream...\n")
     240
     241   (printf "1-element sexpr stream...\n")
    218242   (define test-list (list 1 2 3 4 5 6 7 8 9 10 11))
    219243   (define test-data (list->u8vector test-list))
     
    236260         (check-dir-is-empty store-path)))
    237261
    238    (printf "Testing 2-element sexpr stream...\n")
     262   (printf "2-element sexpr stream...\n")
    239263   (define test-list (list 1 2 3 4 5 6 7 8 9 10 11 12))
    240264   (define test-data (list->u8vector test-list))
     
    259283         (check-dir-is-empty store-path)))
    260284   
    261    (printf "Testing ~A-element sexpr stream...\n" iterations)
     285   (printf "~A-element sexpr stream...\n" iterations)
    262286   (define test-list (list 1 2 3 4 5 6 7 8 9 10 11 12 13))
    263287   (define test-data (list->u8vector test-list))
     
    287311         (check-dir-is-empty store-path)))
    288312   
    289    (printf "Testing files...\n")
     313   (printf "files...\n")
    290314   (define test-string "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.")
    291315   
     
    308332         (check-dir-is-empty store-path)))
    309333   
    310    (printf "Testing directories...\n")
     334   (printf "directories...\n")
    311335   
    312336   (printf "\tStore a directory\n")
     
    325349         (check-dir-is-empty store-path)))
    326350   
    327    (printf "Testing snapshots\n")
     351   (printf "snapshots\n")
    328352
    329353   (printf "\tStore a directory\n")
Note: See TracChangeset for help on using the changeset viewer.