Commit Graph

632 Commits

Author SHA1 Message Date
jfreegman
5880971af8
Make functions take const pointer to IP_Port wherever possible
An IP_Port is a fairly large data structure, and copying them down
the call stack creates a lot of unnecessary overhead.
2022-02-03 10:54:48 -05:00
iphydf
727982d2f9
fix: Fix bootstrap on emscripten/wasm.
Also added a whole bunch of logging that I needed while debugging the
issue. The solution in the end is that bootstrap needs to resolve IPs,
and getaddrinfo fails in the browser. Most of the time we bootstrap
against IPs anyway, so trying to parse as IP address first will shortcut
that.
2022-02-01 21:00:09 +00:00
Robin Linden
2cfa872818
Add a Bazel Buildifier CI job 2022-01-28 00:55:07 +01:00
jfreegman
d2f98b83c2
Fix some minor issues with autotests
- Do null check on autotox pointer for all public functions
- Reverse argument order: autotoxes -> count instead of opposite
2022-01-26 10:27:41 -05:00
zugz (tox)
1157e4e68c
Separate run_auto_tests into a library 2022-01-25 14:25:36 -05:00
jfreegman
10d59d610b
Refactor autotest live network bootstrapping
- Use one node list and public bootstrap function for all autotests
- Use ifdefs for testnet/mainnet nodes
- Replace a few broken nodes with working ones
2022-01-22 11:24:28 -05:00
iphydf
4ce02c0af9
refactor: Deduplicate a bunch of code in TCP client/server.
Also generally a bit of cleanup and better layering.
2022-01-16 09:41:08 +00:00
iphydf
c7ecee7c15
cleanup: Remove old check Suite compat layer.
This doesn't do anything useful for us. It was there so we don't need to
rewrite the tests (which I just did). Finally this is now cleaned up.
2022-01-16 01:37:37 +00:00
iphydf
6823fcbae1
cleanup: Stop using strerror directly.
We have a more portable wrapper that is now also thread-safe. Also
stopped using sprintf in the one place we used it. This doesn't really
help much, but it allows us to forbid sprintf globally.
2022-01-15 01:25:56 +00:00
jfreegman
62cbd5f667
Add a couple more bootstrap nodes to autotests
A little more redundancy can save a lot of pain debugging non-existent
problems
2022-01-14 14:40:14 -05:00
iphydf
d23222c92f
chore: Run static analysers in multiple variants.
Currently: 1) libsodium and 2) nacl.

