X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=contrib%2Fsb-posix%2Fposix-tests.lisp;h=d25708653a81640cc47d54c02bc739315365a721;hb=82f9c527cb607ccd19e5b24261dfe9af7b1ba72e;hp=1d46cdf1e6f50e7b406db8584d8196ae1d10f9af;hpb=9b122ef7235285381cf1933808371ebff5997d2a;p=sbcl.git diff --git a/contrib/sb-posix/posix-tests.lisp b/contrib/sb-posix/posix-tests.lisp index 1d46cdf..d257086 100644 --- a/contrib/sb-posix/posix-tests.lisp +++ b/contrib/sb-posix/posix-tests.lisp @@ -107,13 +107,16 @@ (handler-case (sb-posix:mkdir #-win32 "/" #+win32 "C:/" 0) (sb-posix:syscall-error (c) - (sb-posix:syscall-errno c))) - #+darwin - #.sb-posix:eisdir - #+win32 - #.sb-posix:eacces - #-(or darwin win32) - #.sb-posix::eexist) + ;; The results aren't the most consistent ones across platforms. Darwin + ;; likes EISDIR, Windows either EACCESS or EEXIST, others EEXIST. + ;; ...let's just accept them all. + (when (member (sb-posix:syscall-errno c) + (list #.sb-posix:eisdir + #.sb-posix:eacces + #.sb-posix::eexist) + :test #'eql) + :ok))) + :ok) (define-eacces-test mkdir.error.3 (let* ((dir (merge-pathnames @@ -275,7 +278,7 @@ (deftest stat.5 (let* ((stat-1 (sb-posix:stat "/")) (mode-1 (sb-posix:stat-mode stat-1)) - (stat-2 (sb-posix:stat "C:\\CONFIG.SYS" + (stat-2 (sb-posix:stat "C:\\pagefile.sys" stat-1)) (mode-2 (sb-posix:stat-mode stat-2))) (values @@ -502,6 +505,24 @@ kid-status)) 42) +(deftest read.1 + (progn + (with-open-file (ouf (merge-pathnames "read-test.txt" *test-directory*) + :direction :output + :if-exists :supersede + :if-does-not-exist :create) + (write-string "foo" ouf)) + (let ((fd (sb-posix:open (merge-pathnames "read-test.txt" *test-directory*) sb-posix:o-rdonly))) + (unwind-protect + (let ((buf (make-array 10 :element-type '(unsigned-byte 8)))) + (values + (sb-posix:read fd (sb-sys:vector-sap buf) 10) + (code-char (aref buf 0)) + (code-char (aref buf 1)) + (code-char (aref buf 2)))) + (sb-posix:close fd)))) + 3 #\f #\o #\o) + (deftest opendir.1 (let ((dir (sb-posix:opendir "/"))) (unwind-protect (sb-alien:null-alien dir) @@ -543,6 +564,23 @@ (sb-posix:closedir dir))) t) + +(deftest write.1 + (progn + (let ((fd (sb-posix:open (merge-pathnames "write-test.txt" *test-directory*) + (logior sb-posix:o-creat sb-posix:o-wronly) + (logior sb-posix:s-irusr sb-posix:s-iwusr))) + (retval nil)) + (unwind-protect + (let ((buf (coerce "foo" 'simple-base-string))) + (setf retval (sb-posix:write fd (sb-sys:vector-sap buf) 3))) + (sb-posix:close fd)) + + (with-open-file (inf (merge-pathnames "write-test.txt" *test-directory*) + :direction :input) + (values retval (read-line inf))))) + 3 "foo") + #-win32 (deftest pwent.1 ;; make sure that we found something @@ -821,11 +859,10 @@ :type (format nil "~AXXXXXX" (make-string n :initial-element #\x)) :defaults default)) - (let ((pathname (sb-ext:parse-native-namestring temp))) (unwind-protect - (values (integerp fd) (pathname-name pathname)) - (delete-file temp))))) - t "mkstemp-1") + (values (integerp fd) (subseq temp 0 (position #\. temp))) + (delete-file temp)))) + t "/tmp/mkstemp-1") (deftest envstuff (let ((name1 "ASLIFJLSDKFJKAHGSDKLJH")