55 Commits

Author SHA1 Message Date
iphydf 109752403e feat: Add Tox_Iterate_Options for granular control over tox_iterate.
deploy / Prepare (push) Failing after -2s
deploy / Linux (aarch64) (push) Has been skipped
deploy / Linux (x86_64) (push) Has been skipped
deploy / macOS (arm64) (push) Has been skipped
deploy / macOS (x86_64) (push) Has been skipped
deploy / iOS (ios-arm64) (push) Has been skipped
deploy / iOS (ios-armv7) (push) Has been skipped
deploy / iOS (ios-armv7s) (push) Has been skipped
deploy / iOS (iphonesimulator-arm64) (push) Has been skipped
deploy / iOS (iphonesimulator-x86_64) (push) Has been skipped
deploy / Xcode Framework (push) Has been skipped
deploy / Android (x86) (push) Has been skipped
deploy / Android (x86_64) (push) Has been skipped
deploy / WebAssembly (push) Has been skipped
deploy / Single file (push) Has been skipped
deploy / Source tarball (push) Has been skipped
docker / docker-bootstrap-node (push) Failing after 15s
docker / docker-clusterfuzz (push) Failing after 26s
draft / release (push) Failing after -2s
docker / docker-windows-mingw (64) (push) Failing after 17s
deploy / Android (arm64-v8a) (push) Has been skipped
deploy / Android (armeabi-v7a) (push) Has been skipped
docker / docker-bootstrap-node-websocket (push) Has been skipped
docker / docker-fuzzer (push) Failing after 16s
docker / docker-windows-mingw (32) (push) Failing after 18s
docker / docker-esp32 (push) Failing after 22s
post-submit / build (alpine-s390x) (push) Successful in 33m10s
post-submit / docker-coverage (push) Failing after 21s
sonar-scan / sonar-scan (push) Failing after 16s
post-submit / build (freebsd) (push) Successful in 39m11s
ClusterFuzzLite batch fuzzing / BatchFuzzing (address) (push) Failing after 10s
ClusterFuzzLite batch fuzzing / BatchFuzzing (memory) (push) Failing after 15s
ClusterFuzzLite batch fuzzing / BatchFuzzing (undefined) (push) Failing after 10s
coverity-scan / latest (push) Failing after 22s
ClusterFuzzLite cron tasks / Pruning (push) Failing after 9s
ClusterFuzzLite cron tasks / Coverage (push) Failing after 8s
CodeQL / Analyze (cpp) (push) Failing after 8m47s
2026-02-12 22:50:25 +00:00
iphydf ea597edff7 test: Improve simulation determinism and reliability.
Require explicit seeds for `Simulation` and `SimulatedEnvironment` to
ensure reproducible test results.

Also:
- Drop packets in `FakeUdpSocket` when the receive queue is full to
  prevent unbounded memory growth during stress tests.
- Improve synchronization in `Simulation::run_until` by adding a timeout
  to the barrier wait, preventing hangs if a runner is unregistered.
2026-02-09 09:34:26 +00:00
iphydf 40ce0bce66 cleanup: Use std::size_t in C++ to fix compilation errors.
On some stdlibs, `size_t` doesn't exist in the global namespace.

