Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/regress/usr.bin Add regression tests for basename(1) and dir...
details: https://anonhg.NetBSD.org/src/rev/c8c8a4f6ca48
branches: trunk
changeset: 580005:c8c8a4f6ca48
user: peter <peter%NetBSD.org@localhost>
date: Mon Apr 04 16:48:45 2005 +0000
description:
Add regression tests for basename(1) and dirname(1).
diffstat:
regress/usr.bin/Makefile | 4 +-
regress/usr.bin/basename/Makefile | 8 +++++++
regress/usr.bin/basename/basename.sh | 39 ++++++++++++++++++++++++++++++++++++
regress/usr.bin/dirname/Makefile | 8 +++++++
regress/usr.bin/dirname/dirname.sh | 23 +++++++++++++++++++++
5 files changed, 80 insertions(+), 2 deletions(-)
diffs (105 lines):
diff -r 52686d2696fc -r c8c8a4f6ca48 regress/usr.bin/Makefile
--- a/regress/usr.bin/Makefile Mon Apr 04 16:47:54 2005 +0000
+++ b/regress/usr.bin/Makefile Mon Apr 04 16:48:45 2005 +0000
@@ -1,5 +1,5 @@
-# $NetBSD: Makefile,v 1.9 2004/07/10 19:32:06 yamt Exp $
+# $NetBSD: Makefile,v 1.10 2005/04/04 16:48:45 peter Exp $
-SUBDIR+= bzip2 grep gzip m4 make rtld sort
+SUBDIR+= basename bzip2 dirname grep gzip m4 make rtld sort
.include <bsd.subdir.mk>
diff -r 52686d2696fc -r c8c8a4f6ca48 regress/usr.bin/basename/Makefile
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/regress/usr.bin/basename/Makefile Mon Apr 04 16:48:45 2005 +0000
@@ -0,0 +1,8 @@
+# $NetBSD: Makefile,v 1.1 2005/04/04 16:48:45 peter Exp $
+
+NOMAN= # defined
+
+regress:
+ @sh ${.CURDIR}/basename.sh
+
+.include <bsd.prog.mk>
diff -r 52686d2696fc -r c8c8a4f6ca48 regress/usr.bin/basename/basename.sh
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/regress/usr.bin/basename/basename.sh Mon Apr 04 16:48:45 2005 +0000
@@ -0,0 +1,39 @@
+#!/bin/sh
+#
+# $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 $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 "/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"
diff -r 52686d2696fc -r c8c8a4f6ca48 regress/usr.bin/dirname/Makefile
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/regress/usr.bin/dirname/Makefile Mon Apr 04 16:48:45 2005 +0000
@@ -0,0 +1,8 @@
+# $NetBSD: Makefile,v 1.1 2005/04/04 16:48:45 peter Exp $
+
+NOMAN= # defined
+
+regress:
+ @sh ${.CURDIR}/dirname.sh
+
+.include <bsd.prog.mk>
diff -r 52686d2696fc -r c8c8a4f6ca48 regress/usr.bin/dirname/dirname.sh
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/regress/usr.bin/dirname/dirname.sh Mon Apr 04 16:48:45 2005 +0000
@@ -0,0 +1,23 @@
+#!/bin/sh
+#
+# $NetBSD: dirname.sh,v 1.1 2005/04/04 16:48:45 peter Exp $
+
+test_dirname()
+{
+ echo "Testing $1"
+ result=`dirname $1 2>&1`
+ if [ "$result" != "$2" ]; then
+ echo "Expected $2, but got $result"
+ exit 1
+ fi
+}
+
+test_dirname "/" "/"
+test_dirname "//" "/"
+test_dirname "/usr/bin/" "/usr"
+test_dirname "//usr//bin//" "//usr"
+test_dirname "usr" "."
+test_dirname "\"\"" "."
+test_dirname "/usr" "/"
+test_dirname "/usr/bin" "/usr"
+test_dirname "usr/bin" "usr"
Home |
Main Index |
Thread Index |
Old Index