Squashed 'external/toxcore/c-toxcore/' changes from e29e185c03..f1df709b87
f1df709b87 feat: add ngc events 1b6c907235 refactor: Make event dispatch ordered by receive time. b7f9367f6f test: Upgrade cppcheck, fix some warnings. 766e62bc89 chore: Use `pkg_search_module` directly in cmake. 00ff078f91 cleanup: Use target_link_libraries directly in cmake. c58928cc89 chore: Add `IMPORTED_TARGET` to pkg-config packages. 895a6af122 cleanup: Remove NaCl support. 41dfb1c1c0 fix: unpack enum function names in event impl generator 447666d1a1 chore: Disable targets for cross-compilation. 572924e924 chore: Build a docker image with coverage info in it. 415cb78f5e cleanup: Some portability/warning fixes for Windows builds. 425216d9ec fix: Correct a use-after-free and fix some memory leaks. 4b1cfa3e08 refactor: Change all enum-like `#define` sequences into enums. d3c2704fa9 chore: Fix make_single_file to support core-only. 0ce46b644e refactor: Change the `TCP_PACKET_*` defines into an enum. 22cd38ad50 adopt event impl generation tool to #2392 f31ea1088a add the event impl generation tool 4e603bb613 refactor: Use `enum-from-int` rule from tokstyle. 19d8f180d6 chore: Update github actions `uses`. 6a895be0c7 test: Make esp32 build actually try to instantiate tox. 65d09c9bfb cleanup: Remove test net support. REVERT: e29e185c03 feat: add ngc events git-subtree-dir: external/toxcore/c-toxcore git-subtree-split: f1df709b8792da4c0e946d826b11df77d565064d
This commit is contained in:
@ -31,31 +31,36 @@ static void handle_events_friend_message(Tox *tox, const Tox_Event_Friend_Messag
|
||||
|
||||
static void dump_events(const char *path, const Tox_Events *events)
|
||||
{
|
||||
if (want_dump_events) {
|
||||
FILE *fh = fopen(path, "w");
|
||||
ck_assert(fh != nullptr);
|
||||
const uint32_t len = tox_events_bytes_size(events);
|
||||
uint8_t *buf = (uint8_t *)malloc(len);
|
||||
ck_assert(buf != nullptr);
|
||||
tox_events_get_bytes(events, buf);
|
||||
fwrite(buf, 1, len, fh);
|
||||
free(buf);
|
||||
fclose(fh);
|
||||
}
|
||||
FILE *fh = fopen(path, "w");
|
||||
ck_assert(fh != nullptr);
|
||||
const uint32_t len = tox_events_bytes_size(events);
|
||||
uint8_t *buf = (uint8_t *)malloc(len);
|
||||
ck_assert(buf != nullptr);
|
||||
ck_assert(tox_events_get_bytes(events, buf));
|
||||
fwrite(buf, 1, len, fh);
|
||||
free(buf);
|
||||
fclose(fh);
|
||||
}
|
||||
|
||||
static void print_events(const Tox_System *sys, Tox_Events *events)
|
||||
{
|
||||
const uint32_t size = tox_events_bytes_size(events);
|
||||
|
||||
uint8_t *bytes = (uint8_t *)malloc(size);
|
||||
ck_assert(bytes != nullptr);
|
||||
uint8_t *bytes1 = (uint8_t *)malloc(size);
|
||||
uint8_t *bytes2 = (uint8_t *)malloc(size);
|
||||
ck_assert(bytes1 != nullptr);
|
||||
ck_assert(bytes2 != nullptr);
|
||||
|
||||
tox_events_get_bytes(events, bytes);
|
||||
ck_assert(tox_events_get_bytes(events, bytes1));
|
||||
ck_assert(tox_events_get_bytes(events, bytes2));
|
||||
|
||||
Tox_Events *events_copy = tox_events_load(sys, bytes, size);
|
||||
// Make sure get_bytes is deterministic.
|
||||
ck_assert(memcmp(bytes1, bytes2, size) == 0);
|
||||
|
||||
Tox_Events *events_copy = tox_events_load(sys, bytes1, size);
|
||||
ck_assert(events_copy != nullptr);
|
||||
free(bytes);
|
||||
free(bytes1);
|
||||
free(bytes2);
|
||||
|
||||
ck_assert(tox_events_equal(sys, events, events_copy));
|
||||
|
||||
@ -73,7 +78,9 @@ static bool await_message(Tox **toxes, const Tox_Dispatch *dispatch)
|
||||
// Check if tox 2 got the message from tox 1.
|
||||
Tox_Events *events = tox_events_iterate(toxes[1], false, nullptr);
|
||||
|
||||
dump_events("/tmp/test.mp", events);
|
||||
if (want_dump_events) {
|
||||
dump_events("/tmp/test.mp", events);
|
||||
}
|
||||
|
||||
bool success = false;
|
||||
tox_dispatch_invoke(dispatch, events, toxes[1], &success);
|
||||
@ -164,13 +171,13 @@ static void test_tox_events(void)
|
||||
static void fake_test_unpack(void)
|
||||
{
|
||||
// TODO(Green-Sky): add proper unpack tests and/or implement ngc events
|
||||
(void)tox_unpack_group_privacy_state;
|
||||
(void)tox_unpack_group_privacy_state;
|
||||
(void)tox_unpack_group_voice_state;
|
||||
(void)tox_unpack_group_topic_lock;
|
||||
(void)tox_unpack_group_join_fail;
|
||||
(void)tox_unpack_group_mod_event;
|
||||
(void)tox_unpack_group_exit_type;
|
||||
(void)tox_group_privacy_state_unpack;
|
||||
(void)tox_group_privacy_state_unpack;
|
||||
(void)tox_group_voice_state_unpack;
|
||||
(void)tox_group_topic_lock_unpack;
|
||||
(void)tox_group_join_fail_unpack;
|
||||
(void)tox_group_mod_event_unpack;
|
||||
(void)tox_group_exit_type_unpack;
|
||||
}
|
||||
|
||||
int main(void)
|
||||
|
Reference in New Issue
Block a user