Add test for creating multiple conferences in one tox.

This triggers a code path in Persistent Group Chats that causes a memory
leak. I'm adding this test now, so that we don't merge PGC without fixing
the memory leak first.
This commit is contained in:
iphydf 2018-06-19 20:54:21 +00:00
parent 3a85d88fb1
commit 2296d07e09
No known key found for this signature in database
GPG Key ID: 3855DBA2D74403C9
3 changed files with 32 additions and 0 deletions

View File

@ -498,6 +498,7 @@ endif()
auto_test(TCP) auto_test(TCP)
auto_test(bootstrap) auto_test(bootstrap)
auto_test(conference) auto_test(conference)
auto_test(conference_two)
auto_test(crypto MSVC_DONT_BUILD) auto_test(crypto MSVC_DONT_BUILD)
auto_test(dht MSVC_DONT_BUILD) auto_test(dht MSVC_DONT_BUILD)
auto_test(encryptsave) auto_test(encryptsave)

View File

@ -5,6 +5,7 @@
#include <stdbool.h> #include <stdbool.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#define START_TEST(name) static void name(void) #define START_TEST(name) static void name(void)
#define END_TEST #define END_TEST

View File

@ -0,0 +1,30 @@
// This test checks that we can create two conferences and quit properly.
//
// This test triggers a different code path than if we only allocate a single
// conference. This is the simplest test possible that triggers it.
#ifndef _XOPEN_SOURCE
#define _XOPEN_SOURCE 600
#endif
#include "../toxcore/tox.h"
#include "check_compat.h"
#include "helpers.h"
int main(void)
{
// Create toxes.
uint32_t id = 1;
Tox *tox1 = tox_new_log(nullptr, nullptr, &id);
// Create two conferences and then exit.
TOX_ERR_CONFERENCE_NEW err;
tox_conference_new(tox1, &err);
ck_assert_msg(err == TOX_ERR_CONFERENCE_NEW_OK, "failed to create conference 1: %d", err);
tox_conference_new(tox1, &err);
ck_assert_msg(err == TOX_ERR_CONFERENCE_NEW_OK, "failed to create conference 2: %d", err);
tox_kill(tox1);
return 0;
}