From fa6a02f50e65c47540f51b3177f5080bc6af168e Mon Sep 17 00:00:00 2001 From: Gleb Smirnoff Date: Tue, 20 Feb 2024 14:31:06 -0800 Subject: [PATCH] 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 75c3d6701c0..6ea42bd076a 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); } -- 2.45.0