xref: /freebsd/bin/echo/tests/echo_test.sh (revision 2d15c3cb124d9a5e9f2eff61a8022ab232efc447)
1*2d15c3cbSEnji Cooper#
2*2d15c3cbSEnji Cooper# Copyright 2017 Shivansh Rai
3*2d15c3cbSEnji Cooper# All rights reserved.
4*2d15c3cbSEnji Cooper#
5*2d15c3cbSEnji Cooper# Redistribution and use in source and binary forms, with or without
6*2d15c3cbSEnji Cooper# modification, are permitted provided that the following conditions
7*2d15c3cbSEnji Cooper# are met:
8*2d15c3cbSEnji Cooper# 1. Redistributions of source code must retain the above copyright
9*2d15c3cbSEnji Cooper#    notice, this list of conditions and the following disclaimer.
10*2d15c3cbSEnji Cooper# 2. Redistributions in binary form must reproduce the above copyright
11*2d15c3cbSEnji Cooper#    notice, this list of conditions and the following disclaimer in the
12*2d15c3cbSEnji Cooper#    documentation and/or other materials provided with the distribution.
13*2d15c3cbSEnji Cooper#
14*2d15c3cbSEnji Cooper# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15*2d15c3cbSEnji Cooper# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16*2d15c3cbSEnji Cooper# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17*2d15c3cbSEnji Cooper# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18*2d15c3cbSEnji Cooper# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19*2d15c3cbSEnji Cooper# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20*2d15c3cbSEnji Cooper# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21*2d15c3cbSEnji Cooper# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22*2d15c3cbSEnji Cooper# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23*2d15c3cbSEnji Cooper# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24*2d15c3cbSEnji Cooper# SUCH DAMAGE.
25*2d15c3cbSEnji Cooper#
26*2d15c3cbSEnji Cooper# $FreeBSD$
27*2d15c3cbSEnji Cooper#
28*2d15c3cbSEnji Cooper
29*2d15c3cbSEnji Cooperatf_test_case n_output
30*2d15c3cbSEnji Coopern_output_head() {
31*2d15c3cbSEnji Cooper        atf_set "descr" "Verify that echo(1) does not print the trailing " \
32*2d15c3cbSEnji Cooper                "newline character with option '-n'"
33*2d15c3cbSEnji Cooper}
34*2d15c3cbSEnji Cooper
35*2d15c3cbSEnji Coopern_output_body() {
36*2d15c3cbSEnji Cooper        atf_check -s ignore -o inline:"Hello world" \
37*2d15c3cbSEnji Cooper                /bin/echo -n "Hello world"
38*2d15c3cbSEnji Cooper}
39*2d15c3cbSEnji Cooper
40*2d15c3cbSEnji Cooperatf_test_case append_c_output
41*2d15c3cbSEnji Cooperappend_c_output_head() {
42*2d15c3cbSEnji Cooper        atf_set "descr" "Verify that echo(1) does not print the trailing newline " \
43*2d15c3cbSEnji Cooper                "character when '\c' is appended to the end of the string"
44*2d15c3cbSEnji Cooper}
45*2d15c3cbSEnji Cooper
46*2d15c3cbSEnji Cooperappend_c_output_body() {
47*2d15c3cbSEnji Cooper        atf_check -s ignore -o inline:"Hello world" \
48*2d15c3cbSEnji Cooper                /bin/echo "Hello world\c"
49*2d15c3cbSEnji Cooper}
50*2d15c3cbSEnji Cooper
51*2d15c3cbSEnji Cooperatf_init_test_cases()
52*2d15c3cbSEnji Cooper{
53*2d15c3cbSEnji Cooper        atf_add_test_case n_output
54*2d15c3cbSEnji Cooper        atf_add_test_case append_c_output
55*2d15c3cbSEnji Cooper}
56