diff options
author | iphydf <iphydf@users.noreply.github.com> | 2018-06-19 20:54:21 +0000 |
---|---|---|
committer | iphydf <iphydf@users.noreply.github.com> | 2018-06-19 21:00:26 +0000 |
commit | 2296d07e0963bcf4e0a13db51c6d11b294f941ab (patch) | |
tree | 51ee0fd377f3fb5f20317f12d69f40cacb0caa53 /auto_tests/conference_two_test.c | |
parent | 3a85d88fb1de0a14054d9aaefa5457f0e81a7a6d (diff) |
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.
Diffstat (limited to 'auto_tests/conference_two_test.c')
-rw-r--r-- | auto_tests/conference_two_test.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/auto_tests/conference_two_test.c b/auto_tests/conference_two_test.c new file mode 100644 index 00000000..c3036165 --- /dev/null +++ b/auto_tests/conference_two_test.c | |||
@@ -0,0 +1,30 @@ | |||
1 | // This test checks that we can create two conferences and quit properly. | ||
2 | // | ||
3 | // This test triggers a different code path than if we only allocate a single | ||
4 | // conference. This is the simplest test possible that triggers it. | ||
5 | #ifndef _XOPEN_SOURCE | ||
6 | #define _XOPEN_SOURCE 600 | ||
7 | #endif | ||
8 | |||
9 | #include "../toxcore/tox.h" | ||
10 | |||
11 | #include "check_compat.h" | ||
12 | #include "helpers.h" | ||
13 | |||
14 | int main(void) | ||
15 | { | ||
16 | // Create toxes. | ||
17 | uint32_t id = 1; | ||
18 | Tox *tox1 = tox_new_log(nullptr, nullptr, &id); | ||
19 | |||
20 | // Create two conferences and then exit. | ||
21 | TOX_ERR_CONFERENCE_NEW err; | ||
22 | tox_conference_new(tox1, &err); | ||
23 | ck_assert_msg(err == TOX_ERR_CONFERENCE_NEW_OK, "failed to create conference 1: %d", err); | ||
24 | tox_conference_new(tox1, &err); | ||
25 | ck_assert_msg(err == TOX_ERR_CONFERENCE_NEW_OK, "failed to create conference 2: %d", err); | ||
26 | |||
27 | tox_kill(tox1); | ||
28 | |||
29 | return 0; | ||
30 | } | ||