summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.travis.yml3
-rw-r--r--auto_tests/messenger_test.c23
2 files changed, 21 insertions, 5 deletions
diff --git a/.travis.yml b/.travis.yml
index a1a17f61..68771df9 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -23,6 +23,8 @@ before_script:
23 - sudo ldconfig 23 - sudo ldconfig
24# installing sphinx, needed for documentation 24# installing sphinx, needed for documentation
25 - sudo apt-get install python-sphinx 25 - sudo apt-get install python-sphinx
26# installing check, needed for unit tests
27 - sudo apt-get install check
26 28
27script: 29script:
28 - mkdir build && cd build 30 - mkdir build && cd build
@@ -30,6 +32,7 @@ script:
30 - make -j3 32 - make -j3
31# build docs separately 33# build docs separately
32 - make docs 34 - make docs
35 - cd ../auto_tests/ && ./run_tests
33 36
34notifications: 37notifications:
35 email: false 38 email: false
diff --git a/auto_tests/messenger_test.c b/auto_tests/messenger_test.c
index 42c14fa6..deed498f 100644
--- a/auto_tests/messenger_test.c
+++ b/auto_tests/messenger_test.c
@@ -25,7 +25,7 @@ char *friend_id_str = "1145e295b0fbdc9330d5d74ec204a8bf23c315106040b4035d0d358d0
25char *good_id_a_str = "DB9B569D14850ED8364C3744CAC2C8FF78985D213E980C7C508D0E91E8E45441"; 25char *good_id_a_str = "DB9B569D14850ED8364C3744CAC2C8FF78985D213E980C7C508D0E91E8E45441";
26char *good_id_b_str = "d3f14b6d384d8f5f2a66cff637e69f28f539c5de61bc29744785291fa4ef4d64"; 26char *good_id_b_str = "d3f14b6d384d8f5f2a66cff637e69f28f539c5de61bc29744785291fa4ef4d64";
27 27
28char *bad_id_str = "THIS_IS_A_BAD_IDTHIS_IS_A_BAD_IDTHIS_IS_A_BAD_IDTHIS_IS_A_BAD_ID"; 28char *bad_id_str = "9B569D14ff637e69f2";
29 29
30unsigned char *friend_id = NULL; 30unsigned char *friend_id = NULL;
31unsigned char *good_id_a = NULL; 31unsigned char *good_id_a = NULL;
@@ -69,8 +69,11 @@ START_TEST(test_m_get_userstatus_size)
69 REALLY_BIG_NUMBER); 69 REALLY_BIG_NUMBER);
70 rc = m_get_userstatus_size(friend_id_num); 70 rc = m_get_userstatus_size(friend_id_num);
71 71
72 /* this WILL error if the original m_addfriend_norequest() failed */
72 ck_assert_msg((rc > 0 && rc <= MAX_USERSTATUS_LENGTH), 73 ck_assert_msg((rc > 0 && rc <= MAX_USERSTATUS_LENGTH),
73 "m_get_userstatus_size is returning out of range values!\n"); 74 "m_get_userstatus_size is returning out of range values!\n"
75 "(this can be caused by the error of m_addfriend_norequest"
76 " in the beginning of the suite)\n");
74} 77}
75END_TEST 78END_TEST
76 79
@@ -126,8 +129,11 @@ START_TEST(test_m_addfriend)
126 if(m_addfriend((uint8_t *)friend_id, (uint8_t *)good_data, really_bad_len) != FAERR_TOOLONG) 129 if(m_addfriend((uint8_t *)friend_id, (uint8_t *)good_data, really_bad_len) != FAERR_TOOLONG)
127 ck_abort_msg("m_addfriend did NOT catch the following length: %d\n", really_bad_len); 130 ck_abort_msg("m_addfriend did NOT catch the following length: %d\n", really_bad_len);
128 131
132 /* this will error if the original m_addfriend_norequest() failed */
129 if(m_addfriend((uint8_t *)friend_id, (uint8_t *)good_data, good_len) != FAERR_ALREADYSENT) 133 if(m_addfriend((uint8_t *)friend_id, (uint8_t *)good_data, good_len) != FAERR_ALREADYSENT)
130 ck_abort_msg("m_addfriend did NOT catch adding a friend we already have.\n"); 134 ck_abort_msg("m_addfriend did NOT catch adding a friend we already have.\n"
135 "(this can be caused by the error of m_addfriend_norequest in"
136 " the beginning of the suite)\n");
131 137
132 if(m_addfriend((uint8_t *)good_id_b, (uint8_t *)bad_data, bad_len) != FAERR_NOMESSAGE) 138 if(m_addfriend((uint8_t *)good_id_b, (uint8_t *)bad_data, bad_len) != FAERR_NOMESSAGE)
133 ck_abort_msg("m_addfriend did NOT catch the following length: %d\n", bad_len); 139 ck_abort_msg("m_addfriend did NOT catch the following length: %d\n", bad_len);
@@ -250,8 +256,15 @@ int main(int argc, char *argv[])
250 bad_id = hex_string_to_bin(bad_id_str); 256 bad_id = hex_string_to_bin(bad_id_str);
251 257
252 /* setup a default friend and friendnum */ 258 /* setup a default friend and friendnum */
253 m_addfriend_norequest((uint8_t *)friend_id); 259 if(m_addfriend_norequest((uint8_t *)friend_id) < 0)
254 friend_id_num = getfriend_id((uint8_t *)friend_id); 260 fputs("m_addfriend_norequest() failed on a valid ID!\n"
261 "this was CRITICAL to the test, and the build WILL fail.\n"
262 "the tests will continue now...\n\n", stderr);
263
264 if((friend_id_num = getfriend_id((uint8_t *)friend_id)) < 0)
265 fputs("getfriend_id() failed on a valid ID!\n"
266 "this was CRITICAL to the test, and the build WILL fail.\n"
267 "the tests will continue now...\n\n", stderr);
255 268
256 srunner_run_all(test_runner, CK_NORMAL); 269 srunner_run_all(test_runner, CK_NORMAL);
257 number_failed = srunner_ntests_failed(test_runner); 270 number_failed = srunner_ntests_failed(test_runner);