From 81cd0cfc2f5de0e30d42564cd579d1dca37c7088 Mon Sep 17 00:00:00 2001 From: kevans Date: Mon, 2 Mar 2020 18:40:34 +0000 Subject: [PATCH] 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 MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D23191 --- usr.bin/hexdump/tests/Makefile | 27 ++++++++++++------- .../hexdump/tests/d_hexdump_dflag_a_eb.out | 2 ++ ...p_dflag_a.out => d_hexdump_dflag_a_el.out} | 0 .../hexdump/tests/d_hexdump_dflag_b_eb.out | 4 +++ ...p_dflag_b.out => d_hexdump_dflag_b_el.out} | 0 .../hexdump/tests/d_hexdump_dflag_c_eb.out | 4 +++ ...p_dflag_c.out => d_hexdump_dflag_c_el.out} | 0 .../hexdump/tests/d_hexdump_oflag_a_eb.out | 2 ++ ...p_oflag_a.out => d_hexdump_oflag_a_el.out} | 0 .../hexdump/tests/d_hexdump_oflag_b_eb.out | 4 +++ ...p_oflag_b.out => d_hexdump_oflag_b_el.out} | 0 .../hexdump/tests/d_hexdump_oflag_c_eb.out | 4 +++ ...p_oflag_c.out => d_hexdump_oflag_c_el.out} | 0 .../hexdump/tests/d_hexdump_xflag_a_eb.out | 2 ++ ...p_xflag_a.out => d_hexdump_xflag_a_el.out} | 0 .../hexdump/tests/d_hexdump_xflag_b_eb.out | 4 +++ ...p_xflag_b.out => d_hexdump_xflag_b_el.out} | 0 .../hexdump/tests/d_hexdump_xflag_c_eb.out | 4 +++ ...p_xflag_c.out => d_hexdump_xflag_c_el.out} | 0 usr.bin/hexdump/tests/hexdump_test.sh | 24 ++++++++++------- 20 files changed, 63 insertions(+), 18 deletions(-) create mode 100644 usr.bin/hexdump/tests/d_hexdump_dflag_a_eb.out rename usr.bin/hexdump/tests/{d_hexdump_dflag_a.out => d_hexdump_dflag_a_el.out} (100%) create mode 100644 usr.bin/hexdump/tests/d_hexdump_dflag_b_eb.out rename usr.bin/hexdump/tests/{d_hexdump_dflag_b.out => d_hexdump_dflag_b_el.out} (100%) create mode 100644 usr.bin/hexdump/tests/d_hexdump_dflag_c_eb.out rename usr.bin/hexdump/tests/{d_hexdump_dflag_c.out => d_hexdump_dflag_c_el.out} (100%) create mode 100644 usr.bin/hexdump/tests/d_hexdump_oflag_a_eb.out rename usr.bin/hexdump/tests/{d_hexdump_oflag_a.out => d_hexdump_oflag_a_el.out} (100%) create mode 100644 usr.bin/hexdump/tests/d_hexdump_oflag_b_eb.out rename usr.bin/hexdump/tests/{d_hexdump_oflag_b.out => d_hexdump_oflag_b_el.out} (100%) create mode 100644 usr.bin/hexdump/tests/d_hexdump_oflag_c_eb.out rename usr.bin/hexdump/tests/{d_hexdump_oflag_c.out => d_hexdump_oflag_c_el.out} (100%) create mode 100644 usr.bin/hexdump/tests/d_hexdump_xflag_a_eb.out rename usr.bin/hexdump/tests/{d_hexdump_xflag_a.out => d_hexdump_xflag_a_el.out} (100%) create mode 100644 usr.bin/hexdump/tests/d_hexdump_xflag_b_eb.out rename usr.bin/hexdump/tests/{d_hexdump_xflag_b.out => d_hexdump_xflag_b_el.out} (100%) create mode 100644 usr.bin/hexdump/tests/d_hexdump_xflag_c_eb.out rename usr.bin/hexdump/tests/{d_hexdump_xflag_c.out => d_hexdump_xflag_c_el.out} (100%) diff --git a/usr.bin/hexdump/tests/Makefile b/usr.bin/hexdump/tests/Makefile index 4c81860d6dc2..54863cb05603 100644 --- a/usr.bin/hexdump/tests/Makefile +++ b/usr.bin/hexdump/tests/Makefile @@ -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 diff --git a/usr.bin/hexdump/tests/d_hexdump_dflag_a_eb.out b/usr.bin/hexdump/tests/d_hexdump_dflag_a_eb.out new file mode 100644 index 000000000000..1d01c608f542 --- /dev/null +++ b/usr.bin/hexdump/tests/d_hexdump_dflag_a_eb.out @@ -0,0 +1,2 @@ +0000000 21605 29556 02560 +0000005 diff --git a/usr.bin/hexdump/tests/d_hexdump_dflag_a.out b/usr.bin/hexdump/tests/d_hexdump_dflag_a_el.out similarity index 100% rename from usr.bin/hexdump/tests/d_hexdump_dflag_a.out rename to usr.bin/hexdump/tests/d_hexdump_dflag_a_el.out diff --git a/usr.bin/hexdump/tests/d_hexdump_dflag_b_eb.out b/usr.bin/hexdump/tests/d_hexdump_dflag_b_eb.out new file mode 100644 index 000000000000..eb09cbcb69ba --- /dev/null +++ b/usr.bin/hexdump/tests/d_hexdump_dflag_b_eb.out @@ -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 diff --git a/usr.bin/hexdump/tests/d_hexdump_dflag_b.out b/usr.bin/hexdump/tests/d_hexdump_dflag_b_el.out similarity index 100% rename from usr.bin/hexdump/tests/d_hexdump_dflag_b.out rename to usr.bin/hexdump/tests/d_hexdump_dflag_b_el.out diff --git a/usr.bin/hexdump/tests/d_hexdump_dflag_c_eb.out b/usr.bin/hexdump/tests/d_hexdump_dflag_c_eb.out new file mode 100644 index 000000000000..75eb88e5da10 --- /dev/null +++ b/usr.bin/hexdump/tests/d_hexdump_dflag_c_eb.out @@ -0,0 +1,4 @@ +0000000 16705 16705 16705 16705 16705 16705 16705 16705 +* +0000020 16705 16705 16705 16650 +0000028 diff --git a/usr.bin/hexdump/tests/d_hexdump_dflag_c.out b/usr.bin/hexdump/tests/d_hexdump_dflag_c_el.out similarity index 100% rename from usr.bin/hexdump/tests/d_hexdump_dflag_c.out rename to usr.bin/hexdump/tests/d_hexdump_dflag_c_el.out diff --git a/usr.bin/hexdump/tests/d_hexdump_oflag_a_eb.out b/usr.bin/hexdump/tests/d_hexdump_oflag_a_eb.out new file mode 100644 index 000000000000..ca410afdb2b9 --- /dev/null +++ b/usr.bin/hexdump/tests/d_hexdump_oflag_a_eb.out @@ -0,0 +1,2 @@ +0000000 052145 071564 005000 +0000005 diff --git a/usr.bin/hexdump/tests/d_hexdump_oflag_a.out b/usr.bin/hexdump/tests/d_hexdump_oflag_a_el.out similarity index 100% rename from usr.bin/hexdump/tests/d_hexdump_oflag_a.out rename to usr.bin/hexdump/tests/d_hexdump_oflag_a_el.out diff --git a/usr.bin/hexdump/tests/d_hexdump_oflag_b_eb.out b/usr.bin/hexdump/tests/d_hexdump_oflag_b_eb.out new file mode 100644 index 000000000000..045db8f65e8b --- /dev/null +++ b/usr.bin/hexdump/tests/d_hexdump_oflag_b_eb.out @@ -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 diff --git a/usr.bin/hexdump/tests/d_hexdump_oflag_b.out b/usr.bin/hexdump/tests/d_hexdump_oflag_b_el.out similarity index 100% rename from usr.bin/hexdump/tests/d_hexdump_oflag_b.out rename to usr.bin/hexdump/tests/d_hexdump_oflag_b_el.out diff --git a/usr.bin/hexdump/tests/d_hexdump_oflag_c_eb.out b/usr.bin/hexdump/tests/d_hexdump_oflag_c_eb.out new file mode 100644 index 000000000000..90347e00a452 --- /dev/null +++ b/usr.bin/hexdump/tests/d_hexdump_oflag_c_eb.out @@ -0,0 +1,4 @@ +0000000 040501 040501 040501 040501 040501 040501 040501 040501 +* +0000020 040501 040501 040501 040412 +0000028 diff --git a/usr.bin/hexdump/tests/d_hexdump_oflag_c.out b/usr.bin/hexdump/tests/d_hexdump_oflag_c_el.out similarity index 100% rename from usr.bin/hexdump/tests/d_hexdump_oflag_c.out rename to usr.bin/hexdump/tests/d_hexdump_oflag_c_el.out diff --git a/usr.bin/hexdump/tests/d_hexdump_xflag_a_eb.out b/usr.bin/hexdump/tests/d_hexdump_xflag_a_eb.out new file mode 100644 index 000000000000..777a09c40a69 --- /dev/null +++ b/usr.bin/hexdump/tests/d_hexdump_xflag_a_eb.out @@ -0,0 +1,2 @@ +0000000 5465 7374 0a00 +0000005 diff --git a/usr.bin/hexdump/tests/d_hexdump_xflag_a.out b/usr.bin/hexdump/tests/d_hexdump_xflag_a_el.out similarity index 100% rename from usr.bin/hexdump/tests/d_hexdump_xflag_a.out rename to usr.bin/hexdump/tests/d_hexdump_xflag_a_el.out diff --git a/usr.bin/hexdump/tests/d_hexdump_xflag_b_eb.out b/usr.bin/hexdump/tests/d_hexdump_xflag_b_eb.out new file mode 100644 index 000000000000..1e7672b7fbb2 --- /dev/null +++ b/usr.bin/hexdump/tests/d_hexdump_xflag_b_eb.out @@ -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 diff --git a/usr.bin/hexdump/tests/d_hexdump_xflag_b.out b/usr.bin/hexdump/tests/d_hexdump_xflag_b_el.out similarity index 100% rename from usr.bin/hexdump/tests/d_hexdump_xflag_b.out rename to usr.bin/hexdump/tests/d_hexdump_xflag_b_el.out diff --git a/usr.bin/hexdump/tests/d_hexdump_xflag_c_eb.out b/usr.bin/hexdump/tests/d_hexdump_xflag_c_eb.out new file mode 100644 index 000000000000..3515e498b977 --- /dev/null +++ b/usr.bin/hexdump/tests/d_hexdump_xflag_c_eb.out @@ -0,0 +1,4 @@ +0000000 4141 4141 4141 4141 4141 4141 4141 4141 +* +0000020 4141 4141 4141 410a +0000028 diff --git a/usr.bin/hexdump/tests/d_hexdump_xflag_c.out b/usr.bin/hexdump/tests/d_hexdump_xflag_c_el.out similarity index 100% rename from usr.bin/hexdump/tests/d_hexdump_xflag_c.out rename to usr.bin/hexdump/tests/d_hexdump_xflag_c_el.out diff --git a/usr.bin/hexdump/tests/hexdump_test.sh b/usr.bin/hexdump/tests/hexdump_test.sh index 0a9ac6c6bda4..f51112214717 100755 --- a/usr.bin/hexdump/tests/hexdump_test.sh +++ b/usr.bin/hexdump/tests/hexdump_test.sh @@ -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" }