| 2923 | } |
| 2924 | |
| 2925 | static void runtime_cap_scenario(runtime_cap_order_t order, runtime_cap_outcome_t *outcome) { |
| 2926 | memset(outcome, 0, sizeof(*outcome)); |
| 2927 | cbm_daemon_build_identity_t identity = |
| 2928 | runtime_test_identity("2.4.0", runtime_test_self_build()); |
| 2929 | runtime_test_fixture_t fixture; |
| 2930 | cbm_daemon_runtime_hold_peer_waits_for_testing(true); |
| 2931 | outcome->started = runtime_test_fixture_start_limited(&fixture, "connection-cap", &identity, 2); |
| 2932 | cbm_daemon_ipc_connection_t *slow_hello = NULL; |
| 2933 | cbm_daemon_runtime_client_t *accepted = NULL; |
| 2934 | cbm_daemon_runtime_client_t *overflow = NULL; |
| 2935 | cbm_daemon_runtime_client_t *resurrection = NULL; |
| 2936 | cbm_daemon_runtime_connect_result_t accepted_result = {0}; |
| 2937 | cbm_daemon_runtime_connect_result_t resurrection_result = {0}; |
| 2938 | |
| 2939 | if (outcome->started) { |
| 2940 | slow_hello = cbm_daemon_ipc_connect(fixture.endpoint, RUNTIME_TEST_TIMEOUT_MS); |
| 2941 | } |
| 2942 | if (slow_hello) { |
| 2943 | outcome->slow_slot_counted = cbm_daemon_runtime_service_wait_for_connections( |
| 2944 | fixture.service, 1, RUNTIME_TEST_TIMEOUT_MS); |
| 2945 | accepted = cbm_daemon_runtime_client_connect(fixture.endpoint, &identity, |
| 2946 | RUNTIME_TEST_TIMEOUT_MS, &accepted_result); |
| 2947 | } |
| 2948 | if (accepted) { |
| 2949 | overflow = runtime_cap_overflow_connect(&fixture, &identity, order, outcome); |
| 2950 | |
| 2951 | cbm_daemon_ipc_connection_close(slow_hello); |
| 2952 | slow_hello = NULL; |
| 2953 | outcome->slow_slot_released = cbm_daemon_runtime_service_wait_for_connections( |
| 2954 | fixture.service, 1, RUNTIME_TEST_TIMEOUT_MS); |
| 2955 | (void)cbm_daemon_runtime_client_close(accepted, RUNTIME_TEST_TIMEOUT_MS); |
| 2956 | accepted = NULL; |
| 2957 | outcome->exited = |
| 2958 | cbm_daemon_runtime_service_wait_exited(fixture.service, RUNTIME_TEST_TIMEOUT_MS); |
| 2959 | |
| 2960 | resurrection = cbm_daemon_runtime_client_connect(fixture.endpoint, &identity, 100, |
| 2961 | &resurrection_result); |
| 2962 | cbm_daemon_runtime_service_state_t terminal_state = |
| 2963 | cbm_daemon_runtime_service_state(fixture.service); |
| 2964 | outcome->no_resurrection = |
| 2965 | resurrection == NULL && |
| 2966 | (resurrection_result.status == CBM_DAEMON_RUNTIME_CONNECT_ERROR || |
| 2967 | resurrection_result.status == CBM_DAEMON_RUNTIME_CONNECT_REJECTED) && |
| 2968 | cbm_daemon_runtime_service_active_clients(fixture.service) == 0 && |
| 2969 | (terminal_state == CBM_DAEMON_RUNTIME_SERVICE_STOPPING || |
| 2970 | terminal_state == CBM_DAEMON_RUNTIME_SERVICE_EXITED); |
| 2971 | } |
| 2972 | |
| 2973 | if (resurrection) { |
| 2974 | (void)cbm_daemon_runtime_client_close(resurrection, RUNTIME_TEST_TIMEOUT_MS); |
| 2975 | } |
| 2976 | if (overflow) { |
| 2977 | (void)cbm_daemon_runtime_client_close(overflow, RUNTIME_TEST_TIMEOUT_MS); |
| 2978 | } |
| 2979 | if (accepted) { |
| 2980 | (void)cbm_daemon_runtime_client_close(accepted, RUNTIME_TEST_TIMEOUT_MS); |
| 2981 | } |
| 2982 | cbm_daemon_ipc_connection_close(slow_hello); |
no test coverage detected