;;; test hfs+ interface (use test) (use hfs+) (use files) (use posix) ;; Assumes UNIX files are created with no attributes. ;; Untested: Finder info. Removing resource forks ;; (must set to ""). (test-group "extended-attribute handling" (define file (create-temporary-file "hfs-test")) (define link (string-append file ".link")) ; meh (test "empty initial attribute set" '() (list-extended-attributes file)) ;; (set-extended-attribute! file "com.apple.FinderInfo" (make-string 32 #\x00)) (set-extended-attribute! file "chicken.baz" "quux") (set-extended-attribute! file "chicken.zot" "erp") (set-extended-attribute! file "chicken.foo" "bar") (test "list three attributes in chicken namespace" '("chicken.baz" "chicken.foo" "chicken.zot") (sort (list-extended-attributes file) stringdata ; will segfault (set! file (create-temporary-file "hfs-test")) (set! link (string-append file ".link")) ; meh (set! unpacked-file (create-temporary-file "hfs-test")) (define packed-file (string-append "._" file)) (define packed-link (string-append "._" link)) (set! unpacked-link-file (create-temporary-file "hfs-test")) (set! unpacked-link (string-append unpacked-link-file ".link")) (test (string-append "set extended attributes on " file) #t (begin (set-extended-attribute! file "com.apple.ResourceFork" "spoon!") (set-extended-attribute! file "org.3e8.private" "eye") #t)) (test (string-append "pack " file " to appledouble " packed-file) #t (pack-appledouble file packed-file)) (test (string-append "unpack " file " to " unpacked-file) #t (unpack-appledouble packed-file unpacked-file)) (test (string-append "recover resource fork from " unpacked-file) "spoon!" (get-extended-attribute unpacked-file "com.apple.ResourceFork")) (test (string-append "recover private attribute from " unpacked-file) "eye" (get-extended-attribute unpacked-file "org.3e8.private")) (test (string-append "check attributes on " unpacked-file) '(xattr) (copyfile-check unpacked-file #:metadata)) ;; Attempt to copy attributes from a symbolic link to another symbolic link. ;; This will fail on 10.4, which does not honor no-follow on unpack/pack. ;; Set attributes on the links and backing files beforehand so we can ;; see what propagates through. (create-symbolic-link file link) (create-symbolic-link unpacked-link-file unpacked-link) (set-extended-attribute! link "org.3e8.private" "file") (set-extended-attribute! link "org.3e8.private" "link" #:no-follow) (set-extended-attribute! unpacked-link "org.3e8.private" "unpacked-link" #:no-follow) (set-extended-attribute! unpacked-link-file "org.3e8.private" "unpacked-link-file" #:no-follow) (pack-appledouble link packed-link #:no-follow) (unpack-appledouble packed-link unpacked-link #:no-follow) (test (string-append "recover private attribute from symlink (fails on 10.4)") "link" (get-extended-attribute unpacked-link "org.3e8.private" #:no-follow)) (test (string-append "recover private attribute from backing file (fails on 10.4)") "unpacked-link-file" (get-extended-attribute link "org.3e8.private")) (delete-file file) (delete-file link) (delete-file unpacked-file) (delete-file unpacked-link) (delete-file unpacked-link-file) (delete-file packed-file) (delete-file packed-link)) (test-group "unimplemented or untested" (test (string-append "copyfile #:data") 0 (error "cannot test data->data copyfile on Tiger, may segfault"))) ;;; further tests go here