Commit Graph

499 Commits

Author SHA1 Message Date
iphydf
37d4a0b2ca
Avoid the use of rand() in tests.
We control the random functions in crypto_core, so we can make them
deterministic more easily. This will help test reproducibility in the
future.
2018-04-03 17:43:22 +00:00
iphydf
9706d9a0f0
Disallow stderr logger by default. 2018-03-17 15:04:03 +00:00
iphydf
a2496af71a
Add logging to the onion_test.
Makes debugging easier.
2018-03-17 15:04:03 +00:00
iphydf
aa05095419
Remove the use of the 'hh' format specifier.
It's not supported in mingw.

See https://github.com/TokTok/c-toxcore/issues/786.
2018-03-16 01:57:26 +00:00
iphydf
bd62d11860
Make file transfers 50% faster.
By increasing a magic number.. Also, added more verbose logging to the
file transfer test.
2018-03-02 13:56:49 +00:00
iphydf
1282ef5741
Remove deprecated conference namelist change callback. 2018-02-27 04:30:37 +00:00
iphydf
1334d16517
Fix auto_tests to stop using the deprecated conference API. 2018-02-27 04:30:37 +00:00
iphydf
d3b286cb43
Fix a bunch of compiler warnings and remove suppressions. 2018-02-24 22:20:22 +00:00
iphydf
b2a2a0bbc7
Link all tests to the android cpufeatures library if available.
This is needed for libvpx to work on android.

This also means that we can upload our test binaries to an android device
and actually run them, now that libcheck is no longer a blocker.
2018-02-23 01:05:00 +00:00
iphydf
95c03e0e85
Make the "persistent conference" callback changes new functions.
We can now revert the changes to the callbacks and keep supporting them
until clients have moved off them.
2018-02-20 21:36:05 +00:00
iphydf
097f41f264
Make some sizeof tests linux-only.
net_crypto has pthread types in its struct, so its size is system
dependent. In particular, the sizes are wrong on FreeBSD.
2018-02-19 13:35:41 +00:00
Robin Lindén
ec8b911d7c
Increase range of ports available to Toxes during tests 2018-02-18 23:59:22 +00:00
iphydf
3dc8cf6df8
Disable lan discovery in most tests. 2018-02-18 21:32:28 +00:00
iphydf
d016eb3f0e
Remove tox_test from autotools build. 2018-02-18 17:17:28 +00:00
Robin Lindén
c3515c49e0
Split up tox_test into multiple smaller tests 2018-02-18 14:50:18 +00:00
iphydf
83f7beacc5
Don't print trace level logging in tests. 2018-02-18 14:09:42 +00:00
iphydf
746c624a09
Add static asserts for all the struct sizes in toxcore.
This forces us to record size changes (for LP64) and helps estimate
memory consumption of internal data structures.
2018-02-17 17:08:37 +00:00
zoff99
82662d4e16
Make outgoing Filetransfers round-robin.
Instead of 1 FT blocking all others.
2018-02-17 16:32:25 +00:00
iphydf
35f13ef51d
Get rid of the only GNU extension we used. 2018-02-14 20:51:55 +00:00
iphydf
6cd4fcdec4
Remove libcheck from the dependencies.
We're not gaining much from this library, and it's a burden, especially
for windows development.
2018-02-09 20:51:39 +00:00
iphydf
8a0e98bab8
Fix LAN discovery on FreeBSD.
Also, add an auto-test for bootstrap and for LAN discovery.

Bootstrap is never tested otherwise, and LAN discovery is a prerequisite
for everything else. Having these two tests lets us rule out or identify
LAN discovery as a possible cause for test failures.
2018-02-08 14:57:34 +00:00
iphydf
835b9fbdc9
Improve stability of crypto_memcmp test.
Also reduce number of people in conference to 5, because on Circle CI the
test times out trying to connect more than 6 or 7 people. The persistent
conferences PR will improve this so we can set it much higher then.
2018-02-06 20:21:27 +00:00
iphydf
feaefbcbb3
Format .cpp files with format-source. 2018-02-06 13:44:03 +00:00
iphydf
d9413d5576
Improve conference test stability. 2018-02-01 14:58:00 +00:00
iphydf
92ffad1a72
Use nullptr as NULL pointer constant instead of NULL or 0.
This changes only code, no string literals or comments.
2018-01-30 23:35:50 +00:00
iphydf
6e0ac337c9
Avoid clashes with "build" directories on case-insensitive file systems. 2018-01-28 15:17:34 +00:00
xhe
651ef3adb6
Make audio/video bit rates "properties"
follow TokTok#731. This commit
completely removed all things in namespace bit_rate, and deprecated
functions are to be added back in another commit. set_xxx() is treadted
as a property of namespace audio&video, same as bit_rate change event.

