fix(functests): fix send_receipt_request 60s timeout, rebalance groups, add per-test timing
All checks were successful
CI Code / Check spelling (pull_request) Successful in 19s
CI Code / Check coding style (pull_request) Successful in 35s
CI Code / Code Coverage (pull_request) Successful in 2m28s
CI Code / Linux (debian) (pull_request) Successful in 4m23s
CI Code / Linux (arch) (pull_request) Successful in 4m41s
CI Code / Linux (ubuntu) (pull_request) Successful in 5m14s

Fix send_receipt_request test that wasted 60s on every run:
- Change caps hash from sha-256 to sha-1 (profanity only supports sha-1
  for standard caps path, sha-256 goes to unsupported-hash fallback)
- Fix expected output: 'Buddy1 is online' → 'Buddy1 (laptop) is online'
  (resource is always shown for full JID presence)
- Wrap prof_output_exact in assert_true so mismatches fail fast instead
  of silently waiting the full expect_timeout

Rebalance test groups for parallel execution:
- Move Disco tests (14) from Group 3 → Group 1
- Move DB History tests (12) from Group 2 → Group 3
- Before: G1=31s G2=63s G3=30s G4=37s (bottleneck 63s)
- After:  G1=46s G2=38s G3=40s G4=36s (bottleneck 46s, -27%)

Add per-test wall-clock timing via clock_gettime(CLOCK_MONOTONIC)
in init_prof_test/close_prof_test for profiling individual tests.
This commit is contained in:
2026-03-12 21:02:22 +03:00
parent 0d38a0a2cb
commit 2b1b70665b
3 changed files with 53 additions and 41 deletions

View File

