xref: /freebsd/bin/echo/tests/echo_test.sh (revision d0b2dbfa0ecf2bbc9709efc5e20baf8e4b44bbbf)
12d15c3cbSEnji Cooper#
22d15c3cbSEnji Cooper# Copyright 2017 Shivansh Rai
32d15c3cbSEnji Cooper# All rights reserved.
42d15c3cbSEnji Cooper#
52d15c3cbSEnji Cooper# Redistribution and use in source and binary forms, with or without
62d15c3cbSEnji Cooper# modification, are permitted provided that the following conditions
72d15c3cbSEnji Cooper# are met:
82d15c3cbSEnji Cooper# 1. Redistributions of source code must retain the above copyright
92d15c3cbSEnji Cooper#    notice, this list of conditions and the following disclaimer.
102d15c3cbSEnji Cooper# 2. Redistributions in binary form must reproduce the above copyright
112d15c3cbSEnji Cooper#    notice, this list of conditions and the following disclaimer in the
122d15c3cbSEnji Cooper#    documentation and/or other materials provided with the distribution.
132d15c3cbSEnji Cooper#
142d15c3cbSEnji Cooper# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
152d15c3cbSEnji Cooper# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
162d15c3cbSEnji Cooper# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
172d15c3cbSEnji Cooper# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
182d15c3cbSEnji Cooper# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
192d15c3cbSEnji Cooper# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
202d15c3cbSEnji Cooper# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
212d15c3cbSEnji Cooper# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
222d15c3cbSEnji Cooper# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
232d15c3cbSEnji Cooper# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
242d15c3cbSEnji Cooper# SUCH DAMAGE.
252d15c3cbSEnji Cooper#
262d15c3cbSEnji Cooper#
272d15c3cbSEnji Cooper
282d15c3cbSEnji Cooperatf_test_case n_output
29*f01753c1SAlan Somersn_output_head()
30*f01753c1SAlan Somers{
312d15c3cbSEnji Cooper	atf_set "descr" "Verify that echo(1) does not print the trailing " \
322d15c3cbSEnji Cooper			"newline character with option '-n'"
332d15c3cbSEnji Cooper}
342d15c3cbSEnji Cooper
35*f01753c1SAlan Somersn_output_body()
36*f01753c1SAlan Somers{
372d15c3cbSEnji Cooper	atf_check -s ignore -o inline:"Hello world" \
382d15c3cbSEnji Cooper		/bin/echo -n "Hello world"
392d15c3cbSEnji Cooper}
402d15c3cbSEnji Cooper
412d15c3cbSEnji Cooperatf_test_case append_c_output
42*f01753c1SAlan Somersappend_c_output_head()
43*f01753c1SAlan Somers{
442d15c3cbSEnji Cooper	atf_set "descr" "Verify that echo(1) does not print the trailing newline " \
452d15c3cbSEnji Cooper			"character when '\c' is appended to the end of the string"
462d15c3cbSEnji Cooper}
472d15c3cbSEnji Cooper
48*f01753c1SAlan Somersappend_c_output_body()
49*f01753c1SAlan Somers{
502d15c3cbSEnji Cooper	atf_check -s ignore -o inline:"Hello world" \
512d15c3cbSEnji Cooper		/bin/echo "Hello world\c"
522d15c3cbSEnji Cooper}
532d15c3cbSEnji Cooper
542d15c3cbSEnji Cooperatf_init_test_cases()
552d15c3cbSEnji Cooper{
562d15c3cbSEnji Cooper	atf_add_test_case n_output
572d15c3cbSEnji Cooper	atf_add_test_case append_c_output
582d15c3cbSEnji Cooper}
59