diff options
Diffstat (limited to 'regress/usr.bin/basename/basename.sh')
-rw-r--r-- | regress/usr.bin/basename/basename.sh | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/regress/usr.bin/basename/basename.sh b/regress/usr.bin/basename/basename.sh new file mode 100644 index 00000000000..a0d8d3b40bb --- /dev/null +++ b/regress/usr.bin/basename/basename.sh @@ -0,0 +1,42 @@ +#!/bin/sh +# +# $OpenBSD: basename.sh,v 1.1 2005/04/07 07:24:27 otto Exp $ +# $NetBSD: basename.sh,v 1.1 2005/04/04 16:48:45 peter Exp $ + +test_basename() +{ + echo "Testing \"$1\"" + result=`basename "$1" 2>&1` + if [ "$result" != "$2" ]; then + echo "Expected \"$2\", but got \"$result\"" + exit 1 + fi +} + +test_basename_suffix() +{ + echo "Testing suffix \"$1\" \"$2\"" + result=`basename "$1" "$2" 2>&1` + if [ "$result" != "$3" ]; then + echo "Expected \"$3\", but got \"$result\"" + exit 1 + fi +} + +# Tests without suffix +test_basename "" "." +test_basename "/usr/bin" "bin" +test_basename "/usr" "usr" +test_basename "/" "/" +test_basename "///" "/" +test_basename "/usr//" "usr" +test_basename "//usr//bin" "bin" +test_basename "usr" "usr" +test_basename "usr/bin" "bin" + +# Tests with suffix +test_basename_suffix "/usr/bin" "n" "bi" +test_basename_suffix "/usr/bin" "bin" "bin" +test_basename_suffix "/" "/" "/" +test_basename_suffix "/usr/bin/gcc" "cc" "g" +test_basename_suffix "/usr/bin/gcc" "xx" "gcc" |