Use WITH-SCRATCH-FILE in md5 test

This commit is contained in:
Douglas Katzman 2022-09-23 10:43:35 -04:00
parent c4da17fcbc
commit 9ec3631242
4 changed files with 13 additions and 19 deletions

View file

@ -132,22 +132,13 @@
("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" . "a0d1395c7fb36247bfe2d49376d9d133")
("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" . "ab75504250558b788f99d1ebd219abf2"))))
(deftest sb-md5.md5sum-file.0
(let ((file
(loop with ret
for filename = (format nil "md5-test-~6,'0D" (random 100000))
do (with-open-file (stream filename :direction :output
:if-exists nil
:if-does-not-exist :create)
(when stream
(setf ret stream)))
when ret return ret)))
(unwind-protect
(string= (format nil "~(~{~2,'0X~}~)"
(coerce (md5sum-file file) 'list))
"d41d8cd98f00b204e9800998ecf8427e")
(delete-file file)))
t)
;; This is barely a test. It's md5summing an empty file. Why?
(test-util:with-test (:name :sb-md5.md5sum-file.0)
(test-util:with-scratch-file (name)
(with-open-file (stream name :direction :output :if-does-not-exist :create))
(let ((answer (md5sum-file name)))
(assert (string= (format nil "~(~{~2,'0X~}~)" (coerce answer 'list))
"d41d8cd98f00b204e9800998ecf8427e")))))
(deftest sb-md5.md5sum-sequence.error.0
(handler-case (md5sum-sequence "foo")

View file

@ -116,7 +116,8 @@
"../contrib/sb-simd/test-suite/test-horizontal-functions.lisp"
"../contrib/sb-simd/test-suite/test-hairy-simd-functions.lisp"
"../contrib/sb-simd/test-suite/test-packages.lisp")
("sb-simple-streams.impure.lisp" "contrib/sb-simple-streams.fasl" "contrib/sb-bsd-sockets.fasl")
("sb-simple-streams.impure.lisp" "contrib/sb-simple-streams.fasl" "contrib/sb-bsd-sockets.fasl"
"../contrib/sb-simple-streams/simple-stream-tests.lisp")
("sb-rotate-byte.impure.lisp" "contrib/sb-rotate-byte.fasl"
"../contrib/sb-rotate-byte/rotate-byte-tests.lisp")
("sb-sprof.impure.lisp" "contrib/sb-sprof.fasl"

View file

@ -12,5 +12,4 @@
(when (search "ALIEN-FUNCALL" text)
(error "Compiler bug on ~S" code)))))))))
(setq run-tests::*allowed-inputs* :any) ; makes random pathnames without aid of WITH-SCRATCH-FILE
(load "../contrib/sb-md5/md5-tests.lisp")

View file

@ -1,3 +1,6 @@
(require :sb-simple-streams)
(setq run-tests::*allowed-inputs* :any)
;; impure tests don't use the input manifest under run-tests.sh
;; but do under parallel-exec, which runs each test as if pure,
;; but in a forked child.
#+parallel-test-runner (setq run-tests::*allowed-inputs* :any)
(load "../contrib/sb-simple-streams/simple-stream-tests.lisp")