Coverage Report

Created: 2026-10-24 08:16

/work/auto_tests/scenarios/scenario_events_test.c
Line
Count
Source (jump to first uncovered line)
1
#include "framework/framework.h"
2
#include <stdio.h>
3
#include <stdlib.h>
4
#include <string.h>
5
6
static void alice_script(ToxNode *self, void *ctx)
7
2
{
8
2
    tox_node_wait_for_self_connected(self);
9
2
    tox_node_wait_for_friend_connected(self, 0);
10
11
2
    tox_node_log(self, "Sending message to Bob...");
12
2
    uint8_t msg[] = "hello";
13
2
    Tox_Err_Friend_Send_Message err;
14
2
    tox_friend_send_message(tox_node_get_tox(self), 0, TOX_MESSAGE_TYPE_NORMAL, msg, sizeof(msg), &err);
15
2
    ck_assert(err == TOX_ERR_FRIEND_SEND_MESSAGE_OK);
16
2
}
17
18
static void bob_script(ToxNode *self, void *ctx)
19
1
{
20
1
    tox_node_wait_for_self_connected(self);
21
1
    tox_node_wait_for_friend_connected(self, 0);
22
23
1
    tox_node_log(self, "Waiting for message from Alice...");
24
1
    WAIT_FOR_EVENT(TOX_EVENT_FRIEND_MESSAGE);
25
1
    tox_node_log(self, "Received message!");
26
1
}
27
28
int main(int argc, char *argv[])
29
31
{
30
31
    ToxScenario *s = tox_scenario_new(argc, argv, 60000);
31
32
31
    ToxNode *alice = tox_scenario_add_node(s, "Alice", alice_script, nullptr, 0);
33
31
    ToxNode *bob = tox_scenario_add_node(s, "Bob", bob_script, nullptr, 0);
34
35
31
    tox_node_bootstrap(alice, bob);
36
31
    tox_node_friend_add(alice, bob);
37
31
    tox_node_friend_add(bob, alice);
38
39
31
    ToxScenarioStatus res = tox_scenario_run(s);
40
31
    if (res != TOX_SCENARIO_DONE) {
41
0
        return 1;
42
0
    }
43
44
31
    tox_scenario_free(s);
45
31
    return 0;
46
31
}