1b5ddde39SKyle Evans# 2*f0fb94abSKyle Evans# SPDX-License-Identifier: BSD-2-Clause-FreeBSD 3*f0fb94abSKyle Evans# 4b5ddde39SKyle Evans# Copyright (c) 2017 Kyle Evans <kevans@FreeBSD.org> 5b5ddde39SKyle Evans# 6b5ddde39SKyle Evans# Redistribution and use in source and binary forms, with or without 7b5ddde39SKyle Evans# modification, are permitted provided that the following conditions 8b5ddde39SKyle Evans# are met: 9b5ddde39SKyle Evans# 1. Redistributions of source code must retain the above copyright 10b5ddde39SKyle Evans# notice, this list of conditions and the following disclaimer. 11b5ddde39SKyle Evans# 2. Redistributions in binary form must reproduce the above copyright 12b5ddde39SKyle Evans# notice, this list of conditions and the following disclaimer in the 13b5ddde39SKyle Evans# documentation and/or other materials provided with the distribution. 14b5ddde39SKyle Evans# 15b5ddde39SKyle Evans# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16b5ddde39SKyle Evans# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17b5ddde39SKyle Evans# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18b5ddde39SKyle Evans# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19b5ddde39SKyle Evans# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20b5ddde39SKyle Evans# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21b5ddde39SKyle Evans# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22b5ddde39SKyle Evans# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23b5ddde39SKyle Evans# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24b5ddde39SKyle Evans# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25b5ddde39SKyle Evans# SUCH DAMAGE. 26b5ddde39SKyle Evans# 27b5ddde39SKyle Evans# $FreeBSD$ 28b5ddde39SKyle Evans 29b5ddde39SKyle Evansatf_test_case b_flag 30b5ddde39SKyle Evansb_flag_head() 31b5ddde39SKyle Evans{ 32b5ddde39SKyle Evans atf_set "descr" "Verify -b output" 33b5ddde39SKyle Evans} 34b5ddde39SKyle Evansb_flag_body() 35b5ddde39SKyle Evans{ 36b5ddde39SKyle Evans atf_check -o file:"$(atf_get_srcdir)/d_hexdump_bflag_a.out" \ 37b5ddde39SKyle Evans hexdump -b "$(atf_get_srcdir)/d_hexdump_a.in" 38b5ddde39SKyle Evans atf_check -o file:"$(atf_get_srcdir)/d_hexdump_bflag_b.out" \ 39b5ddde39SKyle Evans hexdump -b "$(atf_get_srcdir)/d_hexdump_b.in" 40b5ddde39SKyle Evans atf_check -o file:"$(atf_get_srcdir)/d_hexdump_bflag_c.out" \ 41b5ddde39SKyle Evans hexdump -b "$(atf_get_srcdir)/d_hexdump_c.in" 42b5ddde39SKyle Evans} 43b5ddde39SKyle Evans 44b5ddde39SKyle Evansatf_test_case c_flag 45b5ddde39SKyle Evansc_flag_head() 46b5ddde39SKyle Evans{ 47b5ddde39SKyle Evans atf_set "descr" "Verify -c output" 48b5ddde39SKyle Evans} 49b5ddde39SKyle Evansc_flag_body() 50b5ddde39SKyle Evans{ 51b5ddde39SKyle Evans atf_check -o file:"$(atf_get_srcdir)/d_hexdump_cflag_a.out" \ 52b5ddde39SKyle Evans hexdump -c "$(atf_get_srcdir)/d_hexdump_a.in" 53b5ddde39SKyle Evans atf_check -o file:"$(atf_get_srcdir)/d_hexdump_cflag_b.out" \ 54b5ddde39SKyle Evans hexdump -c "$(atf_get_srcdir)/d_hexdump_b.in" 55b5ddde39SKyle Evans atf_check -o file:"$(atf_get_srcdir)/d_hexdump_cflag_c.out" \ 56b5ddde39SKyle Evans hexdump -c "$(atf_get_srcdir)/d_hexdump_c.in" 57b5ddde39SKyle Evans} 58b5ddde39SKyle Evans 59b5ddde39SKyle Evansatf_test_case C_flag 60b5ddde39SKyle EvansC_flag_head() 61b5ddde39SKyle Evans{ 62b5ddde39SKyle Evans atf_set "descr" "Verify -C output" 63b5ddde39SKyle Evans} 64b5ddde39SKyle EvansC_flag_body() 65b5ddde39SKyle Evans{ 66b5ddde39SKyle Evans atf_check -o file:"$(atf_get_srcdir)/d_hexdump_UCflag_a.out" \ 67b5ddde39SKyle Evans hexdump -C "$(atf_get_srcdir)/d_hexdump_a.in" 68b5ddde39SKyle Evans atf_check -o file:"$(atf_get_srcdir)/d_hexdump_UCflag_b.out" \ 69b5ddde39SKyle Evans hexdump -C "$(atf_get_srcdir)/d_hexdump_b.in" 70b5ddde39SKyle Evans atf_check -o file:"$(atf_get_srcdir)/d_hexdump_UCflag_c.out" \ 71b5ddde39SKyle Evans hexdump -C "$(atf_get_srcdir)/d_hexdump_c.in" 72b5ddde39SKyle Evans} 73b5ddde39SKyle Evans 74b5ddde39SKyle Evansatf_test_case hd_name 75b5ddde39SKyle Evanshd_name_head() 76b5ddde39SKyle Evans{ 77b5ddde39SKyle Evans atf_set "descr" "Verify hd output matching -C output" 78b5ddde39SKyle Evans} 79b5ddde39SKyle Evanshd_name_body() 80b5ddde39SKyle Evans{ 81b5ddde39SKyle Evans atf_check -o file:"$(atf_get_srcdir)/d_hexdump_UCflag_a.out" \ 82b5ddde39SKyle Evans hd "$(atf_get_srcdir)/d_hexdump_a.in" 83b5ddde39SKyle Evans atf_check -o file:"$(atf_get_srcdir)/d_hexdump_UCflag_b.out" \ 84b5ddde39SKyle Evans hd "$(atf_get_srcdir)/d_hexdump_b.in" 85b5ddde39SKyle Evans atf_check -o file:"$(atf_get_srcdir)/d_hexdump_UCflag_c.out" \ 86b5ddde39SKyle Evans hd "$(atf_get_srcdir)/d_hexdump_c.in" 87b5ddde39SKyle Evans} 88b5ddde39SKyle Evans 89b5ddde39SKyle Evansatf_test_case d_flag 90b5ddde39SKyle Evansd_flag_head() 91b5ddde39SKyle Evans{ 92b5ddde39SKyle Evans atf_set "descr" "Verify -d output" 93b5ddde39SKyle Evans} 94b5ddde39SKyle Evansd_flag_body() 95b5ddde39SKyle Evans{ 96b5ddde39SKyle Evans atf_check -o file:"$(atf_get_srcdir)/d_hexdump_dflag_a.out" \ 97b5ddde39SKyle Evans hexdump -d "$(atf_get_srcdir)/d_hexdump_a.in" 98b5ddde39SKyle Evans atf_check -o file:"$(atf_get_srcdir)/d_hexdump_dflag_b.out" \ 99b5ddde39SKyle Evans hexdump -d "$(atf_get_srcdir)/d_hexdump_b.in" 100b5ddde39SKyle Evans atf_check -o file:"$(atf_get_srcdir)/d_hexdump_dflag_c.out" \ 101b5ddde39SKyle Evans hexdump -d "$(atf_get_srcdir)/d_hexdump_c.in" 102b5ddde39SKyle Evans} 103b5ddde39SKyle Evans 104b5ddde39SKyle Evansatf_test_case n_flag 105b5ddde39SKyle Evansn_flag_head() 106b5ddde39SKyle Evans{ 107b5ddde39SKyle Evans atf_set "descr" "Check -n functionality" 108b5ddde39SKyle Evans} 109b5ddde39SKyle Evansn_flag_body() 110b5ddde39SKyle Evans{ 111b5ddde39SKyle Evans atf_check -o empty hexdump -bn 0 "$(atf_get_srcdir)/d_hexdump_a.in" 112b5ddde39SKyle Evans atf_check -o file:"$(atf_get_srcdir)/d_hexdump_nflag_a.out" \ 113b5ddde39SKyle Evans hexdump -bn 1 "$(atf_get_srcdir)/d_hexdump_a.in" 114b5ddde39SKyle Evans} 115b5ddde39SKyle Evans 116b5ddde39SKyle Evansatf_test_case o_flag 117b5ddde39SKyle Evanso_flag_head() 118b5ddde39SKyle Evans{ 119b5ddde39SKyle Evans atf_set "descr" "Verify -o output" 120b5ddde39SKyle Evans} 121b5ddde39SKyle Evanso_flag_body() 122b5ddde39SKyle Evans{ 123b5ddde39SKyle Evans atf_check -o file:"$(atf_get_srcdir)/d_hexdump_oflag_a.out" \ 124b5ddde39SKyle Evans hexdump -o "$(atf_get_srcdir)/d_hexdump_a.in" 125b5ddde39SKyle Evans atf_check -o file:"$(atf_get_srcdir)/d_hexdump_oflag_b.out" \ 126b5ddde39SKyle Evans hexdump -o "$(atf_get_srcdir)/d_hexdump_b.in" 127b5ddde39SKyle Evans atf_check -o file:"$(atf_get_srcdir)/d_hexdump_oflag_c.out" \ 128b5ddde39SKyle Evans hexdump -o "$(atf_get_srcdir)/d_hexdump_c.in" 129b5ddde39SKyle Evans} 130b5ddde39SKyle Evans 131b5ddde39SKyle Evansatf_test_case s_flag 132b5ddde39SKyle Evanss_flag_head() 133b5ddde39SKyle Evans{ 134b5ddde39SKyle Evans atf_set "descr" "Verify -s output" 135b5ddde39SKyle Evans} 136b5ddde39SKyle Evanss_flag_body() 137b5ddde39SKyle Evans{ 138b5ddde39SKyle Evans atf_check -o file:"$(atf_get_srcdir)/d_hexdump_sflag_a.out" \ 139b5ddde39SKyle Evans hexdump -bs 4 "$(atf_get_srcdir)/d_hexdump_a.in" 140b5ddde39SKyle Evans 141b5ddde39SKyle Evans atf_check -o not-empty hexdump -n 100 -s 1024 /dev/random 142b5ddde39SKyle Evans} 143b5ddde39SKyle Evans 144b5ddde39SKyle Evansatf_test_case v_flag 145b5ddde39SKyle Evansv_flag_head() 146b5ddde39SKyle Evans{ 147b5ddde39SKyle Evans atf_set "descr" "Verify -v functionality" 148b5ddde39SKyle Evans} 149b5ddde39SKyle Evansv_flag_body() 150b5ddde39SKyle Evans{ 151b5ddde39SKyle Evans for i in $(seq 0 7); do 152b5ddde39SKyle Evans atf_check -o match:"^\*$" \ 153b5ddde39SKyle Evans hexdump -s ${i} "$(atf_get_srcdir)/d_hexdump_c.in" 154b5ddde39SKyle Evans atf_check -o not-match:"^\*$" \ 155b5ddde39SKyle Evans hexdump -vs ${i} "$(atf_get_srcdir)/d_hexdump_c.in" 156b5ddde39SKyle Evans done 157b5ddde39SKyle Evans 158b5ddde39SKyle Evans atf_check -o not-match:"^\*$" \ 159b5ddde39SKyle Evans hexdump -s 8 "$(atf_get_srcdir)/d_hexdump_c.in" 160b5ddde39SKyle Evans atf_check -o not-match:"^\*$" \ 161b5ddde39SKyle Evans hexdump -vs 8 "$(atf_get_srcdir)/d_hexdump_c.in" 162b5ddde39SKyle Evans} 163b5ddde39SKyle Evans 164b5ddde39SKyle Evansatf_test_case x_flag 165b5ddde39SKyle Evansx_flag_head() 166b5ddde39SKyle Evans{ 167b5ddde39SKyle Evans atf_set "descr" "Verify -x output" 168b5ddde39SKyle Evans} 169b5ddde39SKyle Evansx_flag_body() 170b5ddde39SKyle Evans{ 171b5ddde39SKyle Evans atf_check -o file:"$(atf_get_srcdir)/d_hexdump_xflag_a.out" \ 172b5ddde39SKyle Evans hexdump -x "$(atf_get_srcdir)/d_hexdump_a.in" 173b5ddde39SKyle Evans atf_check -o file:"$(atf_get_srcdir)/d_hexdump_xflag_b.out" \ 174b5ddde39SKyle Evans hexdump -x "$(atf_get_srcdir)/d_hexdump_b.in" 175b5ddde39SKyle Evans atf_check -o file:"$(atf_get_srcdir)/d_hexdump_xflag_c.out" \ 176b5ddde39SKyle Evans hexdump -x "$(atf_get_srcdir)/d_hexdump_c.in" 177b5ddde39SKyle Evans} 178b5ddde39SKyle Evans 179b5ddde39SKyle Evansatf_init_test_cases() 180b5ddde39SKyle Evans{ 181b5ddde39SKyle Evans atf_add_test_case b_flag 182b5ddde39SKyle Evans atf_add_test_case c_flag 183b5ddde39SKyle Evans atf_add_test_case C_flag 184b5ddde39SKyle Evans atf_add_test_case hd_name 185b5ddde39SKyle Evans atf_add_test_case d_flag 186b5ddde39SKyle Evans atf_add_test_case n_flag 187b5ddde39SKyle Evans atf_add_test_case o_flag 188b5ddde39SKyle Evans atf_add_test_case s_flag 189b5ddde39SKyle Evans atf_add_test_case v_flag 190b5ddde39SKyle Evans atf_add_test_case x_flag 191b5ddde39SKyle Evans} 192