lobase

Linux port of OpenBSDs userland.
Log | Files | Refs | README

commit d818f81ea8fcd9f59b111d25ad64e876a4157e68
parent 8ed1fc52aa5d0d346ca43e032b305a2c8bc7c0d2
Author: Duncaen <mail@duncano.de>
Date:   Tue,  7 Mar 2017 18:01:14 +0100

regress: import usr.bin/basename

Diffstat:
regress/usr.bin/Makefile | 4++--
regress/usr.bin/basename/Makefile | 7+++++++
regress/usr.bin/basename/basename.sh | 42++++++++++++++++++++++++++++++++++++++++++
3 files changed, 51 insertions(+), 2 deletions(-)

diff --git 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 @@ -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 @@ -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"