Squashed 'external/toxcore/c-toxcore/' changes from 3e05824b80..da438763d5

da438763d5 chore: Release 0.2.19
f90417987c chore: Add cmake flag to disable unit tests.
7df3f99417 docs: Document that group topic lock is default on.
9e9ed77390 docs: Add missing param docs for callbacks.
0ec4978de5 refactor: Don't expose Tox_System in the public API
a3d1b8595c docs: Public headers, Core/toxcore -> Tox/the Tox library
f78d0f3f39 docs: Public headers, events_alloc -> internal
817518949e docs: Public headers, NULL-terminated -> NUL-terminated
be085db191 docs: Public headers, spellcheck
4c902955f3 docs: Public headers, 80 column width comments
be8a82a818 docs: Public headers, null -> NULL
419d783d95 docs: Public headers, tox -> Tox
5c8aa65e41 docs: Update user data API explanation
ad4921dbaa cleanup: A more descriptive error for group invite accept function

git-subtree-dir: external/toxcore/c-toxcore
git-subtree-split: da438763d5b8e071de6e061a1dcaddd2177dff7d
This commit is contained in:
2024-03-28 16:13:51 +01:00
parent a5093c4aa3
commit 47ad96e2b6
23 changed files with 1072 additions and 578 deletions

View File

@ -104,7 +104,6 @@ void TestBootstrap(Fuzz_Data &input)
Ptr<Tox_Options> opts(tox_options_new(nullptr), tox_options_free);
assert(opts != nullptr);
tox_options_set_operating_system(opts.get(), sys.sys.get());
tox_options_set_log_callback(opts.get(),
[](Tox *tox, Tox_Log_Level level, const char *file, uint32_t line, const char *func,
@ -134,8 +133,12 @@ void TestBootstrap(Fuzz_Data &input)
tox_options_set_tcp_port(opts.get(), 33445);
}
Tox_Options_Testing tox_options_testing;
tox_options_testing.operating_system = sys.sys.get();
Tox_Err_New error_new;
Tox *tox = tox_new(opts.get(), &error_new);
Tox_Err_New_Testing error_new_testing;
Tox *tox = tox_new_testing(opts.get(), &error_new, &tox_options_testing, &error_new_testing);
if (tox == nullptr) {
// It might fail, because some I/O happens in tox_new, and the fuzzer
@ -144,6 +147,7 @@ void TestBootstrap(Fuzz_Data &input)
}
assert(error_new == TOX_ERR_NEW_OK);
assert(error_new_testing == TOX_ERR_NEW_TESTING_OK);
uint8_t pub_key[TOX_PUBLIC_KEY_SIZE] = {0};

View File

@ -138,7 +138,6 @@ void TestEndToEnd(Fuzz_Data &input)
Ptr<Tox_Options> opts(tox_options_new(nullptr), tox_options_free);
assert(opts != nullptr);
tox_options_set_operating_system(opts.get(), sys.sys.get());
tox_options_set_local_discovery_enabled(opts.get(), false);
tox_options_set_log_callback(opts.get(),
@ -151,8 +150,12 @@ void TestEndToEnd(Fuzz_Data &input)
}
});
Tox_Options_Testing tox_options_testing;
tox_options_testing.operating_system = sys.sys.get();
Tox_Err_New error_new;
Tox *tox = tox_new(opts.get(), &error_new);
Tox_Err_New_Testing error_new_testing;
Tox *tox = tox_new_testing(opts.get(), &error_new, &tox_options_testing, &error_new_testing);
if (tox == nullptr) {
// It might fail, because some I/O happens in tox_new, and the fuzzer
@ -161,6 +164,7 @@ void TestEndToEnd(Fuzz_Data &input)
}
assert(error_new == TOX_ERR_NEW_OK);
assert(error_new_testing == TOX_ERR_NEW_TESTING_OK);
tox_events_init(tox);

View File

