file-utimes.lisp 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. (in-package :translator-test)
  2. (def-test-method file-utimes-test ((test fs-test))
  3. (with-testport (p (file-name-lookup +translator-root+))
  4. (let ((stat (io-stat p))
  5. (tval1 (make-time-value
  6. :seconds 50000
  7. :microseconds 1))
  8. (tval2 (make-time-value
  9. :seconds 20000
  10. :microseconds 5)))
  11. (assert-true (file-utimes p :atime tval1 :mtime tval2))
  12. (let* ((new-stat (io-stat p))
  13. (a-tval (stat-get new-stat 'st-atime))
  14. (m-tval (stat-get new-stat 'st-mtime)))
  15. (assert-equal (time-value-seconds a-tval)
  16. (time-value-seconds tval1))
  17. (assert-equal (time-value-microseconds a-tval)
  18. (time-value-microseconds tval1))
  19. (assert-equal (time-value-seconds m-tval)
  20. (time-value-seconds tval2))
  21. (assert-equal (time-value-microseconds m-tval)
  22. (time-value-microseconds tval2))
  23. (assert-true (file-utimes p
  24. :atime (stat-get stat 'st-atime)
  25. :mtime (stat-get stat 'st-mtime))))
  26. (let ((new-stat (io-stat p)))
  27. (assert-true (time-value-eq (stat-get new-stat 'st-atime)
  28. (stat-get stat 'st-atime)))
  29. (assert-true (time-value-eq (stat-get new-stat 'st-mtime)
  30. (stat-get stat 'st-mtime))))
  31. (assert-true (file-utimes p))
  32. (let ((new-stat (io-stat p)))
  33. (assert-true (time-value-newer-p (stat-get new-stat 'st-atime)
  34. (stat-get stat 'st-atime)))
  35. (assert-true (time-value-newer-p (stat-get new-stat 'st-mtime)
  36. (stat-get stat 'st-atime))))
  37. (assert-true (file-utimes p
  38. :atime (stat-get stat 'st-atime)
  39. :mtime (stat-get stat 'st-mtime))))))