hexdump: tests: take into account byte order

Hexdump test was failling on big endian systems when testing decimal, octal
and hexa outputs as the tests were designed on a little endian system. This
revision adds the two distinct flavors of output expected and determines at
runtime which to compare against.

Submitted by:	Renato Riolino <renato.riolino_eldorado.org.br>
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D23191
This commit is contained in:
Kyle Evans 2020-03-02 18:40:34 +00:00
parent 967c53ac2f
commit 8a9f144c9e
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=358553
20 changed files with 63 additions and 18 deletions

View file

@ -13,20 +13,29 @@ ${PACKAGE}FILES+= d_hexdump_bflag_c.out
${PACKAGE}FILES+= d_hexdump_cflag_a.out
${PACKAGE}FILES+= d_hexdump_cflag_b.out
${PACKAGE}FILES+= d_hexdump_cflag_c.out
${PACKAGE}FILES+= d_hexdump_dflag_a.out
${PACKAGE}FILES+= d_hexdump_dflag_b.out
${PACKAGE}FILES+= d_hexdump_dflag_c.out
${PACKAGE}FILES+= d_hexdump_dflag_a_el.out
${PACKAGE}FILES+= d_hexdump_dflag_b_el.out
${PACKAGE}FILES+= d_hexdump_dflag_c_el.out
${PACKAGE}FILES+= d_hexdump_dflag_a_eb.out
${PACKAGE}FILES+= d_hexdump_dflag_b_eb.out
${PACKAGE}FILES+= d_hexdump_dflag_c_eb.out
${PACKAGE}FILES+= d_hexdump_nflag_a.out
${PACKAGE}FILES+= d_hexdump_oflag_a.out
${PACKAGE}FILES+= d_hexdump_oflag_b.out
${PACKAGE}FILES+= d_hexdump_oflag_c.out
${PACKAGE}FILES+= d_hexdump_oflag_a_el.out
${PACKAGE}FILES+= d_hexdump_oflag_b_el.out
${PACKAGE}FILES+= d_hexdump_oflag_c_el.out
${PACKAGE}FILES+= d_hexdump_oflag_a_eb.out
${PACKAGE}FILES+= d_hexdump_oflag_b_eb.out
${PACKAGE}FILES+= d_hexdump_oflag_c_eb.out
${PACKAGE}FILES+= d_hexdump_sflag_a.out
${PACKAGE}FILES+= d_hexdump_UCflag_a.out
${PACKAGE}FILES+= d_hexdump_UCflag_b.out
${PACKAGE}FILES+= d_hexdump_UCflag_c.out
${PACKAGE}FILES+= d_hexdump_xflag_a.out
${PACKAGE}FILES+= d_hexdump_xflag_b.out
${PACKAGE}FILES+= d_hexdump_xflag_c.out
${PACKAGE}FILES+= d_hexdump_xflag_a_el.out
${PACKAGE}FILES+= d_hexdump_xflag_b_el.out
${PACKAGE}FILES+= d_hexdump_xflag_c_el.out
${PACKAGE}FILES+= d_hexdump_xflag_a_eb.out
${PACKAGE}FILES+= d_hexdump_xflag_b_eb.out
${PACKAGE}FILES+= d_hexdump_xflag_c_eb.out
${PACKAGE}FILES+= d_od_cflag_a.out
${PACKAGE}FILES+= d_od_cflag_b.out

View file

@ -0,0 +1,2 @@
0000000 21605 29556 02560
0000005

View file

@ -0,0 +1,4 @@
0000000 21608 25888 29045 26979 27424 25202 28535 28192
0000010 26223 30752 27253 28016 25956 08303 30309 29216
0000020 29800 25888 25196 30053 08296 28533 29541 02570
0000030

View file

@ -0,0 +1,4 @@
0000000 16705 16705 16705 16705 16705 16705 16705 16705
*
0000020 16705 16705 16705 16650
0000028

View file

@ -0,0 +1,2 @@
0000000 052145 071564 005000
0000005

View file

@ -0,0 +1,4 @@
0000000 052150 062440 070565 064543 065440 061162 067567 067040
0000010 063157 074040 065165 066560 062544 020157 073145 071040
0000020 072150 062440 061154 072545 020150 067565 071545 005012
0000030