@ -16,6 +16,7 @@
#include <vector>
#include "../../toxcore/tox.h"
#include "../../toxcore/tox_private.h"
struct Fuzz_Data {
static constexpr bool DEBUG = false;

View File

@ -195,13 +195,16 @@ void RecordBootstrap(const char *init, const char *bootstrap)
});
Tox_Err_New error_new;
Tox_Err_New_Testing error_new_testing;
Tox_Options_Testing tox_options_testing;
Record_System sys1(global, 4, "tox1"); // fair dice roll
tox_options_set_log_user_data(opts, &sys1);
tox_options_set_operating_system(opts, sys1.sys.get());
Tox *tox1 = tox_new(opts, &error_new);
tox_options_testing.operating_system = sys1.sys.get();
Tox *tox1 = tox_new_testing(opts, &error_new, &tox_options_testing, &error_new_testing);
assert(tox1 != nullptr);
assert(error_new == TOX_ERR_NEW_OK);
assert(error_new_testing == TOX_ERR_NEW_TESTING_OK);
std::array<uint8_t, TOX_ADDRESS_SIZE> address1;
tox_self_get_address(tox1, address1.data());
std::array<uint8_t, TOX_PUBLIC_KEY_SIZE> pk1;
@ -211,10 +214,11 @@ void RecordBootstrap(const char *init, const char *bootstrap)
Record_System sys2(global, 5, "tox2"); // unfair dice roll
tox_options_set_log_user_data(opts, &sys2);
tox_options_set_operating_system(opts, sys2.sys.get());
Tox *tox2 = tox_new(opts, &error_new);
tox_options_testing.operating_system = sys2.sys.get();
Tox *tox2 = tox_new_testing(opts, &error_new, &tox_options_testing, &error_new_testing);
assert(tox2 != nullptr);
assert(error_new == TOX_ERR_NEW_OK);
assert(error_new_testing == TOX_ERR_NEW_TESTING_OK);
std::array<uint8_t, TOX_ADDRESS_SIZE> address2;
tox_self_get_address(tox2, address2.data());
std::array<uint8_t, TOX_PUBLIC_KEY_SIZE> pk2;

View File

@ -142,9 +142,11 @@ void TestEndToEnd(Fuzz_Data &input)
Ptr<Tox_Options> opts(tox_options_new(nullptr), tox_options_free);
assert(opts != nullptr);
tox_options_set_operating_system(opts.get(), sys.sys.get());
tox_options_set_local_discovery_enabled(opts.get(), false);
Tox_Options_Testing tox_options_testing;
tox_options_testing.operating_system = sys.sys.get();
tox_options_set_log_callback(opts.get(),
[](Tox *tox, Tox_Log_Level level, const char *file, uint32_t line, const char *func,
const char *message, void *user_data) {
@ -156,7 +158,8 @@ void TestEndToEnd(Fuzz_Data &input)
});
Tox_Err_New error_new;
Tox *tox = tox_new(opts.get(), &error_new);
Tox_Err_New_Testing error_new_testing;
Tox *tox = tox_new_testing(opts.get(), &error_new, &tox_options_testing, &error_new_testing);
if (tox == nullptr) {
// It might fail, because some I/O happens in tox_new, and the fuzzer
@ -165,6 +168,7 @@ void TestEndToEnd(Fuzz_Data &input)
}
assert(error_new == TOX_ERR_NEW_OK);
assert(error_new_testing == TOX_ERR_NEW_TESTING_OK);
tox_events_init(tox);

View File

@ -20,14 +20,15 @@ void TestSaveDataLoading(Fuzz_Data &input)
const size_t savedata_size = input.size();
CONSUME_OR_RETURN(const uint8_t *savedata, input, savedata_size);
Null_System sys;
tox_options_set_operating_system(tox_options, sys.sys.get());
// pass test data to Tox
tox_options_set_savedata_data(tox_options, savedata, savedata_size);
tox_options_set_savedata_type(tox_options, TOX_SAVEDATA_TYPE_TOX_SAVE);
Tox *tox = tox_new(tox_options, nullptr);
Tox_Options_Testing tox_options_testing;
Null_System sys;
tox_options_testing.operating_system = sys.sys.get();
Tox *tox = tox_new_testing(tox_options, nullptr, &tox_options_testing, nullptr);
tox_options_free(tox_options);
if (tox == nullptr) {
// Tox save was invalid, we're finished here