summaryrefslogtreecommitdiff
path: root/auto_tests
diff options
context:
space:
mode:
authoriphydf <iphydf@users.noreply.github.com>2018-06-17 23:50:54 +0000
committeriphydf <iphydf@users.noreply.github.com>2018-06-18 19:25:30 +0000
commit3a85d88fb1de0a14054d9aaefa5457f0e81a7a6d (patch)
treed928eca2eda902348639592e347adaa2261c7895 /auto_tests
parent90e1d969acfc5d6c3e8b2261e11e1acd0c2fb596 (diff)
Remove resource_leak_test.
This test has never caught a bug. It's better to catch these with asan or the likes.
Diffstat (limited to 'auto_tests')
-rw-r--r--auto_tests/monolith_test.cpp5
-rw-r--r--auto_tests/resource_leak_test.c64
2 files changed, 0 insertions, 69 deletions
diff --git a/auto_tests/monolith_test.cpp b/auto_tests/monolith_test.cpp
index 853c88ec..44a5b16b 100644
--- a/auto_tests/monolith_test.cpp
+++ b/auto_tests/monolith_test.cpp
@@ -95,11 +95,6 @@ namespace onion_test
95int main(void); 95int main(void);
96#include "onion_test.c" 96#include "onion_test.c"
97} 97}
98namespace resource_leak_test
99{
100int main(void);
101#include "resource_leak_test.c"
102}
103namespace save_friend_test 98namespace save_friend_test
104{ 99{
105int main(void); 100int main(void);
diff --git a/auto_tests/resource_leak_test.c b/auto_tests/resource_leak_test.c
deleted file mode 100644
index 55998b72..00000000
--- a/auto_tests/resource_leak_test.c
+++ /dev/null
@@ -1,64 +0,0 @@
1#if defined(__AIX__)
2#define _XOPEN_SOURCE 1
3#endif
4
5#include "helpers.h"
6
7// See man 2 sbrk.
8#if defined(_BSD_SOURCE) || defined(_SVID_SOURCE) || \
9 defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500 || defined(_XOPEN_SOURCE_EXTENDED)) && \
10 !(defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600)
11#define HAVE_SBRK 1
12#else
13#define HAVE_SBRK 0
14#endif
15
16#if HAVE_SBRK
17#include <assert.h>
18#include <unistd.h>
19#endif
20
21#define ITERATIONS 20000
22
23int main(void)
24{
25 setvbuf(stdout, nullptr, _IONBF, 0);
26
27 puts("Warming up: creating/deleting 10 tox instances");
28
29 // Warm-up.
30 for (int i = 0; i < 10; i++) {
31 Tox *tox = tox_new(nullptr, nullptr);
32 tox_iterate(tox, nullptr);
33 tox_kill(tox);
34 }
35
36#if HAVE_SBRK
37 // Low water mark.
38 char *hwm = (char *)sbrk(0);
39#endif
40 printf("Creating/deleting %d tox instances\n", ITERATIONS);
41
42 int allocated = 0;
43
44 for (int i = 0; i < ITERATIONS; i++) {
45 Tox *tox = tox_new(nullptr, nullptr);
46
47 if (tox != nullptr) {
48 tox_iterate(tox, nullptr);
49 tox_kill(tox);
50 allocated++;
51 }
52
53#if HAVE_SBRK
54 char *next_hwm = (char *)sbrk(0);
55 assert(hwm == next_hwm);
56#endif
57 }
58
59 assert(allocated >= ITERATIONS / 2);
60 printf("Success: no resource leaks detected in %d tox_new calls (tried %d)\n",
61 allocated, ITERATIONS);
62
63 return 0;
64}