View file

@ -0,0 +1,4 @@
0000000 040501 040501 040501 040501 040501 040501 040501 040501
*
0000020 040501 040501 040501 040412
0000028

View file

@ -0,0 +1,2 @@
0000000 5465 7374 0a00
0000005

View file

@ -0,0 +1,4 @@
0000000 5468 6520 7175 6963 6b20 6272 6f77 6e20
0000010 666f 7820 6a75 6d70 6564 206f 7665 7220
0000020 7468 6520 626c 7565 2068 6f75 7365 0a0a
0000030

View file

@ -0,0 +1,4 @@
0000000 4141 4141 4141 4141 4141 4141 4141 4141
*
0000020 4141 4141 4141 410a
0000028

View file

@ -26,6 +26,12 @@
#
# $FreeBSD$
ENDIAN=el
ret=$(echo I | tr -d "[:space:]" | od -to2 | head -n1 | awk '{print $2}' | cut -c6)
if [ "$ret" = "0" ]; then
ENDIAN=eb
fi
atf_test_case b_flag
b_flag_head()
{
@ -93,11 +99,11 @@ d_flag_head()
}
d_flag_body()
{
atf_check -o file:"$(atf_get_srcdir)/d_hexdump_dflag_a.out" \
atf_check -o file:"$(atf_get_srcdir)/d_hexdump_dflag_a_$ENDIAN.out" \
hexdump -d "$(atf_get_srcdir)/d_hexdump_a.in"
atf_check -o file:"$(atf_get_srcdir)/d_hexdump_dflag_b.out" \
atf_check -o file:"$(atf_get_srcdir)/d_hexdump_dflag_b_$ENDIAN.out" \
hexdump -d "$(atf_get_srcdir)/d_hexdump_b.in"
atf_check -o file:"$(atf_get_srcdir)/d_hexdump_dflag_c.out" \
atf_check -o file:"$(atf_get_srcdir)/d_hexdump_dflag_c_$ENDIAN.out" \
hexdump -d "$(atf_get_srcdir)/d_hexdump_c.in"
}
@ -120,11 +126,11 @@ o_flag_head()
}
o_flag_body()
{
atf_check -o file:"$(atf_get_srcdir)/d_hexdump_oflag_a.out" \
atf_check -o file:"$(atf_get_srcdir)/d_hexdump_oflag_a_$ENDIAN.out" \
hexdump -o "$(atf_get_srcdir)/d_hexdump_a.in"
atf_check -o file:"$(atf_get_srcdir)/d_hexdump_oflag_b.out" \
atf_check -o file:"$(atf_get_srcdir)/d_hexdump_oflag_b_$ENDIAN.out" \
hexdump -o "$(atf_get_srcdir)/d_hexdump_b.in"
atf_check -o file:"$(atf_get_srcdir)/d_hexdump_oflag_c.out" \
atf_check -o file:"$(atf_get_srcdir)/d_hexdump_oflag_c_$ENDIAN.out" \
hexdump -o "$(atf_get_srcdir)/d_hexdump_c.in"
}
@ -168,11 +174,11 @@ x_flag_head()
}
x_flag_body()
{
atf_check -o file:"$(atf_get_srcdir)/d_hexdump_xflag_a.out" \
atf_check -o file:"$(atf_get_srcdir)/d_hexdump_xflag_a_$ENDIAN.out" \
hexdump -x "$(atf_get_srcdir)/d_hexdump_a.in"
atf_check -o file:"$(atf_get_srcdir)/d_hexdump_xflag_b.out" \
atf_check -o file:"$(atf_get_srcdir)/d_hexdump_xflag_b_$ENDIAN.out" \
hexdump -x "$(atf_get_srcdir)/d_hexdump_b.in"
atf_check -o file:"$(atf_get_srcdir)/d_hexdump_xflag_c.out" \
atf_check -o file:"$(atf_get_srcdir)/d_hexdump_xflag_c_$ENDIAN.out" \
hexdump -x "$(atf_get_srcdir)/d_hexdump_c.in"
}