# Test suite for GNU tar.                             -*- Autotest -*-
# Copyright 2010-2023 Free Software Foundation, Inc.

# This file is part of GNU tar.

# GNU tar is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.

# GNU tar is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

# Description: When creating POSIX multivolume archives, tar may in
# some cases write an extended header at the end of one volume, and
# the corresponding ustar header at the beginning of the next volume.
# Such archives do not fully comply with the POSIX specs, but tar must
# be able to read them anyway. This is what this script tests.
#
# See function try_new_volume, in file src/buffer.c near line 1227
# for additional details.

AT_SETUP([volumes split at an extended header])
AT_KEYWORDS([multivolume multiv multiv07 xsplit])

AT_CHECK([
AT_XFAIL_IF(test -f $[]XFAILFILE)
AT_TARBALL_PREREQ([xsplit-1.tar],[0e008c84c517e48fbf23ca6a7033cde6])
AT_TARBALL_PREREQ([xsplit-2.tar],[03150b9852d285458f43734e9e0b9a45])

exec <&-

cd $TEST_DATA_DIR
tar -t -M -fxsplit-1.tar -fxsplit-2.tar
],
[0],
[Archive volumes split at an extended header Volume 1
foo
bar
])

AT_CLEANUP