tests: add 12 DB persistence functional tests, rebalance groups
Some checks failed
CI Code / Check spelling (pull_request) Successful in 19s
CI Code / Check coding style (pull_request) Successful in 42s
CI Code / Code Coverage (pull_request) Failing after 6m0s
CI Code / Linux (debian) (pull_request) Failing after 7m54s
CI Code / Linux (ubuntu) (pull_request) Failing after 7m56s
CI Code / Linux (arch) (pull_request) Failing after 8m11s

Add backend-agnostic functional tests for database message persistence.
All tests work with both SQLite and flat-file backends.

New tests in test_history.c:
- message_db_history_on_reopen: basic incoming write+read round-trip
- message_db_history_multiple: 3 messages from different resources
- message_db_history_contact_isolation: buddy1 msg absent from buddy2
- message_db_history_special_chars: XML entities survive DB round-trip
- message_db_history_outgoing: sent message persists across reopen
- message_db_history_dialog: outgoing + incoming both in history
- message_db_history_empty: no crash on contact with no history
- message_db_history_long_message: 1000+ char body not truncated
- message_db_history_newline: embedded LF stored correctly
- message_db_history_service_chars: backslash pipe percent braces etc
- message_db_history_verify: /history verify reports no issues
- message_db_history_lmc: XEP-0308 correction replaces original in DB

Rebalance test groups for parallel execution (19/23/22/21):
- Group 1: Connect, Ping, Rooms, Software, LastActivity
- Group 2: Message, Receipts, Roster, DB History
- Group 3: Chat Session, Presence, Disconnect
- Group 4: MUC, Carbons
This commit is contained in:
2026-02-19 16:19:47 +03:00
parent 31538580fb
commit be06d33125
4 changed files with 521 additions and 15 deletions

View File

@@ -15,10 +15,10 @@
* 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
* Group 2: Message, Receipts, Roster, Chat Session
* Group 3: Presence, Disconnect
* Group 4: MUC, Carbons
* Group 1: Connect, Ping, Rooms, Software, Last Activity (19 tests)
* Group 2: Message, Receipts, Roster, DB History (23 tests)
* Group 3: Chat Session, Presence, Disconnect (22 tests)
* Group 4: MUC, Carbons (21 tests)
*
* Parallel execution:
* ./functionaltests - run all tests sequentially
@@ -53,6 +53,7 @@
#include "test_muc.h"
#include "test_disconnect.h"
#include "test_lastactivity.h"
#include "test_history.h"
/* Macro to wrap each test with setup/teardown functions */
#define PROF_FUNC_TEST(test) cmocka_unit_test_setup_teardown(test, init_prof_test, close_prof_test)
@@ -77,8 +78,9 @@ main(int argc, char* argv[])
fprintf(stderr, "[PROF_TEST] Starting functional tests, group=%d\n", group);
/* ============================================================
* GROUP 1: Connect, Ping, Rooms, Software
* GROUP 1: Connect, Ping, Rooms, Software, Last Activity
* Basic XMPP session establishment and server queries
* (19 tests)
* ============================================================ */
const struct CMUnitTest group1_tests[] = {
/* Connection tests - verify login, roster, bookmarks */
@@ -112,8 +114,9 @@ main(int argc, char* argv[])
};
/* ============================================================
* GROUP 2: Message, Receipts, Roster, Chat Session
* GROUP 2: Message, Receipts, Roster, DB History
* Core messaging and contact management
* (23 tests)
* ============================================================ */
const struct CMUnitTest group2_tests[] = {
/* Basic message send/receive */
@@ -133,6 +136,27 @@ main(int argc, char* argv[])
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: Chat Session, Presence, Disconnect
* Session routing, status management, clean teardown
* (22 tests)
* ============================================================ */
const struct CMUnitTest group3_tests[] = {
/* Chat session management - bare/full JID routing */
PROF_FUNC_TEST(sends_message_to_barejid_when_contact_offline),
PROF_FUNC_TEST(sends_message_to_barejid_when_contact_online),
@@ -140,13 +164,8 @@ main(int argc, char* argv[])
PROF_FUNC_TEST(sends_subsequent_messages_to_fulljid),
PROF_FUNC_TEST(resets_to_barejid_after_presence_received),
PROF_FUNC_TEST(new_session_when_message_received_from_different_fulljid),
};
/* ============================================================
* GROUP 3: Presence, Disconnect
* Online/away/xa/dnd/chat status management
* ============================================================ */
const struct CMUnitTest group3_tests[] = {
/* Presence - online/away/xa/dnd/chat status management */
PROF_FUNC_TEST(presence_online),
PROF_FUNC_TEST(presence_online_with_message),
PROF_FUNC_TEST(presence_away),
@@ -170,6 +189,7 @@ main(int argc, char* argv[])
/* ============================================================
* GROUP 4: MUC, Carbons
* Multi-user chat and message synchronization
* (21 tests)
* ============================================================ */
const struct CMUnitTest group4_tests[] = {
/* MUC room join with various options - XEP-0045 */
@@ -212,9 +232,9 @@ main(int argc, char* argv[])
const struct CMUnitTest* tests;
size_t count;
} groups[] = {
{ "Group 1: Connect/Ping/Rooms/Software", group1_tests, ARRAY_SIZE(group1_tests) },
{ "Group 2: Message/Receipts/Roster/Session", group2_tests, ARRAY_SIZE(group2_tests) },
{ "Group 3: Presence/Disconnect", group3_tests, ARRAY_SIZE(group3_tests) },
{ "Group 1: Connect/Ping/Rooms/Software/LastActivity", group1_tests, ARRAY_SIZE(group1_tests) },
{ "Group 2: Message/Receipts/Roster/DBHistory", group2_tests, ARRAY_SIZE(group2_tests) },
{ "Group 3: Session/Presence/Disconnect", group3_tests, ARRAY_SIZE(group3_tests) },
{ "Group 4: MUC/Carbons", group4_tests, ARRAY_SIZE(group4_tests) },
};
const int num_groups = ARRAY_SIZE(groups);