Commit c11a9e3a authored by Eric Timmons's avatar Eric Timmons
Browse files

Add tests for hard and sym links

parent 7278e83e
......@@ -116,6 +116,9 @@
(defmethod entry-symbolic-link-p (entry)
(eql (typeflag entry) +tar-symbolic-link+))
(defmethod entry-hard-link-p (entry)
(eql (typeflag entry) +tar-hard-link+))
(defmethod entry-character-device-p (entry)
(eql (typeflag entry) +tar-character-device+))
......
......@@ -24,10 +24,13 @@
#:mtime
#:uid
#:gid
#:linkname
;; entry tests
#:entry-directory-p
#:entry-regular-file-p
#:entry-symbolic-link-p
#:entry-hard-link-p
#:entry-character-device-p
#:entry-block-device-p
#:entry-fifo-p
......
No preview for this file type
......@@ -8,18 +8,23 @@ touch_file () {
touch_files () {
touch_file "$DIR/a.txt"
touch_file "$DIR/a-symlink.txt"
touch_file "$DIR/a-hardlink.txt"
}
echo "Hello, world!" > "$DIR/a.txt"
ln -s a.txt "$DIR/a-symlink.txt"
ln "$DIR/a.txt" "$DIR/a-hardlink.txt"
run_tar () {
tar -H "$1" -C "$DIR" \
--group=root --owner=root \
-b 20 \
--mtime "Fri Aug 13 09:05:46.5 PM EDT 2021" \
-cf "$1.tar" a.txt
-cf "$1.tar" a.txt a-symlink.txt a-hardlink.txt
}
ls -lah "$DIR"
touch_files
run_tar ustar
touch_files
......
No preview for this file type
......@@ -11,6 +11,7 @@
(let (entry)
;; First entry is a plain file, with the contents "Hello, world!"
(setf entry (tar:read-entry-from-archive a))
(para:is equal (tar:name entry) "a.txt")
(para:is = (tar:size entry) 14)
(para:is equal (tar:uname entry) "root")
(para:is equal (tar:gname entry) "root")
......@@ -22,6 +23,32 @@
(para:is equal "Hello, world!
" (contents-as-string entry))
;; Next is the a-symlink.txt -> a.txt symlink
(setf entry (tar:read-entry-from-archive a))
(para:is equal (tar:name entry) "a-symlink.txt")
(para:is = (tar:size entry) 0)
(para:is equal (tar:uname entry) "root")
(para:is equal (tar:gname entry) "root")
(para:is = (tar:mode entry) #o777)
(para:true (tar:entry-symbolic-link-p entry))
(para:is = (tar:mtime entry) 1628903146)
(para:is = (tar:uid entry) 0)
(para:is = (tar:gid entry) 0)
(para:is equal (tar:linkname entry) "a.txt")
;; Next is the a-hardlink.txt -> a.txt hardlink
(setf entry (tar:read-entry-from-archive a))
(para:is equal (tar:name entry) "a-hardlink.txt")
(para:is = (tar:size entry) 0)
(para:is equal (tar:uname entry) "root")
(para:is equal (tar:gname entry) "root")
(para:is = (tar:mode entry) #o644)
(para:true (tar:entry-hard-link-p entry))
(para:is = (tar:mtime entry) 1628903146)
(para:is = (tar:uid entry) 0)
(para:is = (tar:gid entry) 0)
(para:is equal (tar:linkname entry) "a.txt")
;; End of archive
(setf entry (tar:read-entry-from-archive a))
(para:true (null entry)))))
......@@ -41,6 +68,28 @@
(para:is equal "Hello, world!
" (contents-as-string entry))
;; Next is the a-symlink.txt -> a.txt symlink
(setf entry (tar:read-entry-from-archive a))
(para:is equal (tar:name entry) "a-symlink.txt")
(para:is = (tar:size entry) 0)
(para:is = (tar:mode entry) #o777)
(para:true (tar:entry-symbolic-link-p entry))
(para:is = (tar:mtime entry) 1628903146)
(para:is = (tar:uid entry) 0)
(para:is = (tar:gid entry) 0)
(para:is equal (tar:linkname entry) "a.txt")
;; Next is the a-hardlink.txt -> a.txt hardlink
(setf entry (tar:read-entry-from-archive a))
(para:is equal (tar:name entry) "a-hardlink.txt")
(para:is = (tar:size entry) 0)
(para:is = (tar:mode entry) #o644)
(para:true (tar:entry-hard-link-p entry))
(para:is = (tar:mtime entry) 1628903146)
(para:is = (tar:uid entry) 0)
(para:is = (tar:gid entry) 0)
(para:is equal (tar:linkname entry) "a.txt")
;; End of archive
(setf entry (tar:read-entry-from-archive a))
(para:true (null entry)))))
No preview for this file type
No preview for this file type
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment