LCOV - code coverage report
Current view: top level - tests/functional - test_runner.c (source / functions) Coverage Total Hit
Test: coverage.info Lines: 95.7 % 46 44
Test Date: 2026-04-20 19:54:22 Functions: 100.0 % 1 1

            Line data    Source code
       1              : /**
       2              :  * @file test_runner.c
       3              :  * @brief Entry point for functional tests (linked against real crypto, not mocks).
       4              :  *
       5              :  * These tests exercise the real OpenSSL crypto implementations, unlike the
       6              :  * unit tests which use mock crypto.  They serve as known-answer and round-trip
       7              :  * verification to catch divergence between the mock and real behaviour.
       8              :  */
       9              : 
      10              : #include "test_helpers.h"
      11              : #include <stdio.h>
      12              : #include <string.h>
      13              : 
      14              : int g_tests_run    = 0;
      15              : int g_tests_failed = 0;
      16              : const char *g_test_filter = NULL;
      17              : 
      18              : /* Declarations of test suites */
      19              : void run_ige_aes_functional_tests(void);
      20              : void run_mtproto_crypto_functional_tests(void);
      21              : void run_crypto_kdf_functional_tests(void);
      22              : void run_srp_math_functional_tests(void);
      23              : void run_srp_roundtrip_functional_tests(void);
      24              : void run_tl_skip_message_functional_tests(void);
      25              : void run_tl_forward_compat_tests(void);
      26              : void run_mt_server_smoke_tests(void);
      27              : void run_login_flow_tests(void);
      28              : void run_read_path_tests(void);
      29              : void run_write_path_tests(void);
      30              : void run_upload_download_tests(void);
      31              : void run_dialogs_cache_ttl_tests(void);
      32              : void run_tui_e2e_tests(void);
      33              : void run_send_stdin_tests(void);
      34              : void run_dc_session_cache_skip_tests(void);
      35              : void run_logout_rpc_tests(void);
      36              : void run_wrong_session_id_tests(void);
      37              : void run_config_wizard_batch_tests(void);
      38              : void run_tg_cli_read_dispatch_tests(void);
      39              : void run_logger_lifecycle_tests(void);
      40              : void run_session_corruption_tests(void);
      41              : void run_session_migration_tests(void);
      42              : void run_config_ini_robustness_tests(void);
      43              : void run_resolver_cache_tests(void);
      44              : void run_text_rendering_safety_tests(void);
      45              : void run_history_rich_metadata_tests(void);
      46              : void run_service_messages_tests(void);
      47              : void run_rpc_envelope_tests(void);
      48              : void run_transport_resilience_tests(void);
      49              : void run_service_frames_tests(void);
      50              : void run_login_migrate_tests(void);
      51              : void run_auth_flow_errors_tests(void);
      52              : void run_cross_dc_auth_transfer_tests(void);
      53              : void run_handshake_cold_boot_tests(void);
      54              : void run_rich_media_types_tests(void);
      55              : void run_deep_pagination_tests(void);
      56              : 
      57              : /** Run suite_fn only when no filter is set or the filter is a substring of
      58              :  *  the stringified function name. */
      59              : #define RUN_SUITE(suite_fn) do { \
      60              :     if (!g_test_filter || strstr(#suite_fn, g_test_filter)) { \
      61              :         printf("Running %s...\n", #suite_fn); \
      62              :         suite_fn(); \
      63              :     } \
      64              : } while(0)
      65              : 
      66            2 : int main(int argc, char *argv[]) {
      67            2 :     if (argc > 1) {
      68            0 :         g_test_filter = argv[1];
      69            0 :         printf("--- Functional Tests (filter: \"%s\") ---\n\n", g_test_filter);
      70              :     }
      71              : 
      72            2 :     RUN_SUITE(run_ige_aes_functional_tests);
      73            2 :     RUN_SUITE(run_mtproto_crypto_functional_tests);
      74            2 :     RUN_SUITE(run_crypto_kdf_functional_tests);
      75            2 :     RUN_SUITE(run_srp_math_functional_tests);
      76            2 :     RUN_SUITE(run_srp_roundtrip_functional_tests);
      77            2 :     RUN_SUITE(run_tl_skip_message_functional_tests);
      78            2 :     RUN_SUITE(run_tl_forward_compat_tests);
      79            2 :     RUN_SUITE(run_mt_server_smoke_tests);
      80            2 :     RUN_SUITE(run_login_flow_tests);
      81            2 :     RUN_SUITE(run_read_path_tests);
      82            2 :     RUN_SUITE(run_write_path_tests);
      83            2 :     RUN_SUITE(run_upload_download_tests);
      84            2 :     RUN_SUITE(run_dialogs_cache_ttl_tests);
      85            2 :     RUN_SUITE(run_tui_e2e_tests);
      86            2 :     RUN_SUITE(run_send_stdin_tests);
      87            2 :     RUN_SUITE(run_dc_session_cache_skip_tests);
      88            2 :     RUN_SUITE(run_logout_rpc_tests);
      89            2 :     RUN_SUITE(run_wrong_session_id_tests);
      90            2 :     RUN_SUITE(run_config_wizard_batch_tests);
      91            2 :     RUN_SUITE(run_tg_cli_read_dispatch_tests);
      92            2 :     RUN_SUITE(run_logger_lifecycle_tests);
      93            2 :     RUN_SUITE(run_session_corruption_tests);
      94            2 :     RUN_SUITE(run_session_migration_tests);
      95            2 :     RUN_SUITE(run_config_ini_robustness_tests);
      96            2 :     RUN_SUITE(run_resolver_cache_tests);
      97            2 :     RUN_SUITE(run_text_rendering_safety_tests);
      98            2 :     RUN_SUITE(run_history_rich_metadata_tests);
      99            2 :     RUN_SUITE(run_service_messages_tests);
     100            2 :     RUN_SUITE(run_rpc_envelope_tests);
     101            2 :     RUN_SUITE(run_transport_resilience_tests);
     102            2 :     RUN_SUITE(run_service_frames_tests);
     103            2 :     RUN_SUITE(run_login_migrate_tests);
     104            2 :     RUN_SUITE(run_auth_flow_errors_tests);
     105            2 :     RUN_SUITE(run_cross_dc_auth_transfer_tests);
     106            2 :     RUN_SUITE(run_handshake_cold_boot_tests);
     107            2 :     RUN_SUITE(run_rich_media_types_tests);
     108            2 :     RUN_SUITE(run_deep_pagination_tests);
     109              : 
     110            2 :     printf("\n--- Functional Test Results ---\n");
     111            2 :     printf("Tests Run:    %d\n", g_tests_run);
     112            2 :     printf("Tests Passed: %d\n", g_tests_run - g_tests_failed);
     113            2 :     printf("Tests Failed: %d\n", g_tests_failed);
     114              : 
     115            2 :     return g_tests_failed > 0 ? 1 : 0;
     116              : }
        

Generated by: LCOV version 2.0-1