mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-19 12:56:21 +00:00
Parser (src/database_flatfile_parser.c):
- ff_jid_to_dir: drop GString+step1, in-place mutate str_replace result
- ff_ensure_dir: g_file_test(G_FILE_TEST_IS_SYMLINK) instead of g_lstat
- ff_unescape_*: early-continue for non-escape branch (less nesting)
- ff_readline: strdup("") instead of malloc(1)+'\0' for skip-line return
- ff_write_line: auto_char safe_msg + single fprintf (drop GString full_line)
- ff_parse_line: early return on missing closing bracket;
extract metadata-parts loop into _ff_parse_meta_parts helper
Verify (src/database_flatfile_verify.c):
- Split monolithic ff_verify_integrity into _collect_contact_dirs,
_check_permissions, _first_pass, _lmc_pass, _verify_contact_dir
- _issue_new constructor; g_new0 throughout
- Separate seen_stanza_ids and seen_archive_ids tables (no cross-kind
duplicate confusion)
- ff_skip_bom in second pass (drop manual fgetc x3)
- log_debug when skipping a contact dir without history.log
- Doc comment on ff_verify_integrity in header
SQLite (src/database_sqlite.c):
- Doc block on ChatLogs schema (replaces_db_id <-> replaced_by_db_id
invariant maintained by AFTER INSERT trigger)
- log_error when _get_db_filename returns NULL during init
Flatfile dispatch (src/database_flatfile.c):
- Replace if/else with is_outgoing ternary for log-path contact pick
Tests:
- 6 new invalid-date parser tests: empty / partial ISO / garbage /
impossible calendar / negative year / far future timestamp
- New functional test message_db_history_multi_resource verifying
same-JID-different-resource history rehydration preserves resources
- test_database_stress.c LMC chain loop: auto_char buf, drop redundant
comment/empty pre-filter (ff_parse_line handles those)
61 lines
2.7 KiB
C
61 lines
2.7 KiB
C
/* test_database_export.h — unit tests for flatfile write/parse round-trip,
|
|
* escape/unescape, and jid_to_dir helpers used by export/import. */
|
|
|
|
/* write → parse round-trip */
|
|
void test_ff_roundtrip_simple_chat(void** state);
|
|
void test_ff_roundtrip_with_all_metadata(void** state);
|
|
void test_ff_roundtrip_with_resource(void** state);
|
|
void test_ff_roundtrip_newline_in_body(void** state);
|
|
void test_ff_roundtrip_pipe_in_stanza_id(void** state);
|
|
void test_ff_roundtrip_backslash_in_body(void** state);
|
|
void test_ff_roundtrip_unicode_body(void** state);
|
|
void test_ff_roundtrip_empty_body(void** state);
|
|
void test_ff_roundtrip_colonspace_in_resource(void** state);
|
|
void test_ff_roundtrip_muc_type(void** state);
|
|
void test_ff_roundtrip_omemo_enc(void** state);
|
|
void test_ff_roundtrip_replace_id(void** state);
|
|
void test_ff_roundtrip_to_jid_and_marked_read(void** state);
|
|
|
|
/* escape / unescape symmetry */
|
|
void test_ff_escape_unescape_message_identity(void** state);
|
|
void test_ff_escape_unescape_meta_identity(void** state);
|
|
void test_ff_escape_meta_null_returns_null(void** state);
|
|
void test_ff_escape_message_null_returns_empty(void** state);
|
|
|
|
/* jid_to_dir */
|
|
void test_ff_jid_to_dir_simple(void** state);
|
|
void test_ff_jid_to_dir_with_at(void** state);
|
|
void test_ff_jid_to_dir_path_traversal_rejected(void** state);
|
|
void test_ff_jid_to_dir_null(void** state);
|
|
|
|
/* parser edge cases */
|
|
void test_ff_parse_line_empty(void** state);
|
|
void test_ff_parse_line_comment(void** state);
|
|
void test_ff_parse_line_legacy_format(void** state);
|
|
void test_ff_parse_line_no_metadata(void** state);
|
|
void test_ff_parse_line_invalid_timestamp(void** state);
|
|
void test_ff_parse_line_empty_timestamp(void** state);
|
|
void test_ff_parse_line_partial_iso_timestamp(void** state);
|
|
void test_ff_parse_line_garbage_timestamp(void** state);
|
|
void test_ff_parse_line_impossible_calendar_date(void** state);
|
|
void test_ff_parse_line_negative_year_timestamp(void** state);
|
|
void test_ff_parse_line_far_future_timestamp(void** state);
|
|
|
|
/* type/enc conversion round-trip */
|
|
void test_ff_type_str_roundtrip(void** state);
|
|
void test_ff_enc_str_roundtrip(void** state);
|
|
|
|
/* additional round-trip */
|
|
void test_ff_roundtrip_bracket_in_stanza_id(void** state);
|
|
void test_ff_roundtrip_backslash_in_resource(void** state);
|
|
void test_ff_roundtrip_mucpm_type(void** state);
|
|
void test_ff_roundtrip_all_enc_types(void** state);
|
|
void test_ff_roundtrip_crlf_handling(void** state);
|
|
void test_ff_roundtrip_to_jid_special_chars(void** state);
|
|
void test_ff_roundtrip_multiple_lines(void** state);
|
|
|
|
/* additional parser edge cases */
|
|
void test_ff_parsed_line_free_null_safe(void** state);
|
|
void test_ff_parse_line_no_space_rejected(void** state);
|
|
void test_ff_parse_line_unclosed_bracket(void** state);
|