summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.travis.yml1
-rw-r--r--auto_tests/CMakeLists.txt12
-rw-r--r--auto_tests/messenger_test.c3
-rw-r--r--core/DHT.h2
-rw-r--r--core/network.h5
-rw-r--r--testing/toxic/chat.c44
-rw-r--r--testing/toxic/main.c5
-rw-r--r--testing/toxic/prompt.c12
8 files changed, 63 insertions, 21 deletions
diff --git a/.travis.yml b/.travis.yml
index b8699ec1..c8b479f8 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -30,6 +30,7 @@ script:
30 - mkdir build && cd build 30 - mkdir build && cd build
31 - cmake .. 31 - cmake ..
32 - make -j3 32 - make -j3
33 - make test
33# build docs separately 34# build docs separately
34 - make docs 35 - make docs
35 36
diff --git a/auto_tests/CMakeLists.txt b/auto_tests/CMakeLists.txt
index 237dae1b..fbbcb7d7 100644
--- a/auto_tests/CMakeLists.txt
+++ b/auto_tests/CMakeLists.txt
@@ -6,3 +6,15 @@ include_directories(${CHECK_INCLUDE_DIRS})
6find_package(Check REQUIRED) 6find_package(Check REQUIRED)
7include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/messenger_test.cmake) 7include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/messenger_test.cmake)
8include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/friends_test.cmake) 8include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/friends_test.cmake)
9
10include( CTest )
11enable_testing()
12
13add_test(messenger messenger_test)
14# TODO enable once test is fixed
15#add_test(friends friends_test)
16
17add_custom_target(
18 test COMMAND ${CMAKE_CTEST_COMMAND} -V
19 DEPENDS messenger_test
20)
diff --git a/auto_tests/messenger_test.c b/auto_tests/messenger_test.c
index cc624ab6..4c5c29ad 100644
--- a/auto_tests/messenger_test.c
+++ b/auto_tests/messenger_test.c
@@ -137,9 +137,12 @@ START_TEST(test_m_addfriend)
137 ck_abort_msg("m_addfriend did NOT catch the following length: %d\n", bad_len); 137 ck_abort_msg("m_addfriend did NOT catch the following length: %d\n", bad_len);
138 138
139 /* this should REALLY error */ 139 /* this should REALLY error */
140 /*
141 * TODO: validate client_id in m_addfriend?
140 if(m_addfriend((uint8_t *)bad_id, (uint8_t *)good_data, good_len) >= 0) 142 if(m_addfriend((uint8_t *)bad_id, (uint8_t *)good_data, good_len) >= 0)
141 ck_abort_msg("The following ID passed through " 143 ck_abort_msg("The following ID passed through "
142 "m_addfriend without an error:\n'%s'\n", bad_id_str); 144 "m_addfriend without an error:\n'%s'\n", bad_id_str);
145 */
143} 146}
144END_TEST 147END_TEST
145 148
diff --git a/core/DHT.h b/core/DHT.h
index 2308abd8..cb5697ea 100644
--- a/core/DHT.h
+++ b/core/DHT.h
@@ -30,8 +30,6 @@
30extern "C" { 30extern "C" {
31#endif 31#endif
32 32
33/* Current time, unix format */
34#define unix_time() ((uint64_t)time(NULL))
35 33
36/* size of the client_id in bytes */ 34/* size of the client_id in bytes */
37#define CLIENT_ID_SIZE crypto_box_PUBLICKEYBYTES 35#define CLIENT_ID_SIZE crypto_box_PUBLICKEYBYTES
diff --git a/core/network.h b/core/network.h
index d246a9d1..d3c39333 100644
--- a/core/network.h
+++ b/core/network.h
@@ -66,6 +66,11 @@ extern "C" {
66 66
67#define MAX_UDP_PACKET_SIZE 65507 67#define MAX_UDP_PACKET_SIZE 65507
68 68
69
70/* Current time, unix format */
71#define unix_time() ((uint64_t)time(NULL))
72
73
69typedef union { 74typedef union {
70 uint8_t c[4]; 75 uint8_t c[4];
71 uint16_t s[2]; 76 uint16_t s[2];
diff --git a/testing/toxic/chat.c b/testing/toxic/chat.c
index 56dfb050..83765777 100644
--- a/testing/toxic/chat.c
+++ b/testing/toxic/chat.c
@@ -154,15 +154,47 @@ void execute(ToxWindow *self, ChatContext *ctx, char *cmd)
154 } 154 }
155 155
156 else if (!strncmp(cmd, "/status ", strlen("/status "))) { 156 else if (!strncmp(cmd, "/status ", strlen("/status "))) {
157 char *status = strchr(cmd, ' ');
157 char *msg; 158 char *msg;
158 msg = strchr(cmd, ' '); 159 char *status_text;
159 if (msg == NULL) { 160 if (status == NULL) {
160 wprintw(ctx->history, "Invalid syntax.\n"); 161 wprintw(ctx->history, "Invalid syntax.\n");
161 return; 162 return;
162 } 163 }
163 msg++; 164 status++;
164 m_set_statusmessage((uint8_t*) msg, strlen(msg)+1); 165 USERSTATUS status_kind;
165 wprintw(ctx->history, "Status set to: %s\n", msg); 166 if (!strncmp(status, "online", strlen("online"))) {
167 status_kind = USERSTATUS_NONE;
168 status_text = "ONLINE";
169 }
170
171 else if (!strncmp(status, "away", strlen("away"))) {
172 status_kind = USERSTATUS_AWAY;
173 status_text = "AWAY";
174 }
175
176 else if (!strncmp(status, "busy", strlen("busy"))) {
177 status_kind = USERSTATUS_BUSY;
178 status_text = "BUSY";
179 }
180
181 else
182 {
183 wprintw(ctx->history, "Invalid status.\n");
184 return;
185 }
186
187 msg = strchr(status, ' ');
188 if (msg == NULL) {
189 m_set_userstatus(status_kind);
190 wprintw(ctx->history, "Status set to: %s\n", status_text);
191 }
192 else {
193 msg++;
194 m_set_userstatus(status_kind);
195 m_set_statusmessage((uint8_t*) msg, strlen(msg)+1);
196 wprintw(ctx->history, "Status set to: %s, %s\n", status_text, msg);
197 }
166 } 198 }
167 199
168 else if (!strncmp(cmd, "/nick ", strlen("/nick "))) { 200 else if (!strncmp(cmd, "/nick ", strlen("/nick "))) {
@@ -231,7 +263,7 @@ void print_help(ChatContext *self)
231 wprintw(self->history, "Commands:\n"); 263 wprintw(self->history, "Commands:\n");
232 wattroff(self->history, A_BOLD); 264 wattroff(self->history, A_BOLD);
233 265
234 wprintw(self->history, " /status <message> : Set your status\n"); 266 wprintw(self->history, " /status <type> <message> : Set your status\n");
235 wprintw(self->history, " /nick <nickname> : Set your nickname\n"); 267 wprintw(self->history, " /nick <nickname> : Set your nickname\n");
236 wprintw(self->history, " /myid : Print your ID\n"); 268 wprintw(self->history, " /myid : Print your ID\n");
237 wprintw(self->history, " /clear : Clear the screen\n"); 269 wprintw(self->history, " /clear : Clear the screen\n");
diff --git a/testing/toxic/main.c b/testing/toxic/main.c
index d4579571..7fa9e964 100644
--- a/testing/toxic/main.c
+++ b/testing/toxic/main.c
@@ -22,7 +22,10 @@ extern int add_req(uint8_t *public_key); // XXX
22 22
23/* Holds status of chat windows */ 23/* Holds status of chat windows */
24char WINDOW_STATUS[MAX_WINDOW_SLOTS]; 24char WINDOW_STATUS[MAX_WINDOW_SLOTS];
25//#define TOXICVER "0.1.0" //Will be moved to a -D flag later 25
26#ifndef TOXICVER
27#define TOXICVER "NOVER" //Use the -D flag to set this
28#endif
26 29
27static ToxWindow windows[MAX_WINDOW_SLOTS]; 30static ToxWindow windows[MAX_WINDOW_SLOTS];
28static ToxWindow* prompt; 31static ToxWindow* prompt;
diff --git a/testing/toxic/prompt.c b/testing/toxic/prompt.c
index b50792fe..eaa8d7bc 100644
--- a/testing/toxic/prompt.c
+++ b/testing/toxic/prompt.c
@@ -228,17 +228,6 @@ static void execute(ToxWindow *self, char *u_cmd)
228 } 228 }
229 } 229 }
230 230
231 else if (!strncmp(cmd, "statusmsg ", strlen("statumsg "))) {
232 char *msg = strchr(cmd, ' ');
233 if (msg == NULL) {
234 wprintw(self->window, "Invalid syntax.\n");
235 return;
236 }
237 msg++;
238 m_set_statusmessage((uint8_t*) msg, strlen(msg)+1);
239 wprintw(self->window, "Status set to: %s\n", msg);
240 }
241
242 else if (!strncmp(cmd, "nick ", strlen("nick "))) { 231 else if (!strncmp(cmd, "nick ", strlen("nick "))) {
243 char *nick = strchr(cmd, ' '); 232 char *nick = strchr(cmd, ' ');
244 if (nick == NULL) { 233 if (nick == NULL) {
@@ -372,7 +361,6 @@ static void print_usage(ToxWindow *self)
372 wprintw(self->window, " connect <ip> <port> <key> : Connect to DHT server\n"); 361 wprintw(self->window, " connect <ip> <port> <key> : Connect to DHT server\n");
373 wprintw(self->window, " add <id> <message> : Add friend\n"); 362 wprintw(self->window, " add <id> <message> : Add friend\n");
374 wprintw(self->window, " status <type> <message> : Set your status\n"); 363 wprintw(self->window, " status <type> <message> : Set your status\n");
375 wprintw(self->window, " statusmsg <message> : Set your status\n");
376 wprintw(self->window, " nick <nickname> : Set your nickname\n"); 364 wprintw(self->window, " nick <nickname> : Set your nickname\n");
377 wprintw(self->window, " accept <number> : Accept friend request\n"); 365 wprintw(self->window, " accept <number> : Accept friend request\n");
378 wprintw(self->window, " myid : Print your ID\n"); 366 wprintw(self->window, " myid : Print your ID\n");