git: 270492602b9b - main - diff: Add test case for pagination resource leak

From: Dag-Erling Smørgrav <des_at_FreeBSD.org>
Date: Thu, 05 Feb 2026 14:45:47 UTC
The branch main has been updated by des:

URL: https://cgit.FreeBSD.org/src/commit/?id=270492602b9bd8b8fce4f021f055804978bf3f23

commit 270492602b9bd8b8fce4f021f055804978bf3f23
Author:     Dag-Erling Smørgrav <des@FreeBSD.org>
AuthorDate: 2026-02-05 14:39:47 +0000
Commit:     Dag-Erling Smørgrav <des@FreeBSD.org>
CommitDate: 2026-02-05 14:39:47 +0000

    diff: Add test case for pagination resource leak
    
    The pagination code leaks either processes or descriptors or both,
    depending on the exact version of the code you have.  Add a test case
    which exercises this leak to facilitate fixing it.
    
    MFC after:      1 week
    Sponsored by:   Klara, Inc.
    Reviewed by:    thj, kevans
    Differential Revision:  https://reviews.freebsd.org/D55111
---
 usr.bin/diff/tests/diff_test.sh | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/usr.bin/diff/tests/diff_test.sh b/usr.bin/diff/tests/diff_test.sh
index 89348d3a8b16..a3f76602cf37 100755
--- a/usr.bin/diff/tests/diff_test.sh
+++ b/usr.bin/diff/tests/diff_test.sh
@@ -411,6 +411,27 @@ bigu_body()
 	    diff -Astone -U$(((1<<31)-2)) a b
 }
 
+prleak_head()
+{
+	atf_set "descr" "Verify that pagination does not leak resources"
+}
+prleak_body()
+{
+	local n=32
+	mkdir a b
+	for hi in $(jot -w%02x $n 0) ; do
+		mkdir a/$hi b/$hi
+		for lo in $(jot -w%02x $n 0) ; do
+			echo "$hi$lo" >a/$hi/$lo
+			echo "$hi$lo" >b/$hi/$lo
+		done
+	done
+	ulimit -n 1000
+	ulimit -u 1000
+	atf_check diff -rul a b
+	atf_check diff -Astone -rul a b
+}
+
 atf_init_test_cases()
 {
 	atf_add_test_case simple
@@ -440,4 +461,5 @@ atf_init_test_cases()
 	atf_add_test_case dirloop
 	atf_add_test_case bigc
 	atf_add_test_case bigu
+	atf_add_test_case prleak
 }