Test our output against GNU and BSD tar

This commit is contained in:
Lassi Kortela 2019-06-23 12:16:23 +03:00
parent 0d1c459c32
commit e6d45ea173
4 changed files with 46 additions and 4 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/test*.tar

View File

@ -3,13 +3,25 @@
(import (scheme base)
(scheme file)
(scheme process-context)
(scheme read)
(scheme write)
(tex-parser))
(trivial-tar-writer))
(define (slurp-binary-file filename)
(call-with-port
(open-binary-input-file filename)
(lambda (port)
(let loop ((whole (make-bytevector 0)))
(let ((part (read-bytevector 4096 port)))
(if (eof-object? part)
whole
(loop (bytevector-append whole part))))))))
(tar-write-file "hello/world.text"
(slurp-binary-file "trivial-tar-writer.scm"))
(define (main arguments)
(for-each (lambda (tex-file)
(display (with-input-from-file tex-file read-tex-document))
(newline))
(for-each (lambda (file) (tar-write-file file (slurp-binary-file file)))
(cdr arguments)))
(main (command-line))

15
test-tex-chibi.scm Normal file
View File

@ -0,0 +1,15 @@
#! /usr/bin/env chibi-scheme
(import (scheme base)
(scheme file)
(scheme process-context)
(scheme write)
(tex-parser))
(define (main arguments)
(for-each (lambda (tex-file)
(display (with-input-from-file tex-file read-tex-document))
(newline))
(cdr arguments)))
(main (command-line))

14
test.sh Executable file
View File

@ -0,0 +1,14 @@
#!/bin/sh
set -eux
./test-chibi.scm trivial-tar-writer.scm >test-our.tar
bsdtar -cf test-bsd.tar trivial-tar-writer.scm
gtar -cf test-gnu.tar trivial-tar-writer.scm
hexdump -C test-our.tar
echo
echo
echo
hexdump -C test-gnu.tar
echo
echo
echo
hexdump -C test-bsd.tar