aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDuncaen <mail@duncano.de>2017-03-07 18:01:14 +0100
committerDuncaen <mail@duncano.de>2017-03-07 18:01:14 +0100
commitd818f81ea8fcd9f59b111d25ad64e876a4157e68 (patch)
tree89c9210fa7430db98d227d3237f4bf24cb5ad3fa
parent8ed1fc52aa5d0d346ca43e032b305a2c8bc7c0d2 (diff)
downloadlobase-d818f81ea8fcd9f59b111d25ad64e876a4157e68.tar.gz
regress: import usr.bin/basename
-rw-r--r--regress/usr.bin/Makefile4
-rw-r--r--regress/usr.bin/basename/Makefile7
-rw-r--r--regress/usr.bin/basename/basename.sh42
3 files changed, 51 insertions, 2 deletions
diff --git a/regress/usr.bin/Makefile b/regress/usr.bin/Makefile
index a481799..24cae46 100644
--- a/regress/usr.bin/Makefile
+++ b/regress/usr.bin/Makefile
@@ -1,4 +1,4 @@
-SUBDIR = bc calendar colrm column cut dc diff diff3 dirname file \
+SUBDIR = basename bc calendar colrm column cut dc diff diff3 dirname file \
fmt fold grep jot tail tsort ul wc xargs
-SKIPDIR = grep bc calendar diff3
+SKIPDIR = grep bc calendar diff3 cut jot
include bsd.subdir.mk
diff --git a/regress/usr.bin/basename/Makefile b/regress/usr.bin/basename/Makefile
new file mode 100644
index 0000000..4b719dc
--- /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:
+ @$(SHELL) ${.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 0000000..89279a2
--- /dev/null
+++ b/regress/usr.bin/basename/basename.sh
@@ -0,0 +1,42 @@
+#!/bin/sh
+#
+# $OpenBSD: basename.sh,v 1.2 2005/04/12 06:45:03 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"