/posix/globtest.sh

https://github.com/nitinkamble/x32-glibc · Shell · 795 lines · 728 code · 36 blank · 31 comment · 60 complexity · 5e33434355cf36004cba6395fd30fbda MD5 · raw file

  1. #! /bin/bash
  2. common_objpfx=$1; shift
  3. elf_objpfx=$1; shift
  4. rtld_installed_name=$1; shift
  5. logfile=$common_objpfx/posix/globtest.out
  6. #CMP=cmp
  7. CMP="diff -u"
  8. # We have to make the paths `common_objpfx' absolute.
  9. case "$common_objpfx" in
  10. .*)
  11. common_objpfx="`pwd`/$common_objpfx"
  12. ;;
  13. *)
  14. ;;
  15. esac
  16. # We have to find the libc and the NSS modules.
  17. library_path=${common_objpfx}:${common_objpfx}nss:${common_objpfx}nis:${common_objpfx}db2:${common_objpfx}hesiod
  18. # Since we use `sort' we must make sure to use the same locale everywhere.
  19. LC_ALL=C
  20. export LC_ALL
  21. LANG=C
  22. export LANG
  23. # Create the arena
  24. : ${TMPDIR=/tmp}
  25. testdir=$(mktemp -d $TMPDIR/globtest-dir.XXXXXX)
  26. testout=$(mktemp $TMPDIR/globtest-out.XXXXXX)
  27. trap 'chmod 777 $testdir/noread; rm -fr $testdir $testout' 1 2 3 15
  28. echo 1 > $testdir/file1
  29. echo 2 > $testdir/file2
  30. echo 3 > $testdir/-file3
  31. echo 4 > $testdir/~file4
  32. echo 5 > $testdir/.file5
  33. echo 6 > $testdir/'*file6'
  34. echo 7 > $testdir/'{file7,}'
  35. echo 8 > $testdir/'\{file8\}'
  36. echo 9 > $testdir/'\{file9\,file9b\}'
  37. echo 9 > $testdir/'\file9b\' #'
  38. echo a > $testdir/'filea,'
  39. echo a > $testdir/'fileb}c'
  40. mkdir $testdir/dir1
  41. mkdir $testdir/dir2
  42. test -d $testdir/noread || mkdir $testdir/noread
  43. chmod a-r $testdir/noread
  44. echo 1_1 > $testdir/dir1/file1_1
  45. echo 1_2 > $testdir/dir1/file1_2
  46. ln -fs dir1 $testdir/link1
  47. # Run some tests.
  48. result=0
  49. rm -f $logfile
  50. # Normal test
  51. failed=0
  52. ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
  53. ${common_objpfx}posix/globtest "$testdir" "*" |
  54. sort > $testout
  55. cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
  56. `*file6'
  57. `-file3'
  58. `\file9b\'
  59. `\{file8\}'
  60. `\{file9\,file9b\}'
  61. `dir1'
  62. `dir2'
  63. `file1'
  64. `file2'
  65. `filea,'
  66. `fileb}c'
  67. `link1'
  68. `noread'
  69. `{file7,}'
  70. `~file4'
  71. EOF
  72. if test $failed -ne 0; then
  73. echo "Normal test failed" >> $logfile
  74. result=1
  75. fi
  76. # Don't let glob sort it
  77. failed=0
  78. ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
  79. ${common_objpfx}posix/globtest -s "$testdir" "*" |
  80. sort > $testout
  81. cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
  82. `*file6'
  83. `-file3'
  84. `\file9b\'
  85. `\{file8\}'
  86. `\{file9\,file9b\}'
  87. `dir1'
  88. `dir2'
  89. `file1'
  90. `file2'
  91. `filea,'
  92. `fileb}c'
  93. `link1'
  94. `noread'
  95. `{file7,}'
  96. `~file4'
  97. EOF
  98. if test $failed -ne 0; then
  99. echo "No sort test failed" >> $logfile
  100. result=1
  101. fi
  102. # Mark directories
  103. failed=0
  104. ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
  105. ${common_objpfx}posix/globtest -m "$testdir" "*" |
  106. sort > $testout
  107. cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
  108. `*file6'
  109. `-file3'
  110. `\file9b\'
  111. `\{file8\}'
  112. `\{file9\,file9b\}'
  113. `dir1/'
  114. `dir2/'
  115. `file1'
  116. `file2'
  117. `filea,'
  118. `fileb}c'
  119. `link1/'
  120. `noread/'
  121. `{file7,}'
  122. `~file4'
  123. EOF
  124. if test $failed -ne 0; then
  125. echo "Mark directories test failed" >> $logfile
  126. result=1
  127. fi
  128. # Find files starting with .
  129. failed=0
  130. ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
  131. ${common_objpfx}posix/globtest -p "$testdir" "*" |
  132. sort > $testout
  133. cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
  134. `*file6'
  135. `-file3'
  136. `.'
  137. `..'
  138. `.file5'
  139. `\file9b\'
  140. `\{file8\}'
  141. `\{file9\,file9b\}'
  142. `dir1'
  143. `dir2'
  144. `file1'
  145. `file2'
  146. `filea,'
  147. `fileb}c'
  148. `link1'
  149. `noread'
  150. `{file7,}'
  151. `~file4'
  152. EOF
  153. if test $failed -ne 0; then
  154. echo "Leading period test failed" >> $logfile
  155. result=1
  156. fi
  157. # Test braces
  158. failed=0
  159. ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
  160. ${common_objpfx}posix/globtest -b "$testdir" "file{1,2}" |
  161. sort > $testout
  162. cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
  163. `file1'
  164. `file2'
  165. EOF
  166. if test $failed -ne 0; then
  167. echo "Braces test failed" >> $logfile
  168. result=1
  169. fi
  170. failed=0
  171. ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
  172. ${common_objpfx}posix/globtest -b "$testdir" "{file{1,2},-file3}" |
  173. sort > $testout
  174. cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
  175. `-file3'
  176. `file1'
  177. `file2'
  178. EOF
  179. if test $failed -ne 0; then
  180. echo "Braces test 2 failed" >> $logfile
  181. result=1
  182. fi
  183. failed=0
  184. ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
  185. ${common_objpfx}posix/globtest -b "$testdir" "{" |
  186. sort > $testout
  187. cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
  188. GLOB_NOMATCH
  189. EOF
  190. if test $failed -ne 0; then
  191. echo "Braces test 3 failed" >> $logfile
  192. result=1
  193. fi
  194. # Test NOCHECK
  195. failed=0
  196. ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
  197. ${common_objpfx}posix/globtest -c "$testdir" "abc" |
  198. sort > $testout
  199. cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
  200. `abc'
  201. EOF
  202. if test $failed -ne 0; then
  203. echo "No check test failed" >> $logfile
  204. result=1
  205. fi
  206. # Test NOMAGIC without magic characters
  207. failed=0
  208. ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
  209. ${common_objpfx}posix/globtest -g "$testdir" "abc" |
  210. sort > $testout
  211. cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
  212. `abc'
  213. EOF
  214. if test $failed -ne 0; then
  215. echo "No magic test failed" >> $logfile
  216. result=1
  217. fi
  218. # Test NOMAGIC with magic characters
  219. failed=0
  220. ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
  221. ${common_objpfx}posix/globtest -g "$testdir" "abc*" |
  222. sort > $testout
  223. cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
  224. GLOB_NOMATCH
  225. EOF
  226. if test $failed -ne 0; then
  227. echo "No magic w/ magic chars test failed" >> $logfile
  228. result=1
  229. fi
  230. # Test NOMAGIC for subdirs
  231. failed=0
  232. ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
  233. ${common_objpfx}posix/globtest -g "$testdir" "*/does-not-exist" |
  234. sort > $testout
  235. cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
  236. GLOB_NOMATCH
  237. EOF
  238. if test $failed -ne 0; then
  239. echo "No magic in subdir test failed" >> $logfile
  240. result=1
  241. fi
  242. # Test subdirs correctly
  243. failed=0
  244. ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
  245. ${common_objpfx}posix/globtest "$testdir" "*/*" |
  246. sort > $testout
  247. cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
  248. `dir1/file1_1'
  249. `dir1/file1_2'
  250. `link1/file1_1'
  251. `link1/file1_2'
  252. EOF
  253. if test $failed -ne 0; then
  254. echo "Subdirs test failed" >> $logfile
  255. result=1
  256. fi
  257. # Test subdirs for invalid names
  258. failed=0
  259. ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
  260. ${common_objpfx}posix/globtest "$testdir" "*/1" |
  261. sort > $testout
  262. cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
  263. GLOB_NOMATCH
  264. EOF
  265. if test $failed -ne 0; then
  266. echo "Invalid subdir test failed" >> $logfile
  267. result=1
  268. fi
  269. # Test subdirs with wildcard
  270. failed=0
  271. ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
  272. ${common_objpfx}posix/globtest "$testdir" "*/*1_1" |
  273. sort > $testout
  274. cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
  275. `dir1/file1_1'
  276. `link1/file1_1'
  277. EOF
  278. if test $failed -ne 0; then
  279. echo "Wildcard subdir test failed" >> $logfile
  280. result=1
  281. fi
  282. # Test subdirs with ?
  283. failed=0
  284. ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
  285. ${common_objpfx}posix/globtest "$testdir" "*/*?_?" |
  286. sort > $testout
  287. cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
  288. `dir1/file1_1'
  289. `dir1/file1_2'
  290. `link1/file1_1'
  291. `link1/file1_2'
  292. EOF
  293. if test $failed -ne 0; then
  294. echo "Wildcard2 subdir test failed" >> $logfile
  295. result=1
  296. fi
  297. failed=0
  298. ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
  299. ${common_objpfx}posix/globtest "$testdir" "*/file1_1" |
  300. sort > $testout
  301. cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
  302. `dir1/file1_1'
  303. `link1/file1_1'
  304. EOF
  305. if test $failed -ne 0; then
  306. echo "Wildcard3 subdir test failed" >> $logfile
  307. result=1
  308. fi
  309. failed=0
  310. ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
  311. ${common_objpfx}posix/globtest "$testdir" "*-/*" |
  312. sort > $testout
  313. cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
  314. GLOB_NOMATCH
  315. EOF
  316. if test $failed -ne 0; then
  317. echo "Wildcard4 subdir test failed" >> $logfile
  318. result=1
  319. fi
  320. failed=0
  321. ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
  322. ${common_objpfx}posix/globtest "$testdir" "*-" |
  323. sort > $testout
  324. cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
  325. GLOB_NOMATCH
  326. EOF
  327. if test $failed -ne 0; then
  328. echo "Wildcard5 subdir test failed" >> $logfile
  329. result=1
  330. fi
  331. # Test subdirs with ?
  332. failed=0
  333. ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
  334. ${common_objpfx}posix/globtest "$testdir" "*/*?_?" |
  335. sort > $testout
  336. cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
  337. `dir1/file1_1'
  338. `dir1/file1_2'
  339. `link1/file1_1'
  340. `link1/file1_2'
  341. EOF
  342. if test $failed -ne 0; then
  343. echo "Wildcard6 subdir test failed" >> $logfile
  344. result=1
  345. fi
  346. # Test subdirs with [ .. ]
  347. failed=0
  348. ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
  349. ${common_objpfx}posix/globtest "$testdir" "*/file1_[12]" |
  350. sort > $testout
  351. cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
  352. `dir1/file1_1'
  353. `dir1/file1_2'
  354. `link1/file1_1'
  355. `link1/file1_2'
  356. EOF
  357. if test $failed -ne 0; then
  358. echo "Brackets test failed" >> $logfile
  359. result=1
  360. fi
  361. # Test ']' inside bracket expression
  362. failed=0
  363. ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
  364. ${common_objpfx}posix/globtest "$testdir" "dir1/file1_[]12]" |
  365. sort > $testout
  366. cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
  367. `dir1/file1_1'
  368. `dir1/file1_2'
  369. EOF
  370. if test $failed -ne 0; then
  371. echo "Brackets2 test failed" >> $logfile
  372. result=1
  373. fi
  374. # Test tilde expansion
  375. failed=0
  376. ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
  377. ${common_objpfx}posix/globtest -q -t "$testdir" "~" |
  378. sort >$testout
  379. echo ~ | $CMP - $testout >> $logfile || failed=1
  380. if test $failed -ne 0; then
  381. if test -d ~; then
  382. echo "Tilde test failed" >> $logfile
  383. result=1
  384. else
  385. echo "Tilde test could not be run" >> $logfile
  386. fi
  387. fi
  388. # Test tilde expansion with trailing slash
  389. failed=0
  390. ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
  391. ${common_objpfx}posix/globtest -q -t "$testdir" "~/" |
  392. sort > $testout
  393. # Some shell incorrectly(?) convert ~/ into // if ~ expands to /.
  394. if test ~/ = //; then
  395. echo / | $CMP - $testout >> $logfile || failed=1
  396. else
  397. echo ~/ | $CMP - $testout >> $logfile || failed=1
  398. fi
  399. if test $failed -ne 0; then
  400. if test -d ~/; then
  401. echo "Tilde2 test failed" >> $logfile
  402. result=1
  403. else
  404. echo "Tilde2 test could not be run" >> $logfile
  405. fi
  406. fi
  407. # Test tilde expansion with username
  408. failed=0
  409. ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
  410. ${common_objpfx}posix/globtest -q -t "$testdir" "~"$USER |
  411. sort > $testout
  412. eval echo ~$USER | $CMP - $testout >> $logfile || failed=1
  413. if test $failed -ne 0; then
  414. if eval test -d ~$USER; then
  415. echo "Tilde3 test failed" >> $logfile
  416. result=1
  417. else
  418. echo "Tilde3 test could not be run" >> $logfile
  419. fi
  420. fi
  421. # Tilde expansion shouldn't match a file
  422. failed=0
  423. ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
  424. ${common_objpfx}posix/globtest -T "$testdir" "~file4" |
  425. sort > $testout
  426. cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
  427. GLOB_NOMATCH
  428. EOF
  429. if test $failed -ne 0; then
  430. echo "Tilde4 test failed" >> $logfile
  431. result=1
  432. fi
  433. # Matching \** should only find *file6
  434. failed=0
  435. ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
  436. ${common_objpfx}posix/globtest "$testdir" "\**" |
  437. sort > $testout
  438. cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
  439. `*file6'
  440. EOF
  441. if test $failed -ne 0; then
  442. echo "Star test failed" >> $logfile
  443. result=1
  444. fi
  445. # ... unless NOESCAPE is used, in which case it should entries with a
  446. # leading \.
  447. failed=0
  448. ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
  449. ${common_objpfx}posix/globtest -e "$testdir" "\**" |
  450. sort > $testout
  451. cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
  452. `\file9b\'
  453. `\{file8\}'
  454. `\{file9\,file9b\}'
  455. EOF
  456. if test $failed -ne 0; then
  457. echo "Star2 test failed" >> $logfile
  458. result=1
  459. fi
  460. # Matching \*file6 should find *file6
  461. failed=0
  462. ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
  463. ${common_objpfx}posix/globtest "$testdir" "\*file6" |
  464. sort > $testout
  465. cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
  466. `*file6'
  467. EOF
  468. if test $failed -ne 0; then
  469. echo "Star3 test failed" >> $logfile
  470. result=1
  471. fi
  472. # GLOB_BRACE alone
  473. failed=0
  474. ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
  475. ${common_objpfx}posix/globtest -b "$testdir" '\{file7\,\}' |
  476. sort > $testout
  477. cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
  478. `{file7,}'
  479. EOF
  480. if test $failed -ne 0; then
  481. echo "Brace4 test failed" >> $logfile
  482. result=1
  483. fi
  484. # GLOB_BRACE and GLOB_NOESCAPE
  485. failed=0
  486. ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
  487. ${common_objpfx}posix/globtest -b -e "$testdir" '\{file9\,file9b\}' |
  488. sort > $testout
  489. cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
  490. `\file9b\'
  491. EOF
  492. if test $failed -ne 0; then
  493. echo "Brace5 test failed" >> $logfile
  494. result=1
  495. fi
  496. # Escaped comma
  497. failed=0
  498. ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
  499. ${common_objpfx}posix/globtest -b "$testdir" '{filea\,}' |
  500. sort > $testout
  501. cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
  502. `filea,'
  503. EOF
  504. if test $failed -ne 0; then
  505. echo "Brace6 test failed" >> $logfile
  506. result=1
  507. fi
  508. # Escaped closing brace
  509. failed=0
  510. ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
  511. ${common_objpfx}posix/globtest -b "$testdir" '{fileb\}c}' |
  512. sort > $testout
  513. cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
  514. `fileb}c'
  515. EOF
  516. if test $failed -ne 0; then
  517. echo "Brace7 test failed" >> $logfile
  518. result=1
  519. fi
  520. # Try a recursive failed search
  521. failed=0
  522. ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
  523. ${common_objpfx}posix/globtest -e "$testdir" "a*/*" |
  524. sort > $testout
  525. cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
  526. GLOB_NOMATCH
  527. EOF
  528. if test $failed -ne 0; then
  529. echo "Star4 test failed" >> $logfile
  530. result=1
  531. fi
  532. # ... with GLOB_ERR
  533. failed=0
  534. ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
  535. ${common_objpfx}posix/globtest -E "$testdir" "a*/*" |
  536. sort > $testout
  537. cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
  538. GLOB_NOMATCH
  539. EOF
  540. if test $failed -ne 0; then
  541. echo "Star5 test failed" >> $logfile
  542. result=1
  543. fi
  544. # Try a recursive search in unreadable directory
  545. failed=0
  546. ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
  547. ${common_objpfx}posix/globtest "$testdir" "noread/*" |
  548. sort > $testout
  549. cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
  550. GLOB_NOMATCH
  551. EOF
  552. if test $failed -ne 0; then
  553. echo "Star6 test failed" >> $logfile
  554. result=1
  555. fi
  556. failed=0
  557. ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
  558. ${common_objpfx}posix/globtest "$testdir" "noread*/*" |
  559. sort > $testout
  560. cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
  561. GLOB_NOMATCH
  562. EOF
  563. if test $failed -ne 0; then
  564. echo "Star6 test failed" >> $logfile
  565. result=1
  566. fi
  567. # The following tests will fail if run as root.
  568. user=`id -un 2> /dev/null`
  569. if test -z "$user"; then
  570. uid="$USER"
  571. fi
  572. if test "$user" != root; then
  573. # ... with GLOB_ERR
  574. ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
  575. ${common_objpfx}posix/globtest -E "$testdir" "noread/*" |
  576. sort > $testout
  577. cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
  578. GLOB_ABORTED
  579. EOF
  580. ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
  581. ${common_objpfx}posix/globtest -E "$testdir" "noread*/*" |
  582. sort > $testout
  583. cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
  584. GLOB_ABORTED
  585. EOF
  586. if test $failed -ne 0; then
  587. echo "GLOB_ERR test failed" >> $logfile
  588. result=1
  589. fi
  590. fi # not run as root
  591. # Try multiple patterns (GLOB_APPEND)
  592. failed=0
  593. ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
  594. ${common_objpfx}posix/globtest "$testdir" "file1" "*/*" |
  595. sort > $testout
  596. cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
  597. `dir1/file1_1'
  598. `dir1/file1_2'
  599. `file1'
  600. `link1/file1_1'
  601. `link1/file1_2'
  602. EOF
  603. if test $failed -ne 0; then
  604. echo "GLOB_APPEND test failed" >> $logfile
  605. result=1
  606. fi
  607. # Try multiple patterns (GLOB_APPEND) with offset (GLOB_DOOFFS)
  608. failed=0
  609. ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
  610. ${common_objpfx}posix/globtest -o "$testdir" "file1" "*/*" |
  611. sort > $testout
  612. cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
  613. `abc'
  614. `dir1/file1_1'
  615. `dir1/file1_2'
  616. `file1'
  617. `link1/file1_1'
  618. `link1/file1_2'
  619. EOF
  620. if test $failed -ne 0; then
  621. echo "GLOB_APPEND2 test failed" >> $logfile
  622. result=1
  623. fi
  624. # Test NOCHECK with non-existing file in subdir.
  625. failed=0
  626. ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
  627. ${common_objpfx}posix/globtest -c "$testdir" "*/blahblah" |
  628. sort > $testout
  629. cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
  630. `*/blahblah'
  631. EOF
  632. if test $failed -ne 0; then
  633. echo "No check2 test failed" >> $logfile
  634. result=1
  635. fi
  636. # Test [[:punct:]] not matching leading period.
  637. failed=0
  638. ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
  639. ${common_objpfx}posix/globtest -c "$testdir" "[[:punct:]]*" |
  640. sort > $testout
  641. cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
  642. `*file6'
  643. `-file3'
  644. `\file9b\'
  645. `\{file8\}'
  646. `\{file9\,file9b\}'
  647. `{file7,}'
  648. `~file4'
  649. EOF
  650. if test $failed -ne 0; then
  651. echo "Punct test failed" >> $logfile
  652. result=1
  653. fi
  654. mkdir $testdir/'dir3*'
  655. echo 1 > $testdir/'dir3*'/file1
  656. mkdir $testdir/'dir4[a'
  657. echo 2 > $testdir/'dir4[a'/file1
  658. echo 3 > $testdir/'dir4[a'/file2
  659. mkdir $testdir/'dir5[ab]'
  660. echo 4 > $testdir/'dir5[ab]'/file1
  661. echo 5 > $testdir/'dir5[ab]'/file2
  662. mkdir $testdir/dir6
  663. echo 6 > $testdir/dir6/'file1[a'
  664. echo 7 > $testdir/dir6/'file1[ab]'
  665. failed=0
  666. v=`${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
  667. ${common_objpfx}posix/globtest "$testdir" 'dir3\*/file2'`
  668. test "$v" != 'GLOB_NOMATCH' && echo "$v" >> $logfile && failed=1
  669. ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
  670. ${common_objpfx}posix/globtest -c "$testdir" \
  671. 'dir3\*/file1' 'dir3\*/file2' 'dir1/file\1_1' 'dir1/file\1_9' \
  672. 'dir2\/' 'nondir\/' 'dir4[a/fil*1' 'di*r4[a/file2' 'dir5[ab]/file[12]' \
  673. 'dir6/fil*[a' 'dir*6/file1[a' 'dir6/fi*l[ab]' 'dir*6/file1[ab]' \
  674. 'dir6/file1[[.a.]*' |
  675. sort > $testout
  676. cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
  677. `dir*6/file1[ab]'
  678. `dir1/file1_1'
  679. `dir1/file\1_9'
  680. `dir2/'
  681. `dir3*/file1'
  682. `dir3\*/file2'
  683. `dir4[a/file1'
  684. `dir4[a/file2'
  685. `dir5[ab]/file[12]'
  686. `dir6/fi*l[ab]'
  687. `dir6/file1[a'
  688. `dir6/file1[a'
  689. `dir6/file1[a'
  690. `dir6/file1[ab]'
  691. `nondir\/'
  692. EOF
  693. HOME="$testdir" \
  694. ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
  695. ${common_objpfx}posix/globtest -ct "$testdir" \
  696. '~/dir1/file1_1' '~/dir1/file1_9' '~/dir3\*/file1' '~/dir3\*/file2' \
  697. '~\/dir1/file1_2' |
  698. sort > $testout
  699. cat <<EOF | $CMP - $testout >> $logfile || failed=1
  700. \`$testdir/dir1/file1_1'
  701. \`$testdir/dir1/file1_2'
  702. \`$testdir/dir3*/file1'
  703. \`~/dir1/file1_9'
  704. \`~/dir3\\*/file2'
  705. EOF
  706. if eval test -d ~"$USER"/; then
  707. user=`echo "$USER" | sed -n -e 's/^\([^\\]\)\([^\\][^\\]*\)$/~\1\\\\\2/p'`
  708. if test -n "$user"; then
  709. ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
  710. ${common_objpfx}posix/globtest -ctq "$testdir" "$user/" |
  711. sort > $testout
  712. eval echo ~$USER/ | $CMP - $testout >> $logfile || failed=1
  713. ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
  714. ${common_objpfx}posix/globtest -ctq "$testdir" "$user\\/" |
  715. sort > $testout
  716. eval echo ~$USER/ | $CMP - $testout >> $logfile || failed=1
  717. ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
  718. ${common_objpfx}posix/globtest -ctq "$testdir" "$user" |
  719. sort > $testout
  720. eval echo ~$USER | $CMP - $testout >> $logfile || failed=1
  721. fi
  722. fi
  723. if test $failed -ne 0; then
  724. echo "Escape tests failed" >> $logfile
  725. result=1
  726. fi
  727. if test $result -eq 0; then
  728. chmod 777 $testdir/noread
  729. rm -fr $testdir $testout
  730. echo "All OK." > $logfile
  731. fi
  732. exit $result
  733. # Preserve executable bits for this shell script.
  734. Local Variables:
  735. eval:(defun frobme () (set-file-modes buffer-file-name file-mode))
  736. eval:(make-local-variable 'file-mode)
  737. eval:(setq file-mode (file-modes (buffer-file-name)))
  738. eval:(make-local-variable 'after-save-hook)
  739. eval:(add-hook 'after-save-hook 'frobme)
  740. End: