Commit Graph

4593 Commits

Author SHA1 Message Date
iphydf
751d0948ab
Use named function types for callbacks in net_crypto.
Also:
* compound statements (blocks, e.g. in if/else) must be non-empty.
  Comments don't count.
* `=` is not allowed in subexpressions. We treat it as statement-only.
* `++i` is preferred over `i++` in statements.
* `Type_Names` are camelsnake-case.
2018-07-08 22:32:10 +00:00
iphydf
76e1d05da6
Use named function types for friend_requests callbacks.
Also:
* `#define` must be scoped. If it's used outside a scope, it must be
  defined outside that scope (global `#define` does not need a matching
  `#undef`).
2018-07-08 22:02:52 +00:00
iphydf
c0c3098737
Avoid side-effectful assignments in conditionals.
Only in audio.c for now. This should be done everywhere.
2018-07-08 19:34:45 +00:00
iphydf
465c9380ea
Clarify the intent of "file kinds" in the API. 2018-07-08 19:13:23 +00:00
iphydf
2b49f80395
Rename BS_LIST to BS_List to follow the naming conventions.
`BS_LIST` would be a constant. `BS_List` is a type name.
2018-07-08 19:03:52 +00:00
iphydf
ebdc43285a
Use named types for onion callbacks.
This is now a style rule: you can only use typedef'd function types.

Previous rules now applied in `onion_*.c`:
* `struct`s must have a name (typedef of unnamed struct is not allowed).
* `++i` for increment-stmt, not `i++`, e.g. in loops.
* Only a single declarator per struct member declaration.
* Type_Names vs. variable_names.
2018-07-08 18:23:45 +00:00
iphydf
819fe534ea
Use named function types for friend_connection callbacks.
Also:
* No inner structs.
* One declarator per member declaration.
* Function names are snake_case.
* Names ending in `_cb` are function types.
* `++i` is preferred over `i++`.
2018-07-08 18:06:39 +00:00
iphydf
b3889f0f05
Remove VLA usage from send_audio_packet.
Also use `net_pack_u16` in that function instead of manual ntohs+memcpy
and `net_unpack_u16` in its receiving counterpart.
2018-07-08 13:59:37 +00:00
iphydf
08ff19a63b
Call the "peer leaves" callback only once on group delete.
We used to pass the actual peer numbers of peers leaving, but we no
longer know these in the PGC world, so we don't pass them anymore.
2018-07-07 16:02:00 +00:00
iphydf
3c1025d2dc
Factor out the actual test code from conference_test.
Also, renamed simple_conference_test to conference_simple_test so it's
sorted together with the other conference tests.

Next step is to use run_auto_test.h for the conference test.
2018-07-07 10:35:35 +00:00
iphydf
9d5c55b4b3
Add a test that reproduces the NULL peer nick bug. 2018-07-06 11:14:44 +00:00
hugbubby
47a527509d
lan_discovery_test and version_test cleanup
Removed a pointless declaration of a function in lan_discovery_test
and cleaned up the one error message there. Did an entire restructuring
of the version_test using macros that resulted in fewer lines of code but more
thorough testing.

Formatting of version_test.c

back to old way, save comments and one change

Missing space
My greatest enemy

Add `#include <cstdio>` for `std::printf`.

Make tox.c unambiguously parseable.

Rules:
1. Constants are uppercase names: THE_CONSTANT.
2. SUE[1] types start with an uppercase letter and have at least one
   lowercase letter in it: The_Type, THE_Type.
3. Function types end in "_cb": tox_friend_connection_cb.
4. Variable and function names are all lowercase: the_function.

This makes it easier for humans reading the code to determine what an
identifier means. I'm not convinced by the enum type name change, but I
don't know a better rule. Currently, a lot of enum types are spelled like
constants, which is confusing.

[1] struct/union/enum

Use run_auto_test.h test fixture for some auto-tests.