toxav_basic_test is fixed, either.
2018-01-28 13:21:57 +00:00
iphydf
9c03439ad0
Fix out of bounds read in error case in messenger_test.
Also got rid of two VLAs. They are overused a bit in toxcore. In
irc_syncbot, the array was uninitialised and then filled by a recv system
call. This can cause uninitialised reads if recv doesn't fill the entire
array. It could not cause out of bounds read directly, because a
NUL-terminator was in place, but both cases are undefined behaviour.
2018-01-26 01:30:06 +00:00
xhe
0becafd272
Split bit_rate_set(), one for audio, one for video.
Fixes #572.

As discussed in the issue, there's a risk that toxcore may not hold the
maximum bitrates libvpx supports, if toxcore insists on using integer
type. I initially proposed to have another flag in set(), so that we can
use unsigned type instead. iphydf came up with a better solution, that is
splitting the original functions, one for audio, one for video. Now, we
could safely replace int32_t with uint32_t.

Also: clean video_bit_rate_invalid()

Though this is not a part of issue #572, as it's used in the
toxav_bit_rate_set(), i cleaned the code. As mannol said, there should be
a check. Uint32_t is large enough to hold the maximum bitrates libvpx
supports, but user may pass a value larger than uint while smaller than
uint32_t. Thanks to the reminding from nurupo, it's no longer a stub
function.

