diff options
author | iphydf <iphydf@users.noreply.github.com> | 2018-06-17 23:50:54 +0000 |
---|---|---|
committer | iphydf <iphydf@users.noreply.github.com> | 2018-06-18 19:25:30 +0000 |
commit | 3a85d88fb1de0a14054d9aaefa5457f0e81a7a6d (patch) | |
tree | d928eca2eda902348639592e347adaa2261c7895 | |
parent | 90e1d969acfc5d6c3e8b2261e11e1acd0c2fb596 (diff) |
Remove resource_leak_test.
This test has never caught a bug. It's better to catch these with asan or
the likes.
-rw-r--r-- | CMakeLists.txt | 1 | ||||
-rw-r--r-- | auto_tests/monolith_test.cpp | 5 | ||||
-rw-r--r-- | auto_tests/resource_leak_test.c | 64 |
3 files changed, 0 insertions, 70 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index a12631c9..19dcacff 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt | |||
@@ -509,7 +509,6 @@ auto_test(lossy_packet) | |||
509 | auto_test(messenger MSVC_DONT_BUILD) | 509 | auto_test(messenger MSVC_DONT_BUILD) |
510 | auto_test(network) | 510 | auto_test(network) |
511 | auto_test(onion) | 511 | auto_test(onion) |
512 | auto_test(resource_leak) | ||
513 | auto_test(save_friend) | 512 | auto_test(save_friend) |
514 | auto_test(save_load) | 513 | auto_test(save_load) |
515 | auto_test(send_message) | 514 | auto_test(send_message) |
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 | |||
95 | int main(void); | 95 | int main(void); |
96 | #include "onion_test.c" | 96 | #include "onion_test.c" |
97 | } | 97 | } |
98 | namespace resource_leak_test | ||
99 | { | ||
100 | int main(void); | ||
101 | #include "resource_leak_test.c" | ||
102 | } | ||
103 | namespace save_friend_test | 98 | namespace save_friend_test |
104 | { | 99 | { |
105 | int main(void); | 100 | int 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 | |||
23 | int 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 | } | ||