Note that the "nacl" variant is actually libsodium. We just want to make
sure the static analysers see the `VANILLA_NACL` code paths.
2022-01-14 10:45:11 +00:00
iphydf
28b5e512a2
fix: Fix toxav_basic_test buffer overflow.
We should pass the number of samples, not the byte size of `PCM`.
2022-01-13 22:36:53 +00:00
iphydf
4a2cb37e4b
fix: Fix some uninitialised memory errors found by valgrind and msan.
Also added a valgrind build to run it on every pull request. I've had to
disable a few tests because valgrind makes those run infinitely slowly,
consistently timing them out.
2022-01-13 20:15:21 +00:00
iphydf
f5f22a5c76
chore: Enable layering check in all c-toxcore build files. 2022-01-12 18:33:13 +00:00
sudden6
d2bf72479c
fix: use correct sample size in toxav_basic_test 2022-01-04 21:12:57 +01:00
jfreegman
e6d671eeab
Add ability for autotests to use TCP connections
This also allows us to set other tox options
2022-01-01 15:43:59 -05:00
zugz (tox)
64a48c0e78
cleanup: Remove hardening code from DHT 2021-12-30 00:00:01 +00:00
iphydf
eb4dc4326a
refactor: Extract some functions from the big run_auto_test function.
This reduces complexity of the single function. Also reduced duplication
a bit.
2021-12-29 00:50:12 +00:00
iphydf
d9ab91970d
cleanup: Remove apidsl for everything except the public API.
Apidsl is not powerful enough to express all the things we need and
doesn't know how `#include` works. The generated headers are more complex
than they should be.
2021-12-15 17:36:29 +00:00
iphydf
f49ea44daa
cleanup: Remove crypto_pwhash import.
Vanilla nacl builds won't have toxencryptsave.
2021-12-15 17:16:35 +00:00
iphydf
6b75f8b889
chore: Remove config.h.
This aligns the autotools build with the cmake build, which doesn't have
a config.h file. It also removes the ambiguity of config.h and
other/bootstrap_daemon/src/config.h.
2021-12-15 10:26:50 +00:00
iphydf
5c1796d3c4
chore: Use docker for the autotools ci build.
This makes it easier to run it locally for testing and ensures the
dockerfile continues to work.
2021-12-14 15:51:51 +00:00
iphydf
5c53e6a30f
chore: Add autotools build; exempt crypto_pwhash from tokstyle. 2021-12-13 18:47:45 +00:00
iphydf
fa359091c7
chore: Minor cleanups of warnings given by cppcheck. 2021-12-09 11:08:03 +00:00
jfreegman
edf9d66717
Add logger to onion and onion announce objects
This will be used in the future
2021-12-07 13:01:15 -05:00
iphydf
cdc0286050
cleanup: Minor fixes in test code.
* Buffer overrun in auto test.
* Resource leak in AFL test code.
2021-12-07 17:13:58 +00:00
iphydf
101e235131
cleanup: Fix last instance of -Wcast-align and enable the warning.
We used to have lots of these in the code, but now that all the endian
stuff is no longer dependent on host byte order, we can re-enable the
warning flag and catch any future violations.
2021-12-07 14:51:31 +00:00
Robin Linden
713ce6108c
Improve Tox creation logging in save_load test 2021-12-06 23:28:53 +01:00
jfreegman
b66165977e
fix issue with save_load autotest
The test explicitly wanted a UDP connection when a TCP connection would suffice. This
was a remnant of back when the test was part of a multi-purpose autotest that
didn't attempt to connect to TCP relays and needed a UDP connection specifically.
2021-11-25 15:32:29 -05:00
Robin Linden
a71ddc7eac
Fix tests involving reading/writing files failing on Windows
The issue was that r and w without the b flag on Windows does LF and CR
translations when reading and writing. Not good for binary files.
2020-11-21 13:02:31 +01:00
iphydf
fe8e0fb8fa
Fix tcp_relay_test by adding a second bootstrap node.
This is a non-hermetic network test. initramfs node is down, so let's
have a second one for redundancy.
2020-05-17 12:41:00 +01:00
iphydf
cc99ecd43a
Stop hard-coding packet IDs in tests. 2020-05-04 02:14:56 +01:00
iphydf
02a5bdc60c
Add logging to TCP and onion client. 2020-05-04 01:27:36 +01:00
iphydf
88b90c8225
Fix a bug in savedata loading when malloc fails.
Also added a bunch of asserts to tests where they don't check allocs.
2020-05-03 14:13:48 +00:00
iphydf
2570ddcb17
Fix errors on error paths found by oomer.
* Use-after-free because we free network before dht in one case.
* Various unchecked allocs in tests (not so important).
* We used to not check whether ping arrays were actually allocated in DHT.
* `ping_kill` and `ping_array_kill` used to crash when passing NULL.

Also:
* Added an assert in all public API functions to ensure tox isn't NULL.
  The error message you get from that is a bit nicer than "Segmentation
  fault" when clients (or our tests) do things wrong.
* Decreased the sleep time in iterate_all_wait from 20ms to 5ms.
  Everything seems to still work with 5ms, and this greatly decreases
  the amount of time spent per test run, making oomer run much faster.