Fixes #3020.
2026-02-08 21:57:40 +00:00
iphydf 9c22e79cc8 test(support): add SimulatedEnvironment for deterministic testing
Introduces a new testing support library 'testing/support' that provides
a clean, modular, and fully deterministic environment for testing
toxcore components.
2026-01-07 13:06:18 +00:00
iphydf 0e4715598f test: Add new scenario testing framework. 2026-01-05 21:45:47 +00:00
iphydf 668291f441 refactor(toxcore): decouple Network_Funcs from sockaddr via IP_Port
Replaces the use of the platform-specific `Network_Addr` in the public
`Network_Funcs` interface with the platform-independent `IP_Port`
struct, allowing higher-level abstractions (like simulated networks for
testing) to interact with the network layer without needing to depend on
or mock low-level OS socket headers.
2026-01-05 18:58:33 +00:00
iphydf 46bfdc2df7 fix: correct printf format specifiers for unsigned integers 2026-01-01 16:01:12 +00:00
iphydf 390f7db060 refactor: Move random and memory OS-specifics to os_* files. 2025-10-08 10:59:32 +00:00
iphydf 34ec822da7 cleanup: Fix some clang-19 format warnings. 2025-07-13 12:26:15 +00:00
iphydf 2ccecdc2a1 chore: Add remaining fuzz tests to cflite.
So we can run them daily and get coverage info from them.
2025-02-05 21:03:48 +00:00
iphydf 4626c2e230 test: Add a Net_Crypto fuzz test. 2025-02-05 19:45:48 +00:00
iphydf 463eeae114 cleanup: Avoid clashing with global define DEBUG.
Some systems define this, breaking our test code.
2025-01-22 23:52:44 +00:00
iphydf bc43cec062 chore: Happy new year! 2025-01-05 23:24:52 +00:00
iphydf 0204db6184 cleanup: Fix layering check warnings.
These warnings aren't available yet, but will be in a future
toktok-stack build.
2024-12-04 10:24:23 +00:00
Green Sky 2e94da60d0 feat(net): add missing connect to network struct 2024-11-12 23:28:22 +01:00
Maxim Biro 0ec4978de5 refactor: Don't expose Tox_System in the public API
It makes no sense to include it in the public API as clients can't make
any meaningful use of it via public API, it can only be used if one also
includes other internal/private headers that we don't install.

It's used only in the testing code, which has access to the internal
headers.

Fixes #2739, at least to some degree. I decided against moving things to
a separate `tox_testing.h` and leaving only things in `tox_private.h`
that we are fine with clients using, as otherwise `tox_lock()` /
`tox_unlock()` would have to be moved out of `tox_private.h` to
somewhere else, but `tox_private.h` actually sounds like the right place
for them, naming-wise. So perhaps it's fine if we have things in
`tox_private.h` that we don't want clients to use.
2024-03-17 11:22:43 -04:00
iphydf 93c83fbc7c refactor: Use strong typedef instead of struct for Socket.
Sparse checks it. This is neater than using a struct, which has some
slightly weird syntax at times. This also reduces the risk of someone
adding another struct member.
2024-02-09 01:10:06 +00:00
iphydf 5bdaaaedb6 refactor: Remove Tox * from tox_dispatch.
User data can contain a tox instance if it needs to.
2024-02-04 20:18:26 +00:00
iphydf 4359e3a6bc chore: Rename C++ headers to .hh suffixes.
This helps formatters and other dump (simple) tools know what's C++ and
what's C.
2024-02-01 23:44:37 +00:00
iphydf bcb6592af5 test: Add C++ classes wrapping system interfaces.
These are more convenient and safer than the manual vtables we have in
the fuzzer support code. We can override individual member functions,
and C++ will take care of correctly casting and offsetting this-pointers
when needed.
2024-01-13 16:16:47 +00:00
iphydf 4cea4f9ca4 fix: Make all the fuzzers work again, and add a test for protodump.
fuzz_select_target wasn't selecting anything, so fuzzers using that
function either did nothing or would only ever select one of the
functions.
2024-01-13 15:06:30 +00:00
iphydf 812f931d5f fix: Make sure there's enough space for CONSUME1 in fuzzers. 2024-01-12 14:52:35 +00:00
iphydf 50f1b30fa9 test: Add fuzz tests to the coverage run.
So we don't need to write so many edge case tests ourselves for things
like parsers, which really don't need those manual tests, as long as we
can check for some properties like "can output the parsed data and it'll
be the same as the input".
2024-01-12 12:33:41 +00:00
iphydf 32b68cffca cleanup: Some more test cleanups, removing overly smart code. 2024-01-10 12:42:37 +00:00
iphydf 5cac6d7eb1 cleanup: Move tox_get_system out of the public API.
It's not released, yet, and this function is a pain. We don't want it
going forward.
2024-01-05 19:29:59 +00:00
iphydf c58928cc89 chore: Add IMPORTED_TARGET to pkg-config packages.
Also use `PRIVATE` for `target_link_libraries`. This helps avoid
implicit transitive dependencies.
2023-12-26 00:04:07 +00:00
iphydf 7cfe35dff2 cleanup: Remove explicit layering_check feature.
It's default in .bazelrc now.
2023-11-23 23:55:57 +00:00
iphydf 6be29f01e5 chore: Add more logging to loading conferences from savedata.
Better error messages than "something went wrong in type 20".

