summaryrefslogtreecommitdiff
path: root/posix/globtest.sh
diff options
context:
space:
mode:
Diffstat (limited to 'posix/globtest.sh')
-rwxr-xr-xposix/globtest.sh98
1 files changed, 98 insertions, 0 deletions
diff --git a/posix/globtest.sh b/posix/globtest.sh
new file mode 100755
index 0000000000..c51655b9b3
--- /dev/null
+++ b/posix/globtest.sh
@@ -0,0 +1,98 @@
+#! /bin/sh
+
+common_objpfx=$1; shift
+
+# Create the arena
+: ${TMPDIR=/tmp}
+testdir=$TMPDIR/globtest-dir
+testout=$TMPDIR/globtest-out
+
+trap 'rm -fr $testdir $testout' 1 2 3 15
+
+rm -fr $testdir
+mkdir $testdir
+echo 1 > $testdir/file1
+echo 2 > $testdir/file2
+mkdir $testdir/dir1
+mkdir $testdir/dir2
+echo 1_1 > $testdir/dir1/file1_1
+echo 1_2 > $testdir/dir1/file1_2
+
+# Run some tests.
+result=0
+here=`pwd`
+
+(cd $testdir &&
+ LD_LIBRARY_PATH=$common_objpfx $common_objpfx/posix/globtest "*") |
+sort > $testout
+cat <<"EOF" | cmp - $testout || result=1
+`dir1'
+`dir2'
+`file1'
+`file2'
+not NULL
+EOF
+
+(cd $testdir &&
+ LD_LIBRARY_PATH=$common_objpfx $common_objpfx/posix/globtest "*/*") |
+sort > $testout
+cat <<"EOF" | cmp - $testout || result=1
+`dir1/file1_1'
+`dir1/file1_2'
+not NULL
+EOF
+
+(cd $testdir &&
+ LD_LIBRARY_PATH=$common_objpfx $common_objpfx/posix/globtest "*/1") |
+sort > $testout
+cat <<"EOF" | cmp - $testout || result=1
+GLOB_NOMATCH
+NULL
+EOF
+
+(cd $testdir &&
+ LD_LIBRARY_PATH=$common_objpfx $common_objpfx/posix/globtest "*/*1_1") |
+sort > $testout
+cat <<"EOF" | cmp - $testout || result=1
+`dir1/file1_1'
+not NULL
+EOF
+
+(cd $testdir &&
+ LD_LIBRARY_PATH=$common_objpfx $common_objpfx/posix/globtest "*/file1_1") |
+sort > $testout
+cat <<"EOF" | cmp - $testout || result=1
+`dir1/file1_1'
+not NULL
+EOF
+
+(cd $testdir &&
+ LD_LIBRARY_PATH=$common_objpfx $common_objpfx/posix/globtest "*-/*") |
+sort > $testout
+cat <<"EOF" | cmp - $testout || result=1
+GLOB_NOMATCH
+NULL
+EOF
+
+(cd $testdir &&
+ LD_LIBRARY_PATH=$common_objpfx $common_objpfx/posix/globtest "*-") |
+sort > $testout
+cat <<"EOF" | cmp - $testout || result=1
+GLOB_NOMATCH
+NULL
+EOF
+
+if test $result -eq 0; then
+ rm -fr $testdir $testout
+fi
+
+exit $result
+
+# Preserve executable bits for this shell script.
+Local Variables:
+eval:(defun frobme () (set-file-modes buffer-file-name file-mode))
+eval:(make-local-variable 'file-mode)
+eval:(setq file-mode (file-modes (buffer-file-name)))
+eval:(make-local-variable 'after-save-hook)
+eval:(add-hook 'after-save-hook 'frobme)
+End: