summaryrefslogtreecommitdiff
path: root/auto_tests
diff options
context:
space:
mode:
authoriphydf <iphydf@users.noreply.github.com>2018-08-25 22:50:26 +0000
committeriphydf <iphydf@users.noreply.github.com>2018-08-25 23:25:15 +0000
commit80f8458146061e5fe6edd97e06e039f1ad2cf3a9 (patch)
tree89502730a4d9f26c15946ce08820bc0abe4f4653 /auto_tests
parent17e8195a8f988a45b2822522bc7b967b3ebc3ca6 (diff)
Run save_compatibility_test in the autotools build.
Diffstat (limited to 'auto_tests')
-rw-r--r--auto_tests/Makefile.inc116
-rw-r--r--auto_tests/save_compatibility_test.c22
2 files changed, 72 insertions, 66 deletions
diff --git a/auto_tests/Makefile.inc b/auto_tests/Makefile.inc
index f9cfae9f..6df92dcd 100644
--- a/auto_tests/Makefile.inc
+++ b/auto_tests/Makefile.inc
@@ -1,70 +1,67 @@
1if BUILD_TESTS 1if BUILD_TESTS
2 2
3TESTS = bootstrap_test \ 3TESTS = \
4 conference_double_invite_test \ 4 bootstrap_test \
5 conference_peer_nick_test \ 5 conference_double_invite_test \
6 conference_simple_test \ 6 conference_peer_nick_test \
7 conference_test \ 7 conference_simple_test \
8 conference_two_test \ 8 conference_test \
9 crypto_test \ 9 conference_two_test \
10 dht_test \ 10 crypto_test \
11 encryptsave_test \ 11 dht_test \
12 file_saving_test \ 12 encryptsave_test \
13 file_transfer_test \ 13 file_saving_test \
14 friend_connection_test \ 14 file_transfer_test \
15 friend_request_test \ 15 friend_connection_test \
16 invalid_tcp_proxy_test \ 16 friend_request_test \
17 invalid_udp_proxy_test \ 17 invalid_tcp_proxy_test \
18 lan_discovery_test \ 18 invalid_udp_proxy_test \
19 lossless_packet_test \ 19 lan_discovery_test \
20 lossy_packet_test \ 20 lossless_packet_test \
21 messenger_test \ 21 lossy_packet_test \
22 network_test \ 22 messenger_test \
23 onion_test \ 23 network_test \
24 overflow_recvq_test \ 24 onion_test \
25 overflow_sendq_test \ 25 overflow_recvq_test \
26 save_friend_test \ 26 overflow_sendq_test \
27 save_load_test \ 27 save_compatibility_test \
28 send_message_test \ 28 save_friend_test \
29 set_name_test \ 29 save_load_test \
30 set_status_message_test \ 30 send_message_test \
31 skeleton_test \ 31 set_name_test \
32 tcp_relay_test \ 32 set_status_message_test \
33 TCP_test \ 33 skeleton_test \
34 tox_many_tcp_test \ 34 tcp_relay_test \
35 tox_many_test \ 35 TCP_test \
36 tox_one_test \ 36 tox_many_tcp_test \
37 tox_strncasecmp_test \ 37 tox_many_test \
38 typing_test \ 38 tox_one_test \
39 version_test 39 tox_strncasecmp_test \
40 40 typing_test \
41# TODO(iphydf): make save_compatibility_test work with travis autotools build. 41 version_test
42# save_compatibility_test
43
44check_PROGRAMS = $(TESTS)
45 42
46AUTOTEST_CFLAGS = \ 43AUTOTEST_CFLAGS = \
47 $(LIBSODIUM_CFLAGS) \ 44 $(LIBSODIUM_CFLAGS) \
48 $(NACL_CFLAGS) 45 $(NACL_CFLAGS)
49 46
50AUTOTEST_LDADD = \ 47AUTOTEST_LDADD = \
51 $(LIBSODIUM_LDFLAGS) \ 48 $(LIBSODIUM_LDFLAGS) \
52 $(NACL_LDFLAGS) \ 49 $(NACL_LDFLAGS) \
53 libmisc_tools.la \ 50 libmisc_tools.la \
54 libtoxcore.la \ 51 libtoxcore.la \
55 libtoxencryptsave.la \ 52 libtoxencryptsave.la \
56 $(LIBSODIUM_LIBS) \ 53 $(LIBSODIUM_LIBS) \
57 $(NACL_OBJECTS) \ 54 $(NACL_OBJECTS) \
58 $(NACL_LIBS) 55 $(NACL_LIBS)
59
60 56
61 57
62if BUILD_AV 58if BUILD_AV
63TESTS += toxav_basic_test toxav_many_test 59TESTS += toxav_basic_test toxav_many_test
64check_PROGRAMS += toxav_basic_test toxav_many_test
65AUTOTEST_LDADD += libtoxav.la 60AUTOTEST_LDADD += libtoxav.la
66endif 61endif
67 62
63check_PROGRAMS = $(TESTS)
64
68bootstrap_test_SOURCES = ../auto_tests/bootstrap_test.c 65bootstrap_test_SOURCES = ../auto_tests/bootstrap_test.c
69bootstrap_test_CFLAGS = $(AUTOTEST_CFLAGS) 66bootstrap_test_CFLAGS = $(AUTOTEST_CFLAGS)
70bootstrap_test_LDADD = $(AUTOTEST_LDADD) 67bootstrap_test_LDADD = $(AUTOTEST_LDADD)
@@ -157,9 +154,9 @@ overflow_sendq_test_SOURCES = ../auto_tests/overflow_sendq_test.c
157overflow_sendq_test_CFLAGS = $(AUTOTEST_CFLAGS) 154overflow_sendq_test_CFLAGS = $(AUTOTEST_CFLAGS)
158overflow_sendq_test_LDADD = $(AUTOTEST_LDADD) 155overflow_sendq_test_LDADD = $(AUTOTEST_LDADD)
159 156
160#save_compatibility_test_SOURCES = ../auto_tests/save_compatibility_test.c 157save_compatibility_test_SOURCES = ../auto_tests/save_compatibility_test.c
161#save_compatibility_test_CFLAGS = $(AUTOTEST_CFLAGS) 158save_compatibility_test_CFLAGS = $(AUTOTEST_CFLAGS)
162#save_compatibility_test_LDADD = $(AUTOTEST_LDADD) 159save_compatibility_test_LDADD = $(AUTOTEST_LDADD)
163 160
164save_friend_test_SOURCES = ../auto_tests/save_friend_test.c 161save_friend_test_SOURCES = ../auto_tests/save_friend_test.c
165save_friend_test_CFLAGS = $(AUTOTEST_CFLAGS) 162save_friend_test_CFLAGS = $(AUTOTEST_CFLAGS)
@@ -232,4 +229,7 @@ endif
232endif 229endif
233 230
234 231
235EXTRA_DIST += $(top_srcdir)/auto_tests/check_compat.h $(top_srcdir)/auto_tests/run_auto_test.h 232EXTRA_DIST += \
233 $(top_srcdir)/auto_tests/data/save.tox \
234 $(top_srcdir)/auto_tests/check_compat.h \
235 $(top_srcdir)/auto_tests/run_auto_test.h
diff --git a/auto_tests/save_compatibility_test.c b/auto_tests/save_compatibility_test.c
index 30e87ef8..216b368c 100644
--- a/auto_tests/save_compatibility_test.c
+++ b/auto_tests/save_compatibility_test.c
@@ -1,9 +1,11 @@
1//Tests to make sure new save code is compatible with old save files 1// Tests to make sure new save code is compatible with old save files
2 2
3#include "../testing/misc_tools.h" 3#include "../testing/misc_tools.h"
4#include "../toxcore/tox.h" 4#include "../toxcore/tox.h"
5#include "check_compat.h" 5#include "check_compat.h"
6 6
7#include <stdio.h>
8#include <stdlib.h>
7#include <string.h> 9#include <string.h>
8 10
9#define LOADED_SAVE_FILE "../auto_tests/data/save.tox" 11#define LOADED_SAVE_FILE "../auto_tests/data/save.tox"
@@ -67,12 +69,12 @@ static uint8_t *read_save(const char *save_path, size_t *length)
67 69
68static void test_save_compatibility(const char *save_path) 70static void test_save_compatibility(const char *save_path)
69{ 71{
70 struct Tox_Options options = { 0 }; 72 struct Tox_Options options = {0};
71 tox_options_default(&options); 73 tox_options_default(&options);
72 74
73 size_t size = 0; 75 size_t size = 0;
74 uint8_t *save_data = read_save(save_path, &size); 76 uint8_t *save_data = read_save(save_path, &size);
75 ck_assert_msg(save_data != nullptr, "Error while reading save file."); 77 ck_assert_msg(save_data != nullptr, "error while reading save file '%s'", save_path);
76 78
77 options.savedata_data = save_data; 79 options.savedata_data = save_data;
78 options.savedata_length = size; 80 options.savedata_length = size;
@@ -109,14 +111,14 @@ static void test_save_compatibility(const char *save_path)
109 "number of friends do not match, expected %d got %zu", EXPECTED_NUM_FRIENDS, num_friends); 111 "number of friends do not match, expected %d got %zu", EXPECTED_NUM_FRIENDS, num_friends);
110 112
111 const uint32_t nospam = tox_self_get_nospam(tox); 113 const uint32_t nospam = tox_self_get_nospam(tox);
112 char nospam_str[(TOX_NOSPAM_SIZE * 2) + 1]; 114 char nospam_str[TOX_NOSPAM_SIZE * 2 + 1];
113 const size_t length = snprintf(nospam_str, sizeof(nospam_str), "%08X", nospam); 115 const size_t length = snprintf(nospam_str, sizeof(nospam_str), "%08X", nospam);
114 nospam_str[length] = '\0'; 116 nospam_str[length] = '\0';
115 ck_assert_msg(strcmp(nospam_str, EXPECTED_NOSPAM) == 0, 117 ck_assert_msg(strcmp(nospam_str, EXPECTED_NOSPAM) == 0,
116 "nospam does not match, expected %s got %s", EXPECTED_NOSPAM, nospam_str); 118 "nospam does not match, expected %s got %s", EXPECTED_NOSPAM, nospam_str);
117 119
118 uint8_t tox_id[TOX_ADDRESS_SIZE]; 120 uint8_t tox_id[TOX_ADDRESS_SIZE];
119 char tox_id_str[TOX_ADDRESS_SIZE * 2]; 121 char tox_id_str[TOX_ADDRESS_SIZE * 2 + 1] = {0};
120 tox_self_get_address(tox, tox_id); 122 tox_self_get_address(tox, tox_id);
121 to_hex(tox_id_str, tox_id, TOX_ADDRESS_SIZE); 123 to_hex(tox_id_str, tox_id, TOX_ADDRESS_SIZE);
122 ck_assert_msg(strncmp(tox_id_str, EXPECTED_TOX_ID, TOX_ADDRESS_SIZE * 2) == 0, 124 ck_assert_msg(strncmp(tox_id_str, EXPECTED_TOX_ID, TOX_ADDRESS_SIZE * 2) == 0,
@@ -127,12 +129,16 @@ static void test_save_compatibility(const char *save_path)
127 129
128int main(int argc, char *argv[]) 130int main(int argc, char *argv[])
129{ 131{
130 setvbuf(stdout, nullptr, _IONBF, 0);
131
132 char base_path[4096]; 132 char base_path[4096];
133 133
134 if (argc <= 1) { 134 if (argc <= 1) {
135 strcpy(base_path, "."); 135 const char *srcdir = getenv("srcdir");
136
137 if (srcdir == nullptr) {
138 srcdir = ".";
139 }
140
141 strcpy(base_path, srcdir);
136 } else { 142 } else {
137 strcpy(base_path, argv[1]); 143 strcpy(base_path, argv[1]);
138 base_path[strrchr(base_path, '/') - base_path] = 0; 144 base_path[strrchr(base_path, '/') - base_path] = 0;