Most of the auto-tests should use this fixture, but I've only done a few
to set an example.
2018-07-06 10:25:47 +00:00
iphydf
597f23bdd9
Use run_auto_test.h test fixture for some auto-tests.
Most of the auto-tests should use this fixture, but I've only done a few
to set an example.
2018-07-05 23:41:27 +00:00
iphydf
8739f7fccb
Make tox.c unambiguously parseable.
Rules:
1. Constants are uppercase names: THE_CONSTANT.
2. SUE[1] types start with an uppercase letter and have at least one
   lowercase letter in it: The_Type, THE_Type.
3. Function types end in "_cb": tox_friend_connection_cb.
4. Variable and function names are all lowercase: the_function.

This makes it easier for humans reading the code to determine what an
identifier means. I'm not convinced by the enum type name change, but I
don't know a better rule. Currently, a lot of enum types are spelled like
constants, which is confusing.

[1] struct/union/enum
2018-07-05 23:09:28 +00:00
iphydf
64d0297acc
Add #include <cstdio> for std::printf. 2018-07-04 14:21:12 +00:00
iphydf
3ef1f839fc
Add some tests for our ring_buffer implementation.
These can serve as documentation until we write actual api docs, probably
using apidsl.
2018-07-04 10:37:46 +00:00
iphydf
1a54be06cd
Simplify Travis CI builds.
Have one script per build. This means more duplication between the
scripts, but it's much easier to understand and to run locally.
2018-07-01 08:35:44 +00:00
iphydf
706fad1ce8
Add a test to try and overflow the send queue in net_crypto. 2018-06-29 23:24:20 +00:00
Evgeny Kurnevsky
52f21e3251
Correct check for net_crypto packet index. 2018-06-29 23:02:01 +00:00
iphydf
b9a75d98b2
Remove broken conference tests.
These display some idea, but the tests are not implemented correctly. We
will need to implement the idea correctly later, but for now we can't use
these.
2018-06-29 18:25:44 +00:00
iphydf
86a6b17555
Fix leak of Logger instances in dht_test. 2018-06-28 21:25:21 +00:00
iphydf
7c4b971d67
Various minor cleanups in net_crypto.
* Consistently use `num_packets_array` to get the packet count in the
  packet buffer.
* Use `const` in more places.
* Typo fix: begginning.
* Rewrite `length < 1` for unsigned int to `length == 0`.
* Limit scope of some loop variables by using for-init-decl.
* Use early return in error paths to reduce indentation and for clarity.
* Use `net_unpack_*` instead of manual `ntohs`.
* Fix an uninitialised stack variable copy.
* Fix a potential null pointer dereference.
* Consistently use `get_crypto_connection`. It was inlined in some
  places. I de-inlined it now.
* Add Loggers to some functions in preparation for adding log statements.
2018-06-28 16:04:57 +00:00
hugbubby
4e3bfac47d
Another TCP_test.c upgrade
Mostly documentation + comments. Some cases where code was removed
in exchange for more compact/less sprawly for loops. Introduced a
function that removed like 30 lines of repeated code.
2018-06-28 14:05:03 +00:00
cotox
72863b9b80
Add missing MAX_HOSTNAME_LENGTH doc. 2018-06-27 02:58:56 +00:00
cotox
5b14542d3b
Make arg host understand clearly.
Rename args `host:port` from `address:port`.
The *address* is well known as *Tox Address* in this project. Then we
should reserve *addres* to it, and use *host* to express the hostname or
IP address in TCP domain.
2018-06-26 11:45:17 +00:00
Robin Lindén
ae7899cab8
Release v0.2.3 2018-06-25 23:49:52 +02:00
iphydf
9b7d828f83
Only run astyle if the astyle binary exists. 2018-06-25 20:35:16 +00:00
iphydf
957508f698
Remove utils.c and utils.h from toxencryptsave build.
These were deleted earlier.
2018-06-25 20:27:21 +00:00
iphydf
12365a7cc9
Fixes to the imported sodium sources to compile without warnings. 2018-06-25 20:09:53 +00:00
iphydf
56d249e5ad
Add a MAX_HOSTNAME_LENGTH constant.
Fixes #946.
2018-06-25 19:56:11 +00:00
iphydf
d22332dd50
Remove the format test.
It's annoying to have a test touch every source file. It causes a
recompile of everything after every test run.
2018-06-25 19:48:11 +00:00
Maxim Biro
7684b5ae3e
Make bootstrap daemon use toxcore's version 2018-06-25 00:29:16 -04:00
iphydf
29b2dd6315
Use clang-format for C++ code.
`clang-format -style='{BasedOnStyle: Google, ColumnLimit: 100}'`
2018-06-24 20:17:53 +00:00
iphydf
5c2600d87b
Add new Circle CI configuration.
This one has ASAN enabled, unlike Travis.
2018-06-24 19:51:34 +00:00
iphydf
8e00294b3c
Add Logger to various net_crypto functions.
In preparation for adding log statements.

