git: fa6a02f50e65 - main - tests/fdgrowtable: open more files in the threaded case

From: Gleb Smirnoff <glebius_at_FreeBSD.org>
Date: Tue, 20 Feb 2024 22:31:21 UTC
The branch main has been updated by glebius:

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

commit fa6a02f50e65c47540f51b3177f5080bc6af168e
Author:     Gleb Smirnoff <glebius@FreeBSD.org>
AuthorDate: 2024-02-20 22:31:06 +0000
Commit:     Gleb Smirnoff <glebius@FreeBSD.org>
CommitDate: 2024-02-20 22:31:06 +0000

    tests/fdgrowtable: open more files in the threaded case
    
    This should fix the test failing on some machines/conditions/runs.  This
    won't fix failures in standalone run, but should fix kyua(1) runs.
    Currently with standalone run it will usually fail because the 40-sized
    allocation is skipped (see details below).
    
    This matches what forking test does: open 128 files in the parent and 128
    in the child.  There should actually be no difference where and when the
    files are open, but let's mimic the forking test, and open more files in
    the spawned thread.  Also opening from two different contexts adds a bit
    more entropy to the test.
    
    What the test does it checks that fdgrowtable() has been called at least
    three tmes for the test process, and the old tables are still on the free
    list as long as other execution contexts exist.  Under kyua(1) control the
    first call grows the table from 20 to 40, but the original table of 20 is
    an embedded one, thus is not put on the free list.  Passing 40 open files
    the table grows to 128 and first old table lands on the free list. Passing
    128 open file the table grows to 256 and a second old table lands on the
    free list.  After that the test would pass.  The threaded test was one
    open file off before this fix sometimes.
---
 tests/sys/kern/fdgrowtable_test.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tests/sys/kern/fdgrowtable_test.c b/tests/sys/kern/fdgrowtable_test.c
index 75c3d6701c0c..6ea42bd076ad 100644
--- a/tests/sys/kern/fdgrowtable_test.c
+++ b/tests/sys/kern/fdgrowtable_test.c
@@ -151,6 +151,7 @@ ATF_TC_BODY(free_oldtables, tc)
 static _Noreturn void *
 exec_thread(void *args)
 {
+	openfiles(128);
 	for (;;)
 		sleep(1);
 }