Imported Upstream version 4.5.14
[platform/upstream/findutils.git] / find / testsuite / sv-bug-32043.sh
1 #! /bin/sh
2 testname="$(basename $0)"
3
4 parent="$(cd .. && pwd)"
5 if [ -f "${parent}/ftsfind" ]; then
6     ftsfind="${parent}/ftsfind"
7     oldfind="${parent}/find"
8 elif [ -f "${parent}/oldfind" ]; then
9     ftsfind="${parent}/find"
10     oldfind="${parent}/oldfind"
11 else
12     echo "Cannot find the executables to test." >&2
13     exit 1
14 fi
15 if tstdir=$(mktemp -d); then
16     touch "$tstdir/["
17     expected="$tstdir/["
18     for executable in "$oldfind" "$ftsfind"; do
19         if result=$("$executable" "$tstdir" -name '[' -print); then
20             if ! [ "$result" = "$expected" ]; then
21                 echo "FAIL: $testname with $executable returned '$result' but '$expected' was expected" >&2
22                 exit 1
23             fi
24         else
25             echo "FAIL: $executable returned $?" >&2
26             exit 1
27         fi
28     done
29     rm -rf "$tstdir"
30 else
31     echo "FAIL: could not create a test directory." >&2
32     exit 1
33 fi