testsuite.at 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538
  1. # Process this file with autom4te to create testsuite. -*- Autotest -*-
  2. # Test suite for GNU tar.
  3. # Copyright 2004-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. # We need a recent Autotest.
  16. m4_version_prereq([2.52g])
  17. m4_define([AT_TAR_CHECK_HOOK])
  18. m4_define([AT_TAR_CHECK],[
  19. AT_XFAIL_IF(test -f $[]XFAILFILE)
  20. m4_foreach([FMT],
  21. [m4_if([$7],[],[v7,oldgnu,ustar,posix,gnu],[$7])],
  22. [AT_CHECK([
  23. mkdir FMT
  24. (cd FMT
  25. TEST_TAR_FORMAT=FMT
  26. export TEST_TAR_FORMAT
  27. TAR_OPTIONS="-H FMT"
  28. export TAR_OPTIONS
  29. rm -rf *
  30. $1)],$2,$3,$4,$5,$6)
  31. AT_TAR_CHECK_HOOK])
  32. ])
  33. m4_define([AT_TAR_WITH_HOOK],[
  34. m4_pushdef([AT_TAR_CHECK_HOOK],[$1])
  35. $2
  36. m4_popdef([AT_TAR_CHECK_HOOK])])
  37. m4_define([TAR_IGNREC_HOOK],[
  38. AT_CHECK([grep -v '^.*tar: Record size = ' stderr; exit 0])
  39. ])
  40. m4_define([RE_CHECK],[
  41. AT_DATA([$1.re],[$2])
  42. awk '{print NR " " $[]0}' $1 > $[]$.1
  43. awk '{print NR " " $[]0}' $1.re | join - $[]$.1 |
  44. while read NUM RE LINE
  45. do
  46. echo "$LINE" | grep -- "$RE" >/dev/null || exit 1
  47. done
  48. ])
  49. m4_define([AT_SKIP_TEST],[exit 77])
  50. m4_define([AT_SKIP_LARGE_FILES],[test "${TARTEST_SKIP_LARGE_FILES:-0}" != 0 && AT_SKIP_TEST])
  51. dnl AT_TARBALL_PREREQ(tarball, md5sum) - Check if test tarball exists
  52. dnl in $TEST_DATA_DIR. If it does not, try to download it from
  53. dnl $TEST_DATA_URL. If download fails, or it the file's md5 sum does not
  54. dnl match second argument, skip the test.
  55. m4_define([AT_TARBALL_PREREQ],[
  56. test -z "$[]TEST_DATA_DIR" && AT_SKIP_TEST
  57. tarball_prereq $1 $2 $[]TEST_DATA_DIR $[]TEST_DATA_URL || AT_SKIP_TEST])
  58. dnl AT_STAR_PREREQ(tarball, md5sum) - Same for star testfiles
  59. m4_define([AT_STAR_PREREQ],[
  60. test -z "$STAR_TESTSCRIPTS" && AT_SKIP_TEST
  61. tarball_prereq $1 $2 $[]STAR_TESTSCRIPTS $[]STAR_DATA_URL || AT_SKIP_TEST
  62. ])
  63. dnl AT_GZIP_PREREQ - Skip test unless gzip (or $1) is available
  64. m4_define([AT_GZIP_PREREQ],[
  65. cat /dev/null | m4_if([$1],[],gzip,[$1]) - > /dev/null 2>&1 || AT_SKIP_TEST
  66. ])
  67. dnl AT_SIGPIPE_PREREQ - Skip test unless SIGPIPE handling is the default
  68. m4_define([AT_SIGPIPE_PREREQ],[
  69. case `(cat "$at_myself" 2>&3 | :) 3>&1 >/dev/null` in #(
  70. ?*) AT_SKIP_TEST;;
  71. esac
  72. ])
  73. dnl AT_SORT_PREREQ - Skip test if sort utility outputs unwanted data on stderr
  74. m4_define([AT_SORT_PREREQ],[
  75. test -z "`sort < /dev/null 2>&1`" || AT_SKIP_TEST
  76. ])
  77. dnl AT_UNPRIVILEGED_PREREQ - Skip test if running at root privileges
  78. m4_define([AT_UNPRIVILEGED_PREREQ],[
  79. echo "test" > $[]$
  80. chmod 0 $[]$
  81. cat $[]$ > /dev/null 2>&1
  82. result=$?
  83. rm -f $[]$
  84. test $result -eq 0 && AT_SKIP_TEST
  85. ])
  86. dnl AT_PRIVILEGED_PREREQ - Skip test if not running at root privileges
  87. m4_define([AT_PRIVILEGED_PREREQ],[
  88. echo "test" > $[]$
  89. chmod 0 $[]$
  90. cat $[]$ > /dev/null 2>&1
  91. result=$?
  92. rm -f $[]$
  93. test $result -eq 0 || AT_SKIP_TEST
  94. ])
  95. dnl AT_SEEKHOLE_PREREQ
  96. m4_define([AT_SEEKHOLE_PREREQ],[
  97. checkseekhole || AT_SKIP_TEST
  98. ])
  99. m4_define([AT_TIMEOUT_PREREQ],[
  100. timeout 100 true
  101. if test $? -ne 0; then
  102. echo >&2 "the 'timeout' utility not found"
  103. AT_SKIP_TEST
  104. fi
  105. ])
  106. m4_define([AT_TAR_MKHIER],[
  107. install-sh -d $1 >/dev/null dnl
  108. m4_if([$2],,,&& genfile --file [$1]/[$2]) || AT_SKIP_TEST])
  109. dnl Skip test when utility does not return expected return value
  110. m4_define([AT_CHECK_UTIL],[
  111. $1 > /dev/null 2>&1
  112. if test "$?" != $2; then
  113. AT_SKIP_TEST
  114. fi
  115. ])
  116. m4_define([AT_XATTRS_UTILS_PREREQ],[
  117. file=$(TMPDIR=. mktemp fiXXXXXX)
  118. AT_CHECK_UTIL(setfattr -n user.test -v test $file,0)
  119. AT_CHECK_UTIL(getfattr $file,0)
  120. ])
  121. m4_define([AT_SELINUX_UTILS_PREREQ],[
  122. file=$(TMPDIR=. mktemp fiXXXXXX)
  123. AT_CHECK_UTIL(restorecon $file, 0)
  124. AT_CHECK_UTIL(chcon -h --user=unconfined_u $file,0)
  125. rm -rf $file
  126. ])
  127. m4_define([AT_ACLS_UTILS_PREREQ],[
  128. file=$(TMPDIR=. mktemp fiXXXXXX)
  129. AT_CHECK_UTIL(setfacl -m u:$UID:rwx $file,0)
  130. AT_CHECK_UTIL(getfacl $file,0)
  131. rm -rf $file
  132. ])
  133. m4_define([AT_CAPABILITIES_UTILS_PREREQ],[
  134. file=$(TMPDIR=. mktemp fiXXXXXX)
  135. AT_CHECK_UTIL(setcap "= cap_chown=ei" $file,0)
  136. AT_CHECK_UTIL(getcap $file,0)
  137. rm -rf $file
  138. ])
  139. m4_define([AT_XATTRS_PREREQ],[
  140. AT_XATTRS_UTILS_PREREQ
  141. file=$(TMPDIR=. mktemp fiXXXXXX)
  142. setfattr -n user.test -v ahoj $file
  143. # check whether tar fails to store xattrs
  144. err=$( tar --xattrs -cf /dev/null $file 2>&1 >/dev/null | wc -l )
  145. if test "$err" != "0"; then
  146. AT_SKIP_TEST
  147. fi
  148. ])
  149. m4_define([AT_SELINUX_PREREQ],[
  150. AT_SELINUX_UTILS_PREREQ
  151. file=$(TMPDIR=. mktemp fiXXXXXX)
  152. err=$( tar --selinux -cf /dev/null $file 2>&1 >/dev/null | wc -l )
  153. if test "$err" != "0"; then
  154. AT_SKIP_TEST
  155. fi
  156. ])
  157. m4_define([AT_ACLS_PREREQ],[
  158. AT_ACLS_UTILS_PREREQ
  159. file=$(TMPDIR=. mktemp fiXXXXXX)
  160. setfacl -m u:$UID:rwx $file
  161. err=$( tar --acls -cf /dev/null $file 2>&1 >/dev/null | wc -l )
  162. if test "$err" != "0"; then
  163. AT_SKIP_TEST
  164. fi
  165. ])
  166. dnl Check whether a newly created file has timestamp consistent with the
  167. dnl local time. Skip the test if not.
  168. m4_define([AT_CHECK_TIMESTAMP],[ckmtime || AT_SKIP_TEST])
  169. m4_include([sparsemvp.at])
  170. AT_INIT
  171. AT_TESTED([tar])
  172. m4_include([version.at])
  173. m4_include([pipe.at])
  174. AT_BANNER([Options])
  175. m4_include([options.at])
  176. m4_include([options02.at])
  177. m4_include([options03.at])
  178. AT_BANNER([Option compatibility])
  179. m4_include([opcomp01.at])
  180. m4_include([opcomp02.at])
  181. m4_include([opcomp03.at])
  182. m4_include([opcomp04.at])
  183. m4_include([opcomp05.at])
  184. m4_include([opcomp06.at])
  185. AT_BANNER([Checkpoints])
  186. m4_pushdef([CPT_CHECK],
  187. [AT_CHECK([
  188. mkdir t
  189. cd t
  190. for i in 0 1 2 3 4 5 6 7 8 9
  191. do
  192. genfile --length 10240 --file $i
  193. done
  194. TAR_OPTIONS=-Hgnu
  195. export TAR_OPTIONS
  196. $1
  197. ],m4_shift($@))])
  198. m4_include([checkpoint/defaults.at])
  199. m4_include([checkpoint/interval.at])
  200. m4_include([checkpoint/dot.at])
  201. m4_include([checkpoint/dot-compat.at])
  202. m4_include([checkpoint/dot-int.at])
  203. m4_popdef([CPT_CHECK])
  204. AT_BANNER([Compression])
  205. m4_include([compress.m4])
  206. TAR_CHECK_COMPRESS(gzip, gz, tgz)
  207. TAR_CHECK_COMPRESS(bzip2, bz2, tbz2)
  208. TAR_CHECK_COMPRESS(xz, xz, txz)
  209. dnl: omit lzma, because it would fail due to magic number mismatch
  210. TAR_CHECK_COMPRESS(lzip, lz)
  211. TAR_CHECK_COMPRESS(lzop, lzo)
  212. TAR_CHECK_COMPRESS(zstd, zst, tzst)
  213. AT_BANNER([Positional options])
  214. m4_include([positional01.at])
  215. m4_include([positional02.at])
  216. m4_include([positional03.at])
  217. m4_include([add-file.at])
  218. AT_BANNER([The -T option])
  219. m4_include([T-mult.at])
  220. m4_include([T-nest.at])
  221. m4_include([T-rec.at])
  222. m4_include([T-recurse.at])
  223. m4_include([T-cd.at])
  224. m4_include([T-empty.at])
  225. m4_include([T-null.at])
  226. m4_include([T-null2.at])
  227. m4_include([T-zfile.at])
  228. m4_include([T-nonl.at])
  229. m4_include([T-dir00.at])
  230. m4_include([T-dir01.at])
  231. AT_BANNER([Various options])
  232. m4_include([indexfile.at])
  233. m4_include([verbose.at])
  234. m4_include([gzip.at])
  235. m4_include([recurse.at])
  236. m4_include([recurs02.at])
  237. m4_include([shortrec.at])
  238. m4_include([numeric.at])
  239. AT_BANNER([The --same-order option])
  240. m4_include([same-order01.at])
  241. m4_include([same-order02.at])
  242. AT_BANNER([Append])
  243. m4_include([append.at])
  244. m4_include([append01.at])
  245. m4_include([append02.at])
  246. m4_include([append03.at])
  247. m4_include([append04.at])
  248. m4_include([append05.at])
  249. AT_BANNER([Transforms])
  250. m4_include([xform-h.at])
  251. m4_include([xform01.at])
  252. m4_include([xform02.at])
  253. m4_include([xform03.at])
  254. m4_include([xform04.at])
  255. AT_BANNER([Exclude])
  256. m4_include([exclude.at])
  257. m4_include([exclude01.at])
  258. m4_include([exclude02.at])
  259. m4_include([exclude03.at])
  260. m4_include([exclude04.at])
  261. m4_include([exclude05.at])
  262. m4_include([exclude06.at])
  263. m4_include([exclude07.at])
  264. m4_include([exclude08.at])
  265. m4_include([exclude09.at])
  266. m4_include([exclude10.at])
  267. m4_include([exclude11.at])
  268. m4_include([exclude12.at])
  269. m4_include([exclude13.at])
  270. m4_include([exclude14.at])
  271. m4_include([exclude15.at])
  272. m4_include([exclude16.at])
  273. m4_include([exclude17.at])
  274. m4_include([exclude18.at])
  275. AT_BANNER([Deletions])
  276. m4_include([delete01.at])
  277. m4_include([delete02.at])
  278. m4_include([delete03.at])
  279. m4_include([delete04.at])
  280. m4_include([delete05.at])
  281. m4_include([delete06.at])
  282. AT_BANNER([Extracting])
  283. m4_include([extrac01.at])
  284. m4_include([extrac02.at])
  285. m4_include([extrac03.at])
  286. m4_include([extrac04.at])
  287. m4_include([extrac05.at])
  288. m4_include([extrac06.at])
  289. m4_include([extrac07.at])
  290. m4_include([extrac08.at])
  291. m4_include([extrac09.at])
  292. m4_include([extrac10.at])
  293. m4_include([extrac11.at])
  294. m4_include([extrac12.at])
  295. m4_include([extrac13.at])
  296. m4_include([extrac14.at])
  297. m4_include([extrac15.at])
  298. m4_include([extrac16.at])
  299. m4_include([extrac17.at])
  300. m4_include([extrac18.at])
  301. m4_include([extrac19.at])
  302. m4_include([extrac20.at])
  303. m4_include([extrac21.at])
  304. m4_include([extrac22.at])
  305. m4_include([extrac23.at])
  306. m4_include([extrac24.at])
  307. m4_include([extrac25.at])
  308. m4_include([extrac26.at])
  309. m4_include([backup01.at])
  310. AT_BANNER([Comparing])
  311. m4_include([difflink.at])
  312. AT_BANNER([Volume label operations])
  313. m4_include([label01.at])
  314. m4_include([label02.at])
  315. m4_include([label03.at])
  316. m4_include([label04.at])
  317. m4_include([label05.at])
  318. AT_BANNER([Incremental archives])
  319. m4_include([incremental.at])
  320. m4_include([incr01.at])
  321. m4_include([incr02.at])
  322. m4_include([listed01.at])
  323. m4_include([listed02.at])
  324. m4_include([listed03.at])
  325. m4_include([listed04.at])
  326. m4_include([listed05.at])
  327. m4_include([incr03.at])
  328. m4_include([incr04.at])
  329. m4_include([incr05.at])
  330. m4_include([incr06.at])
  331. m4_include([incr07.at])
  332. m4_include([incr08.at])
  333. m4_include([incr09.at])
  334. m4_include([incr10.at])
  335. m4_include([incr11.at])
  336. AT_BANNER([Files removed while archiving])
  337. m4_include([filerem01.at])
  338. m4_include([filerem02.at])
  339. AT_BANNER([Directories removed while archiving])
  340. m4_include([dirrem01.at])
  341. m4_include([dirrem02.at])
  342. AT_BANNER([Renames])
  343. m4_include([rename01.at])
  344. m4_include([rename02.at])
  345. m4_include([rename03.at])
  346. m4_include([rename04.at])
  347. m4_include([rename05.at])
  348. m4_include([rename06.at])
  349. m4_include([chtype.at])
  350. AT_BANNER([Ignore failing reads])
  351. m4_include([ignfail.at])
  352. AT_BANNER([Link handling])
  353. m4_include([link01.at])
  354. m4_include([link02.at])
  355. m4_include([link03.at])
  356. m4_include([link04.at])
  357. AT_BANNER([Specific archive formats])
  358. m4_include([longv7.at])
  359. m4_include([long01.at])
  360. m4_include([lustar01.at])
  361. m4_include([lustar02.at])
  362. m4_include([lustar03.at])
  363. m4_include([old.at])
  364. m4_include([time01.at])
  365. m4_include([time02.at])
  366. AT_BANNER([Multivolume archives])
  367. m4_include([multiv01.at])
  368. m4_include([multiv02.at])
  369. m4_include([multiv03.at])
  370. m4_include([multiv04.at])
  371. m4_include([multiv05.at])
  372. m4_include([multiv06.at])
  373. m4_include([multiv07.at])
  374. m4_include([multiv08.at])
  375. m4_include([multiv09.at])
  376. m4_include([multiv10.at])
  377. AT_BANNER([Owner and Groups])
  378. m4_include([owner.at])
  379. m4_include([map.at])
  380. AT_BANNER([Sparse files])
  381. m4_include([sparse01.at])
  382. m4_include([sparse02.at])
  383. m4_include([sparse03.at])
  384. m4_include([sparse04.at])
  385. m4_include([sparse05.at])
  386. m4_include([sparse06.at])
  387. m4_include([sparse07.at])
  388. m4_include([sparsemv.at])
  389. m4_include([spmvp00.at])
  390. m4_include([spmvp01.at])
  391. m4_include([spmvp10.at])
  392. m4_include([sptrcreat.at])
  393. m4_include([sptrdiff00.at])
  394. m4_include([sptrdiff01.at])
  395. AT_BANNER([Updates])
  396. m4_include([update.at])
  397. m4_include([update01.at])
  398. m4_include([update02.at])
  399. m4_include([update03.at])
  400. m4_include([update04.at])
  401. AT_BANNER([Verifying the archive])
  402. m4_include([verify.at])
  403. AT_BANNER([Volume operations])
  404. m4_include([volume.at])
  405. m4_include([volsize.at])
  406. AT_BANNER()
  407. m4_include([comprec.at])
  408. m4_include([shortfile.at])
  409. m4_include([shortupd.at])
  410. m4_include([truncate.at])
  411. m4_include([grow.at])
  412. m4_include([sigpipe.at])
  413. m4_include([comperr.at])
  414. AT_BANNER([Removing files after archiving])
  415. m4_include([remfiles01.at])
  416. m4_include([remfiles02.at])
  417. m4_include([remfiles03.at])
  418. m4_include([remfiles04a.at])
  419. m4_include([remfiles04b.at])
  420. m4_include([remfiles04c.at])
  421. m4_include([remfiles05a.at])
  422. m4_include([remfiles05b.at])
  423. m4_include([remfiles05c.at])
  424. m4_include([remfiles06a.at])
  425. m4_include([remfiles06b.at])
  426. m4_include([remfiles06c.at])
  427. m4_include([remfiles07a.at])
  428. m4_include([remfiles07b.at])
  429. m4_include([remfiles07c.at])
  430. m4_include([remfiles08a.at])
  431. m4_include([remfiles08b.at])
  432. m4_include([remfiles08c.at])
  433. m4_include([remfiles09a.at])
  434. m4_include([remfiles09b.at])
  435. m4_include([remfiles09c.at])
  436. m4_include([remfiles10.at])
  437. AT_BANNER([Extended attributes])
  438. m4_include([xattr01.at])
  439. m4_include([xattr02.at])
  440. m4_include([xattr03.at])
  441. m4_include([xattr04.at])
  442. m4_include([xattr05.at])
  443. m4_include([xattr06.at])
  444. m4_include([xattr07.at])
  445. m4_include([xattr08.at])
  446. m4_include([acls01.at])
  447. m4_include([acls02.at])
  448. m4_include([acls03.at])
  449. m4_include([selnx01.at])
  450. m4_include([selacl01.at])
  451. m4_include([capabs_raw01.at])
  452. AT_BANNER([One top level])
  453. m4_include([onetop01.at])
  454. m4_include([onetop02.at])
  455. m4_include([onetop03.at])
  456. m4_include([onetop04.at])
  457. m4_include([onetop05.at])
  458. AT_BANNER([Star tests])
  459. m4_include([star/gtarfail.at])
  460. m4_include([star/gtarfail2.at])
  461. m4_include([star/multi-fail.at])
  462. m4_include([star/ustar-big-2g.at])
  463. m4_include([star/ustar-big-8g.at])
  464. m4_include([star/pax-big-10g.at])