aboutsummaryrefslogtreecommitdiff
path: root/lib/tar
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2023-01-31 11:30:46 +0100
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2023-01-31 18:04:25 +0100
commit72c8155d9fc0eaeac72c053f46ebb7b231d4596a (patch)
tree5758865289c52fa93f56e3fe743bb40c283c5233 /lib/tar
parentcdccc69c62579b0c13b35fad0728079652b8f3c9 (diff)
Reintegrate test code with library code
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/tar')
-rw-r--r--lib/tar/Makemodule.am177
-rw-r--r--lib/tar/test/data/CREDITS35
-rw-r--r--lib/tar/test/data/file-size/12-digit.tarbin0 -> 2048 bytes
-rw-r--r--lib/tar/test/data/file-size/gnu.tarbin0 -> 2048 bytes
-rw-r--r--lib/tar/test/data/file-size/pax.tarbin0 -> 2048 bytes
-rw-r--r--lib/tar/test/data/format-acceptance/gnu-g.tarbin0 -> 2048 bytes
-rw-r--r--lib/tar/test/data/format-acceptance/gnu.tarbin0 -> 2048 bytes
-rw-r--r--lib/tar/test/data/format-acceptance/link_filled.tarbin0 -> 10240 bytes
-rw-r--r--lib/tar/test/data/format-acceptance/pax.tarbin0 -> 3072 bytes
-rw-r--r--lib/tar/test/data/format-acceptance/ustar-pre-posix.tarbin0 -> 2048 bytes
-rw-r--r--lib/tar/test/data/format-acceptance/ustar.tarbin0 -> 2048 bytes
-rw-r--r--lib/tar/test/data/format-acceptance/v7.tarbin0 -> 2048 bytes
-rw-r--r--lib/tar/test/data/large-mtime/12-digit.tarbin0 -> 2048 bytes
-rw-r--r--lib/tar/test/data/large-mtime/gnu.tarbin0 -> 2048 bytes
-rw-r--r--lib/tar/test/data/large-mtime/pax.tarbin0 -> 3072 bytes
-rw-r--r--lib/tar/test/data/long-paths/gnu.tarbin0 -> 3072 bytes
-rw-r--r--lib/tar/test/data/long-paths/pax.tarbin0 -> 3072 bytes
-rw-r--r--lib/tar/test/data/long-paths/ustar.tarbin0 -> 2048 bytes
-rw-r--r--lib/tar/test/data/negative-mtime/gnu.tarbin0 -> 10240 bytes
-rw-r--r--lib/tar/test/data/negative-mtime/pax.tarbin0 -> 10240 bytes
-rw-r--r--lib/tar/test/data/sparse-files/gnu-small.tarbin0 -> 9728 bytes
-rw-r--r--lib/tar/test/data/sparse-files/gnu.tarbin0 -> 34816 bytes
-rw-r--r--lib/tar/test/data/sparse-files/pax-gnu0-0.tarbin0 -> 35840 bytes
-rw-r--r--lib/tar/test/data/sparse-files/pax-gnu0-1.tarbin0 -> 35328 bytes
-rw-r--r--lib/tar/test/data/sparse-files/pax-gnu1-0.tarbin0 -> 35840 bytes
-rw-r--r--lib/tar/test/data/user-group-largenum/8-digit.tarbin0 -> 2048 bytes
-rw-r--r--lib/tar/test/data/user-group-largenum/gnu.tarbin0 -> 2048 bytes
-rw-r--r--lib/tar/test/data/user-group-largenum/pax.tarbin0 -> 3072 bytes
-rw-r--r--lib/tar/test/data/xattr/acl.tarbin0 -> 3072 bytes
-rw-r--r--lib/tar/test/data/xattr/xattr-libarchive.tarbin0 -> 3072 bytes
-rw-r--r--lib/tar/test/data/xattr/xattr-schily-binary.tarbin0 -> 3072 bytes
-rw-r--r--lib/tar/test/data/xattr/xattr-schily.tarbin0 -> 3072 bytes
-rw-r--r--lib/tar/test/tar_big_file.c31
-rw-r--r--lib/tar/test/tar_fuzz.c49
-rw-r--r--lib/tar/test/tar_simple.c64
-rw-r--r--lib/tar/test/tar_sparse.c86
-rw-r--r--lib/tar/test/tar_sparse_gnu.c52
-rw-r--r--lib/tar/test/tar_target_filled.c109
-rw-r--r--lib/tar/test/tar_xattr.c42
-rw-r--r--lib/tar/test/tar_xattr_bin.c50
40 files changed, 695 insertions, 0 deletions
diff --git a/lib/tar/Makemodule.am b/lib/tar/Makemodule.am
index 1db02f1..896ce0f 100644
--- a/lib/tar/Makemodule.am
+++ b/lib/tar/Makemodule.am
@@ -6,3 +6,180 @@ libtar_a_SOURCES = lib/tar/src/read_header.c lib/tar/src/write_header.c \
include/tar/tar.h include/tar/format.h
noinst_LIBRARIES += libtar.a
+
+TARDATADIR=$(top_srcdir)/lib/tar/test/data
+
+test_tar_gnu0_SOURCES = lib/tar/test/tar_simple.c
+test_tar_gnu0_LDADD = libtar.a libio.a libutil.a libcompat.a
+test_tar_gnu0_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(TARDATADIR)
+test_tar_gnu0_CPPFLAGS += -DTESTFILE=format-acceptance/gnu.tar
+
+test_tar_gnu1_SOURCES = lib/tar/test/tar_simple.c
+test_tar_gnu1_LDADD = libtar.a libio.a libutil.a libcompat.a
+test_tar_gnu1_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(TARDATADIR)
+test_tar_gnu1_CPPFLAGS += -DTESTFILE=format-acceptance/gnu-g.tar
+
+test_tar_gnu2_SOURCES = lib/tar/test/tar_simple.c
+test_tar_gnu2_LDADD = libtar.a libio.a libutil.a libcompat.a
+test_tar_gnu2_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(TARDATADIR)
+test_tar_gnu2_CPPFLAGS += -DTESTFILE=user-group-largenum/gnu.tar
+test_tar_gnu2_CPPFLAGS += -DTESTUID=0x80000000 -DTESTGID=0x80000000
+test_tar_gnu2_CPPFLAGS += -DTESTTS=1542995392
+
+test_tar_gnu3_SOURCES = lib/tar/test/tar_simple.c
+test_tar_gnu3_LDADD = libtar.a libio.a libutil.a libcompat.a
+test_tar_gnu3_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(TARDATADIR)
+test_tar_gnu3_CPPFLAGS += -DTESTFILE=negative-mtime/gnu.tar -DTESTTS=-315622800
+
+test_tar_gnu4_SOURCES = lib/tar/test/tar_simple.c
+test_tar_gnu4_LDADD = libtar.a libio.a libutil.a libcompat.a
+test_tar_gnu4_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(TARDATADIR)
+test_tar_gnu4_CPPFLAGS += -DTESTFILE=long-paths/gnu.tar -DLONG_NAME_TEST
+test_tar_gnu4_CPPFLAGS += -DTESTTS=1542909670
+
+test_tar_gnu5_SOURCES = lib/tar/test/tar_simple.c
+test_tar_gnu5_LDADD = libtar.a libio.a libutil.a libcompat.a
+test_tar_gnu5_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(TARDATADIR)
+test_tar_gnu5_CPPFLAGS += -DTESTFILE=large-mtime/gnu.tar -DTESTTS=8589934592L
+
+test_tar_gnu6_SOURCES = lib/tar/test/tar_big_file.c
+test_tar_gnu6_LDADD = libtar.a libio.a libutil.a libcompat.a
+test_tar_gnu6_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(TARDATADIR)
+test_tar_gnu6_CPPFLAGS += -DTESTFILE=file-size/gnu.tar
+
+test_tar_pax0_SOURCES = lib/tar/test/tar_simple.c
+test_tar_pax0_LDADD = libtar.a libio.a libutil.a libcompat.a
+test_tar_pax0_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(TARDATADIR)
+test_tar_pax0_CPPFLAGS += -DTESTFILE=format-acceptance/pax.tar
+
+test_tar_pax1_SOURCES = lib/tar/test/tar_simple.c
+test_tar_pax1_LDADD = libtar.a libio.a libutil.a libcompat.a
+test_tar_pax1_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(TARDATADIR)
+test_tar_pax1_CPPFLAGS += -DTESTFILE=user-group-largenum/pax.tar
+test_tar_pax1_CPPFLAGS += -DTESTUID=2147483648UL -DTESTGID=2147483648UL
+test_tar_pax1_CPPFLAGS += -DTESTTS=1542995392
+
+test_tar_pax2_SOURCES = lib/tar/test/tar_simple.c
+test_tar_pax2_LDADD = libtar.a libio.a libutil.a libcompat.a
+test_tar_pax2_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(TARDATADIR)
+test_tar_pax2_CPPFLAGS += -DTESTFILE=large-mtime/pax.tar -DTESTTS=8589934592L
+
+test_tar_pax3_SOURCES = lib/tar/test/tar_simple.c
+test_tar_pax3_LDADD = libtar.a libio.a libutil.a libcompat.a
+test_tar_pax3_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(TARDATADIR)
+test_tar_pax3_CPPFLAGS += -DTESTFILE=negative-mtime/pax.tar -DTESTTS=-315622800
+
+test_tar_pax4_SOURCES = lib/tar/test/tar_simple.c
+test_tar_pax4_LDADD = libtar.a libio.a libutil.a libcompat.a
+test_tar_pax4_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(TARDATADIR)
+test_tar_pax4_CPPFLAGS += -DTESTFILE=long-paths/pax.tar
+test_tar_pax4_CPPFLAGS += -DLONG_NAME_TEST -DTESTTS=1542909670
+
+test_tar_pax5_SOURCES = lib/tar/test/tar_big_file.c
+test_tar_pax5_LDADD = libtar.a libio.a libutil.a libcompat.a
+test_tar_pax5_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(TARDATADIR)
+test_tar_pax5_CPPFLAGS += -DTESTFILE=file-size/pax.tar
+
+test_tar_ustar0_SOURCES = lib/tar/test/tar_simple.c
+test_tar_ustar0_LDADD = libtar.a libio.a libutil.a libcompat.a
+test_tar_ustar0_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(TARDATADIR)
+test_tar_ustar0_CPPFLAGS += -DTESTFILE=format-acceptance/ustar.tar
+
+test_tar_ustar1_SOURCES = lib/tar/test/tar_simple.c
+test_tar_ustar1_LDADD = libtar.a libio.a libutil.a libcompat.a
+test_tar_ustar1_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(TARDATADIR)
+test_tar_ustar1_CPPFLAGS += -DTESTFILE=format-acceptance/ustar-pre-posix.tar
+
+test_tar_ustar2_SOURCES = lib/tar/test/tar_simple.c
+test_tar_ustar2_LDADD = libtar.a libio.a libutil.a libcompat.a
+test_tar_ustar2_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(TARDATADIR)
+test_tar_ustar2_CPPFLAGS += -DTESTFILE=format-acceptance/v7.tar
+
+test_tar_ustar3_SOURCES = lib/tar/test/tar_simple.c
+test_tar_ustar3_LDADD = libtar.a libio.a libutil.a libcompat.a
+test_tar_ustar3_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(TARDATADIR)
+test_tar_ustar3_CPPFLAGS += -DTESTFILE=user-group-largenum/8-digit.tar
+test_tar_ustar3_CPPFLAGS += -DTESTUID=8388608 -DTESTGID=8388608
+test_tar_ustar3_CPPFLAGS += -DTESTTS=1542995392
+
+test_tar_ustar4_SOURCES = lib/tar/test/tar_simple.c
+test_tar_ustar4_LDADD = libtar.a libio.a libutil.a libcompat.a
+test_tar_ustar4_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(TARDATADIR)
+test_tar_ustar4_CPPFLAGS += -DTESTFILE=large-mtime/12-digit.tar
+test_tar_ustar4_CPPFLAGS += -DTESTTS=8589934592L
+
+test_tar_ustar5_SOURCES = lib/tar/test/tar_simple.c
+test_tar_ustar5_LDADD = libtar.a libio.a libutil.a libcompat.a
+test_tar_ustar5_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(TARDATADIR)
+test_tar_ustar5_CPPFLAGS += -DTESTFILE=long-paths/ustar.tar
+test_tar_ustar5_CPPFLAGS += -DLONG_NAME_TEST -DTESTTS=1542909670
+
+test_tar_ustar6_SOURCES = lib/tar/test/tar_big_file.c
+test_tar_ustar6_LDADD = libtar.a libio.a libutil.a libcompat.a
+test_tar_ustar6_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(TARDATADIR)
+test_tar_ustar6_CPPFLAGS += -DTESTFILE=file-size/12-digit.tar
+
+test_tar_target_filled_SOURCES = lib/tar/test/tar_target_filled.c
+test_tar_target_filled_LDADD = libtar.a libio.a libutil.a libcompat.a
+test_tar_target_filled_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(TARDATADIR)
+
+test_tar_sparse_gnu_SOURCES = lib/tar/test/tar_sparse_gnu.c
+test_tar_sparse_gnu_LDADD = libtar.a libio.a libutil.a libcompat.a
+test_tar_sparse_gnu_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(TARDATADIR)
+
+test_tar_sparse_gnu0_SOURCES = lib/tar/test/tar_sparse.c
+test_tar_sparse_gnu0_LDADD = libtar.a libio.a libutil.a libcompat.a
+test_tar_sparse_gnu0_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(TARDATADIR)
+test_tar_sparse_gnu0_CPPFLAGS += -DTESTFILE=sparse-files/pax-gnu0-0.tar
+
+test_tar_sparse_gnu1_SOURCES = lib/tar/test/tar_sparse.c
+test_tar_sparse_gnu1_LDADD = libtar.a libio.a libutil.a libcompat.a
+test_tar_sparse_gnu1_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(TARDATADIR)
+test_tar_sparse_gnu1_CPPFLAGS += -DTESTFILE=sparse-files/pax-gnu0-1.tar
+
+test_tar_sparse_gnu2_SOURCES = lib/tar/test/tar_sparse.c
+test_tar_sparse_gnu2_LDADD = libtar.a libio.a libutil.a libcompat.a
+test_tar_sparse_gnu2_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(TARDATADIR)
+test_tar_sparse_gnu2_CPPFLAGS += -DTESTFILE=sparse-files/pax-gnu1-0.tar
+
+test_tar_sparse_gnu3_SOURCES = lib/tar/test/tar_sparse.c
+test_tar_sparse_gnu3_LDADD = libtar.a libio.a libutil.a libcompat.a
+test_tar_sparse_gnu3_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(TARDATADIR)
+test_tar_sparse_gnu3_CPPFLAGS += -DTESTFILE=sparse-files/gnu.tar
+
+test_tar_xattr_bsd_SOURCES = lib/tar/test/tar_xattr.c
+test_tar_xattr_bsd_LDADD = libtar.a libio.a libutil.a libcompat.a
+test_tar_xattr_bsd_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(TARDATADIR)
+test_tar_xattr_bsd_CPPFLAGS += -DTESTFILE=xattr/xattr-libarchive.tar
+
+test_tar_xattr_schily_SOURCES = lib/tar/test/tar_xattr.c
+test_tar_xattr_schily_LDADD = libtar.a libio.a libutil.a libcompat.a
+test_tar_xattr_schily_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(TARDATADIR)
+test_tar_xattr_schily_CPPFLAGS += -DTESTFILE=xattr/xattr-schily.tar
+
+test_tar_xattr_schily_bin_SOURCES = lib/tar/test/tar_xattr_bin.c
+test_tar_xattr_schily_bin_LDADD = libtar.a libio.a libutil.a libcompat.a
+test_tar_xattr_schily_bin_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(TARDATADIR)
+test_tar_xattr_schily_bin_CPPFLAGS += -DTESTFILE=xattr/xattr-schily-binary.tar
+
+tar_fuzz_SOURCES = lib/tar/test/tar_fuzz.c
+tar_fuzz_LDADD = libtar.a libio.a libutil.a libcompat.a
+
+LIBTAR_TESTS = \
+ test_tar_ustar0 test_tar_ustar1 test_tar_ustar2 test_tar_ustar3 \
+ test_tar_ustar4 test_tar_ustar5 test_tar_ustar6 \
+ test_tar_pax0 test_tar_pax1 test_tar_pax2 test_tar_pax3 test_tar_pax4 \
+ test_tar_pax5 \
+ test_tar_gnu0 test_tar_gnu1 test_tar_gnu2 test_tar_gnu3 test_tar_gnu4 \
+ test_tar_gnu5 test_tar_gnu6 \
+ test_tar_sparse_gnu test_tar_sparse_gnu0 test_tar_sparse_gnu1 \
+ test_tar_sparse_gnu2 test_tar_sparse_gnu3 \
+ test_tar_xattr_bsd test_tar_xattr_schily test_tar_xattr_schily_bin \
+ test_tar_target_filled
+
+check_PROGRAMS += $(LIBTAR_TESTS)
+TESTS += $(LIBTAR_TESTS)
+
+noinst_PROGRAMS += tar_fuzz
+
+EXTRA_DIST += $(TARDATADIR)
diff --git a/lib/tar/test/data/CREDITS b/lib/tar/test/data/CREDITS
new file mode 100644
index 0000000..7a2738f
--- /dev/null
+++ b/lib/tar/test/data/CREDITS
@@ -0,0 +1,35 @@
+The tar archives in this directory have been obtained from here:
+
+ https://github.com/mgorny/tar-test-inputs
+
+ git commit hash a2110a6
+
+This repository was linked in the following article on interoperability of
+various different tar programs:
+
+ https://dev.gentoo.org/~mgorny/articles/portability-of-tar-features.html
+
+The original intention of the example archives was to test various tar programs
+for interoperability with each others extensions and format quirks.
+
+The following have been removed since there is no intention in adding support
+for those features:
+
+ - volume-label tests
+ - multi-volume tests
+ - longe user + group names
+ - sun tar samples
+ - star samples
+ - file flags tests
+
+In addition to that, the files in "file-size" are truncated, since we are only
+interested in parsing the header.
+
+The following addtional files have been added:
+ - xattr/xattr-shily-binary.tar
+ Created from xattr/xattr-shily.tar by manually patching in a capability
+ xattr key/value pair.
+ - tar/format-acceptance/link_filled.tar
+ Contributed in GitHub issue #64. A tar ball that contains a hard link
+ where the 100 byte target field is completely filled without containing
+ a null-terminator.
diff --git a/lib/tar/test/data/file-size/12-digit.tar b/lib/tar/test/data/file-size/12-digit.tar
new file mode 100644
index 0000000..a6b3553
--- /dev/null
+++ b/lib/tar/test/data/file-size/12-digit.tar
Binary files differ
diff --git a/lib/tar/test/data/file-size/gnu.tar b/lib/tar/test/data/file-size/gnu.tar
new file mode 100644
index 0000000..aad726f
--- /dev/null
+++ b/lib/tar/test/data/file-size/gnu.tar
Binary files differ
diff --git a/lib/tar/test/data/file-size/pax.tar b/lib/tar/test/data/file-size/pax.tar
new file mode 100644
index 0000000..e391fee
--- /dev/null
+++ b/lib/tar/test/data/file-size/pax.tar
Binary files differ
diff --git a/lib/tar/test/data/format-acceptance/gnu-g.tar b/lib/tar/test/data/format-acceptance/gnu-g.tar
new file mode 100644
index 0000000..a72f60d
--- /dev/null
+++ b/lib/tar/test/data/format-acceptance/gnu-g.tar
Binary files differ
diff --git a/lib/tar/test/data/format-acceptance/gnu.tar b/lib/tar/test/data/format-acceptance/gnu.tar
new file mode 100644
index 0000000..98e8157
--- /dev/null
+++ b/lib/tar/test/data/format-acceptance/gnu.tar
Binary files differ
diff --git a/lib/tar/test/data/format-acceptance/link_filled.tar b/lib/tar/test/data/format-acceptance/link_filled.tar
new file mode 100644
index 0000000..9b80f89
--- /dev/null
+++ b/lib/tar/test/data/format-acceptance/link_filled.tar
Binary files differ
diff --git a/lib/tar/test/data/format-acceptance/pax.tar b/lib/tar/test/data/format-acceptance/pax.tar
new file mode 100644
index 0000000..69a029f
--- /dev/null
+++ b/lib/tar/test/data/format-acceptance/pax.tar
Binary files differ
diff --git a/lib/tar/test/data/format-acceptance/ustar-pre-posix.tar b/lib/tar/test/data/format-acceptance/ustar-pre-posix.tar
new file mode 100644
index 0000000..4230f5f
--- /dev/null
+++ b/lib/tar/test/data/format-acceptance/ustar-pre-posix.tar
Binary files differ
diff --git a/lib/tar/test/data/format-acceptance/ustar.tar b/lib/tar/test/data/format-acceptance/ustar.tar
new file mode 100644
index 0000000..9a6d9b3
--- /dev/null
+++ b/lib/tar/test/data/format-acceptance/ustar.tar
Binary files differ
diff --git a/lib/tar/test/data/format-acceptance/v7.tar b/lib/tar/test/data/format-acceptance/v7.tar
new file mode 100644
index 0000000..5483b4b
--- /dev/null
+++ b/lib/tar/test/data/format-acceptance/v7.tar
Binary files differ
diff --git a/lib/tar/test/data/large-mtime/12-digit.tar b/lib/tar/test/data/large-mtime/12-digit.tar
new file mode 100644
index 0000000..8202b28
--- /dev/null
+++ b/lib/tar/test/data/large-mtime/12-digit.tar
Binary files differ
diff --git a/lib/tar/test/data/large-mtime/gnu.tar b/lib/tar/test/data/large-mtime/gnu.tar
new file mode 100644
index 0000000..4e3dda2
--- /dev/null
+++ b/lib/tar/test/data/large-mtime/gnu.tar
Binary files differ
diff --git a/lib/tar/test/data/large-mtime/pax.tar b/lib/tar/test/data/large-mtime/pax.tar
new file mode 100644
index 0000000..8d32530
--- /dev/null
+++ b/lib/tar/test/data/large-mtime/pax.tar
Binary files differ
diff --git a/lib/tar/test/data/long-paths/gnu.tar b/lib/tar/test/data/long-paths/gnu.tar
new file mode 100644
index 0000000..4eee731
--- /dev/null
+++ b/lib/tar/test/data/long-paths/gnu.tar
Binary files differ
diff --git a/lib/tar/test/data/long-paths/pax.tar b/lib/tar/test/data/long-paths/pax.tar
new file mode 100644
index 0000000..1e63e9c
--- /dev/null
+++ b/lib/tar/test/data/long-paths/pax.tar
Binary files differ
diff --git a/lib/tar/test/data/long-paths/ustar.tar b/lib/tar/test/data/long-paths/ustar.tar
new file mode 100644
index 0000000..812255c
--- /dev/null
+++ b/lib/tar/test/data/long-paths/ustar.tar
Binary files differ
diff --git a/lib/tar/test/data/negative-mtime/gnu.tar b/lib/tar/test/data/negative-mtime/gnu.tar
new file mode 100644
index 0000000..a9b1272
--- /dev/null
+++ b/lib/tar/test/data/negative-mtime/gnu.tar
Binary files differ
diff --git a/lib/tar/test/data/negative-mtime/pax.tar b/lib/tar/test/data/negative-mtime/pax.tar
new file mode 100644
index 0000000..d0b3e6c
--- /dev/null
+++ b/lib/tar/test/data/negative-mtime/pax.tar
Binary files differ
diff --git a/lib/tar/test/data/sparse-files/gnu-small.tar b/lib/tar/test/data/sparse-files/gnu-small.tar
new file mode 100644
index 0000000..7a1b222
--- /dev/null
+++ b/lib/tar/test/data/sparse-files/gnu-small.tar
Binary files differ
diff --git a/lib/tar/test/data/sparse-files/gnu.tar b/lib/tar/test/data/sparse-files/gnu.tar
new file mode 100644
index 0000000..3d641a2
--- /dev/null
+++ b/lib/tar/test/data/sparse-files/gnu.tar
Binary files differ
diff --git a/lib/tar/test/data/sparse-files/pax-gnu0-0.tar b/lib/tar/test/data/sparse-files/pax-gnu0-0.tar
new file mode 100644
index 0000000..628f09e
--- /dev/null
+++ b/lib/tar/test/data/sparse-files/pax-gnu0-0.tar
Binary files differ
diff --git a/lib/tar/test/data/sparse-files/pax-gnu0-1.tar b/lib/tar/test/data/sparse-files/pax-gnu0-1.tar
new file mode 100644
index 0000000..87e362e
--- /dev/null
+++ b/lib/tar/test/data/sparse-files/pax-gnu0-1.tar
Binary files differ
diff --git a/lib/tar/test/data/sparse-files/pax-gnu1-0.tar b/lib/tar/test/data/sparse-files/pax-gnu1-0.tar
new file mode 100644
index 0000000..edb0ccf
--- /dev/null
+++ b/lib/tar/test/data/sparse-files/pax-gnu1-0.tar
Binary files differ
diff --git a/lib/tar/test/data/user-group-largenum/8-digit.tar b/lib/tar/test/data/user-group-largenum/8-digit.tar
new file mode 100644
index 0000000..a48ea5d
--- /dev/null
+++ b/lib/tar/test/data/user-group-largenum/8-digit.tar
Binary files differ
diff --git a/lib/tar/test/data/user-group-largenum/gnu.tar b/lib/tar/test/data/user-group-largenum/gnu.tar
new file mode 100644
index 0000000..4c30f57
--- /dev/null
+++ b/lib/tar/test/data/user-group-largenum/gnu.tar
Binary files differ
diff --git a/lib/tar/test/data/user-group-largenum/pax.tar b/lib/tar/test/data/user-group-largenum/pax.tar
new file mode 100644
index 0000000..a9fe54c
--- /dev/null
+++ b/lib/tar/test/data/user-group-largenum/pax.tar
Binary files differ
diff --git a/lib/tar/test/data/xattr/acl.tar b/lib/tar/test/data/xattr/acl.tar
new file mode 100644
index 0000000..a65c0af
--- /dev/null
+++ b/lib/tar/test/data/xattr/acl.tar
Binary files differ
diff --git a/lib/tar/test/data/xattr/xattr-libarchive.tar b/lib/tar/test/data/xattr/xattr-libarchive.tar
new file mode 100644
index 0000000..3bd6125
--- /dev/null
+++ b/lib/tar/test/data/xattr/xattr-libarchive.tar
Binary files differ
diff --git a/lib/tar/test/data/xattr/xattr-schily-binary.tar b/lib/tar/test/data/xattr/xattr-schily-binary.tar
new file mode 100644
index 0000000..0312807
--- /dev/null
+++ b/lib/tar/test/data/xattr/xattr-schily-binary.tar
Binary files differ
diff --git a/lib/tar/test/data/xattr/xattr-schily.tar b/lib/tar/test/data/xattr/xattr-schily.tar
new file mode 100644
index 0000000..1cf525c
--- /dev/null
+++ b/lib/tar/test/data/xattr/xattr-schily.tar
Binary files differ
diff --git a/lib/tar/test/tar_big_file.c b/lib/tar/test/tar_big_file.c
new file mode 100644
index 0000000..deb41f4
--- /dev/null
+++ b/lib/tar/test/tar_big_file.c
@@ -0,0 +1,31 @@
+/* SPDX-License-Identifier: GPL-3.0-or-later */
+/*
+ * tar_big_file.c
+ *
+ * Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at>
+ */
+#include "config.h"
+#include "tar/tar.h"
+#include "io/file.h"
+#include "util/test.h"
+
+int main(int argc, char **argv)
+{
+ tar_header_decoded_t hdr;
+ istream_t *fp;
+ (void)argc; (void)argv;
+
+ fp = istream_open_file(STRVALUE(TESTPATH) "/" STRVALUE(TESTFILE));
+ TEST_NOT_NULL(fp);
+ TEST_ASSERT(read_header(fp, &hdr) == 0);
+ TEST_EQUAL_UI(hdr.mode, S_IFREG | 0644);
+ TEST_EQUAL_UI(hdr.uid, 01750);
+ TEST_EQUAL_UI(hdr.gid, 01750);
+ TEST_EQUAL_UI(hdr.actual_size, 8589934592);
+ TEST_EQUAL_UI(hdr.mtime, 1542959190);
+ TEST_STR_EQUAL(hdr.name, "big-file.bin");
+ TEST_ASSERT(!hdr.unknown_record);
+ clear_header(&hdr);
+ sqfs_drop(fp);
+ return EXIT_SUCCESS;
+}
diff --git a/lib/tar/test/tar_fuzz.c b/lib/tar/test/tar_fuzz.c
new file mode 100644
index 0000000..21e6978
--- /dev/null
+++ b/lib/tar/test/tar_fuzz.c
@@ -0,0 +1,49 @@
+/* SPDX-License-Identifier: GPL-3.0-or-later */
+/*
+ * tar_fuzz.c
+ *
+ * Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at>
+ */
+#include "config.h"
+
+#include "io/file.h"
+#include "tar/tar.h"
+
+#include <stdlib.h>
+#include <stdio.h>
+
+int main(int argc, char **argv)
+{
+ tar_header_decoded_t hdr;
+ istream_t *fp;
+ int ret;
+
+ if (argc != 2) {
+ fputs("usage: tar_fuzz <tarball>\n", stderr);
+ return EXIT_FAILURE;
+ }
+
+ fp = istream_open_file(argv[1]);
+ if (fp == NULL)
+ return EXIT_FAILURE;
+
+ for (;;) {
+ ret = read_header(fp, &hdr);
+ if (ret > 0)
+ break;
+ if (ret < 0)
+ goto fail;
+
+ ret = istream_skip(fp, hdr.record_size);
+
+ clear_header(&hdr);
+ if (ret < 0)
+ goto fail;
+ }
+
+ sqfs_drop(fp);
+ return EXIT_SUCCESS;
+fail:
+ sqfs_drop(fp);
+ return EXIT_FAILURE;
+}
diff --git a/lib/tar/test/tar_simple.c b/lib/tar/test/tar_simple.c
new file mode 100644
index 0000000..cb38abb
--- /dev/null
+++ b/lib/tar/test/tar_simple.c
@@ -0,0 +1,64 @@
+/* SPDX-License-Identifier: GPL-3.0-or-later */
+/*
+ * tar_simple.c
+ *
+ * Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at>
+ */
+#include "config.h"
+#include "io/file.h"
+#include "tar/tar.h"
+#include "util/test.h"
+
+#ifndef TESTUID
+#define TESTUID 1000
+#endif
+
+#ifndef TESTGID
+#define TESTGID TESTUID
+#endif
+
+#ifndef TESTFNAME
+#define TESTFNAME input.txt
+#endif
+
+#ifndef TESTTS
+#define TESTTS 1542905892
+#endif
+
+#ifdef LONG_NAME_TEST
+static const char *fname =
+"012345678901234567890123456789/012345678901234567890123456789/"
+"012345678901234567890123456789/012345678901234567890123456789/"
+"012345678901234567890123456789/input.txt";
+#else
+static const char *fname = STRVALUE(TESTFNAME);
+#endif
+
+int main(int argc, char **argv)
+{
+ tar_header_decoded_t hdr;
+ char buffer[6];
+ sqfs_s64 ts;
+ istream_t *fp;
+ (void)argc; (void)argv;
+
+ fp = istream_open_file(STRVALUE(TESTPATH) "/" STRVALUE(TESTFILE));
+ TEST_NOT_NULL(fp);
+ TEST_ASSERT(read_header(fp, &hdr) == 0);
+ TEST_EQUAL_UI(hdr.mode, S_IFREG | 0644);
+ TEST_EQUAL_UI(hdr.uid, TESTUID);
+ TEST_EQUAL_UI(hdr.gid, TESTGID);
+ TEST_EQUAL_UI(hdr.actual_size, 5);
+
+ ts = TESTTS;
+ TEST_EQUAL_UI(hdr.mtime, ts);
+ TEST_STR_EQUAL(hdr.name, fname);
+ TEST_ASSERT(!hdr.unknown_record);
+
+ TEST_ASSERT(istream_read(fp, buffer, 5) == 5);
+ buffer[5] = '\0';
+ TEST_STR_EQUAL(buffer, "test\n");
+ clear_header(&hdr);
+ sqfs_drop(fp);
+ return EXIT_SUCCESS;
+}
diff --git a/lib/tar/test/tar_sparse.c b/lib/tar/test/tar_sparse.c
new file mode 100644
index 0000000..27ce053
--- /dev/null
+++ b/lib/tar/test/tar_sparse.c
@@ -0,0 +1,86 @@
+/* SPDX-License-Identifier: GPL-3.0-or-later */
+/*
+ * tar_sparse.c
+ *
+ * Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at>
+ */
+#include "config.h"
+#include "io/file.h"
+#include "tar/tar.h"
+#include "util/test.h"
+
+static void test_case_sparse(const char *path)
+{
+ tar_header_decoded_t hdr;
+ sparse_map_t *sparse;
+ istream_t *fp;
+
+ fp = istream_open_file(path);
+ TEST_NOT_NULL(fp);
+ TEST_ASSERT(read_header(fp, &hdr) == 0);
+ TEST_EQUAL_UI(hdr.mode, S_IFREG | 0644);
+ TEST_EQUAL_UI(hdr.uid, 01750);
+ TEST_EQUAL_UI(hdr.gid, 01750);
+ TEST_EQUAL_UI(hdr.actual_size, 2097152);
+ TEST_EQUAL_UI(hdr.record_size, 32768);
+ TEST_STR_EQUAL(hdr.name, "input.bin");
+ TEST_ASSERT(!hdr.unknown_record);
+
+ sparse = hdr.sparse;
+ TEST_NOT_NULL(sparse);
+ TEST_EQUAL_UI(sparse->offset, 0);
+ TEST_EQUAL_UI(sparse->count, 4096);
+
+ sparse = sparse->next;
+ TEST_NOT_NULL(sparse);
+ TEST_EQUAL_UI(sparse->offset, 262144);
+ TEST_EQUAL_UI(sparse->count, 4096);
+
+ sparse = sparse->next;
+ TEST_NOT_NULL(sparse);
+ TEST_EQUAL_UI(sparse->offset, 524288);
+ TEST_EQUAL_UI(sparse->count, 4096);
+
+ sparse = sparse->next;
+ TEST_NOT_NULL(sparse);
+ TEST_EQUAL_UI(sparse->offset, 786432);
+ TEST_EQUAL_UI(sparse->count, 4096);
+
+ sparse = sparse->next;
+ TEST_NOT_NULL(sparse);
+ TEST_EQUAL_UI(sparse->offset, 1048576);
+ TEST_EQUAL_UI(sparse->count, 4096);
+
+ sparse = sparse->next;
+ TEST_NOT_NULL(sparse);
+ TEST_EQUAL_UI(sparse->offset, 1310720);
+ TEST_EQUAL_UI(sparse->count, 4096);
+
+ sparse = sparse->next;
+ TEST_NOT_NULL(sparse);
+ TEST_EQUAL_UI(sparse->offset, 1572864);
+ TEST_EQUAL_UI(sparse->count, 4096);
+
+ sparse = sparse->next;
+ TEST_NOT_NULL(sparse);
+ TEST_EQUAL_UI(sparse->offset, 1835008);
+ TEST_EQUAL_UI(sparse->count, 4096);
+
+ sparse = sparse->next;
+ TEST_NOT_NULL(sparse);
+ TEST_EQUAL_UI(sparse->offset, 2097152);
+ TEST_EQUAL_UI(sparse->count, 0);
+
+ sparse = sparse->next;
+ TEST_NULL(sparse);
+
+ clear_header(&hdr);
+ sqfs_drop(fp);
+}
+
+int main(int argc, char **argv)
+{
+ (void)argc; (void)argv;
+ test_case_sparse( STRVALUE(TESTPATH) "/" STRVALUE(TESTFILE) );
+ return EXIT_SUCCESS;
+}
diff --git a/lib/tar/test/tar_sparse_gnu.c b/lib/tar/test/tar_sparse_gnu.c
new file mode 100644
index 0000000..19ddd0a
--- /dev/null
+++ b/lib/tar/test/tar_sparse_gnu.c
@@ -0,0 +1,52 @@
+/* SPDX-License-Identifier: GPL-3.0-or-later */
+/*
+ * tar_sparse_gnu.c
+ *
+ * Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at>
+ */
+#include "config.h"
+#include "io/file.h"
+#include "tar/tar.h"
+#include "util/test.h"
+
+int main(int argc, char **argv)
+{
+ tar_header_decoded_t hdr;
+ sparse_map_t *sparse;
+ istream_t *fp;
+ (void)argc; (void)argv;
+
+ TEST_ASSERT(chdir(TEST_PATH) == 0);
+
+ fp = istream_open_file("sparse-files/gnu-small.tar");
+ TEST_NOT_NULL(fp);
+ TEST_ASSERT(read_header(fp, &hdr) == 0);
+ TEST_EQUAL_UI(hdr.mode, S_IFREG | 0644);
+ TEST_EQUAL_UI(hdr.uid, 01750);
+ TEST_EQUAL_UI(hdr.gid, 01750);
+ TEST_EQUAL_UI(hdr.actual_size, 524288);
+ TEST_EQUAL_UI(hdr.record_size, 8192);
+ TEST_STR_EQUAL(hdr.name, "input.bin");
+ TEST_ASSERT(!hdr.unknown_record);
+
+ sparse = hdr.sparse;
+ TEST_NOT_NULL(sparse);
+ TEST_EQUAL_UI(sparse->offset, 0);
+ TEST_EQUAL_UI(sparse->count, 4096);
+
+ sparse = sparse->next;
+ TEST_NOT_NULL(sparse);
+ TEST_EQUAL_UI(sparse->offset, 262144);
+ TEST_EQUAL_UI(sparse->count, 4096);
+
+ sparse = sparse->next;
+ TEST_NOT_NULL(sparse);
+ TEST_EQUAL_UI(sparse->offset, 524288);
+ TEST_EQUAL_UI(sparse->count, 0);
+
+ TEST_NULL(sparse->next);
+
+ clear_header(&hdr);
+ sqfs_drop(fp);
+ return EXIT_SUCCESS;
+}
diff --git a/lib/tar/test/tar_target_filled.c b/lib/tar/test/tar_target_filled.c
new file mode 100644
index 0000000..abc6a47
--- /dev/null
+++ b/lib/tar/test/tar_target_filled.c
@@ -0,0 +1,109 @@
+/* SPDX-License-Identifier: GPL-3.0-or-later */
+/*
+ * tar_target_filled.c
+ *
+ * Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at>
+ */
+#include "config.h"
+#include "io/file.h"
+#include "tar/tar.h"
+#include "util/test.h"
+
+int main(int argc, char **argv)
+{
+ tar_header_decoded_t hdr;
+ char buffer[16];
+ istream_t *fp;
+ (void)argc; (void)argv;
+
+ TEST_ASSERT(chdir(TEST_PATH) == 0);
+
+ fp = istream_open_file("format-acceptance/link_filled.tar");
+ TEST_NOT_NULL(fp);
+
+ /* "deep" directory hierarchy containg 2 files */
+ TEST_ASSERT(read_header(fp, &hdr) == 0);
+ TEST_EQUAL_UI(hdr.mode, S_IFDIR | 0777);
+ TEST_STR_EQUAL(hdr.name, "20_characters_here01/");
+ clear_header(&hdr);
+
+ TEST_ASSERT(read_header(fp, &hdr) == 0);
+ TEST_EQUAL_UI(hdr.mode, S_IFDIR | 0777);
+ TEST_STR_EQUAL(hdr.name, "20_characters_here01/20_characters_here02/");
+ clear_header(&hdr);
+
+ TEST_ASSERT(read_header(fp, &hdr) == 0);
+ TEST_EQUAL_UI(hdr.mode, S_IFDIR | 0777);
+ TEST_STR_EQUAL(hdr.name, "20_characters_here01/20_characters_here02/"
+ "20_characters_here03/");
+ clear_header(&hdr);
+
+ TEST_ASSERT(read_header(fp, &hdr) == 0);
+ TEST_EQUAL_UI(hdr.mode, S_IFDIR | 0777);
+ TEST_STR_EQUAL(hdr.name, "20_characters_here01/20_characters_here02/"
+ "20_characters_here03/20_characters_here04/");
+ clear_header(&hdr);
+
+ TEST_ASSERT(read_header(fp, &hdr) == 0);
+ TEST_EQUAL_UI(hdr.mode, S_IFREG | 0777);
+ TEST_STR_EQUAL(hdr.name, "20_characters_here01/20_characters_here02/"
+ "20_characters_here03/20_characters_here04/"
+ "errored_file_tst");
+ TEST_EQUAL_UI(hdr.actual_size, 5);
+ TEST_ASSERT(istream_read(fp, buffer, 5) == 5);
+ buffer[5] = '\0';
+ TEST_STR_EQUAL(buffer, "test\n");
+ TEST_ASSERT(skip_padding(fp, 5) == 0);
+ clear_header(&hdr);
+
+ TEST_ASSERT(read_header(fp, &hdr) == 0);
+ TEST_EQUAL_UI(hdr.mode, S_IFREG | 0777);
+ TEST_STR_EQUAL(hdr.name, "20_characters_here01/20_characters_here02/"
+ "20_characters_here03/20_characters_here04/"
+ "some_test_file");
+ TEST_EQUAL_UI(hdr.actual_size, 5);
+ TEST_ASSERT(istream_read(fp, buffer, 5) == 5);
+ buffer[5] = '\0';
+ TEST_STR_EQUAL(buffer, "test\n");
+ TEST_ASSERT(skip_padding(fp, 5) == 0);
+ clear_header(&hdr);
+
+ /* "deep" directory hierarchy containg a hard link */
+ TEST_ASSERT(read_header(fp, &hdr) == 0);
+ TEST_EQUAL_UI(hdr.mode, S_IFDIR | 0777);
+ TEST_STR_EQUAL(hdr.name, "20CharsForLnkTest001/");
+ clear_header(&hdr);
+
+ TEST_ASSERT(read_header(fp, &hdr) == 0);
+ TEST_EQUAL_UI(hdr.mode, S_IFDIR | 0777);
+ TEST_STR_EQUAL(hdr.name, "20CharsForLnkTest001/20CharsForLnkTest002/");
+ clear_header(&hdr);
+
+ TEST_ASSERT(read_header(fp, &hdr) == 0);
+ TEST_EQUAL_UI(hdr.mode, S_IFDIR | 0777);
+ TEST_STR_EQUAL(hdr.name, "20CharsForLnkTest001/20CharsForLnkTest002/"
+ "20CharsForLnkTest003/");
+ clear_header(&hdr);
+
+ TEST_ASSERT(read_header(fp, &hdr) == 0);
+ TEST_EQUAL_UI(hdr.mode, S_IFDIR | 0777);
+ TEST_STR_EQUAL(hdr.name, "20CharsForLnkTest001/20CharsForLnkTest002/"
+ "20CharsForLnkTest003/20CharsForLnkTest004/");
+ clear_header(&hdr);
+
+ TEST_ASSERT(read_header(fp, &hdr) == 0);
+ TEST_STR_EQUAL(hdr.name, "20CharsForLnkTest001/20CharsForLnkTest002/"
+ "20CharsForLnkTest003/20CharsForLnkTest004/"
+ "01234567890123456789");
+ TEST_ASSERT(hdr.is_hard_link);
+
+ TEST_STR_EQUAL(hdr.link_target, "20_characters_here01/"
+ "20_characters_here02/20_characters_here03/"
+ "20_characters_here04/errored_file_tst");
+ clear_header(&hdr);
+
+ /* end of file */
+ TEST_ASSERT(read_header(fp, &hdr) > 0);
+ sqfs_drop(fp);
+ return EXIT_SUCCESS;
+}
diff --git a/lib/tar/test/tar_xattr.c b/lib/tar/test/tar_xattr.c
new file mode 100644
index 0000000..122d1db
--- /dev/null
+++ b/lib/tar/test/tar_xattr.c
@@ -0,0 +1,42 @@
+/* SPDX-License-Identifier: GPL-3.0-or-later */
+/*
+ * tar_xattr.c
+ *
+ * Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at>
+ */
+#include "config.h"
+#include "io/file.h"
+#include "tar/tar.h"
+#include "util/test.h"
+
+int main(int argc, char **argv)
+{
+ tar_header_decoded_t hdr;
+ char buffer[6];
+ istream_t *fp;
+ (void)argc; (void)argv;
+
+ fp = istream_open_file(STRVALUE(TESTPATH) "/" STRVALUE(TESTFILE));
+ TEST_NOT_NULL(fp);
+ TEST_ASSERT(read_header(fp, &hdr) == 0);
+ TEST_EQUAL_UI(hdr.mode, S_IFREG | 0644);
+ TEST_EQUAL_UI(hdr.uid, 01750);
+ TEST_EQUAL_UI(hdr.gid, 01750);
+ TEST_EQUAL_UI(hdr.actual_size, 5);
+ TEST_EQUAL_UI(hdr.mtime, 1543094477);
+ TEST_STR_EQUAL(hdr.name, "input.txt");
+ TEST_ASSERT(!hdr.unknown_record);
+ TEST_ASSERT(istream_read(fp, buffer, 5) == 5);
+ buffer[5] = '\0';
+ TEST_STR_EQUAL(buffer, "test\n");
+
+ TEST_NOT_NULL(hdr.xattr);
+ TEST_STR_EQUAL(hdr.xattr->key, "user.mime_type");
+ TEST_STR_EQUAL((const char *)hdr.xattr->value, "text/plain");
+ TEST_EQUAL_UI(hdr.xattr->value_len, 10);
+ TEST_NULL(hdr.xattr->next);
+
+ clear_header(&hdr);
+ sqfs_drop(fp);
+ return EXIT_SUCCESS;
+}
diff --git a/lib/tar/test/tar_xattr_bin.c b/lib/tar/test/tar_xattr_bin.c
new file mode 100644
index 0000000..90443a1
--- /dev/null
+++ b/lib/tar/test/tar_xattr_bin.c
@@ -0,0 +1,50 @@
+/* SPDX-License-Identifier: GPL-3.0-or-later */
+/*
+ * tar_xattr_bin.c
+ *
+ * Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at>
+ */
+#include "config.h"
+#include "io/file.h"
+#include "tar/tar.h"
+#include "util/test.h"
+
+static const uint8_t value[] = {
+ 0x00, 0x00, 0x00, 0x02,
+ 0x00, 0x30, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00,
+};
+
+int main(int argc, char **argv)
+{
+ tar_header_decoded_t hdr;
+ char buffer[6];
+ istream_t *fp;
+ (void)argc; (void)argv;
+
+ fp = istream_open_file(STRVALUE(TESTPATH) "/" STRVALUE(TESTFILE));
+ TEST_NOT_NULL(fp);
+ TEST_ASSERT(read_header(fp, &hdr) == 0);
+ TEST_EQUAL_UI(hdr.mode, S_IFREG | 0644);
+ TEST_EQUAL_UI(hdr.uid, 01750);
+ TEST_EQUAL_UI(hdr.gid, 01750);
+ TEST_EQUAL_UI(hdr.actual_size, 5);
+ TEST_EQUAL_UI(hdr.mtime, 1543094477);
+ TEST_STR_EQUAL(hdr.name, "input.txt");
+ TEST_ASSERT(!hdr.unknown_record);
+ TEST_ASSERT(istream_read(fp, buffer, 5) == 5);
+ buffer[5] = '\0';
+ TEST_STR_EQUAL(buffer, "test\n");
+
+ TEST_NOT_NULL(hdr.xattr);
+ TEST_STR_EQUAL(hdr.xattr->key, "security.capability");
+ TEST_EQUAL_UI(hdr.xattr->value_len, sizeof(value));
+ TEST_ASSERT(memcmp(hdr.xattr->value, value, sizeof(value)) == 0);
+ TEST_NULL(hdr.xattr->next);
+
+ clear_header(&hdr);
+ sqfs_drop(fp);
+ return EXIT_SUCCESS;
+}