2020-05-02 21:47:08 +01:00
zugz (tox)
8816e50ed7
Skip invalid TCP relays and DHT nodes when loading save data 2020-04-26 00:00:00 +00:00
iphydf
7c0eb5c70b
Enable TCP relay test in Bazel and autotools build.
This test was fixed by @robinlinden, but not enabled in all builds.
2020-04-20 09:28:00 +00:00
Robin Linden
7f9f8045cd
Fix things not being initialized if creating a TCP-only network 2020-04-13 22:43:51 +02:00
iphydf
4b73607b6f
Fixes towards building on MSVC. 2020-03-29 02:56:09 +00:00
iphydf
44e13956ef
Mark conference test as small.
This used to take a long time, but is now very fast.
2020-03-27 14:51:45 +00:00
zugz (tox)
db07bda7f7
Add "member" invite response
This allows invitations to work in the case that the invitee is already
in the group, which can happen if the group becomes split. Such an
invitation is automatically accepted, leading to the peers becoming
connected in the group and sharing peer lists.
2020-03-18 00:00:00 +00:00
iphydf
52696a0686
Add another bootstrap node to the bootstrap test.
Hopefully not both will be down at the same time.
2020-03-15 23:53:59 +00:00
iphydf
11ad5471b9
Use spdx license identifier instead of GPL blurb. 2020-03-14 13:06:19 +00:00
zugz (tox)
c644ef7681
use -1 rather than ~0 in unsigned integer types
Using ~0 involves a bitwise operation on int, so depends on
the internal representation of signed integers.
2020-03-14 00:00:02 +00:00
iphydf
e671490989
Use rules_cc instead of native cc_library rules. 2020-03-12 12:20:54 +00:00
iphydf
0f7138c010
Upgrade bazel to 2.1.1.
Removed av_test, because it depends on an ancient opencv that starts to
really not exist on modern systems anymore.
2020-03-02 14:23:44 +00:00
sudden6
1b7d7b66c5
synchronize call control actions to tox_iterate 2020-01-02 11:58:42 +01:00
Robin Linden
79748dd9e5
Allow Bazel to rerun tests marked as flaky 2019-11-17 01:24:02 +01:00
Robin Linden
f6235b5f8d
Update tests to use a working bootstrap node 2019-11-02 15:35:21 +01:00
zugz (tox)
306dd1f21f
add configurable limit on number of stored frozen peers 2019-05-19 18:51:28 +02:00
sudden6
b3100c977c
add undef guard in tox_many_tcp_test
This fixes an redefinition error when creating amalgamation.cc during
static analysis
2019-05-01 14:24:46 +02:00
zugz (tox)
efff822aef
Disable failing TCP server test
The test's intermittent failure may well be exposing a real bug in the
TCP relay and/or onion systems, but we can't find the bug, and keeping
the test is disrupting our CI.
2019-04-01 19:43:32 +02:00
zugz (tox)
959f468eac
add API function to test whether av is enabled 2019-02-10 00:00:00 +00:00
zugz (tox)
49e2406ffa
Expose api functions for enabling and disabling AV in AV groups
A group loaded from a savefile starts with AV disabled.
2019-02-10 00:00:00 +00:00
zoff99
78bc9e7403
Added test and patch for VLA stack overflow vuln.
Also added and used the new crypto_malloc and crypto_free.

