diff options
author | Otto Moerbeek <otto@cvs.openbsd.org> | 2005-04-07 07:24:28 +0000 |
---|---|---|
committer | Otto Moerbeek <otto@cvs.openbsd.org> | 2005-04-07 07:24:28 +0000 |
commit | 6f0c8e043c38725e21a6d3ba436f93c066eafc3a (patch) | |
tree | 3eced3569138a05df85f5b535b82662057ea5bde /regress | |
parent | f8a49f0f52c5c38b973a36f61304c5768fb4baba (diff) |
Tests for basename(1). From NetbSD with some local changes.
Diffstat (limited to 'regress')
-rw-r--r-- | regress/usr.bin/basename/Makefile | 7 | ||||
-rw-r--r-- | regress/usr.bin/basename/basename.sh | 42 |
2 files changed, 49 insertions, 0 deletions
diff --git a/regress/usr.bin/basename/Makefile b/regress/usr.bin/basename/Makefile new file mode 100644 index 00000000000..9277e2d2524 --- /dev/null +++ b/regress/usr.bin/basename/Makefile @@ -0,0 +1,7 @@ +# $OpenBSD: Makefile,v 1.1 2005/04/07 07:24:27 otto Exp $ +# $NetBSD: Makefile,v 1.1 2005/04/04 16:48:45 peter Exp $ + +regress: + @sh ${.CURDIR}/basename.sh + +.include <bsd.regress.mk> 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" |