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