xref: /freebsd/bin/echo/tests/echo_test.sh (revision f01753c151b6c3c81a83c7039e3d3f9b70f067ed)
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# $FreeBSD$
272d15c3cbSEnji Cooper#
282d15c3cbSEnji Cooper
292d15c3cbSEnji Cooperatf_test_case n_output
30*f01753c1SAlan Somersn_output_head()
31*f01753c1SAlan Somers{
322d15c3cbSEnji Cooper	atf_set "descr" "Verify that echo(1) does not print the trailing " \
332d15c3cbSEnji Cooper			"newline character with option '-n'"
342d15c3cbSEnji Cooper}
352d15c3cbSEnji Cooper
36*f01753c1SAlan Somersn_output_body()
37*f01753c1SAlan Somers{
382d15c3cbSEnji Cooper	atf_check -s ignore -o inline:"Hello world" \
392d15c3cbSEnji Cooper		/bin/echo -n "Hello world"
402d15c3cbSEnji Cooper}
412d15c3cbSEnji Cooper
422d15c3cbSEnji Cooperatf_test_case append_c_output
43*f01753c1SAlan Somersappend_c_output_head()
44*f01753c1SAlan Somers{
452d15c3cbSEnji Cooper	atf_set "descr" "Verify that echo(1) does not print the trailing newline " \
462d15c3cbSEnji Cooper			"character when '\c' is appended to the end of the string"
472d15c3cbSEnji Cooper}
482d15c3cbSEnji Cooper
49*f01753c1SAlan Somersappend_c_output_body()
50*f01753c1SAlan Somers{
512d15c3cbSEnji Cooper	atf_check -s ignore -o inline:"Hello world" \
522d15c3cbSEnji Cooper		/bin/echo "Hello world\c"
532d15c3cbSEnji Cooper}
542d15c3cbSEnji Cooper
552d15c3cbSEnji Cooperatf_init_test_cases()
562d15c3cbSEnji Cooper{
572d15c3cbSEnji Cooper	atf_add_test_case n_output
582d15c3cbSEnji Cooper	atf_add_test_case append_c_output
592d15c3cbSEnji Cooper}
60