Compare commits

..

1 Commits

Author SHA1 Message Date
f84ed1bf6a perf(functests): speedup — profrc pre-baking, pty-close shutdown, parallel port pools
All checks were successful
CI Code / Check spelling (pull_request) Successful in 18s
CI Code / Check coding style (pull_request) Successful in 32s
CI Code / Code Coverage (pull_request) Successful in 2m46s
CI Code / Linux (debian) (pull_request) Successful in 4m30s
CI Code / Linux (ubuntu) (pull_request) Successful in 4m29s
CI Code / Linux (arch) (pull_request) Successful in 4m44s
CI Code / Check spelling (push) Successful in 18s
CI Code / Check coding style (push) Successful in 33s
CI Code / Code Coverage (push) Successful in 3m4s
CI Code / Linux (ubuntu) (push) Successful in 4m29s
CI Code / Linux (debian) (push) Successful in 4m33s
CI Code / Linux (arch) (push) Successful in 4m48s
Replace 16 interactive UI setup commands with pre-written profrc file
containing [ui] and [notifications] sections (~1800ms saved per test).

Replace sleep(1) + blocking waitpid with close(pty fd) → SIGHUP →
polling waitpid(WNOHANG) → SIGTERM/SIGKILL fallback chain (~4900ms
saved per test).

Remove post-stbbr_start() and post-stbbr_stop() sleeps — bind+listen
completes synchronously before stbbr_start() returns, and
pthread_join() in stbbr_stop() guarantees socket cleanup (~200ms saved).

Add PORTS_PER_GROUP=50 isolated port ranges per test group to enable
safe parallel execution of 4 groups without port conflicts.
2026-03-12 18:20:35 +03:00

View File

@@ -184,6 +184,12 @@ _cleanup_dirs(void)
}
}
static void
sleep_ms(int ms)
{
usleep(ms * MS_TO_US);
}
/*
* Read available data from fd into output_buffer with timeout.
* Returns number of bytes read, 0 on timeout, -1 on error.
@@ -263,7 +269,7 @@ prof_start(void)
fcntl(fd, F_SETFL, flags | O_NONBLOCK);
/* Brief wait for process to initialize */
usleep(INIT_WAIT_MS * MS_TO_US);
sleep_ms(INIT_WAIT_MS);
}
int
@@ -279,7 +285,7 @@ init_prof_test(void **state)
/* Calculate port base: each build uses a different range of
* TEST_GROUPS * PORTS_PER_GROUP ports.
* Build 0 (local/default): BASE_PORT..+199, Full: same, Minimal: +200, etc.
* Build 0 (local/default): 5230-5429, Full: 5230-5429, Minimal: 5430-5629, etc.
* Build 0 and Full share the same range because build 0 is for local runs
* or sequential run (no parallel builds), while Full/Minimal/NoEncrypt/Default
* are used in CI where they run in parallel. */
@@ -388,7 +394,7 @@ close_prof_test(void **state)
/* Close pty master after brief grace — child gets SIGHUP which
* accelerates shutdown instead of waiting for XMPP disconnect
* timeout (~5s). */
usleep(QUIT_GRACE_MS * MS_TO_US);
sleep_ms(QUIT_GRACE_MS);
close(fd);
fd = 0;
int exited = 0;
@@ -397,13 +403,13 @@ close_prof_test(void **state)
exited = 1;
break;
}
usleep(SHUTDOWN_POLL_MS * MS_TO_US);
sleep_ms(SHUTDOWN_POLL_MS);
}
if (!exited) {
kill(child_pid, SIGTERM);
for (int i = 0; i < SIGTERM_POLL_MAX; i++) {
if (waitpid(child_pid, NULL, WNOHANG) != 0) { exited = 1; break; }
usleep(SHUTDOWN_POLL_MS * MS_TO_US);
sleep_ms(SHUTDOWN_POLL_MS);
}
if (!exited) {
kill(child_pid, SIGKILL);
@@ -434,7 +440,7 @@ prof_input(const char *input)
g_string_free(inp_str, TRUE);
/* Small delay to let profanity process input */
usleep(INPUT_DELAY_MS * MS_TO_US);
sleep_ms(INPUT_DELAY_MS);
}
/*
@@ -457,7 +463,7 @@ prof_output_exact(const char *text)
return 1;
}
usleep(OUTPUT_POLL_MS * MS_TO_US);
sleep_ms(OUTPUT_POLL_MS);
}
return 0;
@@ -493,7 +499,7 @@ prof_output_regex(const char *pattern)
return 1;
}
usleep(OUTPUT_POLL_MS * MS_TO_US);
sleep_ms(OUTPUT_POLL_MS);
}
/* Timeout reached - log diagnostic info */