link04.at 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. # Process this file with autom4te to create testsuite. -*- Autotest -*-
  2. # Test suite for GNU tar.
  3. # Copyright 2010-2023 Free Software Foundation, Inc.
  4. # This file is part of GNU tar.
  5. # GNU tar is free software; you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation; either version 3 of the License, or
  8. # (at your option) any later version.
  9. # GNU tar is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU General Public License for more details.
  13. # You should have received a copy of the GNU General Public License
  14. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. # written by Paul Eggert
  16. # Make sure that tar -c correctly handles the case where a file is
  17. # encountered multiple times, even though it has a link count of 1.
  18. # This can occur when "tar -c FOO FOO" is used; it can also occur when
  19. # "tar -ch FOO" is used, if FOO contains symbolic links that point to
  20. # the same file.
  21. AT_SETUP([link count is 1 but multiple occurrences])
  22. AT_KEYWORDS([hardlinks link04])
  23. AT_TAR_CHECK([
  24. mkdir dir
  25. echo TEST > dir/file
  26. ln -s file dir/symlink || AT_SKIP_TEST
  27. tar cf archive dir dir
  28. tar tvf archive | sed '
  29. s,.*[[0-9]] dir/,dir/,
  30. ' | sort
  31. echo --
  32. tar cfl archive dir dir
  33. echo ==
  34. tar chf archive dir
  35. tar tvf archive | sed '
  36. s,.*[[0-9]] dir/,dir/,
  37. s,file,FOO,g
  38. s,symlink,FOO,g
  39. ' | sort
  40. ],
  41. [0],
  42. [dir/
  43. dir/
  44. dir/file
  45. dir/file link to dir/file
  46. dir/symlink -> file
  47. dir/symlink link to dir/symlink
  48. --
  49. ==
  50. dir/
  51. dir/FOO
  52. dir/FOO link to dir/FOO
  53. ])
  54. AT_CLEANUP