mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-19 08:06:21 +00:00
tests: add functional tests for DB message persistence, rebalance groups
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 decode+DB - 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 (ifdef HAVE_HISTORY_VERIFY) - message_db_history_lmc: XEP-0308 correction replaces original in DB Rebalance test groups for parallel execution (19/22/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:
@@ -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, Autoping (fast), Rooms, Software, Last Activity
|
||||
* Group 2: Message, Receipts, Roster, Chat Session
|
||||
* Group 3: Presence, Disconnect, Autoping (slow)
|
||||
* Group 1: Connect, Ping, Rooms, Software, Last Activity, Autoping
|
||||
* Group 2: Message, Receipts, Roster, DB History
|
||||
* Group 3: Chat Session, Presence, Disconnect, Disco
|
||||
* Group 4: MUC, Carbons
|
||||
*
|
||||
* Parallel execution:
|
||||
@@ -55,6 +55,7 @@
|
||||
#include "test_lastactivity.h"
|
||||
#include "test_autoping.h"
|
||||
#include "test_disco.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)
|
||||
@@ -79,8 +80,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 */
|
||||
@@ -124,8 +126,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 */
|
||||
@@ -145,6 +148,29 @@ 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),
|
||||
#ifdef HAVE_HISTORY_VERIFY
|
||||
PROF_FUNC_TEST(message_db_history_verify),
|
||||
#endif
|
||||
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),
|
||||
@@ -152,13 +178,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, Disco
|
||||
* 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),
|
||||
@@ -198,6 +219,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 */
|
||||
@@ -240,9 +262,9 @@ main(int argc, char* argv[])
|
||||
const struct CMUnitTest* tests;
|
||||
size_t count;
|
||||
} groups[] = {
|
||||
{ "Group 1: Connect/Ping/Rooms/Software/Autoping", group1_tests, ARRAY_SIZE(group1_tests) },
|
||||
{ "Group 2: Message/Receipts/Roster/Session", 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", group1_tests, ARRAY_SIZE(group1_tests) },
|
||||
{ "Group 2: Message/Receipts/Roster/DBHistory", group2_tests, ARRAY_SIZE(group2_tests) },
|
||||
{ "Group 3: Session/Presence/Disconnect/Disco", group3_tests, ARRAY_SIZE(group3_tests) },
|
||||
{ "Group 4: MUC/Carbons", group4_tests, ARRAY_SIZE(group4_tests) },
|
||||
};
|
||||
const int num_groups = ARRAY_SIZE(groups);
|
||||
|
||||
Reference in New Issue
Block a user