From: Matteo Croce <teknora...@meta.com> Add a simple test for the --reflink option. The test creates an archive with --reflink, then checks that the resulting aarchive size is multiple of 4k, then checks if the archive contains the comment records to pad the data, and finally extracts it with the --reflink option. --- tests/reflink.at | 55 ++++++++++++++++++++++++++++++++++++++++++++++ tests/testsuite.at | 3 +++ 2 files changed, 58 insertions(+) create mode 100644 tests/reflink.at
diff --git a/tests/reflink.at b/tests/reflink.at new file mode 100644 index 00000000..607c3bb2 --- /dev/null +++ b/tests/reflink.at @@ -0,0 +1,55 @@ +# Process this file with autom4te to create testsuite. -*- Autotest -*- +# Test suite for GNU tar. +# Copyright 2013-2024 Free Software Foundation, Inc. +# +# 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: ensure tar can create and extract archives with +# proper padding used by reflinks, due option --reflink. +# + +AT_SETUP([reflink archive]) +AT_KEYWORDS([create extract reflink archive]) + +AT_TAR_CHECK([ +AT_SORT_PREREQ +mkdir dir +: > dir/0k +dd status=none if=/dev/zero of=dir/3k bs=1k count=3 +dd status=none if=/dev/zero of=dir/5k bs=1k count=5 +dd status=none if=/dev/zero of=dir/9k bs=1k count=9 +tar -vcf foo.tar --reflink --sort=name dir +ls foo.tar +size=@S|@(stat -c%s foo.tar) +echo @S|@((size&4095)) +strings foo.tar |grep -c '@<:@@<:@:digit:@:>@@:>@ comment= ' +tar xvf foo.tar --reflink +], +[0], +[dir/ +dir/0k +dir/3k +dir/5k +dir/9k +foo.tar +0 +3 +dir/ +dir/0k +dir/3k +dir/5k +dir/9k +],[],[],[],[gnu]) + +AT_CLEANUP diff --git a/tests/testsuite.at b/tests/testsuite.at index 33227ef4..1dacbf21 100644 --- a/tests/testsuite.at +++ b/tests/testsuite.at @@ -539,3 +539,6 @@ m4_include([star/ustar-big-2g.at]) m4_include([star/ustar-big-8g.at]) m4_include([star/pax-big-10g.at]) + +AT_BANNER([Reflinks]) +m4_include([reflink.at]) -- 2.46.0