Bitrate error enums are shared for both audio and video
https://github.com/TokTok/c-toxcore/pull/578#issuecomment-360095609, just
as iphydf said.
2018-01-25 14:29:01 +00:00
iphydf
033965b8cc
Make the monolith test a C++ binary.
This way, developers compile toxcore, toxav, and toxencryptsave as C++ at
least once at home, reducing the likelyhood of running into travis
failures where we compile as C++ in the windows build.
2018-01-21 20:56:30 +00:00
iphydf
52778aed93
Make BUILD files more finely-grained.
This allows us to precisely see which libraries depend on which and lets
us split them up more, if necessary.
2018-01-21 19:44:09 +00:00
iphydf
822dd2fac2
Don't allocate or dereference Tox_Options in tests.
This struct will soon become opaque.
2018-01-21 00:14:43 +00:00
iphydf
b030b4d8c0
Fix log message in simple_conference_test: invite -> message. 2018-01-20 13:25:58 +00:00
iphydf
7c2e4dd403
Add a simple conference test with 3 friends.
This tests that a message from tox1 is relayed via tox2 to tox3 when tox1
and tox3 are not friends.
2018-01-20 12:22:52 +00:00
iphydf
25d3001556
Use larger arrays in crypto timing tests.
Increasing from 256K to 1M and increasing the number of iterations from
1000 to 2000. This makes the test more accurate and less flaky.
2018-01-19 18:15:17 +00:00
iphydf
0a5be3cbc5
Use C99 standard in bazel builds. 2018-01-18 21:52:31 +00:00
iphydf
18a33169b8
Add bazel build scripts for c-toxcore.
This allows us and users to reproducibly build verified versions of the
library with checksums. It will power the toktok-stack continuous build
with checked-in checksums at specific git revisions.
2018-01-18 16:11:52 +00:00
iphydf
643eea60bb
Make DHT a module-private type. 2018-01-16 20:06:07 +00:00
iphydf
22db2b9fe5
Make Net_Crypto a module-private type. 2018-01-16 15:46:13 +00:00
iphydf
1eea3f0ab6
Fix some memory or file descriptor leaks in test code.
Also some missing return value checks for `fopen`.
2018-01-14 19:15:28 +00:00
iphydf
bacd74c4dd
Make TCP_Client_Connection a module-private type. 2018-01-14 19:13:32 +00:00
iphydf
c28d362dd2
Make Onion_Client a module-private type. 2018-01-14 16:20:43 +00:00
iphydf
4b54d14d9c
Make Onion_Announce a module-private type. 2018-01-14 14:20:20 +00:00
iphydf
c38d3de604
Filter out annoying log statements in unit tests.
These may be useful when debugging toxcore locally, but are not useful in
unit tests.
2018-01-14 10:52:13 +00:00
yangfl
449c3f12cc Fix some typos in code and cmake comments 2018-01-12 21:22:44 +08:00
iphydf
2fbed5b4c5
Move Networking_Core struct into the .c file.
To make it an abstract type everywhere except in network.c.
2018-01-11 11:59:14 +00:00
iphydf
54ec162558
Fix formatting in some C files.
Also replace &(x) with &x for consistency.
2018-01-10 18:57:37 +00:00
iphydf
d26f0eb3bc
Change toxencryptsave API to never overwrite pass keys. 2017-12-29 23:24:54 +00:00
Diadlo
998f584b0d
Fix Travis fail on addr_resolve testing 2017-12-12 22:18:00 +01:00
Diadlo
05c35462f3
Fix bootstrap port
Test uses the first node as bootstrap, but the port is hardcoded.
2017-11-20 16:53:21 +03:00
Diadlo
8a8442a30c
Remove upper bound of save size 2017-11-20 16:53:21 +03:00
Diadlo
c506d73d5d
Fix assert for the first port value
Port of the first tox instance will be 33445 only if this port was not
in use during testing
2017-11-20 16:53:19 +03:00
yangfl
2651193b99
Fix typo 2017-11-19 23:52:23 +01:00
Diadlo
4d94a07d25
Add workaround for conference test 2017-11-15 21:36:22 +03:00
Diadlo
dd50da48f3
Don't use IPv6 in test if it's unsupported 2017-11-15 15:57:07 +03:00
Diadlo
d037f93811
Fix IPv4 and IPv6 loopbacks 2017-11-15 15:21:39 +03:00
Diadlo
f084f2c621
Add loopback and broadcast constants 2017-08-24 21:09:40 +03:00
Diadlo
e28d48130f
Add platform independent constants 2017-08-24 20:09:08 +03:00
Diadlo
66b8a7685e
AF_INET -> TOX_AF_INET 2017-08-24 20:09:08 +03:00
Maxim Biro
b02f68bb4b Remove unused variable 2017-06-06 15:37:02 -04:00
iphydf
cb69b8a986
Build tests on appveyor, the MSVC build.
Tests are not actually ran on appveyor for now, since they all fault for
some reason. For now, we just build them. Also, some tests are disabled
on msvc entirely, because they don't even compile. We'll need to look
into those, later. They are disabled using `MSVC_DONT_BUILD`.
2017-06-05 13:45:20 +00:00
pranomostro
7f5b057b05
Add test for changing the conference title and not receiving a callback. 2017-06-05 12:50:58 +00:00
iphydf
1e8fa85aad
Add a monolith_test that includes all toxcore sources.
This requires that every symbol, even if static (file-scope), is unique.
The idea is that we can easily run "whole" program static analysis on
programs that include monolith.h ("whole" is in quotes, as we don't
include dependencies like libsodium in this static analysis).
2017-06-04 17:48:23 +00:00
pranomostro
03f99bde2e
Test for memberlist not changing after changing own name.
This test shows that the conference members callback is not invoked when
the own name changes.
2017-06-04 13:40:44 +00:00
pranomostro
7ef27a9105 Make variable names in file saving test less cryptic. 2017-05-13 22:59:50 +02:00
Maxim Biro
c25e3d2d7c Revert "initial version of tox_loop"
This reverts commit 200ee1cace.
2017-04-22 15:31:25 -04:00
Maxim Biro
c7f63737eb Revert "Implement tox_loop"
This reverts commit 5ff099763b.
2017-04-22 15:31:25 -04:00
Diadlo
e565523640
Add test for DHT pack_nodes and unpack_nodes 2017-04-13 20:25:19 +00:00
Ansa89
5ff099763b
Implement tox_loop 2017-04-01 17:47:34 +02:00
michael bishop
200ee1cace
initial version of tox_loop 2017-04-01 17:47:34 +02:00
Diadlo
50c526e1a5
Move c_sleep to helpers.h and misc_tools.h
Also fix a mistake with forgotten braces around parameter
2017-03-25 20:40:34 +03:00
Maxim Biro
def92ab029 Add test for tox_strncasecmp() 2017-03-01 20:43:30 -05:00
Diadlo
b19a9e5464
Add part of platform-independent network API implementation
socket      -> net_socket
htons       -> net_htons
htonl       -> net_htonl
connect     -> net_connect
sendto      -> net_sendto_ip4
getaddrinfo -> net_getipport
sa_family_t -> Family
2017-02-26 23:16:16 +03:00
iphydf
6ae33c16cf
Add VLA compatibility macro for C89-ish compilers. 2017-01-28 20:49:12 +00:00
Diadlo
f00006cf1d
Add platform-independent Socket and IP implementation 2017-01-26 23:11:15 +03:00
zugz
b630121f2f reduce thread-unsafe use of static variables
- rework ip_ntoa() to avoid use of static variables
- rework sort_client_list() to avoid use of static variables
- move static 'lastdump' into Messenger struct
- rework ID2String() to avoid use of static variables; rename to id_to_string()
- fetch_broadcast_info(): attempt to mitigate risks from concurrent execution
- current_time_monotonic(): attempt to mitigate risks from concurrent execution
- comment on non-thread-safety of unix_time_update
2017-01-21 22:08:52 +01:00
iphydf
8f96ca6d86
Update license headers and remove redundant file name comment.
"All rights reserved" was incorrect. The project was licensed under GPL3,
which means a lot of rights are licensed to everybody in the world, i.e.
not reserved to the "Tox Project".
2017-01-19 00:01:44 +00:00
iphydf
8f1dbaa2c5
Set up autotools build to build against vanilla NaCl.
Fixes #363.
2017-01-08 15:27:26 +00:00
endoffile78
d41bb3a8d4
Fix issues in crypto_test.c 2017-01-07 11:47:31 -06:00
endoffile78
e667ec23b9
Replace make_quick_sort with qsort 2017-01-07 11:47:30 -06:00
iphydf
3fb683115c
Add logging callback to messenger_test.
So we can see what went wrong if it fails.
2017-01-06 23:25:46 +00:00
David Zero
8ef1f35ca7 Revert "Revert "Portability fixes""
This reverts commit 59e2a844f0, and
defines _DARWIN_C_SOURCE in toxcore/network.c
2017-01-06 04:20:00 -08:00
endoffile78
59e2a844f0 Revert "Portability fixes"
This reverts commit f3469070fe.
2017-01-05 15:16:56 -06:00
David Zero
f3469070fe Portability fixes
- CFLAG gnu99 was changed to c99.
- CXXFLAG c++98 was changed to c++11.
- CFLAG -pedantic-errors was added so that non-ISO C now throws errors.
- _XOPEN_SOURCE feature test macro added and set to 600 to expose SUSv3
  and c99 definitions in modules that required them.
