diff options
Diffstat (limited to 'testing')
-rw-r--r-- | testing/CMakeLists.txt | 1 | ||||
-rw-r--r-- | testing/Messenger_test.c | 3 | ||||
-rw-r--r-- | testing/cmake/timer_test.cmake | 9 | ||||
-rw-r--r-- | testing/timer_test.c | 68 |
4 files changed, 2 insertions, 79 deletions
diff --git a/testing/CMakeLists.txt b/testing/CMakeLists.txt index 9e07135c..e3cdc838 100644 --- a/testing/CMakeLists.txt +++ b/testing/CMakeLists.txt | |||
@@ -9,7 +9,6 @@ include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/Lossless_UDP_testclient.cmake) | |||
9 | include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/Lossless_UDP_testserver.cmake) | 9 | include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/Lossless_UDP_testserver.cmake) |
10 | include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/Messenger_test.cmake) | 10 | include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/Messenger_test.cmake) |
11 | include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/crypto_speed_test.cmake) | 11 | include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/crypto_speed_test.cmake) |
12 | include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/timer_test.cmake) | ||
13 | 12 | ||
14 | if(WIN32) | 13 | if(WIN32) |
15 | # include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/nTox_win32.cmake) | 14 | # include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/nTox_win32.cmake) |
diff --git a/testing/Messenger_test.c b/testing/Messenger_test.c index f8685b39..c76584d7 100644 --- a/testing/Messenger_test.c +++ b/testing/Messenger_test.c | |||
@@ -48,6 +48,7 @@ | |||
48 | #include <unistd.h> | 48 | #include <unistd.h> |
49 | #include <arpa/inet.h> | 49 | #include <arpa/inet.h> |
50 | #define c_sleep(x) usleep(1000*x) | 50 | #define c_sleep(x) usleep(1000*x) |
51 | #define PORT 33445 | ||
51 | 52 | ||
52 | #endif | 53 | #endif |
53 | 54 | ||
@@ -106,7 +107,7 @@ int main(int argc, char *argv[]) | |||
106 | IP_Port bootstrap_ip_port; | 107 | IP_Port bootstrap_ip_port; |
107 | bootstrap_ip_port.port = htons(atoi(argv[2])); | 108 | bootstrap_ip_port.port = htons(atoi(argv[2])); |
108 | bootstrap_ip_port.ip.i = inet_addr(argv[1]); | 109 | bootstrap_ip_port.ip.i = inet_addr(argv[1]); |
109 | DHT_bootstrap(bootstrap_ip_port, hex_string_to_bin(argv[3])); | 110 | DHT_bootstrap(m->dht, bootstrap_ip_port, hex_string_to_bin(argv[3])); |
110 | } else { | 111 | } else { |
111 | FILE *file = fopen(argv[1], "rb"); | 112 | FILE *file = fopen(argv[1], "rb"); |
112 | 113 | ||
diff --git a/testing/cmake/timer_test.cmake b/testing/cmake/timer_test.cmake deleted file mode 100644 index a5f8c5ec..00000000 --- a/testing/cmake/timer_test.cmake +++ /dev/null | |||
@@ -1,9 +0,0 @@ | |||
1 | cmake_minimum_required(VERSION 2.6.0) | ||
2 | project(timer_test C) | ||
3 | |||
4 | set(exe_name timer_test) | ||
5 | |||
6 | add_executable(${exe_name} | ||
7 | timer_test.c) | ||
8 | |||
9 | linkCoreLibraries(${exe_name}) | ||
diff --git a/testing/timer_test.c b/testing/timer_test.c deleted file mode 100644 index f47d4878..00000000 --- a/testing/timer_test.c +++ /dev/null | |||
@@ -1,68 +0,0 @@ | |||
1 | #include "../core/timer.h" | ||
2 | #include <stdio.h> | ||
3 | |||
4 | #ifdef WINDOWS | ||
5 | #include <windows.h> | ||
6 | #else | ||
7 | #include <unistd.h> | ||
8 | #endif | ||
9 | |||
10 | void mssleep(int ms) | ||
11 | { | ||
12 | #ifdef WINDOWS | ||
13 | Sleep(ms); | ||
14 | #else | ||
15 | usleep(ms * 1000); | ||
16 | #endif | ||
17 | } | ||
18 | |||
19 | int callback(timer *t, void *arg) | ||
20 | { | ||
21 | printf("%s\n", (char *)arg); | ||
22 | return 1; | ||
23 | } | ||
24 | |||
25 | int repeating(timer *t, void *arg) | ||
26 | { | ||
27 | printf("%s\n", (char *)arg); | ||
28 | timer_start(t, 3); | ||
29 | return 0; | ||
30 | } | ||
31 | |||
32 | extern void timer_debug_print(); | ||
33 | |||
34 | int main(int argc, char **argv) | ||
35 | { | ||
36 | timer_init(); | ||
37 | timer_debug_print(); | ||
38 | |||
39 | timer *t = new_timer(); | ||
40 | timer_setup(t, &callback, "Long setup method, 4 seconds"); | ||
41 | timer_start(t, 4); | ||
42 | timer_debug_print(); | ||
43 | |||
44 | timer_single(&repeating, (void *)"This repeats every 3 seconds", 3); | ||
45 | timer_debug_print(); | ||
46 | |||
47 | timer_single(&callback, "Short method, 4 seconds", 4); | ||
48 | timer_debug_print(); | ||
49 | |||
50 | timer_single(&callback, "1 second", 1); | ||
51 | timer_debug_print(); | ||
52 | |||
53 | timer_single(&callback, "15 seconds", 15); | ||
54 | timer_debug_print(); | ||
55 | |||
56 | timer_single(&callback, "10 seconds", 10); | ||
57 | timer_debug_print(); | ||
58 | |||
59 | timer_us(&callback, "100000us", 100000); | ||
60 | timer_us(&callback, "13s", 13 * US_PER_SECOND); | ||
61 | |||
62 | while (true) { | ||
63 | timer_poll(); | ||
64 | mssleep(10); | ||
65 | } | ||
66 | |||
67 | return 0; | ||
68 | } | ||