xref: /netbsd-src/tests/usr.bin/basename/t_basename.sh (revision 28604916d4405d94c855cf455ac3ac6fee06a908)
1*28604916Sjruoho# $NetBSD: t_basename.sh,v 1.1 2012/03/17 16:33:12 jruoho Exp $
2*28604916Sjruoho#
3*28604916Sjruoho# Copyright (c) 2008 The NetBSD Foundation, Inc.
4*28604916Sjruoho# All rights reserved.
5*28604916Sjruoho#
6*28604916Sjruoho# Redistribution and use in source and binary forms, with or without
7*28604916Sjruoho# modification, are permitted provided that the following conditions
8*28604916Sjruoho# are met:
9*28604916Sjruoho# 1. Redistributions of source code must retain the above copyright
10*28604916Sjruoho#    notice, this list of conditions and the following disclaimer.
11*28604916Sjruoho# 2. Redistributions in binary form must reproduce the above copyright
12*28604916Sjruoho#    notice, this list of conditions and the following disclaimer in the
13*28604916Sjruoho#    documentation and/or other materials provided with the distribution.
14*28604916Sjruoho#
15*28604916Sjruoho# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
16*28604916Sjruoho# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17*28604916Sjruoho# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18*28604916Sjruoho# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
19*28604916Sjruoho# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20*28604916Sjruoho# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21*28604916Sjruoho# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22*28604916Sjruoho# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23*28604916Sjruoho# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24*28604916Sjruoho# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25*28604916Sjruoho# POSSIBILITY OF SUCH DAMAGE.
26*28604916Sjruoho#
27*28604916Sjruoho
28*28604916Sjruohoatf_test_case basic
29*28604916Sjruohobasic_head()
30*28604916Sjruoho{
31*28604916Sjruoho	atf_set "descr" "Checks basic functionality"
32*28604916Sjruoho}
33*28604916Sjruohobasic_body()
34*28604916Sjruoho{
35*28604916Sjruoho	atf_check -o inline:"bin\n" basename /usr/bin
36*28604916Sjruoho	atf_check -o inline:"usr\n" basename /usr
37*28604916Sjruoho	atf_check -o inline:"/\n" basename /
38*28604916Sjruoho	atf_check -o inline:"/\n" basename ///
39*28604916Sjruoho	atf_check -o inline:"usr\n" basename /usr//
40*28604916Sjruoho	atf_check -o inline:"bin\n" basename //usr//bin
41*28604916Sjruoho	atf_check -o inline:"usr\n" basename usr
42*28604916Sjruoho	atf_check -o inline:"bin\n" basename usr/bin
43*28604916Sjruoho}
44*28604916Sjruoho
45*28604916Sjruohoatf_test_case suffix
46*28604916Sjruohosuffix_head()
47*28604916Sjruoho{
48*28604916Sjruoho	atf_set "descr" "Checks removing of provided suffix"
49*28604916Sjruoho}
50*28604916Sjruohosuffix_body()
51*28604916Sjruoho{
52*28604916Sjruoho	atf_check -o inline:"bi\n" basename /usr/bin n
53*28604916Sjruoho	atf_check -o inline:"bin\n" basename /usr/bin bin
54*28604916Sjruoho	atf_check -o inline:"/\n" basename / /
55*28604916Sjruoho	atf_check -o inline:"g\n" basename /usr/bin/gcc cc
56*28604916Sjruoho}
57*28604916Sjruoho
58*28604916Sjruohoatf_init_test_cases()
59*28604916Sjruoho{
60*28604916Sjruoho	atf_add_test_case basic
61*28604916Sjruoho	atf_add_test_case suffix
62*28604916Sjruoho}
63