Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@ freebsd_task:
-DAUTOTEST=ON \
-GNinja
cmake --build . --target install
ctest -j50 --output-on-failure --rerun-failed --repeat until-pass:3 || ctest -j50 --output-on-failure --rerun-failed --repeat until-pass:3
ctest -j50 --output-on-failure --rerun-failed --repeat until-pass:3 ||
ctest -j50 --output-on-failure --rerun-failed --repeat until-pass:6
1 change: 1 addition & 0 deletions .clusterfuzzlite/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ FROM gcr.io/oss-fuzz-base/base-builder:latest
RUN apt-get update \
&& apt-get -y install --no-install-suggests --no-install-recommends \
cmake \
ninja-build \
pkg-config \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
Expand Down
12 changes: 9 additions & 3 deletions .clusterfuzzlite/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,18 @@ cd "$WORK"
ls /usr/local/lib/

# Debug build for asserts
cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER="$CC" \
cmake -GNinja \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_C_COMPILER="$CC" \
-DCMAKE_CXX_COMPILER="$CXX" \
-DCMAKE_C_FLAGS="$CFLAGS" \
-DCMAKE_CXX_FLAGS="$CXXFLAGS" \
-DBUILD_TOXAV=OFF -DENABLE_SHARED=NO -DBUILD_FUZZ_TESTS=ON \
-DDHT_BOOTSTRAP=OFF -DBOOTSTRAP_DAEMON=OFF "$SRC"/c-toxcore
-DBUILD_TOXAV=OFF \
-DENABLE_SHARED=OFF \
-DBUILD_FUZZ_TESTS=ON \
-DDHT_BOOTSTRAP=OFF \
-DBOOTSTRAP_DAEMON=OFF \
"$SRC"/c-toxcore

for TARGET in "${FUZZ_TARGETS[@]}"; do
# build fuzzer target
Expand Down
12 changes: 6 additions & 6 deletions .github/scripts/cmake-osx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ brew update
brew install \
libconfig \
libvpx \
ninja \
opus

. ".github/scripts/flags-clang.sh"
Expand All @@ -25,7 +26,7 @@ add_flag -Werror
add_c_flag -Wno-c11-extensions
add_c_flag -Wno-pre-c11-compat

cmake -B_build -H. \
cmake -GNinja -B_build -H. \
-DCMAKE_C_FLAGS="$C_FLAGS" \
-DCMAKE_CXX_FLAGS="$CXX_FLAGS" \
-DCMAKE_EXE_LINKER_FLAGS="$LD_FLAGS" \
Expand All @@ -38,11 +39,10 @@ cmake -B_build -H. \
-DUSE_IPV6=OFF \
-DAUTOTEST=ON

cd _build # pushd
make "-j$NPROC" -k install
cmake --build _build
cmake --install _build

