comparison mrjunejune/test/inference_bridge_test.c @ 280:49e9e591c9bb

Add persistent dictation, prewarmed WebRTC speech input, Copilot SDK routing, animated conversation lifecycle controls, parking, and architecture coverage.
author MrJuneJune <me@mrjunejune.com>
date Tue, 18 Aug 2026 19:14:53 -0700
parents 056790c4fb0d
children
comparison
equal deleted inserted replaced
279:b3b547563ec7 280:49e9e591c9bb
11 pthread_cond_t condition; 11 pthread_cond_t condition;
12 int accepted; 12 int accepted;
13 int deltas; 13 int deltas;
14 int completed; 14 int completed;
15 int usage; 15 int usage;
16 int warmed;
16 int custom; 17 int custom;
17 int done; 18 int done;
18 int closed; 19 int closed;
19 int failed_done; /* turn.done with failed=true */ 20 int failed_done; /* turn.done with failed=true */
20 char delta[128]; 21 char delta[128];
30 { 31 {
31 Test_State *p_state = p_user_data; 32 Test_State *p_state = p_user_data;
32 pthread_mutex_lock(&p_state->mutex); 33 pthread_mutex_lock(&p_state->mutex);
33 if (strcmp(p_event->type, "turn.accepted") == 0) 34 if (strcmp(p_event->type, "turn.accepted") == 0)
34 p_state->accepted++; 35 p_state->accepted++;
36 else if (strcmp(p_event->type, "session.warmed") == 0)
37 p_state->warmed++;
35 else if (strcmp(p_event->type, "assistant.delta") == 0) 38 else if (strcmp(p_event->type, "assistant.delta") == 0)
36 { 39 {
37 p_state->deltas++; 40 p_state->deltas++;
38 snprintf(p_state->delta, sizeof(p_state->delta), "%s", p_event->delta); 41 snprintf(p_state->delta, sizeof(p_state->delta), "%s", p_event->delta);
39 } 42 }
85 assert(result == 0); 88 assert(result == 0);
86 } 89 }
87 pthread_mutex_unlock(&p_state->mutex); 90 pthread_mutex_unlock(&p_state->mutex);
88 } 91 }
89 92
93 static void Wait_Warmed(Test_State *p_state, int target)
94 {
95 struct timespec deadline;
96 clock_gettime(CLOCK_REALTIME, &deadline);
97 deadline.tv_sec += 5;
98 pthread_mutex_lock(&p_state->mutex);
99 while (p_state->warmed < target)
100 {
101 int result = pthread_cond_timedwait(
102 &p_state->condition, &p_state->mutex, &deadline);
103 assert(result == 0);
104 }
105 pthread_mutex_unlock(&p_state->mutex);
106 }
107
90 int main(int argc, char **argv) 108 int main(int argc, char **argv)
91 { 109 {
92 assert(argc == 2); 110 assert(argc == 2);
93 Test_State state = {0}; 111 Test_State state = {0};
94 assert(pthread_mutex_init(&state.mutex, NULL) == 0); 112 assert(pthread_mutex_init(&state.mutex, NULL) == 0);
97 Inference_Bridge *p_bridge = Inference_Bridge_Create( 115 Inference_Bridge *p_bridge = Inference_Bridge_Create(
98 argv[1], argv[1], Handle_Event, &state); 116 argv[1], argv[1], Handle_Event, &state);
99 assert(p_bridge); 117 assert(p_bridge);
100 assert(Inference_Bridge_Start(p_bridge)); 118 assert(Inference_Bridge_Start(p_bridge));
101 assert(Inference_Bridge_Is_Ready(p_bridge)); 119 assert(Inference_Bridge_Is_Ready(p_bridge));
120
121 assert(Inference_Bridge_Warm_Conversation(
122 p_bridge,
123 "warm-1",
124 "warm-conversation",
125 INFERENCE_PROMPT_PROFILE_CANVAS_ORCHESTRATOR,
126 1,
127 1,
128 FALSE));
129 Wait_Warmed(&state, 1);
102 130
103 /* --- Validation: invalid profile --- */ 131 /* --- Validation: invalid profile --- */
104 assert(!Inference_Bridge_Start_Turn( 132 assert(!Inference_Bridge_Start_Turn(
105 p_bridge, 133 p_bridge,
106 "request-invalid-profile", 134 "request-invalid-profile",