Also fix bazel-asan/tsan builds.

https://github.com/tweag/rules_nixpkgs/issues/442 is blocking fuzz
tests under asan.
2023-11-08 15:51:11 +00:00
iphydf 82276ef5ac cleanup: Fix GCC compatibility. 2023-11-07 12:18:22 +00:00
iphydf 24b54722ae fix: Ensure we have allocators available for the error paths. 2023-09-11 21:43:43 +00:00
iphydf a549807df7 refactor: Add mem module to allow tests to override allocators.
This will allow us to do more interesting things with memory allocation
within toxcore, and allow fuzzers to explore various allocation failure
paths.
2023-08-30 22:55:05 +00:00
iphydf 7469a529b1 fix: Add missing #include <array>. 2023-08-15 20:47:27 +00:00
iphydf 2e02d56379 chore: Add missing module dependencies.
Also flip some callback asserts, because they can be reached by fuzzing
eventually.

Also update the bootstrapd checksum, since the alpine image changed a
bit.
2023-08-10 21:01:17 +00:00
sudden6 d222d708b5 fix: expand asserts in fuzz_support.cc 2022-12-08 17:27:00 +01:00
sudden6 9fae455bab test: enable tcp relay for bootstrap fuzzing 2022-12-04 18:52:09 +01:00
iphydf 50094b7385 test: Add a protocol dump test to generate initial fuzzer input. 2022-04-19 23:42:47 +00:00
iphydf debedb3c94 test: Add a Null_System used in toxsave_harness.
This does nothing but has a working simple RNG.
2022-04-14 19:04:25 +00:00
iphydf 19b9cf3812 test: Enable fuzzing for TCP.
If the `recvbuf` network function returns 0 all the time, that means
there is never any data available on the TCP socket. This change makes
it so there is a random amount of data available on the TCP socket.

This invalidates the bootstrap fuzzer corpus.
2022-04-14 13:19:56 +00:00
iphydf d78ee9b12e fix: Fix potential array out-of-bounds in DHT random node retrieval.
It can't happen in almost every reality, except when the RNG is fairly
broken and doesn't add 2 fake DHT friends on startup. Still, this code
should be defensive and never index outside `num_friends` elements.
2022-04-10 23:17:15 +00:00
iphydf 60b71adbfa test: Don't abort fuzz test when tox_new fails.
Right now, it can't fail, but later we want the fuzzer to randomly let
I/O functions fail, so we shouldn't assert tox_new succeeded.
2022-04-10 22:35:00 +00:00
iphydf 27c27b7c8c refactor: Avoid static_cast in Fuzz_System functions.
Declutters the fuzz system code a bit, hiding the cast behind a `!`
operator.
2022-04-10 19:13:01 +00:00
jfreegman 616bd63021 Downgrade C++ version to 17 2022-04-10 12:44:04 -04:00
iphydf cb34fe12d1 test: Add more functionality to the bootstrap harness.
Ideally this would be able to reach some of the events, so we can write
code to respond to those events, but so far only the friend request
event actually happens.
2022-04-07 20:17:56 +00:00
iphydf 941026266e refactor: Allow overriding mono_time in tox_new.
This makes it so if mono_time is overridden, no monotonic time-related
system call is invoked in tox_new.
2022-04-03 22:48:16 +00:00
iphydf dec1399776 test: Add fuzzer support functions for internal toxcore objects.
These help creating fuzzer fixtures with non-trivially constructed
objects and takes care of cleaning them up afterwards so the fuzzer code
can focus on the system under test.
2022-04-03 11:21:06 +00:00
iphydf 7db0c80c93 test: Add DHT and tox_events fuzz tests to the cmake build. 2022-03-29 22:57:23 +00:00
iphydf e4558a287c perf: Make time move a lot faster in fuzzing runs. 2022-03-27 22:52:35 +00:00
iphydf 478ef39b39 test: Add some support functions to make writing fuzzers easier. 2022-03-27 18:43:41 +00:00
sudden6 bc006beb4e cleanup: split CMakeLists.txt and add some missing targets 2022-03-27 20:09:10 +02:00
sudden6 48fb45887f try to save the fuzzed save file again
This should test some additional code paths.
2022-03-26 14:09:04 +01:00