time01.at 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. # Test time stamps for GNU tar. -*- Autotest -*-
  2. #
  3. # Copyright 2012-2023 Free Software Foundation, Inc.
  4. #
  5. # This program 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, or (at your option)
  8. # any later version.
  9. #
  10. # This program 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. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. # written by Paul Eggert
  18. AT_SETUP([time: tricky time stamps])
  19. AT_KEYWORDS([time time01])
  20. AT_TAR_CHECK([
  21. export TZ=UTC0
  22. mkdir dir
  23. # Test files with time stamps that are near common sources of error,
  24. # typically near powers of 2 (for seconds) or near 0, 1970, or 9999 (years).
  25. # Use GNU-style @ notation for very large time stamps, since they
  26. # typically don't render into years correctly due to int overflow.
  27. for s in \
  28. @-9223372036854775809 @-9223372036854775808 @-9223372036854775807 \
  29. 0000-01-01T00:00:00 0000-01-01T00:00:01 \
  30. 0000-01-02T00:00:00 \
  31. 1697-10-17T11:03:27 1697-10-17T11:03:28 1697-10-17T11:03:29 \
  32. 1833-11-24T17:31:43 1833-11-24T17:31:44 1833-11-24T17:31:45 \
  33. 1901-12-13T20:45:51 1901-12-13T20:45:52 1901-12-13T20:45:53 \
  34. 1901-12-14T20:45:51 \
  35. 1969-12-31T23:59:58 1969-12-31T23:59:59 \
  36. 1970-01-01T00:00:00 1970-01-01T00:00:01 \
  37. 2038-01-18T03:14:07 \
  38. 2038-01-19T03:14:07 2038-01-19T03:14:08 \
  39. 2106-02-07T06:28:15 2106-02-07T06:28:16 \
  40. 2242-03-16T12:56:31 2242-03-16T12:56:32 \
  41. 9999-12-31T23:59:58 9999-12-31T23:59:59 \
  42. @9223372036854775807 @9223372036854775808
  43. do
  44. # Skip a time stamp $s if it's out of range for this platform,
  45. # of if it uses a notation that this platform does not recognize.
  46. touch -d $s dir/f$s >/dev/null 2>&1 || continue
  47. # Likewise for $s.1. If $s is the most negative time stamp and
  48. # time stamps are signed, then $s.1 is out of range.
  49. touch -d $s.1 dir/f$s.$ns >/dev/null 2>&1 || continue
  50. for frac in 01 001 00001 000001 0000001 00000001 000000001 0000000001 \
  51. 9 99 999 99999 999999 9999999 99999999 999999999 9999999999
  52. do
  53. touch -d $s.$frac dir/f$s.$frac
  54. done
  55. done
  56. tar -c -f archive.tar dir
  57. tar -d -f archive.tar dir
  58. ],
  59. [0],
  60. [], [], [], [],
  61. [pax])
  62. AT_CLEANUP