Also, fix an uninitialised variable warning in cppcheck.
2018-06-24 19:17:32 +00:00
iphydf
5a8790eab0
Add a test for double conference invite.
In Persistent Group Chats (PGC), this will cause a use-after-free. This
test ensures that we fix this bug before merging PGC.
2018-06-24 01:09:46 +00:00
iphydf
ca75c014a4
Disable UDP when proxy is enabled.
Currently, toxcore does not support UDP over proxies. In the future, we
can relax this by disabling UDP only if the proxy doesn't support it.
2018-06-23 17:36:37 +00:00
iphydf
64d115e52d
Avoid conditional-uninitialised warning for tcp test.
The C compiler warns because the value is initialised in a loop and used
outside of it. In this case, it's always initialised, but changing the
value of `NUM_PORTS` can change that.
2018-06-23 14:39:31 +00:00
iphydf
e4462af919
Add assertions to bootstrap tests for correct connection type. 2018-06-23 14:05:56 +00:00
iphydf
9853f4a535
Make NULL options behave the same as default options.
I.e. make tox_new(0, 0) behave the same as tox_new(tox_options_new(0), 0).
Changing defaults in the options does not currently affect NULL options.
2018-06-23 13:29:11 +00:00
iphydf
cfff361679
Add random testing program.
This can be used as a random stress test for toxcore.
Adjust the weights to make certain actions more or less likely.
2018-06-23 12:43:09 +00:00
iphydf
a48e0c4d18
Add tests for what happens when passing an invalid proxy host.
Related: https://github.com/qTox/qTox/issues/5174
2018-06-23 12:34:33 +00:00
hugbubby
36e20e7e94
Clarify/Improve test_some test
Better error messages, better sleep() call placements, etc.
Did not modify large chunk of function because I couldn't explain
it. Maybe I'll come back later once I've regained lost brain cells.
2018-06-22 19:52:30 +00:00
iphydf
850d7eac38
Make the net_crypto connection state an enum.
It was a list of #defines, but clearly this is a discrete and limited set
of named values, so an enum is more appropriate.
2018-06-22 00:57:22 +00:00
iphydf
2d2b9cfa91
Merge remote-tracking branch 'irungentoo/master' into merge-iru 2018-06-20 23:01:14 +00:00
hugbubby
820e45dece
Better TCP testing (beginnings)
Tests all ports instead of just one, also adds some comments/changes
error messages to be more descriptive
2018-06-20 22:11:08 +00:00
iphydf
2296d07e09
Add test for creating multiple conferences in one tox.
This triggers a code path in Persistent Group Chats that causes a memory
leak. I'm adding this test now, so that we don't merge PGC without fixing
the memory leak first.
2018-06-19 21:00:26 +00:00
iphydf
3a85d88fb1
Remove resource_leak_test.
This test has never caught a bug. It's better to catch these with asan or
the likes.
2018-06-18 19:25:30 +00:00
iphydf
90e1d969ac
Fix linking with address sanitizer.
`-fsanitize=address` also needs to be passed to the linker.
2018-06-18 19:19:31 +00:00
iphydf
16f5cc8c24
Make dht_test more stable.
By making it run in a port range far away from other tests. This test
creates 100 DHTs and makes either itself or other tests run out of ports.
2018-06-17 23:41:42 +00:00