Sync bootstrap from Gnulib
[tar.git] / tests / xattr07.at
blob1e052083b79ebadf504d9ab2893fd4413764009a
1 # Process this file with autom4te to create testsuite. -*- Autotest -*-
3 # Test suite for GNU tar.
4 # Copyright 2011-2024 Free Software Foundation, Inc.
6 # This file is part of GNU tar.
8 # GNU tar is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 3 of the License, or
11 # (at your option) any later version.
13 # GNU tar is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
21 # Test description:
22 # Test that --keep-old-files doesn't change xattrs of already existing file.
23 # Per report:
24 # https://lists.gnu.org/archive/html/bug-tar/2016-10/msg00001.html
26 AT_SETUP([xattrs: xattrs and --skip-old-files])
27 AT_KEYWORDS([xattrs xattr07])
29 AT_TAR_CHECK([
30 AT_XATTRS_PREREQ
31 mkdir dir
32 genfile --file dir/file
33 genfile --file dir/file2
35 setfattr -n user.test -v OurDirValue dir
36 setfattr -n user.test -v OurFileValue dir/file
37 setfattr -n user.test -v OurFileValue dir/file2
39 tar --xattrs --no-recursion -cf archive.tar dir dir/file dir/file2
41 setfattr -n user.test -v OurDirValue2 dir
42 setfattr -n user.test -v OurFileValue2 dir/file
43 setfattr -n user.test -v OurFileValue2 dir/file2
45 # Check that tar continues to file2 too!
46 tar --xattrs -xvf archive.tar --skip-old-files
47 tar --xattrs -xvf archive.tar --keep-old-files
49 getfattr -h -d dir         | grep -v -e '^#' -e ^$
50 getfattr -h -d dir/file    | grep -v -e '^#' -e ^$
51 getfattr -h -d dir/file2   | grep -v -e '^#' -e ^$
53 [0],
54 [dir/
55 dir/file
56 dir/file2
57 dir/
58 dir/file
59 dir/file2
60 user.test="OurDirValue2"
61 user.test="OurFileValue2"
62 user.test="OurFileValue2"
63 ], [tar: dir: skipping existing file
64 tar: dir/file: skipping existing file
65 tar: dir/file2: skipping existing file
66 tar: dir/file: Cannot open: File exists
67 tar: dir/file2: Cannot open: File exists
68 tar: Exiting with failure status due to previous errors
71 AT_CLEANUP