The latter also zeroes out the memory safely. The former only exists for
symmetry (static analysis can detect asymmetric usages).
2019-01-03 11:13:27 +00:00
zugz (tox)
9770880e97
Implement conferences saving
* add global friend_connection status callback, used for group rejoining
* stop leaving groups on killing tox
2018-11-29 21:52:23 +01:00
zugz (tox)
caca350f43
Avoid format truncation in save compatibility test
(without this, gcc-8.2.0 issues a warning)
2018-11-23 18:09:45 +01:00
zugz (tox)
744dc2f5da
Make saving and loading the responsibility of Tox rather than Messenger 2018-10-20 11:03:10 +02:00
zugz (tox)
4dd86f1f29
ensure save data unchanged after save and load 2018-10-11 00:21:39 +02:00
iphydf
605dfe882c
Consistently use camel case enum names.
Including in tests and implementation files.
2018-10-09 17:33:37 +00:00
iphydf
b2b96b1aa1
Avoid use of IPv6 in tests if not supported (e.g. on Travis). 2018-10-06 21:27:02 +00:00
iphydf
4f266f913d
Use a working DHT node for bootstrap tests.
A lot of bootstrap nodes are down :(.
2018-09-25 21:19:07 +00:00
zugz (tox)
e43b2eadc0
Send rejoin packets on conference disconnection
We were mistakenly not making a rejoin attempt on freezing connections
due to all closest connections going down. This fixes that, and tweaks
the test. I've still only done tens rather than hundreds of tests, but
I'm fairly confident that the conference test now consistently passes.
2018-09-20 22:30:28 +02:00
yangfl
d3d5b701cb
Fix typos 2018-09-19 18:16:13 +00:00
iphydf
49bb43f662
Standardise header guards.
Using the full path including the repo name.
2018-09-14 19:09:10 +00:00
hugbubby
0688877fba
Use run_auto_test fixture in typing_test.c 2018-09-14 13:51:41 +00:00
iphydf
d9541d542c
Use (void) for empty parameter lists in C.
Because `()` means "some unknown number of parameters".
2018-09-08 10:59:30 +00:00
zugz
1b2322284f
Add mechanism for recovering from disconnections in conferences
* add freezing and unfreezing of peers
  * add rejoin packet
  * revise handling of temporary invited connections
  * rename "peer kill" packet to "peer leave" packet
  * test rejoining in conference test
  * use custom clock in conference test
2018-09-05 20:56:26 +02:00
iphydf
6872c14e1a
Avoid use of global mutable state in mono_time on win32.
This uses a trick to get read-write access to `this` from a `const`
member function, similar to C++ `mutable`, but uglier.
2018-09-03 20:03:47 +00:00
zugz (tox)
9764285ab1
Use test clock in run_auto_test tests and dht test 2018-08-31 17:08:35 +02:00
zugz (tox)
66ab386d6f
try ipv6 connections even after udp timeout
Also adds a test (auto_reconnect_test) which fails without this change.
2018-08-27 22:27:01 +02:00
iphydf
473cde24d8
Update copyright to 2018. 2018-08-26 18:57:29 +00:00
iphydf
64ddb7fff2
Call abort instead of exit on test failure.
This raises a signal, so we can more easily catch it with gdb.
2018-08-26 13:18:43 +00:00
iphydf
80f8458146
Run save_compatibility_test in the autotools build. 2018-08-25 23:25:15 +00:00
iphydf
17e8195a8f
Fix the PORT_ALLOC failure of save_compatibility_test.
`tox_new_log` has a much larger range of ports it can select from.
2018-08-25 22:28:38 +00:00
iphydf
94b06818fb
Use do-while instead of while in tests.
This forces all the loop bodies to be executed at least once, which is
harmless since it just means one more tox event loop iteration. This
reduces the jitter we see in coverage measurements, which is partially
caused by loops sometimes being entered and sometimes not (because their
condition happens to randomly already be true).
2018-08-25 15:25:33 +00:00
iphydf
853a2a10b1
Stop using massive macros in toxav_basic_test.
Turned a huge macro into a function. Macros are a pain to debug.
2018-08-25 13:46:47 +00:00
zugz (tox)
efcda6c319
Fix auto_tests Makefile
* specify correct source files
* add save_compatibility_test (commented out for now)
* reformat TESTS to one line per test, and set check_PROGRAMS := TESTS
* add run_auto_test.h to EXTRA_DIST
* Fix `AUTO_TEST_CFLAGS` -> `AUTOTEST_CFLAGS`.
2018-08-25 14:30:04 +02:00
endoffile78
76f4ae64b7
Add check to make sure tox was created successfully 2018-08-22 10:12:46 +00:00
iphydf
7aa57afeba
Avoid redefining macros from different files. 2018-08-19 23:15:01 +00:00
iphydf
0fa700b55b
Make the save_compatibility_test work with bazel. 2018-08-19 22:08:02 +00:00
endoffile78
30960dcc7e
Add save file generator, save compatibility test, and generate a save file 2018-08-19 10:38:51 +00:00
iphydf
d6d305feeb
Use per-instance Mono_Time for Messenger and onion. 2018-08-16 21:01:43 +00:00
iphydf
54066f338f
Reduce the number of times unix_time_update is called.
Reduced by, e.g.:
* `file_transfer_test`: 33% of the `clock_gettime` calls.
* `tox_many_test`: 53% of the `clock_gettime` calls.

Other tests will see similar improvements. Real world applications will
be closer to 40-50% improvement, since tox_many_test has 100 nodes, while
file_transfer_test has 2 nodes.
2018-08-16 21:01:38 +00:00
iphydf
c0db255425
Limit the size of a save file in file_saving_test.
Limited to 4GiB. That ought to be enough for any save file.
2018-08-16 10:15:01 +00:00
Leonid Bobrov
006b4f4e5c
Prune long long warnings. 2018-08-16 09:57:37 +00:00
iphydf
a509d25324
Fix some printf format specifiers. 2018-08-13 11:02:32 +00:00
zugz (tox)
d56ab5aaff
add callback for successful connection to a conference 2018-08-12 22:46:06 +02:00
iphydf
d92c96e783
Fix a few warnings from clang.
Also remove the use of a VLA in a context where there can be unbounded
memory allocations.
2018-08-12 14:09:59 +00:00
iphydf
f0f456398d
Check that the save file size isn't larger than our address space. 2018-08-12 12:05:01 +00:00
zugz
aa63c1330c
Fix problems with initial connections and name-setting in conferences
* test names in conference_test
* raise error on attempt to invite friend to group before we are connected
* revise handling of temporary invited connections
    We are now careful not to prematurely delete a connection to a peer
    established during the invitation process; namely, before we have sufficient
    other connections and have confirmed that we have an alternative route to the
    peer.
* process out-of-order messages from a peer
* don't reset names when handling a Peer Response
2018-08-02 22:03:18 +01:00
hugbubby
3a4987da18
Fix autotools build
Mosts of the tests in auto_tests weren't running when the project
was built using autotools. This fixes that.
2018-07-30 12:48:21 +00:00
hugbubby
051eb1d5a7
auto_test fixture and filenames
Renamed a poorly named test, fixed up a few printf statements,
substituted some unsigned integers with fixed size counterparts,
and implemmented the auto_run_test.h fixture for the lossy and
lossless packet tests.
2018-07-28 16:14:06 +00:00
hugbubby
c4d58403f9
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.
2018-07-23 15:10:22 +00:00
iphydf
f627a26a7b
Run Clang global static analysis on Travis.
This uses a single .cc file containing almost all the code in the
repository to perform whole program analysis.
2018-07-22 02:34:30 +00:00
iphydf
7245ac11ef
Avoid implementations in .h files or #including .c files.
Also, avoid the need for putting `_XOPEN_SOURCE` in every test file.
2018-07-21 20:44:26 +00:00
iphydf
7c2b95ef5e
Remove redundant casts to the same type.
Also removed an unused identifier in messenger_test.c.
2018-07-21 15:09:39 +00:00
iphydf
adb12d5340
Add github usernames to TODOs. 2018-07-21 14:56:21 +00:00
iphydf
c1b7edbed3
Add missing braces in dht_test.c.
astyle doesn't catch all of these.
2018-07-21 13:01:34 +02:00
iphydf
affaaee210
Run buildifier on c-toxcore BUILD files. 2018-07-21 01:13:29 +00:00