diff options
author | hugbubby <hugbubby@protonmail.com> | 2018-07-15 20:55:45 -0700 |
---|---|---|
committer | iphydf <iphydf@users.noreply.github.com> | 2018-07-23 15:10:22 +0000 |
commit | c4d58403f966328fb26e062b71adf05842ff3039 (patch) | |
tree | 6fd8129885666eac4595036b424c6b2e9a8439dc /auto_tests/encryptsave_test.c | |
parent | f627a26a7b1c3619ba66f84b87092ff8ba7a95b6 (diff) |
More fixed_width ints and incorporating file_saving_test.c
The file_saving_test.c was not included in the cmake list
and thus was ignored by travis and "make check". I found this
out while introducing ck_assert_msg into the integration test.
Furthermore, removed some variable width integers from encryptsave_test.c,
and the SRunner utilization. Implemmented ck_assert_msg, reorganized some
loops, and removed some longs in file_transfer_test.c.
Diffstat (limited to 'auto_tests/encryptsave_test.c')
-rw-r--r-- | auto_tests/encryptsave_test.c | 48 |
1 files changed, 14 insertions, 34 deletions
diff --git a/auto_tests/encryptsave_test.c b/auto_tests/encryptsave_test.c index 365a9dbb..41a4ed5c 100644 --- a/auto_tests/encryptsave_test.c +++ b/auto_tests/encryptsave_test.c | |||
@@ -40,22 +40,21 @@ static void accept_friend_request(Tox *m, const uint8_t *public_key, const uint8 | |||
40 | } | 40 | } |
41 | } | 41 | } |
42 | 42 | ||
43 | START_TEST(test_known_kdf) | 43 | static void test_known_kdf(void) |
44 | { | 44 | { |
45 | unsigned char out[CRYPTO_SHARED_KEY_SIZE]; | 45 | unsigned char out[CRYPTO_SHARED_KEY_SIZE]; |
46 | int res = crypto_pwhash_scryptsalsa208sha256(out, | 46 | int16_t res = crypto_pwhash_scryptsalsa208sha256(out, |
47 | CRYPTO_SHARED_KEY_SIZE, | 47 | CRYPTO_SHARED_KEY_SIZE, |
48 | pw, | 48 | pw, |
49 | pwlen, | 49 | pwlen, |
50 | test_salt, | 50 | test_salt, |
51 | crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_INTERACTIVE * 8, | 51 | crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_INTERACTIVE * 8, |
52 | crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_INTERACTIVE); | 52 | crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_INTERACTIVE); |
53 | ck_assert_msg(res != -1, "crypto function failed"); | 53 | ck_assert_msg(res != -1, "crypto function failed"); |
54 | ck_assert_msg(memcmp(out, known_key, CRYPTO_SHARED_KEY_SIZE) == 0, "derived key is wrong"); | 54 | ck_assert_msg(memcmp(out, known_key, CRYPTO_SHARED_KEY_SIZE) == 0, "derived key is wrong"); |
55 | } | 55 | } |
56 | END_TEST | ||
57 | 56 | ||
58 | START_TEST(test_save_friend) | 57 | static void test_save_friend(void) |
59 | { | 58 | { |
60 | Tox *tox1 = tox_new_log(nullptr, nullptr, nullptr); | 59 | Tox *tox1 = tox_new_log(nullptr, nullptr, nullptr); |
61 | Tox *tox2 = tox_new_log(nullptr, nullptr, nullptr); | 60 | Tox *tox2 = tox_new_log(nullptr, nullptr, nullptr); |
@@ -137,9 +136,8 @@ START_TEST(test_save_friend) | |||
137 | tox_kill(tox3); | 136 | tox_kill(tox3); |
138 | tox_kill(tox4); | 137 | tox_kill(tox4); |
139 | } | 138 | } |
140 | END_TEST | ||
141 | 139 | ||
142 | START_TEST(test_keys) | 140 | static void test_keys(void) |
143 | { | 141 | { |
144 | TOX_ERR_ENCRYPTION encerr; | 142 | TOX_ERR_ENCRYPTION encerr; |
145 | TOX_ERR_DECRYPTION decerr; | 143 | TOX_ERR_DECRYPTION decerr; |
@@ -188,31 +186,13 @@ START_TEST(test_keys) | |||
188 | tox_pass_key_free(key2); | 186 | tox_pass_key_free(key2); |
189 | tox_pass_key_free(key); | 187 | tox_pass_key_free(key); |
190 | } | 188 | } |
191 | END_TEST | ||
192 | |||
193 | static Suite *encryptsave_suite(void) | ||
194 | { | ||
195 | Suite *s = suite_create("encryptsave"); | ||
196 | |||
197 | DEFTESTCASE_SLOW(known_kdf, 60); | ||
198 | DEFTESTCASE_SLOW(save_friend, 20); | ||
199 | DEFTESTCASE_SLOW(keys, 30); | ||
200 | |||
201 | return s; | ||
202 | } | ||
203 | 189 | ||
204 | int main(void) | 190 | int main(void) |
205 | { | 191 | { |
206 | setvbuf(stdout, nullptr, _IONBF, 0); | 192 | setvbuf(stdout, nullptr, _IONBF, 0); |
193 | test_known_kdf(); | ||
194 | test_save_friend(); | ||
195 | test_keys(); | ||
207 | 196 | ||
208 | Suite *encryptsave = encryptsave_suite(); | 197 | return 0; |
209 | SRunner *test_runner = srunner_create(encryptsave); | ||
210 | |||
211 | int number_failed = 0; | ||
212 | srunner_run_all(test_runner, CK_NORMAL); | ||
213 | number_failed = srunner_ntests_failed(test_runner); | ||
214 | |||
215 | srunner_free(test_runner); | ||
216 | |||
217 | return number_failed; | ||
218 | } | 198 | } |