# TODO(iphydf): Investigate if we can get lan discovery to work on macos CI.
# It works, but CI doesn't let us press the "allow broadcast" button.
ctest -j50 --output-on-failure --rerun-failed --repeat until-pass:6 -E lan_discovery ||
ctest -j50 --output-on-failure --rerun-failed --repeat until-pass:6 -E lan_discovery
cd - # popd
ctest --test-dir _build -j50 --output-on-failure --rerun-failed --repeat until-pass:6 -E lan_discovery ||
ctest --test-dir _build -j50 --output-on-failure --rerun-failed --repeat until-pass:6 -E lan_discovery
14 changes: 13 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,10 @@ set(toxcore_SOURCES
toxcore/onion_client.c
toxcore/onion_client.h
toxcore/onion.h
toxcore/os_memory.c
toxcore/os_memory.h
toxcore/os_random.c
toxcore/os_random.h
toxcore/ping_array.c
toxcore/ping_array.h
toxcore/ping.c
Expand All @@ -340,6 +344,7 @@ set(toxcore_SOURCES
toxcore/timed_auth.c
toxcore/timed_auth.h
toxcore/tox_api.c
toxcore/tox_attributes.h
toxcore/tox.c
toxcore/tox.h
toxcore/tox_dispatch.c
Expand All @@ -350,12 +355,18 @@ set(toxcore_SOURCES
toxcore/tox_events.h
toxcore/tox_log_level.c
toxcore/tox_log_level.h
toxcore/tox_memory.c
toxcore/tox_memory.h
toxcore/tox_memory_impl.h
toxcore/tox_options.c
toxcore/tox_options.h
toxcore/tox_private.c
toxcore/tox_private.h
toxcore/tox_pack.c
toxcore/tox_pack.h
toxcore/tox_random.c
toxcore/tox_random.h
toxcore/tox_random_impl.h
toxcore/tox_unpack.c
toxcore/tox_unpack.h
toxcore/util.c
Expand All @@ -379,7 +390,8 @@ if(EXPERIMENTAL_API)
set(toxcore_API_HEADERS ${toxcore_API_HEADERS}
${toxcore_SOURCE_DIR}/toxcore/tox_dispatch.h^tox
${toxcore_SOURCE_DIR}/toxcore/tox_events.h^tox
${toxcore_SOURCE_DIR}/toxcore/tox_private.h^tox)
${toxcore_SOURCE_DIR}/toxcore/tox_private.h^tox
${toxcore_SOURCE_DIR}/toxcore/tox_random.h^tox)
endif()

################################################################################
Expand Down
2 changes: 2 additions & 0 deletions auto_tests/TCP_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#include "../toxcore/mono_time.h"
#include "../toxcore/net_profile.h"
#include "../toxcore/network.h"
#include "../toxcore/os_memory.h"
#include "../toxcore/os_random.h"
#include "auto_test_support.h"

#define NUM_PORTS 3
Expand Down
6 changes: 2 additions & 4 deletions auto_tests/announce_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@
#include <string.h>

#include "../toxcore/announce.h"
#include "../toxcore/tox.h"
#include "../testing/misc_tools.h"
#include "../toxcore/mono_time.h"
#include "../toxcore/forwarding.h"
#include "../toxcore/net_crypto.h"
#include "../toxcore/util.h"
#include "../toxcore/os_memory.h"
#include "../toxcore/os_random.h"
#include "auto_test_support.h"
#include "check_compat.h"

Expand Down
1 change: 1 addition & 0 deletions auto_tests/conference_av_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <stdint.h>

#include "../toxav/toxav.h"
#include "../toxcore/os_random.h"
#include "check_compat.h"

#define NUM_AV_GROUP_TOX 16
Expand Down
1 change: 1 addition & 0 deletions auto_tests/conference_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <time.h>
#include <stdint.h>

#include "../toxcore/os_random.h"
#include "../toxcore/util.h"

#include "check_compat.h"
Expand Down
3 changes: 2 additions & 1 deletion auto_tests/crypto_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
#include <stdlib.h>
#include <string.h>

#include "../testing/misc_tools.h"
#include "../toxcore/crypto_core.h"
#include "../toxcore/net_crypto.h"
#include "../toxcore/os_memory.h"
#include "../toxcore/os_random.h"
#include "check_compat.h"

static void rand_bytes(const Random *rng, uint8_t *b, size_t blen)
Expand Down
12 changes: 11 additions & 1 deletion auto_tests/dht_nodes_response_api_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
#include "check_compat.h"

#define NUM_TOXES 30
// Maximum number of iterations to wait for all nodes to be crawled. 5 should
// be enough. We pick 10 in case things are slow. This makes the test take
// less time in case it completely fails, so we can retry it.
#define MAX_ITERATIONS 10

typedef struct Dht_Node {
uint8_t public_key[TOX_DHT_NODE_PUBLIC_KEY_SIZE];
Expand Down Expand Up @@ -132,9 +136,15 @@ static void test_dht_nodes_request(AutoTox *autotoxes)
tox_dht_get_num_closelist_announce_capable(autotoxes[i].tox));
}

while (!all_nodes_crawled(autotoxes, NUM_TOXES, public_key_list)) {
bool success = false;
for (size_t i = 0; i < MAX_ITERATIONS; ++i) {
if (all_nodes_crawled(autotoxes, NUM_TOXES, public_key_list)) {
success = true;
break;
}
iterate_all_wait(autotoxes, NUM_TOXES, ITERATION_INTERVAL);
}
ck_assert_msg(success, "Failed to crawl all nodes within %d iterations", MAX_ITERATIONS);

for (size_t i = 0; i < NUM_TOXES; ++i) {
State *state = (State *)autotoxes[i].state;
Expand Down
2 changes: 1 addition & 1 deletion auto_tests/encryptsave_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
#include <string.h>
#include <sys/types.h>

#include "../testing/misc_tools.h"
#include "../toxcore/ccompat.h"
#include "../toxcore/crypto_core.h"
#include "../toxcore/os_random.h"
#include "../toxcore/tox.h"
#include "../toxencryptsave/toxencryptsave.h"
#include "auto_test_support.h"
Expand Down
3 changes: 2 additions & 1 deletion auto_tests/forwarding_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
#include "../toxcore/mono_time.h"
#include "../toxcore/forwarding.h"
#include "../toxcore/net_crypto.h"
#include "../toxcore/util.h"
#include "../toxcore/os_memory.h"
#include "../toxcore/os_random.h"
#include "auto_test_support.h"
#include "check_compat.h"

Expand Down
1 change: 1 addition & 0 deletions auto_tests/group_message_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

#include "auto_test_support.h"
#include "check_compat.h"
#include "../toxcore/os_random.h"
#include "../toxcore/util.h"

typedef struct State {
Expand Down
1 change: 1 addition & 0 deletions auto_tests/group_sync_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include "auto_test_support.h"

#include "../toxcore/os_random.h"
#include "../toxcore/tox.h"
#include "../toxcore/util.h"

Expand Down
3 changes: 1 addition & 2 deletions auto_tests/group_topic_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@

#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>

#include "auto_test_support.h"
#include "check_compat.h"

#include "../toxcore/os_random.h"
#include "../toxcore/tox.h"
#include "../toxcore/group_chats.h"

#define NUM_GROUP_TOXES 3

Expand Down
1 change: 1 addition & 0 deletions auto_tests/network_test.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <string.h>

#include "../toxcore/network.h"
#include "../toxcore/os_memory.h"
#include "check_compat.h"

#ifndef USE_IPV6
Expand Down
3 changes: 2 additions & 1 deletion auto_tests/onion_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
#include "../toxcore/onion.h"
#include "../toxcore/onion_announce.h"
#include "../toxcore/onion_client.h"
#include "../toxcore/util.h"
#include "../toxcore/os_memory.h"
#include "../toxcore/os_random.h"
#include "auto_test_support.h"
#include "check_compat.h"

Expand Down
3 changes: 1 addition & 2 deletions auto_tests/reconnect_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@
*/

#include <stdlib.h>
#include <string.h>
#include <time.h>

#include "../testing/misc_tools.h"
#include "../toxcore/friend_connection.h"
#include "../toxcore/os_random.h"
#include "../toxcore/tox.h"
#include "../toxcore/util.h"
#include "check_compat.h"

#define TOX_COUNT 2
Expand Down
1 change: 1 addition & 0 deletions auto_tests/save_friend_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "../testing/misc_tools.h"
#include "../toxcore/ccompat.h"
#include "../toxcore/crypto_core.h"
#include "../toxcore/os_random.h"
#include "../toxcore/tox.h"
#include "auto_test_support.h"
#include "check_compat.h"
Expand Down
3 changes: 1 addition & 2 deletions auto_tests/tox_many_tcp_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

#include "../testing/misc_tools.h"
#include "../toxcore/crypto_core.h"
#include "../toxcore/os_random.h"
#include "../toxcore/tox.h"
#include "../toxcore/util.h"
#include "auto_test_support.h"
#include "check_compat.h"

Expand Down
3 changes: 1 addition & 2 deletions auto_tests/tox_many_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

#include "../testing/misc_tools.h"
#include "../toxcore/crypto_core.h"
#include "../toxcore/os_random.h"
#include "../toxcore/tox.h"
#include "../toxcore/util.h"
#include "auto_test_support.h"
#include "check_compat.h"

Expand Down
2 changes: 2 additions & 0 deletions other/DHT_bootstrap.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
#include "../toxcore/network.h"
#include "../toxcore/onion.h"
#include "../toxcore/onion_announce.h"
#include "../toxcore/os_memory.h"
#include "../toxcore/os_random.h"
#include "../toxcore/tox.h"

#define TCP_RELAY_ENABLED
Expand Down
2 changes: 2 additions & 0 deletions other/analysis/run-cppcheck
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ CPPCHECK+=("--suppress=knownConditionTrueFalse")
CPPCHECK+=("--suppress=missingIncludeSystem")
# TODO(iphydf): Maybe fix?
CPPCHECK+=("--suppress=signConversion")
# We have suppressions in the code for the misra extension.
CPPCHECK+=("--suppress=unmatchedSuppression")

# We use this for VLAs.
CPPCHECK_CXX+=("--suppress=allocaCalled")
Expand Down
1 change: 1 addition & 0 deletions other/bootstrap_daemon/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ cc_binary(
"//c-toxcore/toxcore:network",
"//c-toxcore/toxcore:onion",
"//c-toxcore/toxcore:onion_announce",
"//c-toxcore/toxcore:os_random",
"//c-toxcore/toxcore:tox",
"@libconfig",
],
Expand Down
7 changes: 4 additions & 3 deletions other/bootstrap_daemon/src/tox-bootstrapd.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,12 @@
#include "../../../toxcore/group_announce.h"
#include "../../../toxcore/group_onion_announce.h"
#include "../../../toxcore/logger.h"
#include "../../../toxcore/mem.h"
#include "../../../toxcore/mono_time.h"
#include "../../../toxcore/network.h"
#include "../../../toxcore/onion.h"
#include "../../../toxcore/onion_announce.h"
#include "../../../toxcore/os_memory.h"
#include "../../../toxcore/os_random.h"

// misc
#include "../../bootstrap_node_packets.h"
Expand Down Expand Up @@ -283,8 +284,8 @@ int main(int argc, char *argv[])
IP ip;
ip_init(&ip, enable_ipv6);

const Memory *mem = os_memory();
const Random *rng = os_random();
const Tox_Memory *mem = os_memory();
const Tox_Random *rng = os_random();
const Network *ns = os_network();

Logger *logger = logger_new(mem);
Expand Down
2 changes: 2 additions & 0 deletions testing/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ cc_binary(
"//c-toxcore/toxcore:Messenger",
"//c-toxcore/toxcore:ccompat",
"//c-toxcore/toxcore:mono_time",
"//c-toxcore/toxcore:os_memory",
"//c-toxcore/toxcore:os_random",
],
)

Expand Down
2 changes: 2 additions & 0 deletions testing/Messenger_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
#include "../toxcore/Messenger.h"
#include "../toxcore/ccompat.h"
#include "../toxcore/mono_time.h"
#include "../toxcore/os_memory.h"
#include "../toxcore/os_random.h"
#include "misc_tools.h"

static void print_message(Messenger *m, uint32_t friendnumber, unsigned int type, const uint8_t *string, size_t length,
Expand Down
Loading
Loading