tarfs: Repeat tests using GNU tar if available.
Sponsored by: Juniper Networks, Inc. Sponsored by: Klara, Inc. Reviewed by: ngie, asomers Differential Revision: https://reviews.freebsd.org/D39018
This commit is contained in:
parent
49cad3daf2
commit
6cb78fa479
@ -48,6 +48,7 @@
|
|||||||
#define SHORTLINKNAME "short_link"
|
#define SHORTLINKNAME "short_link"
|
||||||
#define LONGLINKNAME "long_link"
|
#define LONGLINKNAME "long_link"
|
||||||
|
|
||||||
|
static bool opt_g;
|
||||||
static bool opt_v;
|
static bool opt_v;
|
||||||
|
|
||||||
static void verbose(const char *fmt, ...)
|
static void verbose(const char *fmt, ...)
|
||||||
@ -163,7 +164,7 @@ static void
|
|||||||
usage(void)
|
usage(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
fprintf(stderr, "usage: %s [-v] tarfile\n", PROGNAME);
|
fprintf(stderr, "usage: %s [-gv] tarfile\n", PROGNAME);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -175,8 +176,10 @@ main(int argc, char *argv[])
|
|||||||
int opt, wstatus;
|
int opt, wstatus;
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
|
|
||||||
while ((opt = getopt(argc, argv, "v")) != -1)
|
while ((opt = getopt(argc, argv, "gv")) != -1)
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
|
case 'g':
|
||||||
|
opt_g = true;
|
||||||
case 'v':
|
case 'v':
|
||||||
opt_v = true;
|
opt_v = true;
|
||||||
break;
|
break;
|
||||||
@ -220,10 +223,12 @@ main(int argc, char *argv[])
|
|||||||
err(1, "fork()");
|
err(1, "fork()");
|
||||||
if (pid == 0) {
|
if (pid == 0) {
|
||||||
verbose("creating tarball");
|
verbose("creating tarball");
|
||||||
execlp("tar", "tar",
|
execlp(opt_g ? "gtar" : "tar",
|
||||||
|
"tar",
|
||||||
"-c",
|
"-c",
|
||||||
"-f", tarfilename,
|
"-f", tarfilename,
|
||||||
"-C", dirname,
|
"-C", dirname,
|
||||||
|
"--posix",
|
||||||
"--zstd",
|
"--zstd",
|
||||||
#if 0
|
#if 0
|
||||||
"--options", "zstd:frame-per-file",
|
"--options", "zstd:frame-per-file",
|
||||||
|
@ -26,12 +26,23 @@
|
|||||||
# SUCH DAMAGE.
|
# SUCH DAMAGE.
|
||||||
#
|
#
|
||||||
|
|
||||||
mktar="$(dirname $(realpath "$0"))"/mktar
|
|
||||||
mnt="$(realpath ${TMPDIR:-/tmp})/mnt"
|
mnt="$(realpath ${TMPDIR:-/tmp})/mnt"
|
||||||
|
|
||||||
# expected SHA256 checksum of file contained in test tarball
|
# expected SHA256 checksum of file contained in test tarball
|
||||||
sum=4da2143234486307bb44eaa610375301781a577d1172f362b88bb4b1643dee62
|
sum=4da2143234486307bb44eaa610375301781a577d1172f362b88bb4b1643dee62
|
||||||
|
|
||||||
|
tar() {
|
||||||
|
if [ -n "${TARFS_USE_GNU_TAR}" ] ; then
|
||||||
|
gtar --posix --absolute-names "$@"
|
||||||
|
else
|
||||||
|
bsdtar "$@"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
mktar() {
|
||||||
|
"$(atf_get_srcdir)"/mktar ${TARFS_USE_GNU_TAR+-g} "$@"
|
||||||
|
}
|
||||||
|
|
||||||
atf_test_case tarfs_basic cleanup
|
atf_test_case tarfs_basic cleanup
|
||||||
tarfs_basic_head() {
|
tarfs_basic_head() {
|
||||||
atf_set "descr" "Basic function test"
|
atf_set "descr" "Basic function test"
|
||||||
@ -41,7 +52,7 @@ tarfs_basic_body() {
|
|||||||
local tarball="${PWD}/tarfs_test.tar.zst"
|
local tarball="${PWD}/tarfs_test.tar.zst"
|
||||||
kldload -n tarfs || atf_skip "This test requires tarfs and could not load it"
|
kldload -n tarfs || atf_skip "This test requires tarfs and could not load it"
|
||||||
mkdir "${mnt}"
|
mkdir "${mnt}"
|
||||||
"${mktar}" "${tarball}"
|
mktar "${tarball}"
|
||||||
atf_check mount -rt tarfs "${tarball}" "${mnt}"
|
atf_check mount -rt tarfs "${tarball}" "${mnt}"
|
||||||
atf_check -o match:"^${tarball} on ${mnt} \(tarfs," mount
|
atf_check -o match:"^${tarball} on ${mnt} \(tarfs," mount
|
||||||
atf_check_equal "$(stat -f%d,%i "${mnt}"/sparse_file)" "$(stat -f%d,%i "${mnt}"/hard_link)"
|
atf_check_equal "$(stat -f%d,%i "${mnt}"/sparse_file)" "$(stat -f%d,%i "${mnt}"/hard_link)"
|
||||||
@ -53,6 +64,20 @@ tarfs_basic_cleanup() {
|
|||||||
umount "${mnt}" || true
|
umount "${mnt}" || true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
atf_test_case tarfs_basic_gnu cleanup
|
||||||
|
tarfs_basic_gnu_head() {
|
||||||
|
atf_set "descr" "Basic function test using GNU tar"
|
||||||
|
atf_set "require.user" "root"
|
||||||
|
atf_set "require.progs" "gtar"
|
||||||
|
}
|
||||||
|
tarfs_basic_gnu_body() {
|
||||||
|
TARFS_USE_GNU_TAR=true
|
||||||
|
tarfs_basic_body
|
||||||
|
}
|
||||||
|
tarfs_basic_gnu_cleanup() {
|
||||||
|
tarfs_basic_cleanup
|
||||||
|
}
|
||||||
|
|
||||||
atf_test_case tarfs_notdir_device cleanup
|
atf_test_case tarfs_notdir_device cleanup
|
||||||
tarfs_notdir_device_head() {
|
tarfs_notdir_device_head() {
|
||||||
atf_set "descr" "Regression test for PR 269519 and 269561"
|
atf_set "descr" "Regression test for PR 269519 and 269561"
|
||||||
@ -62,11 +87,11 @@ tarfs_notdir_device_body() {
|
|||||||
kldload -n tarfs || atf_skip "This test requires tarfs and could not load it"
|
kldload -n tarfs || atf_skip "This test requires tarfs and could not load it"
|
||||||
mkdir "${mnt}"
|
mkdir "${mnt}"
|
||||||
atf_check mknod d b 0xdead 0xbeef
|
atf_check mknod d b 0xdead 0xbeef
|
||||||
tar cf tarfs_notdir.tar d
|
tar -cf tarfs_notdir.tar d
|
||||||
rm d
|
rm d
|
||||||
mkdir d
|
mkdir d
|
||||||
echo "boom" >d/f
|
echo "boom" >d/f
|
||||||
tar rf tarfs_notdir.tar d/f
|
tar -rf tarfs_notdir.tar d/f
|
||||||
atf_check -s not-exit:0 -e match:"Invalid" \
|
atf_check -s not-exit:0 -e match:"Invalid" \
|
||||||
mount -rt tarfs tarfs_notdir.tar "${mnt}"
|
mount -rt tarfs tarfs_notdir.tar "${mnt}"
|
||||||
}
|
}
|
||||||
@ -74,6 +99,20 @@ tarfs_notdir_device_cleanup() {
|
|||||||
umount "${mnt}" || true
|
umount "${mnt}" || true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
atf_test_case tarfs_notdir_device_gnu cleanup
|
||||||
|
tarfs_notdir_device_gnu_head() {
|
||||||
|
atf_set "descr" "Regression test for PR 269519 and 269561 using GNU tar"
|
||||||
|
atf_set "require.user" "root"
|
||||||
|
atf_set "require.progs" "gtar"
|
||||||
|
}
|
||||||
|
tarfs_notdir_device_gnu_body() {
|
||||||
|
TARFS_USE_GNU_TAR=true
|
||||||
|
tarfs_notdir_device_body
|
||||||
|
}
|
||||||
|
tarfs_notdir_device_gnu_cleanup() {
|
||||||
|
tarfs_notdir_device_cleanup
|
||||||
|
}
|
||||||
|
|
||||||
atf_test_case tarfs_notdir_dot cleanup
|
atf_test_case tarfs_notdir_dot cleanup
|
||||||
tarfs_notdir_dot_head() {
|
tarfs_notdir_dot_head() {
|
||||||
atf_set "descr" "Regression test for PR 269519 and 269561"
|
atf_set "descr" "Regression test for PR 269519 and 269561"
|
||||||
@ -83,11 +122,11 @@ tarfs_notdir_dot_body() {
|
|||||||
kldload -n tarfs || atf_skip "This test requires tarfs and could not load it"
|
kldload -n tarfs || atf_skip "This test requires tarfs and could not load it"
|
||||||
mkdir "${mnt}"
|
mkdir "${mnt}"
|
||||||
echo "hello" >d
|
echo "hello" >d
|
||||||
tar cf tarfs_notdir.tar d
|
tar -cf tarfs_notdir.tar d
|
||||||
rm d
|
rm d
|
||||||
mkdir d
|
mkdir d
|
||||||
echo "world" >d/f
|
echo "world" >d/f
|
||||||
tar rf tarfs_notdir.tar d/./f
|
tar -rf tarfs_notdir.tar d/./f
|
||||||
atf_check -s not-exit:0 -e match:"Invalid" \
|
atf_check -s not-exit:0 -e match:"Invalid" \
|
||||||
mount -rt tarfs tarfs_notdir.tar "${mnt}"
|
mount -rt tarfs tarfs_notdir.tar "${mnt}"
|
||||||
}
|
}
|
||||||
@ -95,6 +134,20 @@ tarfs_notdir_dot_cleanup() {
|
|||||||
umount "${mnt}" || true
|
umount "${mnt}" || true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
atf_test_case tarfs_notdir_dot_gnu cleanup
|
||||||
|
tarfs_notdir_dot_gnu_head() {
|
||||||
|
atf_set "descr" "Regression test for PR 269519 and 269561 using GNU tar"
|
||||||
|
atf_set "require.user" "root"
|
||||||
|
atf_set "require.progs" "gtar"
|
||||||
|
}
|
||||||
|
tarfs_notdir_dot_gnu_body() {
|
||||||
|
TARFS_USE_GNU_TAR=true
|
||||||
|
tarfs_notdir_dot_body
|
||||||
|
}
|
||||||
|
tarfs_notdir_dot_gnu_cleanup() {
|
||||||
|
tarfs_notdir_dot_cleanup
|
||||||
|
}
|
||||||
|
|
||||||
atf_test_case tarfs_notdir_dotdot cleanup
|
atf_test_case tarfs_notdir_dotdot cleanup
|
||||||
tarfs_notdir_dotdot_head() {
|
tarfs_notdir_dotdot_head() {
|
||||||
atf_set "descr" "Regression test for PR 269519 and 269561"
|
atf_set "descr" "Regression test for PR 269519 and 269561"
|
||||||
@ -104,11 +157,11 @@ tarfs_notdir_dotdot_body() {
|
|||||||
kldload -n tarfs || atf_skip "This test requires tarfs and could not load it"
|
kldload -n tarfs || atf_skip "This test requires tarfs and could not load it"
|
||||||
mkdir "${mnt}"
|
mkdir "${mnt}"
|
||||||
echo "hello" >d
|
echo "hello" >d
|
||||||
tar cf tarfs_notdir.tar d
|
tar -cf tarfs_notdir.tar d
|
||||||
rm d
|
rm d
|
||||||
mkdir d
|
mkdir d
|
||||||
echo "world" >f
|
echo "world" >f
|
||||||
tar rf tarfs_notdir.tar d/../f
|
tar -rf tarfs_notdir.tar d/../f
|
||||||
atf_check -s not-exit:0 -e match:"Invalid" \
|
atf_check -s not-exit:0 -e match:"Invalid" \
|
||||||
mount -rt tarfs tarfs_notdir.tar "${mnt}"
|
mount -rt tarfs tarfs_notdir.tar "${mnt}"
|
||||||
}
|
}
|
||||||
@ -116,6 +169,20 @@ tarfs_notdir_dotdot_cleanup() {
|
|||||||
umount "${mnt}" || true
|
umount "${mnt}" || true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
atf_test_case tarfs_notdir_dotdot_gnu cleanup
|
||||||
|
tarfs_notdir_dotdot_gnu_head() {
|
||||||
|
atf_set "descr" "Regression test for PR 269519 and 269561 using GNU tar"
|
||||||
|
atf_set "require.user" "root"
|
||||||
|
atf_set "require.progs" "gtar"
|
||||||
|
}
|
||||||
|
tarfs_notdir_dotdot_gnu_body() {
|
||||||
|
TARFS_USE_GNU_TAR=true
|
||||||
|
tarfs_notdir_dotdot_body
|
||||||
|
}
|
||||||
|
tarfs_notdir_dotdot_gnu_cleanup() {
|
||||||
|
tarfs_notdir_dotdot_cleanup
|
||||||
|
}
|
||||||
|
|
||||||
atf_test_case tarfs_notdir_file cleanup
|
atf_test_case tarfs_notdir_file cleanup
|
||||||
tarfs_notdir_file_head() {
|
tarfs_notdir_file_head() {
|
||||||
atf_set "descr" "Regression test for PR 269519 and 269561"
|
atf_set "descr" "Regression test for PR 269519 and 269561"
|
||||||
@ -125,11 +192,11 @@ tarfs_notdir_file_body() {
|
|||||||
kldload -n tarfs || atf_skip "This test requires tarfs and could not load it"
|
kldload -n tarfs || atf_skip "This test requires tarfs and could not load it"
|
||||||
mkdir "${mnt}"
|
mkdir "${mnt}"
|
||||||
echo "hello" >d
|
echo "hello" >d
|
||||||
tar cf tarfs_notdir.tar d
|
tar -cf tarfs_notdir.tar d
|
||||||
rm d
|
rm d
|
||||||
mkdir d
|
mkdir d
|
||||||
echo "world" >d/f
|
echo "world" >d/f
|
||||||
tar rf tarfs_notdir.tar d/f
|
tar -rf tarfs_notdir.tar d/f
|
||||||
atf_check -s not-exit:0 -e match:"Invalid" \
|
atf_check -s not-exit:0 -e match:"Invalid" \
|
||||||
mount -rt tarfs tarfs_notdir.tar "${mnt}"
|
mount -rt tarfs tarfs_notdir.tar "${mnt}"
|
||||||
}
|
}
|
||||||
@ -137,10 +204,29 @@ tarfs_notdir_file_cleanup() {
|
|||||||
umount "${mnt}" || true
|
umount "${mnt}" || true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
atf_test_case tarfs_notdir_file_gnu cleanup
|
||||||
|
tarfs_notdir_file_gnu_head() {
|
||||||
|
atf_set "descr" "Regression test for PR 269519 and 269561 using GNU tar"
|
||||||
|
atf_set "require.user" "root"
|
||||||
|
atf_set "require.progs" "gtar"
|
||||||
|
}
|
||||||
|
tarfs_notdir_file_gnu_body() {
|
||||||
|
TARFS_USE_GNU_TAR=true
|
||||||
|
tarfs_notdir_file_body
|
||||||
|
}
|
||||||
|
tarfs_notdir_file_gnu_cleanup() {
|
||||||
|
tarfs_notdir_file_cleanup
|
||||||
|
}
|
||||||
|
|
||||||
atf_init_test_cases() {
|
atf_init_test_cases() {
|
||||||
atf_add_test_case tarfs_basic
|
atf_add_test_case tarfs_basic
|
||||||
|
atf_add_test_case tarfs_basic_gnu
|
||||||
atf_add_test_case tarfs_notdir_device
|
atf_add_test_case tarfs_notdir_device
|
||||||
|
atf_add_test_case tarfs_notdir_device_gnu
|
||||||
atf_add_test_case tarfs_notdir_dot
|
atf_add_test_case tarfs_notdir_dot
|
||||||
|
atf_add_test_case tarfs_notdir_dot_gnu
|
||||||
atf_add_test_case tarfs_notdir_dotdot
|
atf_add_test_case tarfs_notdir_dotdot
|
||||||
|
atf_add_test_case tarfs_notdir_dotdot_gnu
|
||||||
atf_add_test_case tarfs_notdir_file
|
atf_add_test_case tarfs_notdir_file
|
||||||
|
atf_add_test_case tarfs_notdir_file_gnu
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user