@@ -15,9 +15,9 @@
* functional tests run less frequently than unit tests.
*
* Tests are organized into groups for better maintainability and parallel execution:
* Group 1: Connect, Ping, Rooms, Software, Last Activity, Autoping
* Group 2: Message, Receipts, Roster, DB History (+export/import with SQLite)
* Group 3: Presence, Disconnect, Disco
* Group 1: Connect, Ping, Rooms, Software, Last Activity, Autoping, Disco
* Group 2: Message, Receipts, Roster, Export/Import (+SQLite)
* Group 3: Presence, Disconnect, DB History
* Group 4: Chat Session, MUC, Carbons
*
* Parallel execution:
@@ -83,7 +83,7 @@ main(int argc, char* argv[])
fprintf(stderr, "[PROF_TEST] Starting functional tests, group=%d\n", group);
/* ============================================================
* GROUP 1: Connect, Ping, Rooms, Software, Last Activity
* GROUP 1: Connect, Ping, Rooms, Software, Last Activity, Disco
* Basic XMPP session establishment and server queries
* ============================================================ */
const struct CMUnitTest group1_tests[] = {
@@ -125,10 +125,26 @@ main(int argc, char* argv[])
/* Autoping slow tests - require sleep for timer triggers (~2s each) */
PROF_FUNC_TEST(autoping_sends_ping_after_interval),
PROF_FUNC_TEST(autoping_server_not_supporting_ping),
/* Service Discovery - XEP-0030 */
PROF_FUNC_TEST(disco_info_shows_identity),
PROF_FUNC_TEST(disco_info_shows_features),
PROF_FUNC_TEST(disco_info_to_server),
PROF_FUNC_TEST(disco_info_to_jid),
PROF_FUNC_TEST(disco_info_not_found),
PROF_FUNC_TEST(disco_items_shows_items),
PROF_FUNC_TEST(disco_items_empty_result),
PROF_FUNC_TEST(disco_requires_connection),
PROF_FUNC_TEST(disco_items_to_jid),
PROF_FUNC_TEST(disco_info_empty_result),
PROF_FUNC_TEST(disco_info_multiple_identities),
PROF_FUNC_TEST(disco_info_without_name),
PROF_FUNC_TEST(disco_items_without_name),
PROF_FUNC_TEST(disco_info_service_unavailable),
};
/* ============================================================
* GROUP 2: Message, Receipts, Roster, DB History
* GROUP 2: Message, Receipts, Roster, Export/Import
* Core messaging and contact management
* ============================================================ */
const struct CMUnitTest group2_tests[] = {
@@ -162,25 +178,11 @@ main(int argc, char* argv[])
PROF_FUNC_TEST(sends_remove_item),
PROF_FUNC_TEST(sends_remove_item_nick),
PROF_FUNC_TEST(sends_nick_change),
/* Database persistence - message write+read round-trip */
PROF_FUNC_TEST(message_db_history_on_reopen),
PROF_FUNC_TEST(message_db_history_multiple),
PROF_FUNC_TEST(message_db_history_contact_isolation),
PROF_FUNC_TEST(message_db_history_special_chars),
PROF_FUNC_TEST(message_db_history_outgoing),
PROF_FUNC_TEST(message_db_history_dialog),
PROF_FUNC_TEST(message_db_history_empty),
PROF_FUNC_TEST(message_db_history_long_message),
PROF_FUNC_TEST(message_db_history_newline),
PROF_FUNC_TEST(message_db_history_service_chars),
PROF_FUNC_TEST(message_db_history_verify),
PROF_FUNC_TEST(message_db_history_lmc),
};
/* ============================================================
* GROUP 3: Presence, Disconnect, Disco
* Status management, clean teardown, service discovery
* GROUP 3: Presence, Disconnect, DB History
* Status management, clean teardown, message persistence
* ============================================================ */
const struct CMUnitTest group3_tests[] = {
/* Presence - online/away/xa/dnd/chat status management */
@@ -203,21 +205,19 @@ main(int argc, char* argv[])
/* Disconnect - clean session termination */
PROF_FUNC_TEST(disconnect_ends_session),
/* Service Discovery - XEP-0030 */
PROF_FUNC_TEST(disco_info_shows_identity),
PROF_FUNC_TEST(disco_info_shows_features),
PROF_FUNC_TEST(disco_info_to_server),
PROF_FUNC_TEST(disco_info_to_jid),
PROF_FUNC_TEST(disco_info_not_found),
PROF_FUNC_TEST(disco_items_shows_items),
PROF_FUNC_TEST(disco_items_empty_result),
PROF_FUNC_TEST(disco_requires_connection),
PROF_FUNC_TEST(disco_items_to_jid),
PROF_FUNC_TEST(disco_info_empty_result),
PROF_FUNC_TEST(disco_info_multiple_identities),
PROF_FUNC_TEST(disco_info_without_name),
PROF_FUNC_TEST(disco_items_without_name),
PROF_FUNC_TEST(disco_info_service_unavailable),
/* Database persistence - message write+read round-trip */
PROF_FUNC_TEST(message_db_history_on_reopen),
PROF_FUNC_TEST(message_db_history_multiple),
PROF_FUNC_TEST(message_db_history_contact_isolation),
PROF_FUNC_TEST(message_db_history_special_chars),
PROF_FUNC_TEST(message_db_history_outgoing),
PROF_FUNC_TEST(message_db_history_dialog),
PROF_FUNC_TEST(message_db_history_empty),
PROF_FUNC_TEST(message_db_history_long_message),
PROF_FUNC_TEST(message_db_history_newline),
PROF_FUNC_TEST(message_db_history_service_chars),
PROF_FUNC_TEST(message_db_history_verify),
PROF_FUNC_TEST(message_db_history_lmc),
};
/* ============================================================
@@ -274,9 +274,9 @@ main(int argc, char* argv[])
const struct CMUnitTest* tests;
size_t count;
} groups[] = {
{ "Group 1: Connect/Ping/Rooms/Software/LastActivity/Autoping", group1_tests, ARRAY_SIZE(group1_tests) },
{ "Group 2: Message/Receipts/Roster/DBHistory", group2_tests, ARRAY_SIZE(group2_tests) },
{ "Group 3: Presence/Disconnect/Disco", group3_tests, ARRAY_SIZE(group3_tests) },
{ "Group 1: Connect/Ping/Rooms/Software/LastActivity/Autoping/Disco", group1_tests, ARRAY_SIZE(group1_tests) },
{ "Group 2: Message/Receipts/Roster/ExportImport", group2_tests, ARRAY_SIZE(group2_tests) },
{ "Group 3: Presence/Disconnect/DBHistory", group3_tests, ARRAY_SIZE(group3_tests) },
{ "Group 4: Session/MUC/Carbons", group4_tests, ARRAY_SIZE(group4_tests) },
};
const int num_groups = ARRAY_SIZE(groups);

View File

@@ -13,6 +13,7 @@
#include <sys/select.h>
#include <regex.h>
#include <signal.h>
#include <time.h>
#include <stabber.h>
@@ -77,6 +78,9 @@ static size_t output_len = 0;
/* Timeout for expect operations in seconds */
static int expect_timeout = EXPECT_TIMEOUT_DEFAULT;
/* Per-test wall-clock timer */
static struct timespec test_start_ts;
gboolean
_create_dir(const char *name)
{
@@ -275,6 +279,7 @@ prof_start(void)
int
init_prof_test(void **state)
{
clock_gettime(CLOCK_MONOTONIC, &test_start_ts);
/* Get test group from environment for static resource allocation */
const char *group_env = getenv("PROF_TEST_GROUP");
int group = group_env ? atoi(group_env) : 0;
@@ -427,6 +432,13 @@ close_prof_test(void **state)
}
stbbr_stop();
struct timespec now;
clock_gettime(CLOCK_MONOTONIC, &now);
double elapsed = (now.tv_sec - test_start_ts.tv_sec)
+ (now.tv_nsec - test_start_ts.tv_nsec) / 1e9;
printf("[PROF_TEST] test took %.3f s\n", elapsed);
return 0;
}

View File

@@ -44,11 +44,11 @@ send_receipt_request(void **state)
"<presence to='stabber@localhost' from='buddy1@localhost/laptop'>"
"<priority>15</priority>"
"<status>My status</status>"
"<c hash='sha-256' xmlns='http://jabber.org/protocol/caps' node='http://profanity-im.github.io' ver='hAkb1xZdJV9BQpgGNw8zG5Xsals='/>"
"<c hash='sha-1' xmlns='http://jabber.org/protocol/caps' node='http://profanity-im.github.io' ver='hAkb1xZdJV9BQpgGNw8zG5Xsals='/>"
"</presence>"
);
prof_output_exact("Buddy1 is online, \"My status\"");
assert_true(prof_output_exact("Buddy1 (laptop) is online, \"My status\""));
prof_input("/msg Buddy1");
prof_input("/resource set laptop");