1.0.1.14: Make sb-posix:mkstemp return both the FD and the file name.
[sbcl.git] / contrib / sb-posix / posix-tests.lisp
index c228642..78b4754 100644 (file)
       (ignore-errors (delete-file pathname))))
   t)
 \f
-(defvar *test-directory* (merge-pathnames "test-lab/"))
 ;;; see comment in filename's designator definition, in macros.lisp
 (deftest filename-designator.1
   (let ((file (format nil "~A/[foo].txt" (namestring *test-directory*))))
       (sb-posix:closedir dir)))
   t)
 
+(deftest readdir/dirent-name
+    (let ((dir (sb-posix:opendir *current-directory*)))
+      (unwind-protect
+           (equal (sort (loop for entry = (sb-posix:readdir dir)
+                           until (sb-alien:null-alien entry)
+                           collect (sb-posix:dirent-name entry))
+                        #'string<)
+                  (sort (append '("." "..")
+                                (mapcar (lambda (p)
+                                          (let ((string (enough-namestring p *current-directory*)))
+                                            (if (pathname-name p)
+                                                string
+                                                (subseq string 0 (1- (length string))))))
+                                        (directory (make-pathname
+                                                    :name :wild
+                                                    :type :wild
+                                                    :defaults *current-directory*))))
+                        #'string<))
+        (sb-posix:closedir dir)))
+  t)
+
 #-win32
 (deftest pwent.1
   ;; make sure that we found something