aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/cmp/tests/cmp_test2.sh
diff options
context:
space:
mode:
authorKyle Evans <kevans@FreeBSD.org>2021-09-23 05:26:52 +0000
committerKyle Evans <kevans@FreeBSD.org>2021-09-29 18:03:34 +0000
commit4e380e8474609875c4cf5277b3755ac29079a8b5 (patch)
treee59459a8471e686af8dfb74c1367a7cd027f77c1 /usr.bin/cmp/tests/cmp_test2.sh
parentf6787614fd4db2a9d5e649af0e819852ebd5a19d (diff)
cmp: add -n, --bytes to limit number of bytes to compare
This is compatible with GNU cmp. Reviewed by: markj Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D32072
Diffstat (limited to 'usr.bin/cmp/tests/cmp_test2.sh')
-rwxr-xr-xusr.bin/cmp/tests/cmp_test2.sh23
1 files changed, 23 insertions, 0 deletions
diff --git a/usr.bin/cmp/tests/cmp_test2.sh b/usr.bin/cmp/tests/cmp_test2.sh
index 334e9f357730..c513984daf8b 100755
--- a/usr.bin/cmp/tests/cmp_test2.sh
+++ b/usr.bin/cmp/tests/cmp_test2.sh
@@ -91,10 +91,33 @@ skipsuff_body()
atf_check -s exit:0 cmp -s a b 1k 1k
}
+atf_test_case limit
+limit_head()
+{
+ atf_set "descr" "Test cmp(1) -n (limit)"
+}
+limit_body()
+{
+ echo -n "aaaabbbb" > a
+ echo -n "aaaaxxxx" > b
+
+ atf_check -s exit:1 -o ignore cmp -s a b
+ atf_check -s exit:0 cmp -sn 4 a b
+ atf_check -s exit:0 cmp -sn 3 a b
+ atf_check -s exit:1 -o ignore cmp -sn 5 a b
+
+ # Test special, too. The implementation for link is effectively
+ # identical.
+ atf_check -s exit:0 -e empty -x "cat a | cmp -sn 4 b -"
+ atf_check -s exit:0 -e empty -x "cat a | cmp -sn 3 b -"
+ atf_check -s exit:1 -o ignore -x "cat a | cmp -sn 5 b -"
+}
+
atf_init_test_cases()
{
atf_add_test_case special
atf_add_test_case symlink
atf_add_test_case pr252542
atf_add_test_case skipsuff
+ atf_add_test_case limit
}