PageRenderTime 2854ms CodeModel.GetById 1ms RepoModel.GetById 0ms app.codeStats 0ms

/posix/globtest.sh

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