aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/diff/tests
diff options
context:
space:
mode:
authorPiotr Pawel Stefaniak <pstef@FreeBSD.org>2021-08-22 19:57:13 +0000
committerPiotr Pawel Stefaniak <pstef@FreeBSD.org>2021-08-23 14:09:05 +0000
commit3cbf98e2bee91db9ed9118ff557e02cdd449f49a (patch)
treed5b1ded69f97342f7a9441c28f48eeb212d65b1b /usr.bin/diff/tests
parentbc5304a006238115291e7568583632889dffbab9 (diff)
Diffstat (limited to 'usr.bin/diff/tests')
-rwxr-xr-xusr.bin/diff/tests/diff_test.sh14
1 files changed, 14 insertions, 0 deletions
diff --git a/usr.bin/diff/tests/diff_test.sh b/usr.bin/diff/tests/diff_test.sh
index b8b7fe1d8068..4f73b23d686a 100755
--- a/usr.bin/diff/tests/diff_test.sh
+++ b/usr.bin/diff/tests/diff_test.sh
@@ -18,6 +18,7 @@ atf_test_case conflicting_format
atf_test_case label
atf_test_case report_identical
atf_test_case non_regular_file
+atf_test_case binary
simple_body()
{
@@ -265,6 +266,18 @@ non_regular_file_body()
diff --label A --label B -u A B
}
+binary_body()
+{
+ # the NUL byte has to be after at least BUFSIZ bytes to trick asciifile()
+ yes 012345678901234567890123456789012345678901234567890 | head -n 174 > A
+ cp A B
+ printf '\n\0\n' >> A
+ printf '\nx\n' >> B
+
+ atf_check -o inline:"Binary files A and B differ\n" -s exit:1 diff A B
+ atf_check -o inline:"176c\nx\n.\n" -s exit:1 diff -ae A B
+}
+
atf_init_test_cases()
{
atf_add_test_case simple
@@ -285,4 +298,5 @@ atf_init_test_cases()
atf_add_test_case label
atf_add_test_case report_identical
atf_add_test_case non_regular_file
+ atf_add_test_case binary
}