dir-readdir.lisp 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. (in-package :translator-test)
  2. (defun %my-readdir (dir &key (entry 0)
  3. (nentries -1))
  4. (loop for item in (dir-readdir dir
  5. :entry entry
  6. :nentries nentries)
  7. collect (list (dirent-name item)
  8. (dirent-type item))))
  9. (def-test-method dir-readdir-test ((test fs-test))
  10. (with-testport (dir (file-name-lookup +main-dir+
  11. :flags '(:read)))
  12. (let ((size (length (dir-readdir dir))))
  13. (assert-equal '(("." :dir)
  14. (".." :dir)
  15. ("a" :reg)
  16. ("b" :reg)
  17. ("c" :reg)
  18. ("d" :reg)
  19. ("dir1" :dir)
  20. ("dir2" :dir)
  21. ("dir3" :dir)
  22. ("f" :lnk)
  23. ("g" :lnk)
  24. ("h" :lnk))
  25. (%my-readdir dir))
  26. (assert-equal '(("." :dir)
  27. (".." :dir))
  28. (%my-readdir dir :nentries 2))
  29. (assert-equal '(("a" :reg))
  30. (%my-readdir dir :nentries 1
  31. :entry 2))
  32. (assert-equal nil
  33. (%my-readdir dir :nentries 0))
  34. (assert-equal nil
  35. (%my-readdir dir :entry 50))
  36. (assert-equal '(("dir3" :dir)
  37. ("f" :lnk)
  38. ("g" :lnk)
  39. ("h" :lnk))
  40. (%my-readdir dir :entry 8)))))