xattr07.at 2.1 KB

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