- Fixed tests (and bootstrap daemon logging) that were failing due to
  the altered build flags.
- Avoid string suffix misinterpretation; explicit narrowing conversion.
- Misc. additions to .gitignore to make sure build artifacts don't wind
  up in version control.
2017-01-04 13:44:39 -08:00
Diadlo
b99e99f5d9
Add tests to secure memcmp and memzero functions. 2017-01-04 01:34:20 +03:00
iphydf
ce49e88d33
avoid dereferencing Tox_Options 2016-12-23 00:26:46 +00:00
iphydf
1c20e9f76b
Remove tox_options_copy. 2016-12-22 20:42:47 +00:00
iphydf
db71602731
Use tox_options_set_* instead of direct member access.
Also added a `tox_options_copy` function for cloning an options object.
This can be useful when creating several Tox instances with slightly
varying options.
2016-12-22 10:53:39 +00:00
iphydf
2328cb74ab
Improve documentation of crypto_core. 2016-12-22 10:26:59 +00:00
iphydf
ce29c8e7ec
Wrap all sodium/nacl functions in crypto_core.c. 2016-12-22 10:26:59 +00:00
iphydf
de623f9eb9
Add test to check if tox_new/tox_kill leaks.
We create and destroy 20k tox instances and run a single tox_iterate on
it. This test is not comprehensive, but provides a simple check to see
whether the destruction properly cleans up memory and perhaps other
resources.
2016-12-20 20:27:51 +00:00
pranomostro
1a1529c2c5
Add test for obtaining savedata, writing it to a file, reading it again and checking if it was read correctly. 2016-12-16 04:35:25 +00:00
pchk
22fca79ad7
Fixed attempt to join detached threads 2016-12-14 10:40:54 +00:00
iphydf
4cf69996cc
Add apidsl file for toxencryptsave.
This breaks the toxencryptsave API. It hides the Tox_Pass_Key struct
definition.
2016-12-13 14:24:40 +00:00
sudden6
3cfe5544b1
Fix version compatibility test.
Also added some test cases for it.
2016-12-13 02:06:25 +00:00
Robin Lindén
029c4fb83f Fix padding in SAVED_FRIEND struct and add test.
Test covers saving and loading of a Tox instance with a friend added.
2016-12-13 01:36:28 +01:00
iphydf
c8d7cf5002
Fix off by one error in saving our own status message. 2016-12-10 15:22:06 +00:00
Gregory Mullen (grayhatter)
ad517eb1df
add NAT hole punching level to Tox API 2016-11-24 17:38:34 -08:00
Robin Lindén
6e1a01bd16 Made saveformat platform-independent.
Fixes #215.
2016-11-21 00:28:33 +00:00
endoffile78
8899b69b40
Add DHT_create_packet 2016-11-11 15:53:04 -06:00