Compare commits
48 Commits
good_maste
...
7359e30c3e
Author | SHA1 | Date | |
---|---|---|---|
7359e30c3e | |||
5effe64474 | |||
61accfe184 | |||
2f44996edc | |||
b1fe064484 | |||
18ca88a0d4 | |||
565aa4b7eb | |||
b117da5ccf | |||
8eb4892b49 | |||
82fe4c3dd7 | |||
78b0e9a77f | |||
7fa6aa7ac2 | |||
20b4cdc5f1 | |||
7c576dd4d0 | |||
f6cda522ca | |||
3d2f5b644b | |||
9ace11a0e2 | |||
6104d3b6d1 | |||
f637c7c942 | |||
afb886ea7c | |||
74129cabef | |||
be8ceb861c | |||
da0f59a3f5 | |||
000254320e | |||
2fac7206d2 | |||
e8234f2a4a | |||
a0ba0b39d8 | |||
845967cf12 | |||
92b58cbfa9 | |||
5a0651eaf0 | |||
14fcaf1d7e | |||
5a0252d8d0 | |||
9c0ffd38ce | |||
b2ae9530a4 | |||
ae1fb0fde3 | |||
35ebbbef93 | |||
83e200df43 | |||
260d3b7818 | |||
4ebffd8c63 | |||
8923e09b36 | |||
ec4195f18a | |||
062ad7ae80 | |||
aad07611c7 | |||
0dcb66f143 | |||
331c25b0e6 | |||
e50844be06 | |||
4dd7c98c1a | |||
63bad2e99a |
72
.github/workflows/cd.yml
vendored
72
.github/workflows/cd.yml
vendored
@@ -10,10 +10,40 @@ env:
|
|||||||
BUILD_TYPE: Release
|
BUILD_TYPE: Release
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
linux-ubuntu:
|
||||||
|
timeout-minutes: 10
|
||||||
|
|
||||||
|
runs-on: ubuntu-20.04
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
submodules: recursive
|
||||||
|
|
||||||
|
- name: Install Dependencies
|
||||||
|
run: sudo apt update && sudo apt -y install libsodium-dev
|
||||||
|
|
||||||
|
- name: Configure CMake
|
||||||
|
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4
|
||||||
|
|
||||||
|
- name: temp test
|
||||||
|
run: ${{github.workspace}}/build/bin/mono_time_test
|
||||||
|
|
||||||
|
- uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: ${{ github.event.repository.name }}-ubuntu20.04-x86_64
|
||||||
|
# TODO: do propper packing
|
||||||
|
path: |
|
||||||
|
${{github.workspace}}/build/bin/
|
||||||
|
|
||||||
|
|
||||||
windows:
|
windows:
|
||||||
timeout-minutes: 15
|
timeout-minutes: 15
|
||||||
|
|
||||||
runs-on: windows-latest
|
runs-on: windows-2019
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
@@ -34,10 +64,50 @@ jobs:
|
|||||||
- name: Build
|
- name: Build
|
||||||
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4
|
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4
|
||||||
|
|
||||||
|
- name: temp test
|
||||||
|
run: ${{github.workspace}}/build/bin/mono_time_test.exe
|
||||||
|
|
||||||
- uses: actions/upload-artifact@v3
|
- uses: actions/upload-artifact@v3
|
||||||
|
if: success() || failure()
|
||||||
with:
|
with:
|
||||||
name: ${{ github.event.repository.name }}-windows-msvc-x86_64
|
name: ${{ github.event.repository.name }}-windows-msvc-x86_64
|
||||||
# TODO: do propper packing
|
# TODO: do propper packing
|
||||||
path: |
|
path: |
|
||||||
${{github.workspace}}/build/bin/
|
${{github.workspace}}/build/bin/
|
||||||
|
|
||||||
|
windows-asan:
|
||||||
|
timeout-minutes: 15
|
||||||
|
|
||||||
|
runs-on: windows-2019
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
submodules: recursive
|
||||||
|
|
||||||
|
- name: Install Dependencies
|
||||||
|
run: vcpkg install libsodium:x64-windows-static pthreads:x64-windows-static
|
||||||
|
|
||||||
|
# setup vs env
|
||||||
|
- uses: ilammy/msvc-dev-cmd@v1
|
||||||
|
with:
|
||||||
|
arch: amd64
|
||||||
|
|
||||||
|
- name: Configure CMake
|
||||||
|
run: cmake -G Ninja -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows-static -DTOMATO_ASAN=ON -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4
|
||||||
|
|
||||||
|
- name: temp test
|
||||||
|
run: ${{github.workspace}}/build/bin/mono_time_test.exe
|
||||||
|
|
||||||
|
- uses: actions/upload-artifact@v3
|
||||||
|
if: success() || failure()
|
||||||
|
with:
|
||||||
|
name: ${{ github.event.repository.name }}-windows-msvc-asan-x86_64
|
||||||
|
# TODO: do propper packing
|
||||||
|
# TODO: also switch to asan dlls
|
||||||
|
path: |
|
||||||
|
${{github.workspace}}/build/bin/
|
||||||
|
|
||||||
|
6
.github/workflows/ci.yml
vendored
6
.github/workflows/ci.yml
vendored
@@ -29,6 +29,9 @@ jobs:
|
|||||||
- name: Build
|
- name: Build
|
||||||
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4
|
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4
|
||||||
|
|
||||||
|
- name: temp test
|
||||||
|
run: ${{github.workspace}}/build/bin/mono_time_test
|
||||||
|
|
||||||
macos:
|
macos:
|
||||||
timeout-minutes: 10
|
timeout-minutes: 10
|
||||||
|
|
||||||
@@ -72,3 +75,6 @@ jobs:
|
|||||||
- name: Build
|
- name: Build
|
||||||
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4
|
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4
|
||||||
|
|
||||||
|
- name: temp test
|
||||||
|
run: ${{github.workspace}}/build/bin/mono_time_test.exe
|
||||||
|
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
cmake_minimum_required(VERSION 3.9 FATAL_ERROR)
|
cmake_minimum_required(VERSION 3.14...3.24 FATAL_ERROR)
|
||||||
|
|
||||||
# cmake setup begin
|
# cmake setup begin
|
||||||
project(tomato)
|
project(tomato)
|
||||||
@@ -18,6 +18,26 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
|
|||||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
|
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
|
||||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
|
||||||
|
|
||||||
|
option(TOMATO_ASAN "Build tomato with asan (gcc/clang/msvc)" OFF)
|
||||||
|
|
||||||
|
if (TOMATO_ASAN)
|
||||||
|
if (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU" OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
|
||||||
|
if (NOT WIN32) # exclude mingw
|
||||||
|
link_libraries(-fsanitize=address)
|
||||||
|
#link_libraries(-fsanitize=address,undefined)
|
||||||
|
#link_libraries(-fsanitize=undefined)
|
||||||
|
message("II enabled ASAN")
|
||||||
|
else()
|
||||||
|
message("!! can not enable ASAN on this platform (gcc/clang + win)")
|
||||||
|
endif()
|
||||||
|
elseif (MSVC)
|
||||||
|
add_compile_options("/fsanitize=address")
|
||||||
|
message("II enabled ASAN")
|
||||||
|
else()
|
||||||
|
message("!! can not enable ASAN on this platform")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
# external libs
|
# external libs
|
||||||
add_subdirectory(./external) # before increasing warn levels, sad :(
|
add_subdirectory(./external) # before increasing warn levels, sad :(
|
||||||
|
|
||||||
@@ -33,13 +53,8 @@ if (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU" OR ${CMAKE_CXX_COMPILER_ID} STREQUAL
|
|||||||
#-Wsign-conversion # Warn on sign conversions
|
#-Wsign-conversion # Warn on sign conversions
|
||||||
-Wshadow # Warn if a variable declaration shadows one from a parent context
|
-Wshadow # Warn if a variable declaration shadows one from a parent context
|
||||||
)
|
)
|
||||||
|
|
||||||
if (NOT WIN32)
|
|
||||||
#link_libraries(-fsanitize=address,undefined)
|
|
||||||
#link_libraries(-fsanitize=undefined)
|
|
||||||
endif()
|
|
||||||
elseif (${CMAKE_CXX_COMPILER_ID} STREQUAL "MSVC")
|
elseif (${CMAKE_CXX_COMPILER_ID} STREQUAL "MSVC")
|
||||||
if (CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
|
if (MSVC)
|
||||||
string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||||
else()
|
else()
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
|
||||||
|
2
external/solanaceae_message3
vendored
2
external/solanaceae_message3
vendored
Submodule external/solanaceae_message3 updated: 1a036c2321...60fc0d34eb
2
external/solanaceae_plugin
vendored
2
external/solanaceae_plugin
vendored
Submodule external/solanaceae_plugin updated: eeab3109e7...b502690621
2
external/solanaceae_tox
vendored
2
external/solanaceae_tox
vendored
Submodule external/solanaceae_tox updated: 89e74b35f8...ce760a800c
2
external/solanaceae_toxcore
vendored
2
external/solanaceae_toxcore
vendored
Submodule external/solanaceae_toxcore updated: d05875f489...3df9125877
2
external/solanaceae_util
vendored
2
external/solanaceae_util
vendored
Submodule external/solanaceae_util updated: 2b20c2d2a4...fa0a09df87
10
external/toxcore/CMakeLists.txt
vendored
10
external/toxcore/CMakeLists.txt
vendored
@@ -127,11 +127,15 @@ add_library(toxcore STATIC
|
|||||||
${TOX_DIR}toxcore/tox.c
|
${TOX_DIR}toxcore/tox.c
|
||||||
${TOX_DIR}toxcore/tox_dispatch.c
|
${TOX_DIR}toxcore/tox_dispatch.c
|
||||||
${TOX_DIR}toxcore/tox_dispatch.h
|
${TOX_DIR}toxcore/tox_dispatch.h
|
||||||
|
${TOX_DIR}toxcore/tox_event.c
|
||||||
|
${TOX_DIR}toxcore/tox_event.h
|
||||||
${TOX_DIR}toxcore/tox_events.c
|
${TOX_DIR}toxcore/tox_events.c
|
||||||
${TOX_DIR}toxcore/tox_events.h
|
${TOX_DIR}toxcore/tox_events.h
|
||||||
${TOX_DIR}toxcore/tox.h
|
${TOX_DIR}toxcore/tox.h
|
||||||
${TOX_DIR}toxcore/tox_private.c
|
${TOX_DIR}toxcore/tox_private.c
|
||||||
${TOX_DIR}toxcore/tox_private.h
|
${TOX_DIR}toxcore/tox_private.h
|
||||||
|
${TOX_DIR}toxcore/tox_pack.h
|
||||||
|
${TOX_DIR}toxcore/tox_pack.c
|
||||||
${TOX_DIR}toxcore/tox_unpack.c
|
${TOX_DIR}toxcore/tox_unpack.c
|
||||||
${TOX_DIR}toxcore/tox_unpack.h
|
${TOX_DIR}toxcore/tox_unpack.h
|
||||||
${TOX_DIR}toxcore/util.c
|
${TOX_DIR}toxcore/util.c
|
||||||
@@ -203,6 +207,10 @@ add_executable(DHT_Bootstrap EXCLUDE_FROM_ALL
|
|||||||
${TOX_DIR}testing/misc_tools.h
|
${TOX_DIR}testing/misc_tools.h
|
||||||
${TOX_DIR}testing/misc_tools.c
|
${TOX_DIR}testing/misc_tools.c
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(DHT_Bootstrap toxcore)
|
target_link_libraries(DHT_Bootstrap toxcore)
|
||||||
|
|
||||||
|
add_executable(mono_time_test
|
||||||
|
./mono_time_test.cc
|
||||||
|
)
|
||||||
|
target_link_libraries(mono_time_test toxcore)
|
||||||
|
target_compile_features(mono_time_test PUBLIC cxx_std_11)
|
||||||
|
44
external/toxcore/c-toxcore/.circleci/config.yml
vendored
44
external/toxcore/c-toxcore/.circleci/config.yml
vendored
@@ -15,9 +15,7 @@ workflows:
|
|||||||
- ubsan
|
- ubsan
|
||||||
# Static analysis
|
# Static analysis
|
||||||
- clang-analyze
|
- clang-analyze
|
||||||
- clang-tidy
|
|
||||||
- cpplint
|
- cpplint
|
||||||
- infer
|
|
||||||
- static-analysis
|
- static-analysis
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
@@ -70,6 +68,7 @@ jobs:
|
|||||||
cmake
|
cmake
|
||||||
git
|
git
|
||||||
libconfig-dev
|
libconfig-dev
|
||||||
|
libgmock-dev
|
||||||
libgtest-dev
|
libgtest-dev
|
||||||
libopus-dev
|
libopus-dev
|
||||||
libsodium-dev
|
libsodium-dev
|
||||||
@@ -103,27 +102,6 @@ jobs:
|
|||||||
- run: git submodule update --init --recursive
|
- run: git submodule update --init --recursive
|
||||||
- run: CC=clang .circleci/cmake-ubsan
|
- run: CC=clang .circleci/cmake-ubsan
|
||||||
|
|
||||||
infer:
|
|
||||||
working_directory: ~/work
|
|
||||||
docker:
|
|
||||||
- image: toxchat/infer
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- run: *apt_install
|
|
||||||
- checkout
|
|
||||||
- run: git submodule update --init --recursive
|
|
||||||
- run: infer --no-progress-bar -- cc
|
|
||||||
auto_tests/auto_test_support.c
|
|
||||||
auto_tests/lossless_packet_test.c
|
|
||||||
testing/misc_tools.c
|
|
||||||
toxav/*.c
|
|
||||||
toxcore/*.c
|
|
||||||
toxcore/*/*.c
|
|
||||||
toxencryptsave/*.c
|
|
||||||
third_party/cmp/*.c
|
|
||||||
-lpthread
|
|
||||||
$(pkg-config --cflags --libs libsodium opus vpx)
|
|
||||||
|
|
||||||
static-analysis:
|
static-analysis:
|
||||||
working_directory: ~/work
|
working_directory: ~/work
|
||||||
docker:
|
docker:
|
||||||
@@ -134,7 +112,6 @@ jobs:
|
|||||||
- run:
|
- run:
|
||||||
apt-get install -y --no-install-recommends
|
apt-get install -y --no-install-recommends
|
||||||
ca-certificates
|
ca-certificates
|
||||||
cppcheck
|
|
||||||
g++
|
g++
|
||||||
llvm-dev
|
llvm-dev
|
||||||
- checkout
|
- checkout
|
||||||
@@ -142,7 +119,6 @@ jobs:
|
|||||||
- run: other/analysis/check_includes
|
- run: other/analysis/check_includes
|
||||||
- run: other/analysis/check_logger_levels
|
- run: other/analysis/check_logger_levels
|
||||||
- run: other/analysis/run-clang
|
- run: other/analysis/run-clang
|
||||||
- run: other/analysis/run-cppcheck
|
|
||||||
- run: other/analysis/run-gcc
|
- run: other/analysis/run-gcc
|
||||||
|
|
||||||
clang-analyze:
|
clang-analyze:
|
||||||
@@ -156,24 +132,6 @@ jobs:
|
|||||||
- run: git submodule update --init --recursive
|
- run: git submodule update --init --recursive
|
||||||
- run: other/analysis/run-clang-analyze
|
- run: other/analysis/run-clang-analyze
|
||||||
|
|
||||||
clang-tidy:
|
|
||||||
working_directory: ~/work
|
|
||||||
docker:
|
|
||||||
- image: ubuntu
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- run: *apt_install
|
|
||||||
- run:
|
|
||||||
apt-get install -y --no-install-recommends
|
|
||||||
ca-certificates
|
|
||||||
clang-tidy-14
|
|
||||||
- checkout
|
|
||||||
- run: git submodule update --init --recursive
|
|
||||||
- run:
|
|
||||||
other/analysis/run-clang-tidy ||
|
|
||||||
other/analysis/run-clang-tidy ||
|
|
||||||
other/analysis/run-clang-tidy
|
|
||||||
|
|
||||||
cpplint:
|
cpplint:
|
||||||
working_directory: ~/work
|
working_directory: ~/work
|
||||||
docker:
|
docker:
|
||||||
|
9
external/toxcore/c-toxcore/.clang-tidy
vendored
9
external/toxcore/c-toxcore/.clang-tidy
vendored
@@ -1,4 +1,5 @@
|
|||||||
# vim:ft=yaml
|
# vim:ft=yaml
|
||||||
|
HeaderFilterRegex: "/c-toxcore/[^/]+/[^.].+"
|
||||||
CheckOptions:
|
CheckOptions:
|
||||||
- key: readability-identifier-naming.ClassCase
|
- key: readability-identifier-naming.ClassCase
|
||||||
value: Camel_Snake_Case
|
value: Camel_Snake_Case
|
||||||
@@ -35,6 +36,12 @@ CheckOptions:
|
|||||||
value: lower_case
|
value: lower_case
|
||||||
|
|
||||||
- key: llvmlibc-restrict-system-libc-headers.Includes
|
- key: llvmlibc-restrict-system-libc-headers.Includes
|
||||||
value: "arpa/inet.h,assert.h,ctype.h,errno.h,fcntl.h,getopt.h,libconfig.h,linux/netdevice.h,math.h,netdb.h,netinet/in.h,opus.h,pthread.h,signal.h,sodium/crypto_scalarmult_curve25519.h,sodium.h,sodium/randombytes.h,stdio.h,stdlib.h,string.h,sys/ioctl.h,syslog.h,sys/resource.h,sys/socket.h,sys/stat.h,sys/time.h,sys/types.h,time.h,unistd.h,vpx/vp8cx.h,vpx/vp8dx.h,vpx/vpx_decoder.h,vpx/vpx_encoder.h,vpx/vpx_image.h"
|
value: "arpa/inet.h,assert.h,ctype.h,errno.h,fcntl.h,getopt.h,libconfig.h,limits.h,linux/if.h,math.h,netdb.h,netinet/in.h,opus.h,pthread.h,signal.h,sodium/crypto_scalarmult_curve25519.h,sodium.h,sodium/randombytes.h,stdarg.h,stdbool.h,stddef.h,stdint.h,stdio.h,stdlib.h,string.h,sys/ioctl.h,syslog.h,sys/resource.h,sys/socket.h,sys/stat.h,sys/time.h,sys/types.h,time.h,unistd.h,vpx/vp8cx.h,vpx/vp8dx.h,vpx/vpx_decoder.h,vpx/vpx_encoder.h,vpx/vpx_image.h"
|
||||||
- key: hicpp-signed-bitwise.IgnorePositiveIntegerLiterals
|
- key: hicpp-signed-bitwise.IgnorePositiveIntegerLiterals
|
||||||
value: true
|
value: true
|
||||||
|
- key: concurrency-mt-unsafe.FunctionSet
|
||||||
|
value: posix
|
||||||
|
- key: misc-include-cleaner.IgnoreHeaders
|
||||||
|
value: "pthread.h;stdbool.h;stddef.h;stdint.;stdint.h;stdint...;cstdint;sodium.*;sys/.*;unistd.h;opus.*;vpx.*;attributes.h;tox_struct.h"
|
||||||
|
- key: readability-function-cognitive-complexity.Threshold
|
||||||
|
value: 153 # TODO(iphydf): Decrease. tox_new is the highest at the moment.
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
#!/bin/bash -eu
|
#!/bin/bash -eu
|
||||||
|
|
||||||
FUZZ_TARGETS="bootstrap_fuzzer toxsave_fuzzer"
|
FUZZ_TARGETS="bootstrap_fuzz_test toxsave_fuzz_test"
|
||||||
|
|
||||||
# out of tree build
|
# out of tree build
|
||||||
cd "$WORK"
|
cd "$WORK"
|
||||||
|
@@ -11,10 +11,7 @@ add_ld_flag -Wl,-z,defs
|
|||||||
# Make compilation error on a warning
|
# Make compilation error on a warning
|
||||||
add_flag -Werror
|
add_flag -Werror
|
||||||
|
|
||||||
add_config_flag --with-nacl-libs="$CACHEDIR/lib/amd64"
|
|
||||||
add_config_flag --with-nacl-headers="$CACHEDIR/include/amd64"
|
|
||||||
add_config_flag --disable-ipv6
|
add_config_flag --disable-ipv6
|
||||||
add_config_flag --enable-nacl
|
|
||||||
add_config_flag --enable-daemon
|
add_config_flag --enable-daemon
|
||||||
add_config_flag --with-log-level=TRACE
|
add_config_flag --with-log-level=TRACE
|
||||||
|
|
||||||
|
@@ -1,61 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
set -eu
|
|
||||||
|
|
||||||
NPROC=$(nproc)
|
|
||||||
|
|
||||||
sudo apt-get install -y --no-install-recommends \
|
|
||||||
libgtest-dev \
|
|
||||||
libopus-dev \
|
|
||||||
libsodium-dev \
|
|
||||||
libvpx-dev \
|
|
||||||
llvm-14 \
|
|
||||||
ninja-build
|
|
||||||
git clone --depth=1 https://github.com/ralight/mallocfail /tmp/mallocfail
|
|
||||||
cd /tmp/mallocfail # pushd
|
|
||||||
make
|
|
||||||
sudo make install
|
|
||||||
cd - # popd
|
|
||||||
|
|
||||||
export CC=clang
|
|
||||||
export CXX=clang++
|
|
||||||
|
|
||||||
sudo install other/docker/coverage/run_mallocfail /usr/local/bin/run_mallocfail
|
|
||||||
(cd other/proxy && go get && go build)
|
|
||||||
other/proxy/proxy &
|
|
||||||
|
|
||||||
. ".github/scripts/flags-coverage.sh"
|
|
||||||
|
|
||||||
cmake -B_build -H. -GNinja \
|
|
||||||
-DCMAKE_C_FLAGS="$C_FLAGS" \
|
|
||||||
-DCMAKE_CXX_FLAGS="$CXX_FLAGS" \
|
|
||||||
-DCMAKE_EXE_LINKER_FLAGS="$LD_FLAGS" \
|
|
||||||
-DCMAKE_SHARED_LINKER_FLAGS="$LD_FLAGS" \
|
|
||||||
-DCMAKE_INSTALL_PREFIX:PATH="$PWD/_install" \
|
|
||||||
-DENABLE_SHARED=OFF \
|
|
||||||
-DMIN_LOGGER_LEVEL=TRACE \
|
|
||||||
-DMUST_BUILD_TOXAV=ON \
|
|
||||||
-DNON_HERMETIC_TESTS=OFF \
|
|
||||||
-DSTRICT_ABI=ON \
|
|
||||||
-DTEST_TIMEOUT_SECONDS=120 \
|
|
||||||
-DUSE_IPV6=OFF \
|
|
||||||
-DAUTOTEST=ON \
|
|
||||||
-DPROXY_TEST=ON
|
|
||||||
|
|
||||||
cmake --build _build --parallel "$NPROC" --target install -- -k 0
|
|
||||||
|
|
||||||
cd _build # pushd
|
|
||||||
ctest -j50 --output-on-failure --rerun-failed --repeat until-pass:6 ||
|
|
||||||
ctest -j50 --output-on-failure --rerun-failed --repeat until-pass:6
|
|
||||||
|
|
||||||
export PYTHONUNBUFFERED=1
|
|
||||||
run_mallocfail --ctest=2 --jobs=8
|
|
||||||
cd - # popd
|
|
||||||
|
|
||||||
#coveralls \
|
|
||||||
# --exclude auto_tests \
|
|
||||||
# --exclude other \
|
|
||||||
# --exclude testing \
|
|
||||||
# --gcov-options '\-lp'
|
|
||||||
|
|
||||||
bash <(curl -s https://codecov.io/bash) -x "llvm-cov-14 gcov"
|
|
@@ -65,6 +65,8 @@ add_cxx_flag -Wno-c++98-compat-pedantic
|
|||||||
add_cxx_flag -Wno-c99-extensions
|
add_cxx_flag -Wno-c99-extensions
|
||||||
# We're C-compatible, so use C style casts.
|
# We're C-compatible, so use C style casts.
|
||||||
add_cxx_flag -Wno-old-style-cast
|
add_cxx_flag -Wno-old-style-cast
|
||||||
|
# GTest does this.
|
||||||
|
add_cxx_flag -Wno-global-constructors
|
||||||
|
|
||||||
# Downgrade to warning so we still see it.
|
# Downgrade to warning so we still see it.
|
||||||
add_flag -Wno-error=unreachable-code
|
add_flag -Wno-error=unreachable-code
|
||||||
|
@@ -5,16 +5,16 @@
|
|||||||
add_ld_flag -Wl,-z,defs
|
add_ld_flag -Wl,-z,defs
|
||||||
|
|
||||||
# Make compilation error on a warning
|
# Make compilation error on a warning
|
||||||
add_flag -Werror
|
add_flag -Werror -Wno-unsafe-buffer-usage
|
||||||
|
|
||||||
# Coverage flags.
|
# Coverage flags.
|
||||||
add_flag --coverage
|
add_flag -fprofile-instr-generate -fcoverage-mapping
|
||||||
|
|
||||||
# Optimisation, but keep stack traces useful.
|
# Optimisation, but keep stack traces useful.
|
||||||
add_c_flag -fno-inline -fno-omit-frame-pointer
|
add_c_flag -fno-inline -fno-omit-frame-pointer
|
||||||
|
|
||||||
# Show useful stack traces on crash.
|
# Show useful stack traces on crash.
|
||||||
add_flag -fsanitize=undefined -fno-sanitize-recover=all
|
add_flag -fsanitize=undefined -fno-sanitize-recover=all -D_DEBUG
|
||||||
|
|
||||||
# In test code (_test.cc and libgtest), throw away all debug information.
|
# In test code (_test.cc and libgtest), throw away all debug information.
|
||||||
# We only care about stack frames inside toxcore (which is C). Without this,
|
# We only care about stack frames inside toxcore (which is C). Without this,
|
||||||
|
@@ -1,12 +1,15 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
set -exu
|
set -exu -o pipefail
|
||||||
|
|
||||||
LOCAL="${1:-}"
|
LOCAL="${1:-}"
|
||||||
|
|
||||||
readarray -t FILES <<<"$(git ls-files)"
|
readarray -t FILES <<<"$(git ls-files)"
|
||||||
|
|
||||||
tar c "${FILES[@]}" | docker build -f other/bootstrap_daemon/docker/Dockerfile -t toxchat/bootstrap-node -
|
if ! tar c "${FILES[@]}" | docker build -f other/bootstrap_daemon/docker/Dockerfile -t toxchat/bootstrap-node - 2>&1 | tee docker-build.log; then
|
||||||
|
grep -o "::error.*::[a-f0-9]* /usr/local/bin/tox-bootstrapd" docker-build.log
|
||||||
|
false
|
||||||
|
fi
|
||||||
docker tag toxchat/bootstrap-node:latest toxchat/bootstrap-node:"$(other/print-version)"
|
docker tag toxchat/bootstrap-node:latest toxchat/bootstrap-node:"$(other/print-version)"
|
||||||
|
|
||||||
sudo useradd \
|
sudo useradd \
|
||||||
|
86
external/toxcore/c-toxcore/.github/settings.yml
vendored
86
external/toxcore/c-toxcore/.github/settings.yml
vendored
@@ -1,86 +0,0 @@
|
|||||||
---
|
|
||||||
_extends: .github
|
|
||||||
|
|
||||||
repository:
|
|
||||||
name: c-toxcore
|
|
||||||
description: The future of online communications.
|
|
||||||
homepage: https://tox.chat/
|
|
||||||
topics: toxcore, network, p2p, security, encryption, cryptography
|
|
||||||
|
|
||||||
branches:
|
|
||||||
- name: "master"
|
|
||||||
protection:
|
|
||||||
required_status_checks:
|
|
||||||
contexts:
|
|
||||||
- "bazel-dbg"
|
|
||||||
- "bazel-opt"
|
|
||||||
- "build-alpine-s390x"
|
|
||||||
- "build-android"
|
|
||||||
- "build-compcert"
|
|
||||||
- "build-macos"
|
|
||||||
- "build-nacl"
|
|
||||||
- "build-tcc"
|
|
||||||
- "build-win32"
|
|
||||||
- "build-win64"
|
|
||||||
- "ci/circleci: asan"
|
|
||||||
- "ci/circleci: bazel-asan"
|
|
||||||
- "ci/circleci: bazel-msan"
|
|
||||||
- "ci/circleci: bazel-tsan"
|
|
||||||
- "ci/circleci: clang-analyze"
|
|
||||||
- "ci/circleci: clang-tidy"
|
|
||||||
- "ci/circleci: cpplint"
|
|
||||||
- "ci/circleci: infer"
|
|
||||||
- "ci/circleci: static-analysis"
|
|
||||||
- "ci/circleci: tsan"
|
|
||||||
- "ci/circleci: ubsan"
|
|
||||||
- "cimple"
|
|
||||||
- "cimplefmt"
|
|
||||||
- "CodeFactor"
|
|
||||||
- "code-review/reviewable"
|
|
||||||
- "common / buildifier"
|
|
||||||
- "coverage-linux"
|
|
||||||
- "docker-bootstrap-node"
|
|
||||||
- "docker-bootstrap-node-websocket"
|
|
||||||
- "docker-clusterfuzz"
|
|
||||||
- "docker-esp32"
|
|
||||||
- "docker-fuzzer"
|
|
||||||
- "docker-toxcore-js"
|
|
||||||
- "docker-win32"
|
|
||||||
- "docker-win64"
|
|
||||||
- "doxygen"
|
|
||||||
- "freebsd"
|
|
||||||
- "Hound"
|
|
||||||
- "misra"
|
|
||||||
- "mypy"
|
|
||||||
- "program-analysis"
|
|
||||||
- "sonar-scan"
|
|
||||||
- "tokstyle"
|
|
||||||
- "TokTok.c-toxcore"
|
|
||||||
- "TokTok.c-toxcore (windows_msvc_conan shared)"
|
|
||||||
- "TokTok.c-toxcore (windows_msvc_conan static)"
|
|
||||||
|
|
||||||
# Labels specific to c-toxcore.
|
|
||||||
labels:
|
|
||||||
- name: "bootstrap"
|
|
||||||
color: "#01707f"
|
|
||||||
description: "Bootstrap"
|
|
||||||
|
|
||||||
- name: "crypto"
|
|
||||||
color: "#1d76db"
|
|
||||||
description: "Crypto"
|
|
||||||
|
|
||||||
- name: "file transfers"
|
|
||||||
color: "#e02abf"
|
|
||||||
description: "File Transfers"
|
|
||||||
|
|
||||||
- name: "messenger"
|
|
||||||
color: "#d93f0b"
|
|
||||||
description: "Messenger"
|
|
||||||
|
|
||||||
- name: "network"
|
|
||||||
color: "#d4c5f9"
|
|
||||||
description: "Network"
|
|
||||||
|
|
||||||
- name: "toxav"
|
|
||||||
color: "#0052cc"
|
|
||||||
description: "Audio/video"
|
|
231
external/toxcore/c-toxcore/.github/workflows/ci.yml
vendored
231
external/toxcore/c-toxcore/.github/workflows/ci.yml
vendored
@@ -13,14 +13,115 @@ jobs:
|
|||||||
common:
|
common:
|
||||||
uses: TokTok/ci-tools/.github/workflows/common-ci.yml@master
|
uses: TokTok/ci-tools/.github/workflows/common-ci.yml@master
|
||||||
|
|
||||||
|
analysis:
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
tool: [autotools, clang-tidy, compcert, cppcheck, doxygen, infer, misra, tcc, tokstyle]
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
- name: Docker Build
|
||||||
|
uses: docker/build-push-action@v4
|
||||||
|
with:
|
||||||
|
file: other/docker/${{ matrix.tool }}/Dockerfile
|
||||||
|
|
||||||
|
coverage-linux:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
submodules: recursive
|
||||||
|
- name: Build, test, and upload coverage
|
||||||
|
run: other/docker/coverage/run
|
||||||
|
|
||||||
|
generate-events:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
submodules: recursive
|
||||||
|
- name: Run generate_event_c
|
||||||
|
run: |
|
||||||
|
other/event_tooling/run
|
||||||
|
git diff --exit-code
|
||||||
|
|
||||||
|
cimplefmt:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
submodules: recursive
|
||||||
|
- name: Run cimplefmt
|
||||||
|
run: other/docker/cimplefmt/run -u $(find tox* -name "*.[ch]")
|
||||||
|
|
||||||
|
build-android:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
submodules: recursive
|
||||||
|
- run: .github/scripts/cmake-android armeabi-v7a
|
||||||
|
- run: .github/scripts/cmake-android arm64-v8a
|
||||||
|
- run: .github/scripts/cmake-android x86
|
||||||
|
- run: .github/scripts/cmake-android x86_64
|
||||||
|
|
||||||
|
build-macos:
|
||||||
|
runs-on: macos-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
submodules: recursive
|
||||||
|
- name: Build and test
|
||||||
|
run: .github/scripts/cmake-osx
|
||||||
|
|
||||||
|
build-msvc:
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
version: [2019, 2022]
|
||||||
|
runs-on: windows-${{ matrix.version }}
|
||||||
|
env:
|
||||||
|
VCPKG_ROOT: "C:/vcpkg"
|
||||||
|
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
submodules: recursive
|
||||||
|
- name: Export GitHub Actions cache environment variables
|
||||||
|
uses: actions/github-script@v6
|
||||||
|
with:
|
||||||
|
script: |
|
||||||
|
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
|
||||||
|
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
|
||||||
|
- name: Configure CMake
|
||||||
|
run: cmake --preset windows-default
|
||||||
|
- name: Build
|
||||||
|
run: cmake --build _build -j $([int]$env:NUMBER_OF_PROCESSORS+2)
|
||||||
|
- name: Test
|
||||||
|
run: |
|
||||||
|
cd _build
|
||||||
|
ctest -j50 --output-on-failure --rerun-failed --repeat until-pass:6 --build-config Debug
|
||||||
|
|
||||||
|
build-windows:
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
bits: [32, 64]
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
submodules: recursive
|
||||||
|
- name: Cross compilation
|
||||||
|
run: .github/scripts/cmake-win${{ matrix.bits }} script
|
||||||
|
|
||||||
mypy:
|
mypy:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
submodules: recursive
|
submodules: recursive
|
||||||
- name: Set up Python 3.9
|
- name: Set up Python 3.9
|
||||||
uses: actions/setup-python@v1
|
uses: actions/setup-python@v5
|
||||||
with:
|
with:
|
||||||
python-version: 3.9
|
python-version: 3.9
|
||||||
- name: Install mypy
|
- name: Install mypy
|
||||||
@@ -29,129 +130,3 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
(find . -name "*.py" -and -not -name "conanfile.py"; grep -lR '^#!.*python') \
|
(find . -name "*.py" -and -not -name "conanfile.py"; grep -lR '^#!.*python') \
|
||||||
| xargs -n1 -P8 mypy --strict
|
| xargs -n1 -P8 mypy --strict
|
||||||
|
|
||||||
doxygen:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v1
|
|
||||||
- name: Docker Build
|
|
||||||
uses: docker/build-push-action@v2
|
|
||||||
with:
|
|
||||||
file: other/docker/doxygen/Dockerfile
|
|
||||||
|
|
||||||
tokstyle:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v1
|
|
||||||
- name: Docker Build
|
|
||||||
uses: docker/build-push-action@v2
|
|
||||||
with:
|
|
||||||
file: other/docker/tokstyle/Dockerfile
|
|
||||||
|
|
||||||
misra:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v1
|
|
||||||
- name: Docker Build
|
|
||||||
uses: docker/build-push-action@v2
|
|
||||||
with:
|
|
||||||
file: other/docker/misra/Dockerfile
|
|
||||||
|
|
||||||
build-nacl:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v1
|
|
||||||
- name: Docker Build
|
|
||||||
uses: docker/build-push-action@v2
|
|
||||||
with:
|
|
||||||
file: other/docker/autotools/Dockerfile
|
|
||||||
|
|
||||||
build-tcc:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v1
|
|
||||||
- name: Docker Build
|
|
||||||
uses: docker/build-push-action@v2
|
|
||||||
with:
|
|
||||||
file: other/docker/tcc/Dockerfile
|
|
||||||
|
|
||||||
build-compcert:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v1
|
|
||||||
- name: Docker Build
|
|
||||||
uses: docker/build-push-action@v2
|
|
||||||
with:
|
|
||||||
file: other/docker/compcert/Dockerfile
|
|
||||||
|
|
||||||
build-alpine-s390x:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v1
|
|
||||||
- name: Docker Build
|
|
||||||
uses: docker/build-push-action@v2
|
|
||||||
with:
|
|
||||||
file: other/docker/alpine-s390x/Dockerfile
|
|
||||||
|
|
||||||
cimplefmt:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
with:
|
|
||||||
submodules: recursive
|
|
||||||
- name: Run cimplefmt
|
|
||||||
run: other/docker/cimplefmt/run -u $(find tox* -name "*.[ch]")
|
|
||||||
|
|
||||||
build-win32:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
with:
|
|
||||||
submodules: recursive
|
|
||||||
- name: Cross compilation
|
|
||||||
run: .github/scripts/cmake-win32 script
|
|
||||||
|
|
||||||
build-win64:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
with:
|
|
||||||
submodules: recursive
|
|
||||||
- name: Cross compilation
|
|
||||||
run: .github/scripts/cmake-win64 script
|
|
||||||
|
|
||||||
build-macos:
|
|
||||||
runs-on: macos-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
with:
|
|
||||||
submodules: recursive
|
|
||||||
- name: Build and test
|
|
||||||
run: .github/scripts/cmake-osx
|
|
||||||
|
|
||||||
coverage-linux:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
with:
|
|
||||||
submodules: recursive
|
|
||||||
- name: Build, test, and upload coverage
|
|
||||||
run: .github/scripts/coverage-linux
|
|
||||||
|
|
||||||
build-android:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
with:
|
|
||||||
submodules: recursive
|
|
||||||
- run: .github/scripts/cmake-android armeabi-v7a
|
|
||||||
- run: .github/scripts/cmake-android arm64-v8a
|
|
||||||
- run: .github/scripts/cmake-android x86
|
|
||||||
- run: .github/scripts/cmake-android x86_64
|
|
||||||
|
@@ -17,11 +17,11 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Login to DockerHub
|
- name: Login to DockerHub
|
||||||
if: ${{ github.event_name == 'push' }}
|
if: ${{ github.event_name == 'push' }}
|
||||||
uses: docker/login-action@v1
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
submodules: recursive
|
submodules: recursive
|
||||||
- name: Docker Build
|
- name: Docker Build
|
||||||
@@ -38,15 +38,15 @@ jobs:
|
|||||||
needs: [docker-bootstrap-node]
|
needs: [docker-bootstrap-node]
|
||||||
steps:
|
steps:
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v1
|
uses: docker/setup-buildx-action@v3
|
||||||
- name: Login to DockerHub
|
- name: Login to DockerHub
|
||||||
if: ${{ github.event_name == 'push' }}
|
if: ${{ github.event_name == 'push' }}
|
||||||
uses: docker/login-action@v1
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
- name: Build and push
|
- name: Build and push
|
||||||
uses: docker/build-push-action@v2
|
uses: docker/build-push-action@v4
|
||||||
with:
|
with:
|
||||||
context: "{{defaultContext}}:other/bootstrap_daemon/websocket"
|
context: "{{defaultContext}}:other/bootstrap_daemon/websocket"
|
||||||
push: ${{ github.event_name == 'push' }}
|
push: ${{ github.event_name == 'push' }}
|
||||||
@@ -57,17 +57,17 @@ jobs:
|
|||||||
docker-clusterfuzz:
|
docker-clusterfuzz:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v4
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v1
|
uses: docker/setup-buildx-action@v3
|
||||||
- name: Login to DockerHub
|
- name: Login to DockerHub
|
||||||
if: ${{ github.event_name == 'push' }}
|
if: ${{ github.event_name == 'push' }}
|
||||||
uses: docker/login-action@v1
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
- name: Build and push
|
- name: Build and push
|
||||||
uses: docker/build-push-action@v2
|
uses: docker/build-push-action@v4
|
||||||
with:
|
with:
|
||||||
context: "."
|
context: "."
|
||||||
file: .clusterfuzzlite/Dockerfile
|
file: .clusterfuzzlite/Dockerfile
|
||||||
@@ -80,15 +80,15 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v1
|
uses: docker/setup-buildx-action@v3
|
||||||
- name: Login to DockerHub
|
- name: Login to DockerHub
|
||||||
if: ${{ github.event_name == 'push' }}
|
if: ${{ github.event_name == 'push' }}
|
||||||
uses: docker/login-action@v1
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
- name: Build and push
|
- name: Build and push
|
||||||
uses: docker/build-push-action@v2
|
uses: docker/build-push-action@v4
|
||||||
with:
|
with:
|
||||||
file: testing/Dockerfile
|
file: testing/Dockerfile
|
||||||
push: ${{ github.event_name == 'push' }}
|
push: ${{ github.event_name == 'push' }}
|
||||||
@@ -100,15 +100,15 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v1
|
uses: docker/setup-buildx-action@v3
|
||||||
- name: Login to DockerHub
|
- name: Login to DockerHub
|
||||||
if: ${{ github.event_name == 'push' }}
|
if: ${{ github.event_name == 'push' }}
|
||||||
uses: docker/login-action@v1
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
- name: Build and push
|
- name: Build and push
|
||||||
uses: docker/build-push-action@v2
|
uses: docker/build-push-action@v4
|
||||||
with:
|
with:
|
||||||
file: other/emscripten/Dockerfile
|
file: other/emscripten/Dockerfile
|
||||||
push: ${{ github.event_name == 'push' }}
|
push: ${{ github.event_name == 'push' }}
|
||||||
@@ -120,22 +120,22 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v1
|
uses: docker/setup-buildx-action@v3
|
||||||
with:
|
with:
|
||||||
driver: docker
|
driver: docker
|
||||||
- name: Login to DockerHub
|
- name: Login to DockerHub
|
||||||
if: ${{ github.event_name == 'push' }}
|
if: ${{ github.event_name == 'push' }}
|
||||||
uses: docker/login-action@v1
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
- name: Build toxchat/c-toxcore:sources
|
- name: Build toxchat/c-toxcore:sources
|
||||||
uses: docker/build-push-action@v2
|
uses: docker/build-push-action@v4
|
||||||
with:
|
with:
|
||||||
file: other/docker/sources/Dockerfile
|
file: other/docker/sources/Dockerfile
|
||||||
tags: toxchat/c-toxcore:sources
|
tags: toxchat/c-toxcore:sources
|
||||||
- name: Build and push
|
- name: Build and push
|
||||||
uses: docker/build-push-action@v2
|
uses: docker/build-push-action@v4
|
||||||
with:
|
with:
|
||||||
file: other/docker/esp32/Dockerfile
|
file: other/docker/esp32/Dockerfile
|
||||||
push: ${{ github.event_name == 'push' }}
|
push: ${{ github.event_name == 'push' }}
|
||||||
@@ -147,15 +147,15 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v1
|
uses: docker/setup-buildx-action@v3
|
||||||
- name: Login to DockerHub
|
- name: Login to DockerHub
|
||||||
if: ${{ github.event_name == 'push' }}
|
if: ${{ github.event_name == 'push' }}
|
||||||
uses: docker/login-action@v1
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
- name: Build and push
|
- name: Build and push
|
||||||
uses: docker/build-push-action@v2
|
uses: docker/build-push-action@v4
|
||||||
with:
|
with:
|
||||||
context: "{{defaultContext}}:other/docker/windows"
|
context: "{{defaultContext}}:other/docker/windows"
|
||||||
push: ${{ github.event_name == 'push' }}
|
push: ${{ github.event_name == 'push' }}
|
||||||
@@ -171,15 +171,15 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v1
|
uses: docker/setup-buildx-action@v3
|
||||||
- name: Login to DockerHub
|
- name: Login to DockerHub
|
||||||
if: ${{ github.event_name == 'push' }}
|
if: ${{ github.event_name == 'push' }}
|
||||||
uses: docker/login-action@v1
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
- name: Build and push
|
- name: Build and push
|
||||||
uses: docker/build-push-action@v2
|
uses: docker/build-push-action@v4
|
||||||
with:
|
with:
|
||||||
context: "{{defaultContext}}:other/docker/windows"
|
context: "{{defaultContext}}:other/docker/windows"
|
||||||
push: ${{ github.event_name == 'push' }}
|
push: ${{ github.event_name == 'push' }}
|
||||||
|
43
external/toxcore/c-toxcore/.github/workflows/post-submit.yml
vendored
Normal file
43
external/toxcore/c-toxcore/.github/workflows/post-submit.yml
vendored
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
name: post-submit
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [master]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-alpine-s390x:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
- name: Docker Build
|
||||||
|
uses: docker/build-push-action@v4
|
||||||
|
with:
|
||||||
|
file: other/docker/alpine-s390x/Dockerfile
|
||||||
|
|
||||||
|
docker-coverage:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
with:
|
||||||
|
driver: docker
|
||||||
|
- name: Login to DockerHub
|
||||||
|
if: ${{ github.event_name == 'push' }}
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
- name: Build toxchat/c-toxcore:sources
|
||||||
|
uses: docker/build-push-action@v4
|
||||||
|
with:
|
||||||
|
file: other/docker/sources/Dockerfile
|
||||||
|
tags: toxchat/c-toxcore:sources
|
||||||
|
- name: Build and push
|
||||||
|
uses: docker/build-push-action@v4
|
||||||
|
with:
|
||||||
|
file: other/docker/coverage/Dockerfile
|
||||||
|
push: ${{ github.event_name == 'push' }}
|
||||||
|
tags: toxchat/c-toxcore:coverage
|
||||||
|
cache-from: type=registry,ref=toxchat/c-toxcore:coverage
|
||||||
|
cache-to: type=inline
|
@@ -19,13 +19,14 @@ jobs:
|
|||||||
SONAR_SERVER_URL: "https://sonarcloud.io"
|
SONAR_SERVER_URL: "https://sonarcloud.io"
|
||||||
BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory # Directory where build-wrapper output will be placed
|
BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory # Directory where build-wrapper output will be placed
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
|
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
|
||||||
submodules: recursive
|
submodules: recursive
|
||||||
- name: Set up JDK 17
|
- name: Set up JDK 17
|
||||||
uses: actions/setup-java@v1
|
uses: actions/setup-java@v2
|
||||||
with:
|
with:
|
||||||
|
distribution: "zulu"
|
||||||
java-version: 17
|
java-version: 17
|
||||||
- name: Download and set up sonar-scanner
|
- name: Download and set up sonar-scanner
|
||||||
env:
|
env:
|
||||||
|
7
external/toxcore/c-toxcore/.gitignore
vendored
7
external/toxcore/c-toxcore/.gitignore
vendored
@@ -14,6 +14,8 @@ Thumbs.db
|
|||||||
/_build
|
/_build
|
||||||
/_install
|
/_install
|
||||||
/tox-0.0.0*
|
/tox-0.0.0*
|
||||||
|
/.vs
|
||||||
|
/CppProperties.json
|
||||||
CMakeCache.txt
|
CMakeCache.txt
|
||||||
CMakeFiles
|
CMakeFiles
|
||||||
Makefile
|
Makefile
|
||||||
@@ -91,4 +93,9 @@ cscope.files
|
|||||||
# rpm
|
# rpm
|
||||||
tox.spec
|
tox.spec
|
||||||
|
|
||||||
|
# clangd
|
||||||
|
.cache/
|
||||||
|
compile_commands.json
|
||||||
|
|
||||||
|
/infer
|
||||||
.idea/
|
.idea/
|
||||||
|
2
external/toxcore/c-toxcore/BUILD.bazel
vendored
2
external/toxcore/c-toxcore/BUILD.bazel
vendored
@@ -1,7 +1,7 @@
|
|||||||
load("@rules_cc//cc:defs.bzl", "cc_library")
|
load("@rules_cc//cc:defs.bzl", "cc_library")
|
||||||
load("//tools/project:build_defs.bzl", "project")
|
load("//tools/project:build_defs.bzl", "project")
|
||||||
|
|
||||||
project()
|
project(license = "gpl3-https")
|
||||||
|
|
||||||
genrule(
|
genrule(
|
||||||
name = "public_headers",
|
name = "public_headers",
|
||||||
|
169
external/toxcore/c-toxcore/CMakeLists.txt
vendored
169
external/toxcore/c-toxcore/CMakeLists.txt
vendored
@@ -14,8 +14,8 @@
|
|||||||
#
|
#
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
cmake_minimum_required(VERSION 3.5)
|
cmake_minimum_required(VERSION 3.16)
|
||||||
cmake_policy(VERSION 3.5)
|
cmake_policy(VERSION 3.16)
|
||||||
project(toxcore)
|
project(toxcore)
|
||||||
|
|
||||||
list(APPEND CMAKE_MODULE_PATH ${toxcore_SOURCE_DIR}/cmake)
|
list(APPEND CMAKE_MODULE_PATH ${toxcore_SOURCE_DIR}/cmake)
|
||||||
@@ -76,11 +76,12 @@ if(APPLE)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
enable_testing()
|
enable_testing()
|
||||||
|
find_package(GTest)
|
||||||
|
|
||||||
set(CMAKE_MACOSX_RPATH ON)
|
set(CMAKE_MACOSX_RPATH ON)
|
||||||
|
|
||||||
# Set standard version for compiler.
|
# Set standard version for compiler.
|
||||||
if(MSVC)
|
if(MSVC AND MSVC_TOOLSET_VERSION LESS 143)
|
||||||
# https://developercommunity.visualstudio.com/t/older-winsdk-headers-are-incompatible-with-zcprepr/1593479
|
# https://developercommunity.visualstudio.com/t/older-winsdk-headers-are-incompatible-with-zcprepr/1593479
|
||||||
set(CMAKE_C_STANDARD 99)
|
set(CMAKE_C_STANDARD 99)
|
||||||
else()
|
else()
|
||||||
@@ -93,6 +94,35 @@ set(CMAKE_CXX_EXTENSIONS OFF)
|
|||||||
message(STATUS "Supported C compiler features = ${CMAKE_C_COMPILE_FEATURES}")
|
message(STATUS "Supported C compiler features = ${CMAKE_C_COMPILE_FEATURES}")
|
||||||
message(STATUS "Supported C++ compiler features = ${CMAKE_CXX_COMPILE_FEATURES}")
|
message(STATUS "Supported C++ compiler features = ${CMAKE_CXX_COMPILE_FEATURES}")
|
||||||
|
|
||||||
|
# Enable some warnings if we know the compiler.
|
||||||
|
if(MSVC)
|
||||||
|
add_compile_options(/W4 /analyze)
|
||||||
|
add_compile_options(/wd4100) # unreferenced formal parameter
|
||||||
|
add_compile_options(/wd4267) # narrowing conversion
|
||||||
|
add_compile_options(/wd4244) # narrowing conversion
|
||||||
|
add_compile_options(/wd4127) # conditional expression is constant
|
||||||
|
add_compile_options(/wd4995) # #pragma deprecated
|
||||||
|
add_compile_options(/wd4018) # signed/unsigned compare
|
||||||
|
add_compile_options(/wd4310) # cast truncates constant value
|
||||||
|
add_compile_options(/wd4389) # signed/unsigned compare
|
||||||
|
add_compile_options(/wd4245) # signed/unsigned assign/return/function call
|
||||||
|
add_compile_options(/wd4200) # nonstandard extension used: zero-sized array in struct/union
|
||||||
|
add_compile_options(/wd4702) # unreachable code
|
||||||
|
add_compile_options(/wd6340) # unsigned int passed to signed parameter
|
||||||
|
add_compile_options(/wd6326) # potential comparison of a constant with another constant
|
||||||
|
|
||||||
|
# TODO(iphydf): Look into these
|
||||||
|
add_compile_options(/wd4996) # use WSAAddressToStringW() instead of WSAAddressToStringA()
|
||||||
|
add_compile_options(/wd6255) # don't use alloca
|
||||||
|
add_compile_options(/wd6385) # reading invalid data
|
||||||
|
add_compile_options(/wd6001) # using uninitialized memory
|
||||||
|
add_compile_options(/wd6101) # returning uninitialized memory
|
||||||
|
add_compile_options(/wd6386) # buffer overrun
|
||||||
|
add_compile_options(/wd6011) # NULL dereference
|
||||||
|
add_compile_options(/wd6031) # sscanf return value ignored
|
||||||
|
add_compile_options(/wd6387) # passing NULL to fwrite
|
||||||
|
endif()
|
||||||
|
|
||||||
set(MIN_LOGGER_LEVEL "" CACHE STRING "Logging level to use (TRACE, DEBUG, INFO, WARNING, ERROR)")
|
set(MIN_LOGGER_LEVEL "" CACHE STRING "Logging level to use (TRACE, DEBUG, INFO, WARNING, ERROR)")
|
||||||
if(MIN_LOGGER_LEVEL)
|
if(MIN_LOGGER_LEVEL)
|
||||||
if(("${MIN_LOGGER_LEVEL}" STREQUAL "TRACE") OR
|
if(("${MIN_LOGGER_LEVEL}" STREQUAL "TRACE") OR
|
||||||
@@ -111,11 +141,6 @@ if(NOT USE_IPV6)
|
|||||||
add_definitions(-DUSE_IPV6=0)
|
add_definitions(-DUSE_IPV6=0)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
option(USE_TEST_NETWORK "Use a separate test network with different packet IDs" OFF)
|
|
||||||
if(USE_TEST_NETWORK)
|
|
||||||
add_definitions(-DUSE_TEST_NETWORK=1)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
option(BUILD_MISC_TESTS "Build additional tests and utilities" OFF)
|
option(BUILD_MISC_TESTS "Build additional tests and utilities" OFF)
|
||||||
option(BUILD_FUN_UTILS "Build additional just for fun utilities" OFF)
|
option(BUILD_FUN_UTILS "Build additional just for fun utilities" OFF)
|
||||||
|
|
||||||
@@ -135,21 +160,7 @@ if(BOOTSTRAP_DAEMON AND WIN32)
|
|||||||
set(BOOTSTRAP_DAEMON OFF)
|
set(BOOTSTRAP_DAEMON OFF)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Enabling this breaks all other tests and no network connections will be possible
|
|
||||||
option(BUILD_FUZZ_TESTS "Build fuzzing harnesses" OFF)
|
option(BUILD_FUZZ_TESTS "Build fuzzing harnesses" OFF)
|
||||||
if(BUILD_FUZZ_TESTS)
|
|
||||||
message(STATUS "Building in fuzz testing mode, no network connection will be possible")
|
|
||||||
# Disable everything we can
|
|
||||||
set(AUTOTEST OFF)
|
|
||||||
set(BUILD_MISC_TESTS OFF)
|
|
||||||
set(BUILD_FUN_UTILS OFF)
|
|
||||||
set(ENABLE_SHARED OFF)
|
|
||||||
set(MUST_BUILD_TOXAV OFF)
|
|
||||||
set(BUILD_TOXAV OFF)
|
|
||||||
set(BOOTSTRAP_DAEMON OFF)
|
|
||||||
set(DHT_BOOTSTRAP OFF)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
|
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
option(MSVC_STATIC_SODIUM "Whether to link libsodium statically for MSVC" OFF)
|
option(MSVC_STATIC_SODIUM "Whether to link libsodium statically for MSVC" OFF)
|
||||||
@@ -320,16 +331,27 @@ set(toxcore_SOURCES
|
|||||||
toxcore/tox.c
|
toxcore/tox.c
|
||||||
toxcore/tox_dispatch.c
|
toxcore/tox_dispatch.c
|
||||||
toxcore/tox_dispatch.h
|
toxcore/tox_dispatch.h
|
||||||
|
toxcore/tox_event.c
|
||||||
|
toxcore/tox_event.h
|
||||||
toxcore/tox_events.c
|
toxcore/tox_events.c
|
||||||
toxcore/tox_events.h
|
toxcore/tox_events.h
|
||||||
toxcore/tox.h
|
toxcore/tox.h
|
||||||
toxcore/tox_private.c
|
toxcore/tox_private.c
|
||||||
toxcore/tox_private.h
|
toxcore/tox_private.h
|
||||||
|
toxcore/tox_pack.c
|
||||||
|
toxcore/tox_pack.h
|
||||||
toxcore/tox_unpack.c
|
toxcore/tox_unpack.c
|
||||||
toxcore/tox_unpack.h
|
toxcore/tox_unpack.h
|
||||||
toxcore/util.c
|
toxcore/util.c
|
||||||
toxcore/util.h)
|
toxcore/util.h)
|
||||||
set(toxcore_LINK_MODULES ${toxcore_LINK_MODULES} ${LIBSODIUM_LIBRARIES})
|
if(TARGET unofficial-sodium::sodium)
|
||||||
|
set(toxcore_LINK_LIBRARIES ${toxcore_LINK_LIBRARIES} unofficial-sodium::sodium)
|
||||||
|
else()
|
||||||
|
set(toxcore_LINK_LIBRARIES ${toxcore_LINK_LIBRARIES} ${LIBSODIUM_LIBRARIES})
|
||||||
|
set(toxcore_LINK_DIRECTORIES ${toxcore_LINK_DIRECTORIES} ${LIBSODIUM_LIBRARY_DIRS})
|
||||||
|
set(toxcore_INCLUDE_DIRECTORIES ${toxcore_INCLUDE_DIRECTORIES} ${LIBSODIUM_INCLUDE_DIRS})
|
||||||
|
set(toxcore_COMPILE_OPTIONS ${toxcore_COMPILE_OPTIONS} ${LIBSODIUM_CFLAGS_OTHER})
|
||||||
|
endif()
|
||||||
set(toxcore_PKGCONFIG_REQUIRES ${toxcore_PKGCONFIG_REQUIRES} libsodium)
|
set(toxcore_PKGCONFIG_REQUIRES ${toxcore_PKGCONFIG_REQUIRES} libsodium)
|
||||||
set(toxcore_API_HEADERS
|
set(toxcore_API_HEADERS
|
||||||
${toxcore_SOURCE_DIR}/toxcore/tox.h^tox
|
${toxcore_SOURCE_DIR}/toxcore/tox.h^tox
|
||||||
@@ -365,7 +387,14 @@ if(BUILD_TOXAV)
|
|||||||
set(toxcore_API_HEADERS ${toxcore_API_HEADERS}
|
set(toxcore_API_HEADERS ${toxcore_API_HEADERS}
|
||||||
${toxcore_SOURCE_DIR}/toxav/toxav.h^toxav)
|
${toxcore_SOURCE_DIR}/toxav/toxav.h^toxav)
|
||||||
|
|
||||||
set(toxcore_LINK_MODULES ${toxcore_LINK_MODULES} ${OPUS_LIBRARIES} ${VPX_LIBRARIES})
|
if(MSVC)
|
||||||
|
set(toxcore_LINK_LIBRARIES ${toxcore_LINK_LIBRARIES} PkgConfig::OPUS PkgConfig::VPX)
|
||||||
|
else()
|
||||||
|
set(toxcore_LINK_LIBRARIES ${toxcore_LINK_LIBRARIES} ${OPUS_LIBRARIES} ${VPX_LIBRARIES})
|
||||||
|
set(toxcore_LINK_DIRECTORIES ${toxcore_LINK_DIRECTORIES} ${OPUS_LIBRARY_DIRS} ${VPX_LIBRARY_DIRS})
|
||||||
|
set(toxcore_INCLUDE_DIRECTORIES ${toxcore_INCLUDE_DIRECTORIES} ${OPUS_INCLUDE_DIRS} ${VPX_INCLUDE_DIRS})
|
||||||
|
set(toxcore_COMPILE_OPTIONS ${toxcore_COMPILE_OPTIONS} ${OPUS_CFLAGS_OTHER} ${VPX_CFLAGS_OTHER})
|
||||||
|
endif()
|
||||||
set(toxcore_PKGCONFIG_REQUIRES ${toxcore_PKGCONFIG_REQUIRES} opus vpx)
|
set(toxcore_PKGCONFIG_REQUIRES ${toxcore_PKGCONFIG_REQUIRES} opus vpx)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@@ -392,29 +421,32 @@ set(toxcore_API_HEADERS ${toxcore_API_HEADERS}
|
|||||||
# any potential libvpx linking.
|
# any potential libvpx linking.
|
||||||
message("CMAKE_THREAD_LIBS_INIT: ${CMAKE_THREAD_LIBS_INIT}")
|
message("CMAKE_THREAD_LIBS_INIT: ${CMAKE_THREAD_LIBS_INIT}")
|
||||||
if(CMAKE_THREAD_LIBS_INIT)
|
if(CMAKE_THREAD_LIBS_INIT)
|
||||||
set(toxcore_LINK_MODULES ${toxcore_LINK_MODULES} ${CMAKE_THREAD_LIBS_INIT})
|
set(toxcore_LINK_LIBRARIES ${toxcore_LINK_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
|
||||||
set(toxcore_PKGCONFIG_LIBS ${toxcore_PKGCONFIG_LIBS} ${CMAKE_THREAD_LIBS_INIT})
|
set(toxcore_PKGCONFIG_LIBS ${toxcore_PKGCONFIG_LIBS} ${CMAKE_THREAD_LIBS_INIT})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
if(NSL_LIBRARIES)
|
if(NSL_LIBRARIES)
|
||||||
set(toxcore_LINK_MODULES ${toxcore_LINK_MODULES} ${NSL_LIBRARIES})
|
set(toxcore_LINK_LIBRARIES ${toxcore_LINK_LIBRARIES} ${NSL_LIBRARIES})
|
||||||
set(toxcore_PKGCONFIG_LIBS ${toxcore_PKGCONFIG_LIBS} -lnsl)
|
set(toxcore_PKGCONFIG_LIBS ${toxcore_PKGCONFIG_LIBS} -lnsl)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(RT_LIBRARIES)
|
if(RT_LIBRARIES)
|
||||||
set(toxcore_LINK_MODULES ${toxcore_LINK_MODULES} ${RT_LIBRARIES})
|
set(toxcore_LINK_LIBRARIES ${toxcore_LINK_LIBRARIES} ${RT_LIBRARIES})
|
||||||
set(toxcore_PKGCONFIG_LIBS ${toxcore_PKGCONFIG_LIBS} -lrt)
|
set(toxcore_PKGCONFIG_LIBS ${toxcore_PKGCONFIG_LIBS} -lrt)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(SOCKET_LIBRARIES)
|
if(SOCKET_LIBRARIES)
|
||||||
set(toxcore_LINK_MODULES ${toxcore_LINK_MODULES} ${SOCKET_LIBRARIES})
|
set(toxcore_LINK_LIBRARIES ${toxcore_LINK_LIBRARIES} ${SOCKET_LIBRARIES})
|
||||||
set(toxcore_PKGCONFIG_LIBS ${toxcore_PKGCONFIG_LIBS} -lsocket)
|
set(toxcore_PKGCONFIG_LIBS ${toxcore_PKGCONFIG_LIBS} -lsocket)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(TARGET PThreads4W::PThreads4W)
|
||||||
|
set(toxcore_LINK_LIBRARIES ${toxcore_LINK_LIBRARIES} PThreads4W::PThreads4W)
|
||||||
|
elseif(TARGET Threads::Threads)
|
||||||
|
set(toxcore_LINK_LIBRARIES ${toxcore_LINK_LIBRARIES} Threads::Threads)
|
||||||
|
endif()
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
set(toxcore_LINK_MODULES ${toxcore_LINK_MODULES} ws2_32 iphlpapi)
|
set(toxcore_LINK_LIBRARIES ${toxcore_LINK_LIBRARIES} iphlpapi wsock32 ws2_32)
|
||||||
set(toxcore_PKGCONFIG_LIBS ${toxcore_PKGCONFIG_LIBS} -lws2_32 -liphlpapi)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
@@ -424,10 +456,34 @@ endif()
|
|||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
# Create combined library from all the sources.
|
# Create combined library from all the sources.
|
||||||
add_module(toxcore ${toxcore_SOURCES})
|
if(ENABLE_SHARED)
|
||||||
|
add_library(toxcore_shared SHARED ${toxcore_SOURCES})
|
||||||
|
set_target_properties(toxcore_shared PROPERTIES OUTPUT_NAME toxcore)
|
||||||
|
target_link_libraries(toxcore_shared PRIVATE ${toxcore_LINK_LIBRARIES})
|
||||||
|
target_link_directories(toxcore_shared PUBLIC ${toxcore_LINK_DIRECTORIES})
|
||||||
|
target_include_directories(toxcore_shared SYSTEM PRIVATE ${toxcore_INCLUDE_DIRECTORIES})
|
||||||
|
target_compile_options(toxcore_shared PRIVATE ${toxcore_COMPILE_OPTIONS})
|
||||||
|
endif()
|
||||||
|
|
||||||
# Link it to all dependencies.
|
if(ENABLE_STATIC)
|
||||||
target_link_modules(toxcore ${toxcore_LINK_MODULES})
|
add_library(toxcore_static STATIC ${toxcore_SOURCES})
|
||||||
|
if(NOT MSVC)
|
||||||
|
set_target_properties(toxcore_static PROPERTIES OUTPUT_NAME toxcore)
|
||||||
|
endif()
|
||||||
|
target_link_libraries(toxcore_static PRIVATE ${toxcore_LINK_LIBRARIES})
|
||||||
|
target_link_directories(toxcore_static PUBLIC ${toxcore_LINK_DIRECTORIES})
|
||||||
|
target_include_directories(toxcore_static SYSTEM PRIVATE ${toxcore_INCLUDE_DIRECTORIES})
|
||||||
|
target_compile_options(toxcore_static PRIVATE ${toxcore_COMPILE_OPTIONS})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(BUILD_FUZZ_TESTS)
|
||||||
|
add_library(toxcore_fuzz STATIC ${toxcore_SOURCES})
|
||||||
|
target_link_libraries(toxcore_fuzz PRIVATE ${toxcore_LINK_LIBRARIES})
|
||||||
|
target_link_directories(toxcore_fuzz PUBLIC ${toxcore_LINK_DIRECTORIES})
|
||||||
|
target_include_directories(toxcore_fuzz SYSTEM PRIVATE ${toxcore_INCLUDE_DIRECTORIES})
|
||||||
|
target_compile_options(toxcore_fuzz PRIVATE ${toxcore_COMPILE_OPTIONS})
|
||||||
|
target_compile_definitions(toxcore_fuzz PUBLIC "FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION")
|
||||||
|
endif()
|
||||||
|
|
||||||
# Make version script (on systems that support it) to limit symbol visibility.
|
# Make version script (on systems that support it) to limit symbol visibility.
|
||||||
make_version_script(toxcore ${toxcore_API_HEADERS})
|
make_version_script(toxcore ${toxcore_API_HEADERS})
|
||||||
@@ -442,10 +498,35 @@ install_module(toxcore DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/tox)
|
|||||||
#
|
#
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
include(CompileGTest)
|
add_library(test_util STATIC
|
||||||
|
toxcore/DHT_test_util.cc
|
||||||
|
toxcore/DHT_test_util.hh
|
||||||
|
toxcore/crypto_core_test_util.cc
|
||||||
|
toxcore/crypto_core_test_util.hh
|
||||||
|
toxcore/mem_test_util.cc
|
||||||
|
toxcore/mem_test_util.hh
|
||||||
|
toxcore/network_test_util.cc
|
||||||
|
toxcore/network_test_util.hh
|
||||||
|
toxcore/test_util.cc
|
||||||
|
toxcore/test_util.hh)
|
||||||
|
|
||||||
|
function(unit_test subdir target)
|
||||||
|
add_executable(unit_${target}_test ${subdir}/${target}_test.cc)
|
||||||
|
target_link_libraries(unit_${target}_test PRIVATE test_util)
|
||||||
|
if(TARGET toxcore_static)
|
||||||
|
target_link_libraries(unit_${target}_test PRIVATE toxcore_static)
|
||||||
|
else()
|
||||||
|
target_link_libraries(unit_${target}_test PRIVATE toxcore_shared)
|
||||||
|
endif()
|
||||||
|
target_link_libraries(unit_${target}_test PRIVATE GTest::gtest GTest::gtest_main GTest::gmock)
|
||||||
|
set_target_properties(unit_${target}_test PROPERTIES COMPILE_FLAGS "${TEST_CXX_FLAGS}")
|
||||||
|
add_test(NAME ${target} COMMAND ${CROSSCOMPILING_EMULATOR} unit_${target}_test)
|
||||||
|
set_property(TEST ${target} PROPERTY ENVIRONMENT "LLVM_PROFILE_FILE=${target}.profraw")
|
||||||
|
endfunction()
|
||||||
|
|
||||||
# The actual unit tests follow.
|
# The actual unit tests follow.
|
||||||
#
|
#
|
||||||
|
if(GTEST_FOUND)
|
||||||
unit_test(toxav ring_buffer)
|
unit_test(toxav ring_buffer)
|
||||||
unit_test(toxav rtp)
|
unit_test(toxav rtp)
|
||||||
unit_test(toxcore DHT)
|
unit_test(toxcore DHT)
|
||||||
@@ -453,11 +534,14 @@ unit_test(toxcore bin_pack)
|
|||||||
unit_test(toxcore crypto_core)
|
unit_test(toxcore crypto_core)
|
||||||
unit_test(toxcore group_announce)
|
unit_test(toxcore group_announce)
|
||||||
unit_test(toxcore group_moderation)
|
unit_test(toxcore group_moderation)
|
||||||
|
unit_test(toxcore list)
|
||||||
unit_test(toxcore mem)
|
unit_test(toxcore mem)
|
||||||
unit_test(toxcore mono_time)
|
unit_test(toxcore mono_time)
|
||||||
unit_test(toxcore ping_array)
|
unit_test(toxcore ping_array)
|
||||||
|
unit_test(toxcore test_util)
|
||||||
unit_test(toxcore tox)
|
unit_test(toxcore tox)
|
||||||
unit_test(toxcore util)
|
unit_test(toxcore util)
|
||||||
|
endif()
|
||||||
|
|
||||||
add_subdirectory(testing)
|
add_subdirectory(testing)
|
||||||
|
|
||||||
@@ -481,7 +565,20 @@ if(DHT_BOOTSTRAP)
|
|||||||
add_executable(DHT_bootstrap
|
add_executable(DHT_bootstrap
|
||||||
other/DHT_bootstrap.c
|
other/DHT_bootstrap.c
|
||||||
other/bootstrap_node_packets.c)
|
other/bootstrap_node_packets.c)
|
||||||
target_link_modules(DHT_bootstrap toxcore misc_tools)
|
if(TARGET toxcore_static)
|
||||||
|
target_link_libraries(DHT_bootstrap PRIVATE toxcore_static)
|
||||||
|
else()
|
||||||
|
target_link_libraries(DHT_bootstrap PRIVATE toxcore_shared)
|
||||||
|
endif()
|
||||||
|
target_link_libraries(DHT_bootstrap PRIVATE misc_tools)
|
||||||
|
if(TARGET unofficial-sodium::sodium)
|
||||||
|
target_link_libraries(DHT_bootstrap PRIVATE unofficial-sodium::sodium)
|
||||||
|
endif()
|
||||||
|
if(TARGET PThreads4W::PThreads4W)
|
||||||
|
target_link_libraries(DHT_bootstrap PRIVATE PThreads4W::PThreads4W)
|
||||||
|
elseif(TARGET Threads::Threads)
|
||||||
|
target_link_libraries(DHT_bootstrap PRIVATE Threads::Threads)
|
||||||
|
endif()
|
||||||
install(TARGETS DHT_bootstrap RUNTIME DESTINATION bin)
|
install(TARGETS DHT_bootstrap RUNTIME DESTINATION bin)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
21
external/toxcore/c-toxcore/CMakePresets.json
vendored
Normal file
21
external/toxcore/c-toxcore/CMakePresets.json
vendored
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
"version": 3,
|
||||||
|
"configurePresets": [
|
||||||
|
{
|
||||||
|
"name": "windows-default",
|
||||||
|
"binaryDir": "${sourceDir}/_build",
|
||||||
|
"cacheVariables": {
|
||||||
|
"ENABLE_SHARED": true,
|
||||||
|
"ENABLE_STATIC": true,
|
||||||
|
"AUTOTEST": true,
|
||||||
|
"BUILD_MISC_TESTS": true,
|
||||||
|
"BOOTSTRAP_DAEMON": false,
|
||||||
|
"MUST_BUILD_TOXAV": true,
|
||||||
|
"TEST_TIMEOUT_SECONDS": "60",
|
||||||
|
"CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS": true,
|
||||||
|
"CMAKE_COMPILE_WARNING_AS_ERROR": true,
|
||||||
|
"CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
6
external/toxcore/c-toxcore/INSTALL.md
vendored
6
external/toxcore/c-toxcore/INSTALL.md
vendored
@@ -33,10 +33,10 @@ These instructions will guide you through the process of building and installing
|
|||||||
This repository, although called `toxcore`, in fact contains several libraries besides `toxcore` which complement it, as well as several executables. However, note that although these are separate libraries, at the moment, when building the libraries, they are all merged into a single `toxcore` library. Here is the full list of the main components that can be built using the CMake, their dependencies and descriptions.
|
This repository, although called `toxcore`, in fact contains several libraries besides `toxcore` which complement it, as well as several executables. However, note that although these are separate libraries, at the moment, when building the libraries, they are all merged into a single `toxcore` library. Here is the full list of the main components that can be built using the CMake, their dependencies and descriptions.
|
||||||
|
|
||||||
| Name | Type | Dependencies | Platform | Description |
|
| Name | Type | Dependencies | Platform | Description |
|
||||||
|------------------|------------|-----------------------------------------------|----------------|----------------------------------------------------------------------------|
|
|------------------|------------|------------------------------------|----------------|----------------------------------------------------------------------------|
|
||||||
| `toxcore` | Library | libnacl or libsodium, libm, libpthread, librt | Cross-platform | The main Tox library that provides the messenger functionality. |
|
| `toxcore` | Library | libsodium, libm, libpthread, librt | Cross-platform | The main Tox library that provides the messenger functionality. |
|
||||||
| `toxav` | Library | libtoxcore, libopus, libvpx | Cross-platform | Provides audio/video functionality. |
|
| `toxav` | Library | libtoxcore, libopus, libvpx | Cross-platform | Provides audio/video functionality. |
|
||||||
| `toxencryptsave` | Library | libtoxcore, libnacl or libsodium | Cross-platform | Provides encryption of Tox profiles (savedata), as well as arbitrary data. |
|
| `toxencryptsave` | Library | libtoxcore, libsodium | Cross-platform | Provides encryption of Tox profiles (savedata), as well as arbitrary data. |
|
||||||
| `DHT_bootstrap` | Executable | libtoxcore | Cross-platform | A simple DHT bootstrap node. |
|
| `DHT_bootstrap` | Executable | libtoxcore | Cross-platform | A simple DHT bootstrap node. |
|
||||||
| `tox-bootstrapd` | Executable | libtoxcore, libconfig | Unix-like | Highly configurable DHT bootstrap node daemon (systemd, SysVinit, Docker). |
|
| `tox-bootstrapd` | Executable | libtoxcore, libconfig | Unix-like | Highly configurable DHT bootstrap node daemon (systemd, SysVinit, Docker). |
|
||||||
| `cmp` | Library | | Cross-platform | C implementation of the MessagePack serialization format. [https://github.com/camgunz/cmp](https://github.com/camgunz/cmp) |
|
| `cmp` | Library | | Cross-platform | C implementation of the MessagePack serialization format. [https://github.com/camgunz/cmp](https://github.com/camgunz/cmp) |
|
||||||
|
9
external/toxcore/c-toxcore/LICENSE
vendored
9
external/toxcore/c-toxcore/LICENSE
vendored
@@ -1,7 +1,7 @@
|
|||||||
GNU GENERAL PUBLIC LICENSE
|
GNU GENERAL PUBLIC LICENSE
|
||||||
Version 3, 29 June 2007
|
Version 3, 29 June 2007
|
||||||
|
|
||||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||||
Everyone is permitted to copy and distribute verbatim copies
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
of this license document, but changing it is not allowed.
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
@@ -645,7 +645,7 @@ the "copyright" line and a pointer to where the full notice is found.
|
|||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
Also add information on how to contact you by electronic and paper mail.
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
@@ -664,12 +664,11 @@ might be different; for a GUI interface, you would use an "about box".
|
|||||||
You should also get your employer (if you work as a programmer) or school,
|
You should also get your employer (if you work as a programmer) or school,
|
||||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||||
For more information on this, and how to apply and follow the GNU GPL, see
|
For more information on this, and how to apply and follow the GNU GPL, see
|
||||||
<http://www.gnu.org/licenses/>.
|
<https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
The GNU General Public License does not permit incorporating your program
|
The GNU General Public License does not permit incorporating your program
|
||||||
into proprietary programs. If your program is a subroutine library, you
|
into proprietary programs. If your program is a subroutine library, you
|
||||||
may consider it more useful to permit linking proprietary applications with
|
may consider it more useful to permit linking proprietary applications with
|
||||||
the library. If this is what you want to do, use the GNU Lesser General
|
the library. If this is what you want to do, use the GNU Lesser General
|
||||||
Public License instead of this License. But first, please read
|
Public License instead of this License. But first, please read
|
||||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||||
|
|
||||||
|
15
external/toxcore/c-toxcore/README.md
vendored
15
external/toxcore/c-toxcore/README.md
vendored
@@ -8,7 +8,8 @@
|
|||||||
|
|
||||||
Tox is a peer to peer (serverless) instant messenger aimed at making security
|
Tox is a peer to peer (serverless) instant messenger aimed at making security
|
||||||
and privacy easy to obtain for regular users. It uses
|
and privacy easy to obtain for regular users. It uses
|
||||||
[NaCl](https://nacl.cr.yp.to/) for its encryption and authentication.
|
[libsodium](https://doc.libsodium.org/) (based on
|
||||||
|
[NaCl](https://nacl.cr.yp.to/)) for its encryption and authentication.
|
||||||
|
|
||||||
## IMPORTANT!
|
## IMPORTANT!
|
||||||
|
|
||||||
@@ -18,12 +19,12 @@ This is an **experimental** cryptographic network library. It has not been
|
|||||||
formally audited by an independent third party that specializes in
|
formally audited by an independent third party that specializes in
|
||||||
cryptography or cryptanalysis. **Use this library at your own risk.**
|
cryptography or cryptanalysis. **Use this library at your own risk.**
|
||||||
|
|
||||||
The underlying crypto library [NaCl](https://nacl.cr.yp.to/install.html)
|
The underlying crypto library [libsodium](https://doc.libsodium.org/) provides
|
||||||
provides reliable encryption, but the security model has not yet been fully
|
reliable encryption, but the security model has not yet been fully specified.
|
||||||
specified. See [issue 210](https://github.com/TokTok/c-toxcore/issues/210) for
|
See [issue 210](https://github.com/TokTok/c-toxcore/issues/210) for a
|
||||||
a discussion on developing a threat model. See other issues for known
|
discussion on developing a threat model. See other issues for known weaknesses
|
||||||
weaknesses (e.g. [issue 426](https://github.com/TokTok/c-toxcore/issues/426)
|
(e.g. [issue 426](https://github.com/TokTok/c-toxcore/issues/426) describes
|
||||||
describes what can happen if your secret key is stolen).
|
what can happen if your secret key is stolen).
|
||||||
|
|
||||||
## Toxcore Development Roadmap
|
## Toxcore Development Roadmap
|
||||||
|
|
||||||
|
@@ -3,19 +3,35 @@ set(TEST_TIMEOUT_SECONDS "" CACHE STRING "Limit runtime of each test to the numb
|
|||||||
add_library(auto_test_support
|
add_library(auto_test_support
|
||||||
auto_test_support.c
|
auto_test_support.c
|
||||||
auto_test_support.h)
|
auto_test_support.h)
|
||||||
target_link_modules(auto_test_support toxcore misc_tools)
|
target_link_libraries(auto_test_support PRIVATE misc_tools)
|
||||||
|
if(TARGET toxcore_static)
|
||||||
|
target_link_libraries(auto_test_support PRIVATE toxcore_static)
|
||||||
|
else()
|
||||||
|
target_link_libraries(auto_test_support PRIVATE toxcore_shared)
|
||||||
|
endif()
|
||||||
|
if(TARGET PThreads4W::PThreads4W)
|
||||||
|
target_link_libraries(auto_test_support PRIVATE PThreads4W::PThreads4W)
|
||||||
|
elseif(TARGET Threads::Threads)
|
||||||
|
target_link_libraries(auto_test_support PRIVATE Threads::Threads)
|
||||||
|
endif()
|
||||||
|
|
||||||
function(auto_test target)
|
function(auto_test target)
|
||||||
if(AUTOTEST AND NOT (MSVC AND ARGV1 STREQUAL "MSVC_DONT_BUILD"))
|
|
||||||
add_executable(auto_${target}_test ${target}_test.c)
|
add_executable(auto_${target}_test ${target}_test.c)
|
||||||
target_link_modules(auto_${target}_test toxcore misc_tools auto_test_support)
|
target_link_libraries(auto_${target}_test PRIVATE misc_tools auto_test_support)
|
||||||
if(NOT ARGV1 STREQUAL "DONT_RUN")
|
if(TARGET toxcore_static)
|
||||||
|
target_link_libraries(auto_${target}_test PRIVATE toxcore_static)
|
||||||
|
else()
|
||||||
|
target_link_libraries(auto_${target}_test PRIVATE toxcore_shared)
|
||||||
|
endif()
|
||||||
|
if(TARGET PThreads4W::PThreads4W)
|
||||||
|
target_link_libraries(auto_${target}_test PRIVATE PThreads4W::PThreads4W)
|
||||||
|
elseif(TARGET Threads::Threads)
|
||||||
|
target_link_libraries(auto_${target}_test PRIVATE Threads::Threads)
|
||||||
|
endif()
|
||||||
add_test(NAME ${target} COMMAND ${CROSSCOMPILING_EMULATOR} auto_${target}_test)
|
add_test(NAME ${target} COMMAND ${CROSSCOMPILING_EMULATOR} auto_${target}_test)
|
||||||
set_tests_properties(${target} PROPERTIES TIMEOUT "${TEST_TIMEOUT_SECONDS}")
|
set_tests_properties(${target} PROPERTIES TIMEOUT "${TEST_TIMEOUT_SECONDS}")
|
||||||
# add the source dir as environment variable, so the testdata can be found
|
# add the source dir as environment variable, so the testdata can be found
|
||||||
set_tests_properties(${target} PROPERTIES ENVIRONMENT "LLVM_PROFILE_FILE=${target}.profraw;srcdir=${CMAKE_CURRENT_SOURCE_DIR}")
|
set_tests_properties(${target} PROPERTIES ENVIRONMENT "LLVM_PROFILE_FILE=${target}.profraw;srcdir=${CMAKE_CURRENT_SOURCE_DIR}")
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
auto_test(TCP)
|
auto_test(TCP)
|
||||||
@@ -30,8 +46,9 @@ auto_test(crypto)
|
|||||||
#auto_test(dht) # Doesn't work with UNITY_BUILD.
|
#auto_test(dht) # Doesn't work with UNITY_BUILD.
|
||||||
auto_test(dht_getnodes_api)
|
auto_test(dht_getnodes_api)
|
||||||
auto_test(encryptsave)
|
auto_test(encryptsave)
|
||||||
auto_test(file_transfer)
|
|
||||||
auto_test(file_saving)
|
auto_test(file_saving)
|
||||||
|
auto_test(file_streaming)
|
||||||
|
auto_test(file_transfer)
|
||||||
auto_test(forwarding)
|
auto_test(forwarding)
|
||||||
auto_test(friend_connection)
|
auto_test(friend_connection)
|
||||||
auto_test(friend_request)
|
auto_test(friend_request)
|
||||||
@@ -69,17 +86,33 @@ auto_test(typing)
|
|||||||
auto_test(version)
|
auto_test(version)
|
||||||
auto_test(save_compatibility)
|
auto_test(save_compatibility)
|
||||||
|
|
||||||
|
target_include_directories(auto_encryptsave_test SYSTEM PRIVATE ${LIBSODIUM_INCLUDE_DIRS})
|
||||||
|
|
||||||
if(NON_HERMETIC_TESTS)
|
if(NON_HERMETIC_TESTS)
|
||||||
auto_test(bootstrap)
|
auto_test(bootstrap)
|
||||||
auto_test(tcp_relay)
|
auto_test(tcp_relay)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(BUILD_TOXAV)
|
if(BUILD_TOXAV)
|
||||||
auto_test(conference_av MSVC_DONT_BUILD)
|
auto_test(conference_av)
|
||||||
auto_test(toxav_basic)
|
auto_test(toxav_basic)
|
||||||
auto_test(toxav_many)
|
auto_test(toxav_many)
|
||||||
endif()
|
|
||||||
|
|
||||||
|
if(MSVC)
|
||||||
|
target_link_libraries(auto_toxav_basic_test PRIVATE PkgConfig::VPX)
|
||||||
|
target_link_libraries(auto_toxav_many_test PRIVATE PkgConfig::VPX)
|
||||||
|
else()
|
||||||
|
target_link_libraries(auto_toxav_basic_test PRIVATE ${VPX_LIBRARIES})
|
||||||
|
target_link_directories(auto_toxav_basic_test PRIVATE ${VPX_LIBRARY_DIRS})
|
||||||
|
target_include_directories(auto_toxav_basic_test SYSTEM PRIVATE ${VPX_INCLUDE_DIRS})
|
||||||
|
target_compile_options(auto_toxav_basic_test PRIVATE ${VPX_CFLAGS_OTHER})
|
||||||
|
|
||||||
|
target_link_libraries(auto_toxav_many_test PRIVATE ${VPX_LIBRARIES})
|
||||||
|
target_link_directories(auto_toxav_many_test PRIVATE ${VPX_LIBRARY_DIRS})
|
||||||
|
target_include_directories(auto_toxav_many_test SYSTEM PRIVATE ${VPX_INCLUDE_DIRS})
|
||||||
|
target_compile_options(auto_toxav_many_test PRIVATE ${VPX_CFLAGS_OTHER})
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
if(PROXY_TEST)
|
if(PROXY_TEST)
|
||||||
auto_test(proxy)
|
auto_test(proxy)
|
||||||
|
@@ -13,6 +13,9 @@ TESTS = \
|
|||||||
conference_test \
|
conference_test \
|
||||||
conference_two_test \
|
conference_two_test \
|
||||||
crypto_test \
|
crypto_test \
|
||||||
|
encryptsave_test \
|
||||||
|
file_saving_test \
|
||||||
|
file_streaming_test \
|
||||||
file_transfer_test \
|
file_transfer_test \
|
||||||
forwarding_test \
|
forwarding_test \
|
||||||
friend_connection_test \
|
friend_connection_test \
|
||||||
@@ -34,34 +37,24 @@ TESTS = \
|
|||||||
set_name_test \
|
set_name_test \
|
||||||
set_status_message_test \
|
set_status_message_test \
|
||||||
TCP_test \
|
TCP_test \
|
||||||
tox_events_test \
|
|
||||||
tox_dispatch_test \
|
tox_dispatch_test \
|
||||||
|
tox_events_test \
|
||||||
tox_many_tcp_test \
|
tox_many_tcp_test \
|
||||||
tox_many_test \
|
tox_many_test \
|
||||||
tox_strncasecmp_test \
|
tox_strncasecmp_test \
|
||||||
typing_test \
|
typing_test \
|
||||||
version_test
|
version_test
|
||||||
|
|
||||||
if !WITH_NACL
|
|
||||||
TESTS += \
|
|
||||||
encryptsave_test \
|
|
||||||
file_saving_test
|
|
||||||
endif
|
|
||||||
|
|
||||||
AUTOTEST_CFLAGS = \
|
AUTOTEST_CFLAGS = \
|
||||||
$(LIBSODIUM_CFLAGS) \
|
$(LIBSODIUM_CFLAGS)
|
||||||
$(NACL_CFLAGS)
|
|
||||||
|
|
||||||
AUTOTEST_LDADD = \
|
AUTOTEST_LDADD = \
|
||||||
$(LIBSODIUM_LDFLAGS) \
|
$(LIBSODIUM_LDFLAGS) \
|
||||||
$(NACL_LDFLAGS) \
|
|
||||||
libmisc_tools.la \
|
libmisc_tools.la \
|
||||||
libauto_test_support.la \
|
libauto_test_support.la \
|
||||||
libtoxcore.la \
|
libtoxcore.la \
|
||||||
libtoxencryptsave.la \
|
libtoxencryptsave.la \
|
||||||
$(LIBSODIUM_LIBS) \
|
$(LIBSODIUM_LIBS)
|
||||||
$(NACL_OBJECTS) \
|
|
||||||
$(NACL_LIBS)
|
|
||||||
|
|
||||||
|
|
||||||
if BUILD_AV
|
if BUILD_AV
|
||||||
@@ -111,6 +104,10 @@ file_saving_test_SOURCES = ../auto_tests/file_saving_test.c
|
|||||||
file_saving_test_CFLAGS = $(AUTOTEST_CFLAGS)
|
file_saving_test_CFLAGS = $(AUTOTEST_CFLAGS)
|
||||||
file_saving_test_LDADD = $(AUTOTEST_LDADD)
|
file_saving_test_LDADD = $(AUTOTEST_LDADD)
|
||||||
|
|
||||||
|
file_streaming_test_SOURCES = ../auto_tests/file_streaming_test.c
|
||||||
|
file_streaming_test_CFLAGS = $(AUTOTEST_CFLAGS)
|
||||||
|
file_streaming_test_LDADD = $(AUTOTEST_LDADD)
|
||||||
|
|
||||||
file_transfer_test_SOURCES = ../auto_tests/file_transfer_test.c
|
file_transfer_test_SOURCES = ../auto_tests/file_transfer_test.c
|
||||||
file_transfer_test_CFLAGS = $(AUTOTEST_CFLAGS)
|
file_transfer_test_CFLAGS = $(AUTOTEST_CFLAGS)
|
||||||
file_transfer_test_LDADD = $(AUTOTEST_LDADD)
|
file_transfer_test_LDADD = $(AUTOTEST_LDADD)
|
||||||
@@ -195,14 +192,14 @@ TCP_test_SOURCES = ../auto_tests/TCP_test.c
|
|||||||
TCP_test_CFLAGS = $(AUTOTEST_CFLAGS)
|
TCP_test_CFLAGS = $(AUTOTEST_CFLAGS)
|
||||||
TCP_test_LDADD = $(AUTOTEST_LDADD)
|
TCP_test_LDADD = $(AUTOTEST_LDADD)
|
||||||
|
|
||||||
tox_events_test_SOURCES = ../auto_tests/tox_events_test.c
|
|
||||||
tox_events_test_CFLAGS = $(AUTOTEST_CFLAGS)
|
|
||||||
tox_events_test_LDADD = $(AUTOTEST_LDADD)
|
|
||||||
|
|
||||||
tox_dispatch_test_SOURCES = ../auto_tests/tox_dispatch_test.c
|
tox_dispatch_test_SOURCES = ../auto_tests/tox_dispatch_test.c
|
||||||
tox_dispatch_test_CFLAGS = $(AUTOTEST_CFLAGS)
|
tox_dispatch_test_CFLAGS = $(AUTOTEST_CFLAGS)
|
||||||
tox_dispatch_test_LDADD = $(AUTOTEST_LDADD)
|
tox_dispatch_test_LDADD = $(AUTOTEST_LDADD)
|
||||||
|
|
||||||
|
tox_events_test_SOURCES = ../auto_tests/tox_events_test.c
|
||||||
|
tox_events_test_CFLAGS = $(AUTOTEST_CFLAGS)
|
||||||
|
tox_events_test_LDADD = $(AUTOTEST_LDADD)
|
||||||
|
|
||||||
tox_many_tcp_test_SOURCES = ../auto_tests/tox_many_tcp_test.c
|
tox_many_tcp_test_SOURCES = ../auto_tests/tox_many_tcp_test.c
|
||||||
tox_many_tcp_test_CFLAGS = $(AUTOTEST_CFLAGS)
|
tox_many_tcp_test_CFLAGS = $(AUTOTEST_CFLAGS)
|
||||||
tox_many_tcp_test_LDADD = $(AUTOTEST_LDADD)
|
tox_many_tcp_test_LDADD = $(AUTOTEST_LDADD)
|
||||||
|
@@ -61,9 +61,13 @@ static void test_store_data(void)
|
|||||||
ck_assert(log != nullptr);
|
ck_assert(log != nullptr);
|
||||||
logger_callback_log(log, print_debug_logger, nullptr, nullptr);
|
logger_callback_log(log, print_debug_logger, nullptr, nullptr);
|
||||||
Mono_Time *mono_time = mono_time_new(mem, nullptr, nullptr);
|
Mono_Time *mono_time = mono_time_new(mem, nullptr, nullptr);
|
||||||
|
ck_assert(mono_time != nullptr);
|
||||||
Networking_Core *net = new_networking_no_udp(log, mem, ns);
|
Networking_Core *net = new_networking_no_udp(log, mem, ns);
|
||||||
|
ck_assert(net != nullptr);
|
||||||
DHT *dht = new_dht(log, mem, rng, ns, mono_time, net, true, true);
|
DHT *dht = new_dht(log, mem, rng, ns, mono_time, net, true, true);
|
||||||
|
ck_assert(dht != nullptr);
|
||||||
Forwarding *forwarding = new_forwarding(log, rng, mono_time, dht);
|
Forwarding *forwarding = new_forwarding(log, rng, mono_time, dht);
|
||||||
|
ck_assert(forwarding != nullptr);
|
||||||
Announcements *announce = new_announcements(log, mem, rng, mono_time, forwarding);
|
Announcements *announce = new_announcements(log, mem, rng, mono_time, forwarding);
|
||||||
ck_assert(announce != nullptr);
|
ck_assert(announce != nullptr);
|
||||||
|
|
||||||
|
@@ -13,6 +13,10 @@
|
|||||||
#define ABORT_ON_LOG_ERROR true
|
#define ABORT_ON_LOG_ERROR true
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef USE_IPV6
|
||||||
|
#define USE_IPV6 1
|
||||||
|
#endif
|
||||||
|
|
||||||
Run_Auto_Options default_run_auto_options(void)
|
Run_Auto_Options default_run_auto_options(void)
|
||||||
{
|
{
|
||||||
return (Run_Auto_Options) {
|
return (Run_Auto_Options) {
|
||||||
@@ -28,7 +32,6 @@ static const struct BootstrapNodes {
|
|||||||
uint16_t port;
|
uint16_t port;
|
||||||
const uint8_t key[32];
|
const uint8_t key[32];
|
||||||
} bootstrap_nodes[] = {
|
} bootstrap_nodes[] = {
|
||||||
#ifndef USE_TEST_NETWORK
|
|
||||||
{
|
{
|
||||||
"tox.abilinski.com", 33445,
|
"tox.abilinski.com", 33445,
|
||||||
0x10, 0xC0, 0x0E, 0xB2, 0x50, 0xC3, 0x23, 0x3E,
|
0x10, 0xC0, 0x0E, 0xB2, 0x50, 0xC3, 0x23, 0x3E,
|
||||||
@@ -57,22 +60,6 @@ static const struct BootstrapNodes {
|
|||||||
0x6D, 0xC9, 0xD0, 0xA3, 0x00, 0xE6, 0xC3, 0x57,
|
0x6D, 0xC9, 0xD0, 0xA3, 0x00, 0xE6, 0xC3, 0x57,
|
||||||
0x63, 0x4E, 0xE2, 0xDA, 0x88, 0xC3, 0x54, 0x63,
|
0x63, 0x4E, 0xE2, 0xDA, 0x88, 0xC3, 0x54, 0x63,
|
||||||
},
|
},
|
||||||
#else
|
|
||||||
{
|
|
||||||
"172.93.52.70", 33445,
|
|
||||||
0x79, 0xCA, 0xDA, 0x49, 0x74, 0xB0, 0x92, 0x6F,
|
|
||||||
0x28, 0x6F, 0x02, 0x5C, 0xD5, 0xFF, 0xDF, 0x3E,
|
|
||||||
0x65, 0x4A, 0x37, 0x58, 0xC5, 0x3E, 0x02, 0x73,
|
|
||||||
0xEC, 0xFC, 0x4D, 0x12, 0xC2, 0x1D, 0xCA, 0x48,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"tox.plastiras.org", 38445,
|
|
||||||
0x5E, 0x47, 0xBA, 0x1D, 0xC3, 0x91, 0x3E, 0xB2,
|
|
||||||
0xCB, 0xF2, 0xD6, 0x4C, 0xE4, 0xF2, 0x3D, 0x8B,
|
|
||||||
0xFE, 0x53, 0x91, 0xBF, 0xAB, 0xE5, 0xC4, 0x3C,
|
|
||||||
0x5B, 0xAD, 0x13, 0xF0, 0xA4, 0x14, 0xCD, 0x77,
|
|
||||||
},
|
|
||||||
#endif // USE_TEST_NETWORK
|
|
||||||
{ nullptr, 0, 0 },
|
{ nullptr, 0, 0 },
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -166,6 +153,8 @@ void set_mono_time_callback(AutoTox *autotox)
|
|||||||
Mono_Time *mono_time = autotox->tox->mono_time;
|
Mono_Time *mono_time = autotox->tox->mono_time;
|
||||||
|
|
||||||
autotox->clock = current_time_monotonic(mono_time);
|
autotox->clock = current_time_monotonic(mono_time);
|
||||||
|
ck_assert_msg(autotox->clock >= 1000,
|
||||||
|
"clock is too low (not initialised?): %lu", (unsigned long)autotox->clock);
|
||||||
mono_time_set_current_time_callback(mono_time, nullptr, nullptr); // set to default first
|
mono_time_set_current_time_callback(mono_time, nullptr, nullptr); // set to default first
|
||||||
mono_time_set_current_time_callback(mono_time, get_state_clock_callback, &autotox->clock);
|
mono_time_set_current_time_callback(mono_time, get_state_clock_callback, &autotox->clock);
|
||||||
}
|
}
|
||||||
@@ -208,6 +197,7 @@ void reload(AutoTox *autotox)
|
|||||||
|
|
||||||
struct Tox_Options *const options = tox_options_new(nullptr);
|
struct Tox_Options *const options = tox_options_new(nullptr);
|
||||||
ck_assert(options != nullptr);
|
ck_assert(options != nullptr);
|
||||||
|
tox_options_set_ipv6_enabled(options, USE_IPV6);
|
||||||
tox_options_set_savedata_type(options, TOX_SAVEDATA_TYPE_TOX_SAVE);
|
tox_options_set_savedata_type(options, TOX_SAVEDATA_TYPE_TOX_SAVE);
|
||||||
tox_options_set_savedata_data(options, autotox->save_state, autotox->save_size);
|
tox_options_set_savedata_data(options, autotox->save_state, autotox->save_size);
|
||||||
autotox->tox = tox_new_log(options, nullptr, &autotox->index);
|
autotox->tox = tox_new_log(options, nullptr, &autotox->index);
|
||||||
@@ -229,6 +219,8 @@ static void initialise_autotox(struct Tox_Options *options, AutoTox *autotox, ui
|
|||||||
struct Tox_Options *default_opts = tox_options_new(nullptr);
|
struct Tox_Options *default_opts = tox_options_new(nullptr);
|
||||||
ck_assert(default_opts != nullptr);
|
ck_assert(default_opts != nullptr);
|
||||||
|
|
||||||
|
tox_options_set_ipv6_enabled(default_opts, USE_IPV6);
|
||||||
|
|
||||||
if (options == nullptr) {
|
if (options == nullptr) {
|
||||||
options = default_opts;
|
options = default_opts;
|
||||||
}
|
}
|
||||||
@@ -332,7 +324,7 @@ static void bootstrap_autotoxes(struct Tox_Options *options, uint32_t tox_count,
|
|||||||
for (uint32_t i = 1; i < tox_count; ++i) {
|
for (uint32_t i = 1; i < tox_count; ++i) {
|
||||||
Tox_Err_Bootstrap err;
|
Tox_Err_Bootstrap err;
|
||||||
tox_bootstrap(autotoxes[i].tox, "localhost", dht_port, dht_key, &err);
|
tox_bootstrap(autotoxes[i].tox, "localhost", dht_port, dht_key, &err);
|
||||||
ck_assert(err == TOX_ERR_BOOTSTRAP_OK);
|
ck_assert_msg(err == TOX_ERR_BOOTSTRAP_OK, "bootstrap error for port %d: %d", dht_port, err);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!udp_enabled) {
|
if (!udp_enabled) {
|
||||||
@@ -441,6 +433,7 @@ Tox *tox_new_log_lan(struct Tox_Options *options, Tox_Err_New *err, void *log_us
|
|||||||
|
|
||||||
assert(log_options != nullptr);
|
assert(log_options != nullptr);
|
||||||
|
|
||||||
|
tox_options_set_ipv6_enabled(log_options, USE_IPV6);
|
||||||
tox_options_set_local_discovery_enabled(log_options, lan_discovery);
|
tox_options_set_local_discovery_enabled(log_options, lan_discovery);
|
||||||
// Use a higher start port for non-LAN-discovery tests so it's more likely for the LAN discovery
|
// Use a higher start port for non-LAN-discovery tests so it's more likely for the LAN discovery
|
||||||
// test to get the default port 33445.
|
// test to get the default port 33445.
|
||||||
|
@@ -9,7 +9,7 @@
|
|||||||
#define ck_assert(ok) do { \
|
#define ck_assert(ok) do { \
|
||||||
if (!(ok)) { \
|
if (!(ok)) { \
|
||||||
fprintf(stderr, "%s:%d: failed `%s'\n", __FILE__, __LINE__, #ok); \
|
fprintf(stderr, "%s:%d: failed `%s'\n", __FILE__, __LINE__, #ok); \
|
||||||
abort(); \
|
exit(7); \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
@@ -18,7 +18,7 @@
|
|||||||
fprintf(stderr, "%s:%d: failed `%s': ", __FILE__, __LINE__, #ok); \
|
fprintf(stderr, "%s:%d: failed `%s': ", __FILE__, __LINE__, #ok); \
|
||||||
fprintf(stderr, __VA_ARGS__); \
|
fprintf(stderr, __VA_ARGS__); \
|
||||||
fprintf(stderr, "\n"); \
|
fprintf(stderr, "\n"); \
|
||||||
abort(); \
|
exit(7); \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
@@ -26,7 +26,7 @@
|
|||||||
fprintf(stderr, "%s:%d: ", __FILE__, __LINE__); \
|
fprintf(stderr, "%s:%d: ", __FILE__, __LINE__); \
|
||||||
fprintf(stderr, __VA_ARGS__); \
|
fprintf(stderr, __VA_ARGS__); \
|
||||||
fprintf(stderr, "\n"); \
|
fprintf(stderr, "\n"); \
|
||||||
abort(); \
|
exit(7); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#endif // C_TOXCORE_AUTO_TESTS_CHECK_COMPAT_H
|
#endif // C_TOXCORE_AUTO_TESTS_CHECK_COMPAT_H
|
||||||
|
@@ -3,7 +3,6 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#ifndef VANILLA_NACL
|
|
||||||
#include <sodium.h>
|
#include <sodium.h>
|
||||||
|
|
||||||
#include "../testing/misc_tools.h"
|
#include "../testing/misc_tools.h"
|
||||||
@@ -232,9 +231,3 @@ int main(void)
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#else // VANILLA_NACL
|
|
||||||
int main(void)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
275
external/toxcore/c-toxcore/auto_tests/file_streaming_test.c
vendored
Normal file
275
external/toxcore/c-toxcore/auto_tests/file_streaming_test.c
vendored
Normal file
@@ -0,0 +1,275 @@
|
|||||||
|
/* File transfer test: streaming version (no known size).
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
|
#include "../testing/misc_tools.h"
|
||||||
|
#include "../toxcore/ccompat.h"
|
||||||
|
#include "../toxcore/tox.h"
|
||||||
|
#include "../toxcore/util.h"
|
||||||
|
#include "auto_test_support.h"
|
||||||
|
#include "check_compat.h"
|
||||||
|
|
||||||
|
#ifndef USE_IPV6
|
||||||
|
#define USE_IPV6 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef TOX_LOCALHOST
|
||||||
|
#undef TOX_LOCALHOST
|
||||||
|
#endif
|
||||||
|
#if USE_IPV6
|
||||||
|
#define TOX_LOCALHOST "::1"
|
||||||
|
#else
|
||||||
|
#define TOX_LOCALHOST "127.0.0.1"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static void accept_friend_request(Tox *m, const uint8_t *public_key, const uint8_t *data, size_t length, void *userdata)
|
||||||
|
{
|
||||||
|
if (length == 7 && memcmp("Gentoo", data, 7) == 0) {
|
||||||
|
tox_friend_add_norequest(m, public_key, nullptr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static uint64_t size_recv;
|
||||||
|
static uint64_t sending_pos;
|
||||||
|
|
||||||
|
static uint8_t file_cmp_id[TOX_FILE_ID_LENGTH];
|
||||||
|
static uint32_t file_accepted;
|
||||||
|
static uint64_t file_size;
|
||||||
|
static void tox_file_receive(Tox *tox, uint32_t friend_number, uint32_t file_number, uint32_t kind, uint64_t filesize,
|
||||||
|
const uint8_t *filename, size_t filename_length, void *userdata)
|
||||||
|
{
|
||||||
|
ck_assert_msg(kind == TOX_FILE_KIND_DATA, "bad kind");
|
||||||
|
|
||||||
|
ck_assert_msg(filename_length == sizeof("Gentoo.exe")
|
||||||
|
&& memcmp(filename, "Gentoo.exe", sizeof("Gentoo.exe")) == 0, "bad filename");
|
||||||
|
|
||||||
|
uint8_t file_id[TOX_FILE_ID_LENGTH];
|
||||||
|
|
||||||
|
ck_assert_msg(tox_file_get_file_id(tox, friend_number, file_number, file_id, nullptr), "tox_file_get_file_id error");
|
||||||
|
|
||||||
|
ck_assert_msg(memcmp(file_id, file_cmp_id, TOX_FILE_ID_LENGTH) == 0, "bad file_id");
|
||||||
|
|
||||||
|
uint8_t empty[TOX_FILE_ID_LENGTH] = {0};
|
||||||
|
|
||||||
|
ck_assert_msg(memcmp(empty, file_cmp_id, TOX_FILE_ID_LENGTH) != 0, "empty file_id");
|
||||||
|
|
||||||
|
file_size = filesize;
|
||||||
|
|
||||||
|
if (filesize) {
|
||||||
|
sending_pos = size_recv = 1337;
|
||||||
|
|
||||||
|
Tox_Err_File_Seek err_s;
|
||||||
|
|
||||||
|
ck_assert_msg(tox_file_seek(tox, friend_number, file_number, 1337, &err_s), "tox_file_seek error");
|
||||||
|
|
||||||
|
ck_assert_msg(err_s == TOX_ERR_FILE_SEEK_OK, "tox_file_seek wrong error");
|
||||||
|
|
||||||
|
} else {
|
||||||
|
sending_pos = size_recv = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
Tox_Err_File_Control error;
|
||||||
|
|
||||||
|
ck_assert_msg(tox_file_control(tox, friend_number, file_number, TOX_FILE_CONTROL_RESUME, &error),
|
||||||
|
"tox_file_control failed. %i", error);
|
||||||
|
++file_accepted;
|
||||||
|
|
||||||
|
Tox_Err_File_Seek err_s;
|
||||||
|
|
||||||
|
ck_assert_msg(!tox_file_seek(tox, friend_number, file_number, 1234, &err_s), "tox_file_seek no error");
|
||||||
|
|
||||||
|
ck_assert_msg(err_s == TOX_ERR_FILE_SEEK_DENIED, "tox_file_seek wrong error");
|
||||||
|
}
|
||||||
|
|
||||||
|
static uint32_t sendf_ok;
|
||||||
|
static void file_print_control(Tox *tox, uint32_t friend_number, uint32_t file_number, Tox_File_Control control,
|
||||||
|
void *userdata)
|
||||||
|
{
|
||||||
|
/* First send file num is 0.*/
|
||||||
|
if (file_number == 0 && control == TOX_FILE_CONTROL_RESUME) {
|
||||||
|
sendf_ok = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static uint64_t max_sending;
|
||||||
|
static bool m_send_reached;
|
||||||
|
static uint8_t sending_num;
|
||||||
|
static bool file_sending_done;
|
||||||
|
static void tox_file_chunk_request(Tox *tox, uint32_t friend_number, uint32_t file_number, uint64_t position,
|
||||||
|
size_t length, void *user_data)
|
||||||
|
{
|
||||||
|
ck_assert_msg(sendf_ok, "didn't get resume control");
|
||||||
|
|
||||||
|
ck_assert_msg(sending_pos == position, "bad position %lu", (unsigned long)position);
|
||||||
|
|
||||||
|
if (length == 0) {
|
||||||
|
ck_assert_msg(!file_sending_done, "file sending already done");
|
||||||
|
|
||||||
|
file_sending_done = 1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (position + length > max_sending) {
|
||||||
|
ck_assert_msg(!m_send_reached, "requested done file transfer");
|
||||||
|
|
||||||
|
length = max_sending - position;
|
||||||
|
m_send_reached = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
VLA(uint8_t, f_data, length);
|
||||||
|
memset(f_data, sending_num, length);
|
||||||
|
|
||||||
|
Tox_Err_File_Send_Chunk error;
|
||||||
|
tox_file_send_chunk(tox, friend_number, file_number, position, f_data, length, &error);
|
||||||
|
|
||||||
|
|
||||||
|
ck_assert_msg(error == TOX_ERR_FILE_SEND_CHUNK_OK,
|
||||||
|
"could not send chunk, error num=%d pos=%d len=%d", (int)error, (int)position, (int)length);
|
||||||
|
|
||||||
|
++sending_num;
|
||||||
|
sending_pos += length;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static uint8_t num;
|
||||||
|
static bool file_recv;
|
||||||
|
static void write_file(Tox *tox, uint32_t friendnumber, uint32_t filenumber, uint64_t position, const uint8_t *data,
|
||||||
|
size_t length, void *user_data)
|
||||||
|
{
|
||||||
|
ck_assert_msg(size_recv == position, "bad position");
|
||||||
|
|
||||||
|
if (length == 0) {
|
||||||
|
file_recv = 1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
VLA(uint8_t, f_data, length);
|
||||||
|
memset(f_data, num, length);
|
||||||
|
++num;
|
||||||
|
|
||||||
|
ck_assert_msg(memcmp(f_data, data, length) == 0, "FILE_CORRUPTED");
|
||||||
|
|
||||||
|
size_recv += length;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void file_transfer_test(void)
|
||||||
|
{
|
||||||
|
printf("Starting test: few_clients\n");
|
||||||
|
uint32_t index[] = { 1, 2, 3 };
|
||||||
|
long long unsigned int cur_time = time(nullptr);
|
||||||
|
Tox_Err_New t_n_error;
|
||||||
|
Tox *tox1 = tox_new_log(nullptr, &t_n_error, &index[0]);
|
||||||
|
ck_assert_msg(t_n_error == TOX_ERR_NEW_OK, "wrong error");
|
||||||
|
Tox *tox2 = tox_new_log(nullptr, &t_n_error, &index[1]);
|
||||||
|
ck_assert_msg(t_n_error == TOX_ERR_NEW_OK, "wrong error");
|
||||||
|
Tox *tox3 = tox_new_log(nullptr, &t_n_error, &index[2]);
|
||||||
|
ck_assert_msg(t_n_error == TOX_ERR_NEW_OK, "wrong error");
|
||||||
|
|
||||||
|
ck_assert_msg(tox1 && tox2 && tox3, "Failed to create 3 tox instances");
|
||||||
|
|
||||||
|
tox_callback_friend_request(tox2, accept_friend_request);
|
||||||
|
uint8_t address[TOX_ADDRESS_SIZE];
|
||||||
|
tox_self_get_address(tox2, address);
|
||||||
|
uint32_t test = tox_friend_add(tox3, address, (const uint8_t *)"Gentoo", 7, nullptr);
|
||||||
|
ck_assert_msg(test == 0, "Failed to add friend error code: %u", test);
|
||||||
|
|
||||||
|
uint8_t dht_key[TOX_PUBLIC_KEY_SIZE];
|
||||||
|
tox_self_get_dht_id(tox1, dht_key);
|
||||||
|
uint16_t dht_port = tox_self_get_udp_port(tox1, nullptr);
|
||||||
|
|
||||||
|
tox_bootstrap(tox2, TOX_LOCALHOST, dht_port, dht_key, nullptr);
|
||||||
|
tox_bootstrap(tox3, TOX_LOCALHOST, dht_port, dht_key, nullptr);
|
||||||
|
|
||||||
|
printf("Waiting for toxes to come online\n");
|
||||||
|
|
||||||
|
do {
|
||||||
|
tox_iterate(tox1, nullptr);
|
||||||
|
tox_iterate(tox2, nullptr);
|
||||||
|
tox_iterate(tox3, nullptr);
|
||||||
|
|
||||||
|
printf("Connections: self (%d, %d, %d), friends (%d, %d)\n",
|
||||||
|
tox_self_get_connection_status(tox1),
|
||||||
|
tox_self_get_connection_status(tox2),
|
||||||
|
tox_self_get_connection_status(tox3),
|
||||||
|
tox_friend_get_connection_status(tox2, 0, nullptr),
|
||||||
|
tox_friend_get_connection_status(tox3, 0, nullptr));
|
||||||
|
c_sleep(ITERATION_INTERVAL);
|
||||||
|
} while (tox_self_get_connection_status(tox1) == TOX_CONNECTION_NONE ||
|
||||||
|
tox_self_get_connection_status(tox2) == TOX_CONNECTION_NONE ||
|
||||||
|
tox_self_get_connection_status(tox3) == TOX_CONNECTION_NONE ||
|
||||||
|
tox_friend_get_connection_status(tox2, 0, nullptr) == TOX_CONNECTION_NONE ||
|
||||||
|
tox_friend_get_connection_status(tox3, 0, nullptr) == TOX_CONNECTION_NONE);
|
||||||
|
|
||||||
|
printf("Starting file transfer test: 100MiB file.\n");
|
||||||
|
|
||||||
|
file_accepted = file_size = sendf_ok = size_recv = 0;
|
||||||
|
file_recv = 0;
|
||||||
|
max_sending = UINT64_MAX;
|
||||||
|
uint64_t totalf_size = 100 * 1024 * 1024;
|
||||||
|
|
||||||
|
printf("Starting file streaming transfer test.\n");
|
||||||
|
|
||||||
|
file_sending_done = 0;
|
||||||
|
file_accepted = 0;
|
||||||
|
file_size = 0;
|
||||||
|
sendf_ok = 0;
|
||||||
|
size_recv = 0;
|
||||||
|
file_recv = 0;
|
||||||
|
tox_callback_file_recv_chunk(tox3, write_file);
|
||||||
|
tox_callback_file_recv_control(tox2, file_print_control);
|
||||||
|
tox_callback_file_chunk_request(tox2, tox_file_chunk_request);
|
||||||
|
tox_callback_file_recv_control(tox3, file_print_control);
|
||||||
|
tox_callback_file_recv(tox3, tox_file_receive);
|
||||||
|
totalf_size = UINT64_MAX;
|
||||||
|
Tox_File_Number fnum = tox_file_send(
|
||||||
|
tox2, 0, TOX_FILE_KIND_DATA, totalf_size, nullptr,
|
||||||
|
(const uint8_t *)"Gentoo.exe", sizeof("Gentoo.exe"), nullptr);
|
||||||
|
ck_assert_msg(fnum != UINT32_MAX, "tox_new_file_sender fail");
|
||||||
|
|
||||||
|
Tox_Err_File_Get gfierr;
|
||||||
|
ck_assert_msg(!tox_file_get_file_id(tox2, 1, fnum, file_cmp_id, &gfierr), "tox_file_get_file_id didn't fail");
|
||||||
|
ck_assert_msg(gfierr == TOX_ERR_FILE_GET_FRIEND_NOT_FOUND, "wrong error");
|
||||||
|
ck_assert_msg(!tox_file_get_file_id(tox2, 0, fnum + 1, file_cmp_id, &gfierr), "tox_file_get_file_id didn't fail");
|
||||||
|
ck_assert_msg(gfierr == TOX_ERR_FILE_GET_NOT_FOUND, "wrong error");
|
||||||
|
ck_assert_msg(tox_file_get_file_id(tox2, 0, fnum, file_cmp_id, &gfierr), "tox_file_get_file_id failed");
|
||||||
|
ck_assert_msg(gfierr == TOX_ERR_FILE_GET_OK, "wrong error");
|
||||||
|
|
||||||
|
max_sending = 100 * 1024;
|
||||||
|
m_send_reached = 0;
|
||||||
|
|
||||||
|
do {
|
||||||
|
tox_iterate(tox1, nullptr);
|
||||||
|
tox_iterate(tox2, nullptr);
|
||||||
|
tox_iterate(tox3, nullptr);
|
||||||
|
|
||||||
|
uint32_t tox1_interval = tox_iteration_interval(tox1);
|
||||||
|
uint32_t tox2_interval = tox_iteration_interval(tox2);
|
||||||
|
uint32_t tox3_interval = tox_iteration_interval(tox3);
|
||||||
|
|
||||||
|
c_sleep(min_u32(tox1_interval, min_u32(tox2_interval, tox3_interval)));
|
||||||
|
} while (!file_sending_done);
|
||||||
|
|
||||||
|
ck_assert_msg(sendf_ok && file_recv && m_send_reached && totalf_size == file_size && size_recv == max_sending
|
||||||
|
&& sending_pos == size_recv && file_accepted == 1,
|
||||||
|
"something went wrong in file transfer %u %u %u %u %u %u %u %lu %lu %lu %lu", sendf_ok, file_recv,
|
||||||
|
m_send_reached, totalf_size == file_size, size_recv == max_sending, sending_pos == size_recv, file_accepted == 1,
|
||||||
|
(unsigned long)totalf_size, (unsigned long)file_size,
|
||||||
|
(unsigned long)size_recv, (unsigned long)sending_pos);
|
||||||
|
|
||||||
|
printf("file_transfer_test succeeded, took %llu seconds\n", time(nullptr) - cur_time);
|
||||||
|
|
||||||
|
tox_kill(tox1);
|
||||||
|
tox_kill(tox2);
|
||||||
|
tox_kill(tox3);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
setvbuf(stdout, nullptr, _IONBF, 0);
|
||||||
|
file_transfer_test();
|
||||||
|
return 0;
|
||||||
|
}
|
@@ -13,9 +13,14 @@
|
|||||||
#include "auto_test_support.h"
|
#include "auto_test_support.h"
|
||||||
#include "check_compat.h"
|
#include "check_compat.h"
|
||||||
|
|
||||||
/* The Travis-CI container responds poorly to ::1 as a localhost address
|
#ifndef USE_IPV6
|
||||||
* You're encouraged to -D FORCE_TESTS_IPV6 on a local test */
|
#define USE_IPV6 1
|
||||||
#ifdef FORCE_TESTS_IPV6
|
#endif
|
||||||
|
|
||||||
|
#ifdef TOX_LOCALHOST
|
||||||
|
#undef TOX_LOCALHOST
|
||||||
|
#endif
|
||||||
|
#if USE_IPV6
|
||||||
#define TOX_LOCALHOST "::1"
|
#define TOX_LOCALHOST "::1"
|
||||||
#else
|
#else
|
||||||
#define TOX_LOCALHOST "127.0.0.1"
|
#define TOX_LOCALHOST "127.0.0.1"
|
||||||
@@ -261,53 +266,6 @@ static void file_transfer_test(void)
|
|||||||
|
|
||||||
printf("100MiB file sent in %lu seconds\n", (unsigned long)(time(nullptr) - f_time));
|
printf("100MiB file sent in %lu seconds\n", (unsigned long)(time(nullptr) - f_time));
|
||||||
|
|
||||||
printf("Starting file streaming transfer test.\n");
|
|
||||||
|
|
||||||
file_sending_done = 0;
|
|
||||||
file_accepted = 0;
|
|
||||||
file_size = 0;
|
|
||||||
sendf_ok = 0;
|
|
||||||
size_recv = 0;
|
|
||||||
file_recv = 0;
|
|
||||||
tox_callback_file_recv_chunk(tox3, write_file);
|
|
||||||
tox_callback_file_recv_control(tox2, file_print_control);
|
|
||||||
tox_callback_file_chunk_request(tox2, tox_file_chunk_request);
|
|
||||||
tox_callback_file_recv_control(tox3, file_print_control);
|
|
||||||
tox_callback_file_recv(tox3, tox_file_receive);
|
|
||||||
totalf_size = UINT64_MAX;
|
|
||||||
fnum = tox_file_send(tox2, 0, TOX_FILE_KIND_DATA, totalf_size, nullptr,
|
|
||||||
(const uint8_t *)"Gentoo.exe", sizeof("Gentoo.exe"), nullptr);
|
|
||||||
ck_assert_msg(fnum != UINT32_MAX, "tox_new_file_sender fail");
|
|
||||||
|
|
||||||
ck_assert_msg(!tox_file_get_file_id(tox2, 1, fnum, file_cmp_id, &gfierr), "tox_file_get_file_id didn't fail");
|
|
||||||
ck_assert_msg(gfierr == TOX_ERR_FILE_GET_FRIEND_NOT_FOUND, "wrong error");
|
|
||||||
ck_assert_msg(!tox_file_get_file_id(tox2, 0, fnum + 1, file_cmp_id, &gfierr), "tox_file_get_file_id didn't fail");
|
|
||||||
ck_assert_msg(gfierr == TOX_ERR_FILE_GET_NOT_FOUND, "wrong error");
|
|
||||||
ck_assert_msg(tox_file_get_file_id(tox2, 0, fnum, file_cmp_id, &gfierr), "tox_file_get_file_id failed");
|
|
||||||
ck_assert_msg(gfierr == TOX_ERR_FILE_GET_OK, "wrong error");
|
|
||||||
|
|
||||||
max_sending = 100 * 1024;
|
|
||||||
m_send_reached = 0;
|
|
||||||
|
|
||||||
do {
|
|
||||||
tox_iterate(tox1, nullptr);
|
|
||||||
tox_iterate(tox2, nullptr);
|
|
||||||
tox_iterate(tox3, nullptr);
|
|
||||||
|
|
||||||
uint32_t tox1_interval = tox_iteration_interval(tox1);
|
|
||||||
uint32_t tox2_interval = tox_iteration_interval(tox2);
|
|
||||||
uint32_t tox3_interval = tox_iteration_interval(tox3);
|
|
||||||
|
|
||||||
c_sleep(min_u32(tox1_interval, min_u32(tox2_interval, tox3_interval)));
|
|
||||||
} while (!file_sending_done);
|
|
||||||
|
|
||||||
ck_assert_msg(sendf_ok && file_recv && m_send_reached && totalf_size == file_size && size_recv == max_sending
|
|
||||||
&& sending_pos == size_recv && file_accepted == 1,
|
|
||||||
"something went wrong in file transfer %u %u %u %u %u %u %u %lu %lu %lu %lu", sendf_ok, file_recv,
|
|
||||||
m_send_reached, totalf_size == file_size, size_recv == max_sending, sending_pos == size_recv, file_accepted == 1,
|
|
||||||
(unsigned long)totalf_size, (unsigned long)file_size,
|
|
||||||
(unsigned long)size_recv, (unsigned long)sending_pos);
|
|
||||||
|
|
||||||
printf("starting file 0 transfer test.\n");
|
printf("starting file 0 transfer test.\n");
|
||||||
|
|
||||||
file_sending_done = 0;
|
file_sending_done = 0;
|
||||||
|
@@ -9,6 +9,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "auto_test_support.h"
|
#include "auto_test_support.h"
|
||||||
|
#include "../toxcore/tox_private.h"
|
||||||
|
|
||||||
typedef struct State {
|
typedef struct State {
|
||||||
size_t peer_joined_count;
|
size_t peer_joined_count;
|
||||||
@@ -42,6 +43,22 @@ typedef struct State {
|
|||||||
|
|
||||||
#define PEER_LIMIT 20
|
#define PEER_LIMIT 20
|
||||||
|
|
||||||
|
static void print_ip(Tox *tox, uint32_t groupnumber, uint32_t peer_id)
|
||||||
|
{
|
||||||
|
Tox_Err_Group_Peer_Query err;
|
||||||
|
size_t length = tox_group_peer_get_ip_address_size(tox, groupnumber, peer_id, &err);
|
||||||
|
|
||||||
|
ck_assert_msg(err == TOX_ERR_GROUP_PEER_QUERY_OK, "failed to get ip address size: error %d", err);
|
||||||
|
|
||||||
|
uint8_t ip_str[TOX_GROUP_PEER_IP_STRING_MAX_LENGTH];
|
||||||
|
tox_group_peer_get_ip_address(tox, groupnumber, peer_id, ip_str, &err);
|
||||||
|
ip_str[length] = '\0';
|
||||||
|
|
||||||
|
ck_assert_msg(err == TOX_ERR_GROUP_PEER_QUERY_OK, "failed to get ip address: error %d", err);
|
||||||
|
|
||||||
|
fprintf(stderr, "%s\n", ip_str);
|
||||||
|
}
|
||||||
|
|
||||||
static bool all_group_peers_connected(AutoTox *autotoxes, uint32_t tox_count, uint32_t groupnumber, size_t name_length)
|
static bool all_group_peers_connected(AutoTox *autotoxes, uint32_t tox_count, uint32_t groupnumber, size_t name_length)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < tox_count; ++i) {
|
for (size_t i = 0; i < tox_count; ++i) {
|
||||||
@@ -119,6 +136,9 @@ static void group_peer_join_handler(Tox *tox, uint32_t groupnumber, uint32_t pee
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fprintf(stderr, "%s joined with IP: ", peer_name);
|
||||||
|
print_ip(tox, groupnumber, peer_id);
|
||||||
|
|
||||||
state->peer_id = peer_id;
|
state->peer_id = peer_id;
|
||||||
++state->peer_joined_count;
|
++state->peer_joined_count;
|
||||||
}
|
}
|
||||||
@@ -178,6 +198,11 @@ static void group_peer_self_join_handler(Tox *tox, uint32_t groupnumber, void *u
|
|||||||
ck_assert_msg(query_err == TOX_ERR_GROUP_STATE_QUERIES_OK, "%d", query_err);
|
ck_assert_msg(query_err == TOX_ERR_GROUP_STATE_QUERIES_OK, "%d", query_err);
|
||||||
ck_assert(memcmp(topic, TOPIC, TOPIC_LEN) == 0);
|
ck_assert(memcmp(topic, TOPIC, TOPIC_LEN) == 0);
|
||||||
|
|
||||||
|
uint32_t peer_id = tox_group_self_get_peer_id(tox, groupnumber, nullptr);
|
||||||
|
|
||||||
|
fprintf(stderr, "self joined with IP: ");
|
||||||
|
print_ip(tox, groupnumber, peer_id);
|
||||||
|
|
||||||
++state->self_joined_count;
|
++state->self_joined_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -234,7 +259,6 @@ static void group_peer_status_handler(Tox *tox, uint32_t groupnumber, uint32_t p
|
|||||||
|
|
||||||
static void group_announce_test(AutoTox *autotoxes)
|
static void group_announce_test(AutoTox *autotoxes)
|
||||||
{
|
{
|
||||||
#ifndef VANILLA_NACL
|
|
||||||
ck_assert_msg(NUM_GROUP_TOXES == 2, "NUM_GROUP_TOXES needs to be 2");
|
ck_assert_msg(NUM_GROUP_TOXES == 2, "NUM_GROUP_TOXES needs to be 2");
|
||||||
|
|
||||||
Tox *tox0 = autotoxes[0].tox;
|
Tox *tox0 = autotoxes[0].tox;
|
||||||
@@ -341,6 +365,7 @@ static void group_announce_test(AutoTox *autotoxes)
|
|||||||
ck_assert(memcmp(tox0_pk_query, tox0_self_pk, TOX_GROUP_PEER_PUBLIC_KEY_SIZE) == 0);
|
ck_assert(memcmp(tox0_pk_query, tox0_self_pk, TOX_GROUP_PEER_PUBLIC_KEY_SIZE) == 0);
|
||||||
|
|
||||||
fprintf(stderr, "Peer 0 disconnecting...\n");
|
fprintf(stderr, "Peer 0 disconnecting...\n");
|
||||||
|
|
||||||
// tox 0 disconnects then reconnects
|
// tox 0 disconnects then reconnects
|
||||||
Tox_Err_Group_Disconnect d_err;
|
Tox_Err_Group_Disconnect d_err;
|
||||||
tox_group_disconnect(tox0, groupnumber, &d_err);
|
tox_group_disconnect(tox0, groupnumber, &d_err);
|
||||||
@@ -410,7 +435,6 @@ static void group_announce_test(AutoTox *autotoxes)
|
|||||||
ck_assert(num_groups1 == num_groups2 && num_groups2 == 0);
|
ck_assert(num_groups1 == num_groups2 && num_groups2 == 0);
|
||||||
|
|
||||||
printf("All tests passed!\n");
|
printf("All tests passed!\n");
|
||||||
#endif // VANILLA_NACL
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
|
@@ -102,7 +102,6 @@ static void group_peer_join_handler(Tox *tox, uint32_t group_number, uint32_t pe
|
|||||||
|
|
||||||
static void group_invite_test(AutoTox *autotoxes)
|
static void group_invite_test(AutoTox *autotoxes)
|
||||||
{
|
{
|
||||||
#ifndef VANILLA_NACL
|
|
||||||
ck_assert_msg(NUM_GROUP_TOXES > 7, "NUM_GROUP_TOXES is too small: %d", NUM_GROUP_TOXES);
|
ck_assert_msg(NUM_GROUP_TOXES > 7, "NUM_GROUP_TOXES is too small: %d", NUM_GROUP_TOXES);
|
||||||
|
|
||||||
for (size_t i = 0; i < NUM_GROUP_TOXES; ++i) {
|
for (size_t i = 0; i < NUM_GROUP_TOXES; ++i) {
|
||||||
@@ -260,8 +259,6 @@ static void group_invite_test(AutoTox *autotoxes)
|
|||||||
}
|
}
|
||||||
|
|
||||||
printf("All tests passed!\n");
|
printf("All tests passed!\n");
|
||||||
|
|
||||||
#endif // VANILLA_NACL
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
|
@@ -350,7 +350,6 @@ static void group_message_handler_wraparound_test(Tox *tox, uint32_t groupnumber
|
|||||||
|
|
||||||
static void group_message_test(AutoTox *autotoxes)
|
static void group_message_test(AutoTox *autotoxes)
|
||||||
{
|
{
|
||||||
#ifndef VANILLA_NACL
|
|
||||||
ck_assert_msg(NUM_GROUP_TOXES >= 2, "NUM_GROUP_TOXES is too small: %d", NUM_GROUP_TOXES);
|
ck_assert_msg(NUM_GROUP_TOXES >= 2, "NUM_GROUP_TOXES is too small: %d", NUM_GROUP_TOXES);
|
||||||
|
|
||||||
const Random *rng = system_random();
|
const Random *rng = system_random();
|
||||||
@@ -396,8 +395,9 @@ static void group_message_test(AutoTox *autotoxes)
|
|||||||
iterate_all_wait(autotoxes, NUM_GROUP_TOXES, ITERATION_INTERVAL);
|
iterate_all_wait(autotoxes, NUM_GROUP_TOXES, ITERATION_INTERVAL);
|
||||||
|
|
||||||
if (state1->peer_joined && !state1->message_sent) {
|
if (state1->peer_joined && !state1->message_sent) {
|
||||||
tox_group_send_message(tox1, group_number, TOX_MESSAGE_TYPE_NORMAL, (const uint8_t *)TEST_MESSAGE,
|
state1->pseudo_msg_id = tox_group_send_message(
|
||||||
TEST_MESSAGE_LEN, &state1->pseudo_msg_id, &err_send);
|
tox1, group_number, TOX_MESSAGE_TYPE_NORMAL, (const uint8_t *)TEST_MESSAGE,
|
||||||
|
TEST_MESSAGE_LEN, &err_send);
|
||||||
ck_assert(err_send == TOX_ERR_GROUP_SEND_MESSAGE_OK);
|
ck_assert(err_send == TOX_ERR_GROUP_SEND_MESSAGE_OK);
|
||||||
state1->message_sent = true;
|
state1->message_sent = true;
|
||||||
}
|
}
|
||||||
@@ -420,7 +420,7 @@ static void group_message_test(AutoTox *autotoxes)
|
|||||||
|
|
||||||
// tox1 sends group a message which should not be seen by tox0's message handler
|
// tox1 sends group a message which should not be seen by tox0's message handler
|
||||||
tox_group_send_message(tox1, group_number, TOX_MESSAGE_TYPE_NORMAL, (const uint8_t *)IGNORE_MESSAGE,
|
tox_group_send_message(tox1, group_number, TOX_MESSAGE_TYPE_NORMAL, (const uint8_t *)IGNORE_MESSAGE,
|
||||||
IGNORE_MESSAGE_LEN, nullptr, &err_send);
|
IGNORE_MESSAGE_LEN, &err_send);
|
||||||
|
|
||||||
iterate_all_wait(autotoxes, NUM_GROUP_TOXES, ITERATION_INTERVAL);
|
iterate_all_wait(autotoxes, NUM_GROUP_TOXES, ITERATION_INTERVAL);
|
||||||
|
|
||||||
@@ -507,7 +507,7 @@ static void group_message_test(AutoTox *autotoxes)
|
|||||||
|
|
||||||
memcpy(m + 2, &checksum, sizeof(uint16_t));
|
memcpy(m + 2, &checksum, sizeof(uint16_t));
|
||||||
|
|
||||||
tox_group_send_message(tox0, group_number, TOX_MESSAGE_TYPE_NORMAL, (const uint8_t *)m, message_size, nullptr, &err_send);
|
tox_group_send_message(tox0, group_number, TOX_MESSAGE_TYPE_NORMAL, (const uint8_t *)m, message_size, &err_send);
|
||||||
|
|
||||||
ck_assert(err_send == TOX_ERR_GROUP_SEND_MESSAGE_OK);
|
ck_assert(err_send == TOX_ERR_GROUP_SEND_MESSAGE_OK);
|
||||||
}
|
}
|
||||||
@@ -529,7 +529,7 @@ static void group_message_test(AutoTox *autotoxes)
|
|||||||
|
|
||||||
memcpy(m, &i, sizeof(uint16_t));
|
memcpy(m, &i, sizeof(uint16_t));
|
||||||
|
|
||||||
tox_group_send_message(tox0, group_number, TOX_MESSAGE_TYPE_NORMAL, (const uint8_t *)m, 2, nullptr, &err_send);
|
tox_group_send_message(tox0, group_number, TOX_MESSAGE_TYPE_NORMAL, (const uint8_t *)m, 2, &err_send);
|
||||||
ck_assert(err_send == TOX_ERR_GROUP_SEND_MESSAGE_OK);
|
ck_assert(err_send == TOX_ERR_GROUP_SEND_MESSAGE_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -544,7 +544,6 @@ static void group_message_test(AutoTox *autotoxes)
|
|||||||
}
|
}
|
||||||
|
|
||||||
fprintf(stderr, "All tests passed!\n");
|
fprintf(stderr, "All tests passed!\n");
|
||||||
#endif // VANILLA_NACL
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
|
@@ -247,7 +247,7 @@ static void handle_user(State *state, const char *peer_name, size_t peer_name_le
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void group_mod_event_handler(Tox *tox, uint32_t group_number, uint32_t source_peer_id, uint32_t target_peer_id,
|
static void group_mod_event_handler(Tox *tox, uint32_t group_number, uint32_t source_peer_id, uint32_t target_peer_id,
|
||||||
Tox_Group_Mod_Event event, void *user_data)
|
Tox_Group_Mod_Event mod_type, void *user_data)
|
||||||
{
|
{
|
||||||
AutoTox *autotox = (AutoTox *)user_data;
|
AutoTox *autotox = (AutoTox *)user_data;
|
||||||
ck_assert(autotox != nullptr);
|
ck_assert(autotox != nullptr);
|
||||||
@@ -275,7 +275,11 @@ static void group_mod_event_handler(Tox *tox, uint32_t group_number, uint32_t so
|
|||||||
Tox_Group_Role role = tox_group_peer_get_role(tox, group_number, target_peer_id, &q_err);
|
Tox_Group_Role role = tox_group_peer_get_role(tox, group_number, target_peer_id, &q_err);
|
||||||
ck_assert(q_err == TOX_ERR_GROUP_PEER_QUERY_OK);
|
ck_assert(q_err == TOX_ERR_GROUP_PEER_QUERY_OK);
|
||||||
|
|
||||||
switch (event) {
|
fprintf(stderr, "tox%u: got moderator event %d (%s), role = %s\n",
|
||||||
|
autotox->index, mod_type, tox_group_mod_event_to_string(mod_type),
|
||||||
|
tox_group_role_to_string(role));
|
||||||
|
|
||||||
|
switch (mod_type) {
|
||||||
case TOX_GROUP_MOD_EVENT_MODERATOR: {
|
case TOX_GROUP_MOD_EVENT_MODERATOR: {
|
||||||
handle_mod(state, peer_name, peer_name_len, role);
|
handle_mod(state, peer_name, peer_name_len, role);
|
||||||
break;
|
break;
|
||||||
@@ -298,7 +302,7 @@ static void group_mod_event_handler(Tox *tox, uint32_t group_number, uint32_t so
|
|||||||
}
|
}
|
||||||
|
|
||||||
default: {
|
default: {
|
||||||
ck_assert_msg(0, "Got invalid moderator event %d", event);
|
ck_assert_msg(0, "Got invalid moderator event %d", mod_type);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -334,21 +338,21 @@ static void voice_state_message_test(AutoTox *autotox, Tox_Group_Voice_State voi
|
|||||||
ck_assert(sq_err == TOX_ERR_GROUP_SELF_QUERY_OK);
|
ck_assert(sq_err == TOX_ERR_GROUP_SELF_QUERY_OK);
|
||||||
|
|
||||||
Tox_Err_Group_Send_Message msg_err;
|
Tox_Err_Group_Send_Message msg_err;
|
||||||
bool send_ret = tox_group_send_message(autotox->tox, state->group_number, TOX_MESSAGE_TYPE_NORMAL,
|
tox_group_send_message(autotox->tox, state->group_number, TOX_MESSAGE_TYPE_NORMAL,
|
||||||
(const uint8_t *)"test", 4, nullptr, &msg_err);
|
(const uint8_t *)"test", 4, &msg_err);
|
||||||
|
|
||||||
switch (self_role) {
|
switch (self_role) {
|
||||||
case TOX_GROUP_ROLE_OBSERVER: {
|
case TOX_GROUP_ROLE_OBSERVER: {
|
||||||
ck_assert(!send_ret && msg_err == TOX_ERR_GROUP_SEND_MESSAGE_PERMISSIONS);
|
ck_assert(msg_err == TOX_ERR_GROUP_SEND_MESSAGE_PERMISSIONS);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case TOX_GROUP_ROLE_USER: {
|
case TOX_GROUP_ROLE_USER: {
|
||||||
if (voice_state != TOX_GROUP_VOICE_STATE_ALL) {
|
if (voice_state != TOX_GROUP_VOICE_STATE_ALL) {
|
||||||
ck_assert_msg(!send_ret && msg_err == TOX_ERR_GROUP_SEND_MESSAGE_PERMISSIONS,
|
ck_assert_msg(msg_err == TOX_ERR_GROUP_SEND_MESSAGE_PERMISSIONS,
|
||||||
"%d, %d", send_ret, msg_err);
|
"%d", msg_err);
|
||||||
} else {
|
} else {
|
||||||
ck_assert(send_ret && msg_err == TOX_ERR_GROUP_SEND_MESSAGE_OK);
|
ck_assert(msg_err == TOX_ERR_GROUP_SEND_MESSAGE_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@@ -356,16 +360,16 @@ static void voice_state_message_test(AutoTox *autotox, Tox_Group_Voice_State voi
|
|||||||
|
|
||||||
case TOX_GROUP_ROLE_MODERATOR: {
|
case TOX_GROUP_ROLE_MODERATOR: {
|
||||||
if (voice_state != TOX_GROUP_VOICE_STATE_FOUNDER) {
|
if (voice_state != TOX_GROUP_VOICE_STATE_FOUNDER) {
|
||||||
ck_assert(send_ret && msg_err == TOX_ERR_GROUP_SEND_MESSAGE_OK);
|
ck_assert(msg_err == TOX_ERR_GROUP_SEND_MESSAGE_OK);
|
||||||
} else {
|
} else {
|
||||||
ck_assert(!send_ret && msg_err == TOX_ERR_GROUP_SEND_MESSAGE_PERMISSIONS);
|
ck_assert(msg_err == TOX_ERR_GROUP_SEND_MESSAGE_PERMISSIONS);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case TOX_GROUP_ROLE_FOUNDER: {
|
case TOX_GROUP_ROLE_FOUNDER: {
|
||||||
ck_assert(send_ret && msg_err == TOX_ERR_GROUP_SEND_MESSAGE_OK);
|
ck_assert(msg_err == TOX_ERR_GROUP_SEND_MESSAGE_OK);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -432,7 +436,6 @@ static void check_voice_state(AutoTox *autotoxes, uint32_t num_toxes)
|
|||||||
|
|
||||||
static void group_moderation_test(AutoTox *autotoxes)
|
static void group_moderation_test(AutoTox *autotoxes)
|
||||||
{
|
{
|
||||||
#ifndef VANILLA_NACL
|
|
||||||
ck_assert_msg(NUM_GROUP_TOXES >= 4, "NUM_GROUP_TOXES is too small: %d", NUM_GROUP_TOXES);
|
ck_assert_msg(NUM_GROUP_TOXES >= 4, "NUM_GROUP_TOXES is too small: %d", NUM_GROUP_TOXES);
|
||||||
ck_assert_msg(NUM_GROUP_TOXES < 10, "NUM_GROUP_TOXES is too big: %d", NUM_GROUP_TOXES);
|
ck_assert_msg(NUM_GROUP_TOXES < 10, "NUM_GROUP_TOXES is too big: %d", NUM_GROUP_TOXES);
|
||||||
|
|
||||||
@@ -634,7 +637,6 @@ static void group_moderation_test(AutoTox *autotoxes)
|
|||||||
}
|
}
|
||||||
|
|
||||||
fprintf(stderr, "All tests passed!\n");
|
fprintf(stderr, "All tests passed!\n");
|
||||||
#endif // VANILLA_NACL
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
|
@@ -148,7 +148,6 @@ static int has_correct_self_state(const Tox *tox, uint32_t group_number, const u
|
|||||||
|
|
||||||
static void group_save_test(AutoTox *autotoxes)
|
static void group_save_test(AutoTox *autotoxes)
|
||||||
{
|
{
|
||||||
#ifndef VANILLA_NACL
|
|
||||||
ck_assert_msg(NUM_GROUP_TOXES > 1, "NUM_GROUP_TOXES is too small: %d", NUM_GROUP_TOXES);
|
ck_assert_msg(NUM_GROUP_TOXES > 1, "NUM_GROUP_TOXES is too small: %d", NUM_GROUP_TOXES);
|
||||||
|
|
||||||
for (size_t i = 0; i < NUM_GROUP_TOXES; ++i) {
|
for (size_t i = 0; i < NUM_GROUP_TOXES; ++i) {
|
||||||
@@ -270,8 +269,6 @@ static void group_save_test(AutoTox *autotoxes)
|
|||||||
tox_kill(new_tox);
|
tox_kill(new_tox);
|
||||||
|
|
||||||
printf("All tests passed!\n");
|
printf("All tests passed!\n");
|
||||||
|
|
||||||
#endif // VANILLA_NACL
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
|
@@ -238,7 +238,6 @@ static void set_group_state(Tox *tox, uint32_t groupnumber, uint32_t peer_limit,
|
|||||||
|
|
||||||
static void group_state_test(AutoTox *autotoxes)
|
static void group_state_test(AutoTox *autotoxes)
|
||||||
{
|
{
|
||||||
#ifndef VANILLA_NACL
|
|
||||||
ck_assert_msg(NUM_GROUP_TOXES >= 3, "NUM_GROUP_TOXES is too small: %d", NUM_GROUP_TOXES);
|
ck_assert_msg(NUM_GROUP_TOXES >= 3, "NUM_GROUP_TOXES is too small: %d", NUM_GROUP_TOXES);
|
||||||
|
|
||||||
for (size_t i = 0; i < NUM_GROUP_TOXES; ++i) {
|
for (size_t i = 0; i < NUM_GROUP_TOXES; ++i) {
|
||||||
@@ -318,8 +317,6 @@ static void group_state_test(AutoTox *autotoxes)
|
|||||||
}
|
}
|
||||||
|
|
||||||
fprintf(stderr, "All tests passed!\n");
|
fprintf(stderr, "All tests passed!\n");
|
||||||
|
|
||||||
#endif /* VANILLA_NACL */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
|
@@ -330,7 +330,6 @@ static void topic_spam(const Random *rng, AutoTox *autotoxes, uint32_t num_peers
|
|||||||
|
|
||||||
static void group_sync_test(AutoTox *autotoxes)
|
static void group_sync_test(AutoTox *autotoxes)
|
||||||
{
|
{
|
||||||
#ifndef VANILLA_NACL
|
|
||||||
ck_assert(NUM_GROUP_TOXES >= 5);
|
ck_assert(NUM_GROUP_TOXES >= 5);
|
||||||
const Random *rng = system_random();
|
const Random *rng = system_random();
|
||||||
ck_assert(rng != nullptr);
|
ck_assert(rng != nullptr);
|
||||||
@@ -443,8 +442,6 @@ static void group_sync_test(AutoTox *autotoxes)
|
|||||||
}
|
}
|
||||||
|
|
||||||
fprintf(stderr, "All tests passed!\n");
|
fprintf(stderr, "All tests passed!\n");
|
||||||
|
|
||||||
#endif // VANILLA_NACL
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
|
@@ -8,8 +8,6 @@
|
|||||||
|
|
||||||
#include "auto_test_support.h"
|
#include "auto_test_support.h"
|
||||||
|
|
||||||
#ifdef USE_TEST_NETWORK
|
|
||||||
|
|
||||||
#define NUM_GROUP_TOXES 2
|
#define NUM_GROUP_TOXES 2
|
||||||
#define CODEWORD "RONALD MCDONALD"
|
#define CODEWORD "RONALD MCDONALD"
|
||||||
#define CODEWORD_LEN (sizeof(CODEWORD) - 1)
|
#define CODEWORD_LEN (sizeof(CODEWORD) - 1)
|
||||||
@@ -129,7 +127,6 @@ static bool all_peers_got_code(AutoTox *autotoxes)
|
|||||||
|
|
||||||
static void group_tcp_test(AutoTox *autotoxes)
|
static void group_tcp_test(AutoTox *autotoxes)
|
||||||
{
|
{
|
||||||
#ifndef VANILLA_NACL
|
|
||||||
ck_assert(NUM_GROUP_TOXES >= 2);
|
ck_assert(NUM_GROUP_TOXES >= 2);
|
||||||
|
|
||||||
State *state0 = (State *)autotoxes[0].state;
|
State *state0 = (State *)autotoxes[0].state;
|
||||||
@@ -209,7 +206,7 @@ static void group_tcp_test(AutoTox *autotoxes)
|
|||||||
|
|
||||||
Tox_Err_Group_Send_Message merr;
|
Tox_Err_Group_Send_Message merr;
|
||||||
tox_group_send_message(autotoxes[0].tox, groupnumber, TOX_MESSAGE_TYPE_NORMAL,
|
tox_group_send_message(autotoxes[0].tox, groupnumber, TOX_MESSAGE_TYPE_NORMAL,
|
||||||
(const uint8_t *)CODEWORD, CODEWORD_LEN, nullptr, &merr);
|
(const uint8_t *)CODEWORD, CODEWORD_LEN, &merr);
|
||||||
ck_assert(merr == TOX_ERR_GROUP_SEND_MESSAGE_OK);
|
ck_assert(merr == TOX_ERR_GROUP_SEND_MESSAGE_OK);
|
||||||
|
|
||||||
while (!state1->got_second_code) {
|
while (!state1->got_second_code) {
|
||||||
@@ -222,34 +219,29 @@ static void group_tcp_test(AutoTox *autotoxes)
|
|||||||
}
|
}
|
||||||
|
|
||||||
printf("Test passed!\n");
|
printf("Test passed!\n");
|
||||||
|
|
||||||
#endif // VANILLA_NACL
|
|
||||||
}
|
}
|
||||||
#endif // USE_TEST_NETWORK
|
|
||||||
|
|
||||||
int main(void)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
#ifdef USE_TEST_NETWORK // TODO(Jfreegman): Enable this test when the mainnet works with DHT groupchats
|
|
||||||
setvbuf(stdout, nullptr, _IONBF, 0);
|
setvbuf(stdout, nullptr, _IONBF, 0);
|
||||||
|
|
||||||
struct Tox_Options *options = (struct Tox_Options *)calloc(1, sizeof(struct Tox_Options));
|
struct Tox_Options *options = tox_options_new(nullptr);
|
||||||
ck_assert(options != nullptr);
|
ck_assert(options != nullptr);
|
||||||
|
|
||||||
tox_options_default(options);
|
|
||||||
tox_options_set_udp_enabled(options, false);
|
tox_options_set_udp_enabled(options, false);
|
||||||
|
|
||||||
Run_Auto_Options autotest_opts = default_run_auto_options();
|
Run_Auto_Options autotest_opts = default_run_auto_options();
|
||||||
autotest_opts.graph = GRAPH_COMPLETE;
|
autotest_opts.graph = GRAPH_COMPLETE;
|
||||||
|
|
||||||
|
// TODO(JFreegman): Fix this test and remove the "if".
|
||||||
|
if (argc > 2) {
|
||||||
run_auto_test(options, NUM_GROUP_TOXES, group_tcp_test, sizeof(State), &autotest_opts);
|
run_auto_test(options, NUM_GROUP_TOXES, group_tcp_test, sizeof(State), &autotest_opts);
|
||||||
|
}
|
||||||
|
|
||||||
tox_options_free(options);
|
tox_options_free(options);
|
||||||
#endif
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_TEST_NETWORK
|
|
||||||
#undef NUM_GROUP_TOXES
|
|
||||||
#undef CODEWORD_LEN
|
#undef CODEWORD_LEN
|
||||||
#undef CODEWORD
|
#undef CODEWORD
|
||||||
#endif // USE_TEST_NETWORK
|
#undef NUM_GROUP_TOXES
|
||||||
|
@@ -203,7 +203,6 @@ static uint32_t set_topic_all_peers(const Random *rng, AutoTox *autotoxes, size_
|
|||||||
|
|
||||||
static void group_topic_test(AutoTox *autotoxes)
|
static void group_topic_test(AutoTox *autotoxes)
|
||||||
{
|
{
|
||||||
#ifndef VANILLA_NACL
|
|
||||||
ck_assert_msg(NUM_GROUP_TOXES >= 3, "NUM_GROUP_TOXES is too small: %d", NUM_GROUP_TOXES);
|
ck_assert_msg(NUM_GROUP_TOXES >= 3, "NUM_GROUP_TOXES is too small: %d", NUM_GROUP_TOXES);
|
||||||
|
|
||||||
const Random *rng = system_random();
|
const Random *rng = system_random();
|
||||||
@@ -318,8 +317,6 @@ static void group_topic_test(AutoTox *autotoxes)
|
|||||||
}
|
}
|
||||||
|
|
||||||
fprintf(stderr, "All tests passed!\n");
|
fprintf(stderr, "All tests passed!\n");
|
||||||
|
|
||||||
#endif /* VANILLA_NACL */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
|
@@ -7,15 +7,8 @@
|
|||||||
#include "auto_test_support.h"
|
#include "auto_test_support.h"
|
||||||
#include "check_compat.h"
|
#include "check_compat.h"
|
||||||
|
|
||||||
static uint8_t const key[] = {
|
// Try to bootstrap for 20 seconds.
|
||||||
0x15, 0xE9, 0xC3, 0x09, 0xCF, 0xCB, 0x79, 0xFD,
|
#define NUM_ITERATIONS (unsigned)(20.0 / (ITERATION_INTERVAL / 1000.0))
|
||||||
0xDF, 0x0E, 0xBA, 0x05, 0x7D, 0xAB, 0xB4, 0x9F,
|
|
||||||
0xE1, 0x5F, 0x38, 0x03, 0xB1, 0xBF, 0xF0, 0x65,
|
|
||||||
0x36, 0xAE, 0x2E, 0x5B, 0xA5, 0xE4, 0x69, 0x0E,
|
|
||||||
};
|
|
||||||
|
|
||||||
// Try to bootstrap for 30 seconds.
|
|
||||||
#define NUM_ITERATIONS (unsigned)(30.0 / (ITERATION_INTERVAL / 1000.0))
|
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
@@ -24,13 +17,12 @@ int main(void)
|
|||||||
struct Tox_Options *opts = tox_options_new(nullptr);
|
struct Tox_Options *opts = tox_options_new(nullptr);
|
||||||
tox_options_set_udp_enabled(opts, false);
|
tox_options_set_udp_enabled(opts, false);
|
||||||
tox_options_set_proxy_type(opts, TOX_PROXY_TYPE_SOCKS5);
|
tox_options_set_proxy_type(opts, TOX_PROXY_TYPE_SOCKS5);
|
||||||
tox_options_set_proxy_host(opts, "localhost");
|
tox_options_set_proxy_host(opts, "127.0.0.1");
|
||||||
tox_options_set_proxy_port(opts, 51724);
|
tox_options_set_proxy_port(opts, 51724);
|
||||||
Tox *tox = tox_new_log(opts, nullptr, nullptr);
|
Tox *tox = tox_new_log(opts, nullptr, nullptr);
|
||||||
tox_options_free(opts);
|
tox_options_free(opts);
|
||||||
|
|
||||||
tox_add_tcp_relay(tox, "tox.ngc.zone", 33445, key, nullptr);
|
bootstrap_tox_live_network(tox, true);
|
||||||
tox_bootstrap(tox, "tox.ngc.zone", 33445, key, nullptr);
|
|
||||||
|
|
||||||
printf("Waiting for connection...\n");
|
printf("Waiting for connection...\n");
|
||||||
|
|
||||||
|
@@ -7,15 +7,8 @@
|
|||||||
#include "auto_test_support.h"
|
#include "auto_test_support.h"
|
||||||
#include "check_compat.h"
|
#include "check_compat.h"
|
||||||
|
|
||||||
static uint8_t const key[] = {
|
// Try to bootstrap for 20 seconds.
|
||||||
0x15, 0xE9, 0xC3, 0x09, 0xCF, 0xCB, 0x79, 0xFD,
|
#define NUM_ITERATIONS (unsigned)(20.0 / (ITERATION_INTERVAL / 1000.0))
|
||||||
0xDF, 0x0E, 0xBA, 0x05, 0x7D, 0xAB, 0xB4, 0x9F,
|
|
||||||
0xE1, 0x5F, 0x38, 0x03, 0xB1, 0xBF, 0xF0, 0x65,
|
|
||||||
0x36, 0xAE, 0x2E, 0x5B, 0xA5, 0xE4, 0x69, 0x0E,
|
|
||||||
};
|
|
||||||
|
|
||||||
// Try to bootstrap for 30 seconds.
|
|
||||||
#define NUM_ITERATIONS (unsigned)(30.0 / (ITERATION_INTERVAL / 1000.0))
|
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
@@ -24,13 +17,12 @@ int main(void)
|
|||||||
struct Tox_Options *opts = tox_options_new(nullptr);
|
struct Tox_Options *opts = tox_options_new(nullptr);
|
||||||
tox_options_set_udp_enabled(opts, true);
|
tox_options_set_udp_enabled(opts, true);
|
||||||
tox_options_set_proxy_type(opts, TOX_PROXY_TYPE_SOCKS5);
|
tox_options_set_proxy_type(opts, TOX_PROXY_TYPE_SOCKS5);
|
||||||
tox_options_set_proxy_host(opts, "localhost");
|
tox_options_set_proxy_host(opts, "127.0.0.1");
|
||||||
tox_options_set_proxy_port(opts, 51724);
|
tox_options_set_proxy_port(opts, 51724);
|
||||||
Tox *tox = tox_new_log(opts, nullptr, nullptr);
|
Tox *tox = tox_new_log(opts, nullptr, nullptr);
|
||||||
tox_options_free(opts);
|
tox_options_free(opts);
|
||||||
|
|
||||||
tox_add_tcp_relay(tox, "tox.ngc.zone", 33445, key, nullptr);
|
bootstrap_tox_live_network(tox, true);
|
||||||
tox_bootstrap(tox, "tox.ngc.zone", 33445, key, nullptr);
|
|
||||||
|
|
||||||
printf("Waiting for connection...");
|
printf("Waiting for connection...");
|
||||||
|
|
||||||
|
@@ -53,7 +53,7 @@ static int handle_test_1(void *object, const IP_Port *source, const uint8_t *pac
|
|||||||
res_packet[0] = NET_PACKET_ANNOUNCE_RESPONSE;
|
res_packet[0] = NET_PACKET_ANNOUNCE_RESPONSE;
|
||||||
memcpy(res_packet + 1, res_message, sizeof(res_message));
|
memcpy(res_packet + 1, res_message, sizeof(res_message));
|
||||||
|
|
||||||
if (send_onion_response(onion->net, source, res_packet, sizeof(res_packet),
|
if (send_onion_response(onion->log, onion->net, source, res_packet, sizeof(res_packet),
|
||||||
packet + sizeof(res_packet)) == -1) {
|
packet + sizeof(res_packet)) == -1) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -293,7 +293,7 @@ static void test_basic(void)
|
|||||||
uint64_t s;
|
uint64_t s;
|
||||||
memcpy(&s, sb_data, sizeof(uint64_t));
|
memcpy(&s, sb_data, sizeof(uint64_t));
|
||||||
memcpy(test_3_pub_key, nodes[3].public_key, CRYPTO_PUBLIC_KEY_SIZE);
|
memcpy(test_3_pub_key, nodes[3].public_key, CRYPTO_PUBLIC_KEY_SIZE);
|
||||||
int ret = send_announce_request(onion1->net, rng, &path, &nodes[3],
|
int ret = send_announce_request(log1, onion1->net, rng, &path, &nodes[3],
|
||||||
dht_get_self_public_key(onion1->dht),
|
dht_get_self_public_key(onion1->dht),
|
||||||
dht_get_self_secret_key(onion1->dht),
|
dht_get_self_secret_key(onion1->dht),
|
||||||
zeroes,
|
zeroes,
|
||||||
@@ -315,7 +315,7 @@ static void test_basic(void)
|
|||||||
memcpy(onion_announce_entry_public_key(onion2_a, 1), dht_get_self_public_key(onion2->dht), CRYPTO_PUBLIC_KEY_SIZE);
|
memcpy(onion_announce_entry_public_key(onion2_a, 1), dht_get_self_public_key(onion2->dht), CRYPTO_PUBLIC_KEY_SIZE);
|
||||||
onion_announce_entry_set_time(onion2_a, 1, mono_time_get(mono_time2));
|
onion_announce_entry_set_time(onion2_a, 1, mono_time_get(mono_time2));
|
||||||
networking_registerhandler(onion1->net, NET_PACKET_ONION_DATA_RESPONSE, &handle_test_4, onion1);
|
networking_registerhandler(onion1->net, NET_PACKET_ONION_DATA_RESPONSE, &handle_test_4, onion1);
|
||||||
send_announce_request(onion1->net, rng, &path, &nodes[3],
|
send_announce_request(log1, onion1->net, rng, &path, &nodes[3],
|
||||||
dht_get_self_public_key(onion1->dht),
|
dht_get_self_public_key(onion1->dht),
|
||||||
dht_get_self_secret_key(onion1->dht),
|
dht_get_self_secret_key(onion1->dht),
|
||||||
test_3_ping_id,
|
test_3_ping_id,
|
||||||
@@ -340,7 +340,7 @@ static void test_basic(void)
|
|||||||
ck_assert_msg((onion3 != nullptr), "Onion failed initializing.");
|
ck_assert_msg((onion3 != nullptr), "Onion failed initializing.");
|
||||||
|
|
||||||
random_nonce(rng, nonce);
|
random_nonce(rng, nonce);
|
||||||
ret = send_data_request(onion3->net, rng, &path, &nodes[3].ip_port,
|
ret = send_data_request(log3, onion3->net, rng, &path, &nodes[3].ip_port,
|
||||||
dht_get_self_public_key(onion1->dht),
|
dht_get_self_public_key(onion1->dht),
|
||||||
dht_get_self_public_key(onion1->dht),
|
dht_get_self_public_key(onion1->dht),
|
||||||
nonce, (const uint8_t *)"Install gentoo", sizeof("Install gentoo"));
|
nonce, (const uint8_t *)"Install gentoo", sizeof("Install gentoo"));
|
||||||
|
@@ -14,12 +14,14 @@
|
|||||||
#include "auto_test_support.h"
|
#include "auto_test_support.h"
|
||||||
#include "check_compat.h"
|
#include "check_compat.h"
|
||||||
|
|
||||||
/* The Travis-CI container responds poorly to ::1 as a localhost address
|
#ifndef USE_IPV6
|
||||||
* You're encouraged to -D FORCE_TESTS_IPV6 on a local test */
|
#define USE_IPV6 1
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef TOX_LOCALHOST
|
#ifdef TOX_LOCALHOST
|
||||||
#undef TOX_LOCALHOST
|
#undef TOX_LOCALHOST
|
||||||
#endif
|
#endif
|
||||||
#ifdef FORCE_TESTS_IPV6
|
#if USE_IPV6
|
||||||
#define TOX_LOCALHOST "::1"
|
#define TOX_LOCALHOST "::1"
|
||||||
#else
|
#else
|
||||||
#define TOX_LOCALHOST "127.0.0.1"
|
#define TOX_LOCALHOST "127.0.0.1"
|
||||||
@@ -74,6 +76,7 @@ static void reload_tox(Tox **tox, struct Tox_Options *const in_opts, void *user_
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct Tox_Options *const options = (in_opts == nullptr) ? tox_options_new(nullptr) : in_opts;
|
struct Tox_Options *const options = (in_opts == nullptr) ? tox_options_new(nullptr) : in_opts;
|
||||||
|
tox_options_set_ipv6_enabled(options, USE_IPV6);
|
||||||
|
|
||||||
tox_options_set_savedata_type(options, TOX_SAVEDATA_TYPE_TOX_SAVE);
|
tox_options_set_savedata_type(options, TOX_SAVEDATA_TYPE_TOX_SAVE);
|
||||||
|
|
||||||
@@ -138,6 +141,7 @@ static void test_few_clients(void)
|
|||||||
time_t con_time = 0, cur_time = time(nullptr);
|
time_t con_time = 0, cur_time = time(nullptr);
|
||||||
|
|
||||||
struct Tox_Options *opts1 = tox_options_new(nullptr);
|
struct Tox_Options *opts1 = tox_options_new(nullptr);
|
||||||
|
tox_options_set_ipv6_enabled(opts1, USE_IPV6);
|
||||||
tox_options_set_tcp_port(opts1, TCP_RELAY_PORT);
|
tox_options_set_tcp_port(opts1, TCP_RELAY_PORT);
|
||||||
Tox_Err_New t_n_error;
|
Tox_Err_New t_n_error;
|
||||||
Tox *tox1 = tox_new_log(opts1, &t_n_error, &index[0]);
|
Tox *tox1 = tox_new_log(opts1, &t_n_error, &index[0]);
|
||||||
@@ -145,12 +149,14 @@ static void test_few_clients(void)
|
|||||||
tox_options_free(opts1);
|
tox_options_free(opts1);
|
||||||
|
|
||||||
struct Tox_Options *opts2 = tox_options_new(nullptr);
|
struct Tox_Options *opts2 = tox_options_new(nullptr);
|
||||||
|
tox_options_set_ipv6_enabled(opts2, USE_IPV6);
|
||||||
tox_options_set_udp_enabled(opts2, false);
|
tox_options_set_udp_enabled(opts2, false);
|
||||||
tox_options_set_local_discovery_enabled(opts2, false);
|
tox_options_set_local_discovery_enabled(opts2, false);
|
||||||
Tox *tox2 = tox_new_log(opts2, &t_n_error, &index[1]);
|
Tox *tox2 = tox_new_log(opts2, &t_n_error, &index[1]);
|
||||||
ck_assert_msg(t_n_error == TOX_ERR_NEW_OK, "Failed to create tox instance: %d", t_n_error);
|
ck_assert_msg(t_n_error == TOX_ERR_NEW_OK, "Failed to create tox instance: %d", t_n_error);
|
||||||
|
|
||||||
struct Tox_Options *opts3 = tox_options_new(nullptr);
|
struct Tox_Options *opts3 = tox_options_new(nullptr);
|
||||||
|
tox_options_set_ipv6_enabled(opts3, USE_IPV6);
|
||||||
tox_options_set_local_discovery_enabled(opts3, false);
|
tox_options_set_local_discovery_enabled(opts3, false);
|
||||||
Tox *tox3 = tox_new_log(opts3, &t_n_error, &index[2]);
|
Tox *tox3 = tox_new_log(opts3, &t_n_error, &index[2]);
|
||||||
ck_assert_msg(t_n_error == TOX_ERR_NEW_OK, "Failed to create tox instance: %d", t_n_error);
|
ck_assert_msg(t_n_error == TOX_ERR_NEW_OK, "Failed to create tox instance: %d", t_n_error);
|
||||||
|
@@ -42,6 +42,7 @@ static void send_message_test(AutoTox *autotoxes)
|
|||||||
|
|
||||||
const size_t msgs_len = tox_max_message_length() + 1;
|
const size_t msgs_len = tox_max_message_length() + 1;
|
||||||
uint8_t *msgs = (uint8_t *)malloc(msgs_len);
|
uint8_t *msgs = (uint8_t *)malloc(msgs_len);
|
||||||
|
ck_assert(msgs != nullptr);
|
||||||
memset(msgs, MESSAGE_FILLER, msgs_len);
|
memset(msgs, MESSAGE_FILLER, msgs_len);
|
||||||
|
|
||||||
Tox_Err_Friend_Send_Message errm;
|
Tox_Err_Friend_Send_Message errm;
|
||||||
|
@@ -10,6 +10,8 @@
|
|||||||
#include "../toxcore/tox.h"
|
#include "../toxcore/tox.h"
|
||||||
#include "../toxcore/tox_dispatch.h"
|
#include "../toxcore/tox_dispatch.h"
|
||||||
#include "../toxcore/tox_events.h"
|
#include "../toxcore/tox_events.h"
|
||||||
|
#include "../toxcore/tox_private.h"
|
||||||
|
#include "../toxcore/tox_unpack.h"
|
||||||
#include "auto_test_support.h"
|
#include "auto_test_support.h"
|
||||||
#include "check_compat.h"
|
#include "check_compat.h"
|
||||||
|
|
||||||
@@ -30,31 +32,36 @@ static void handle_events_friend_message(Tox *tox, const Tox_Event_Friend_Messag
|
|||||||
|
|
||||||
static void dump_events(const char *path, const Tox_Events *events)
|
static void dump_events(const char *path, const Tox_Events *events)
|
||||||
{
|
{
|
||||||
if (want_dump_events) {
|
|
||||||
FILE *fh = fopen(path, "w");
|
FILE *fh = fopen(path, "w");
|
||||||
ck_assert(fh != nullptr);
|
ck_assert(fh != nullptr);
|
||||||
const uint32_t len = tox_events_bytes_size(events);
|
const uint32_t len = tox_events_bytes_size(events);
|
||||||
uint8_t *buf = (uint8_t *)malloc(len);
|
uint8_t *buf = (uint8_t *)malloc(len);
|
||||||
ck_assert(buf != nullptr);
|
ck_assert(buf != nullptr);
|
||||||
tox_events_get_bytes(events, buf);
|
ck_assert(tox_events_get_bytes(events, buf));
|
||||||
fwrite(buf, 1, len, fh);
|
fwrite(buf, 1, len, fh);
|
||||||
free(buf);
|
free(buf);
|
||||||
fclose(fh);
|
fclose(fh);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
static void print_events(const Tox_System *sys, Tox_Events *events)
|
static void print_events(const Tox_System *sys, Tox_Events *events)
|
||||||
{
|
{
|
||||||
const uint32_t size = tox_events_bytes_size(events);
|
const uint32_t size = tox_events_bytes_size(events);
|
||||||
|
|
||||||
uint8_t *bytes = (uint8_t *)malloc(size);
|
uint8_t *bytes1 = (uint8_t *)malloc(size);
|
||||||
ck_assert(bytes != nullptr);
|
uint8_t *bytes2 = (uint8_t *)malloc(size);
|
||||||
|
ck_assert(bytes1 != nullptr);
|
||||||
|
ck_assert(bytes2 != nullptr);
|
||||||
|
|
||||||
tox_events_get_bytes(events, bytes);
|
ck_assert(tox_events_get_bytes(events, bytes1));
|
||||||
|
ck_assert(tox_events_get_bytes(events, bytes2));
|
||||||
|
|
||||||
Tox_Events *events_copy = tox_events_load(sys, bytes, size);
|
// Make sure get_bytes is deterministic.
|
||||||
|
ck_assert(memcmp(bytes1, bytes2, size) == 0);
|
||||||
|
|
||||||
|
Tox_Events *events_copy = tox_events_load(sys, bytes1, size);
|
||||||
ck_assert(events_copy != nullptr);
|
ck_assert(events_copy != nullptr);
|
||||||
free(bytes);
|
free(bytes1);
|
||||||
|
free(bytes2);
|
||||||
|
|
||||||
ck_assert(tox_events_equal(sys, events, events_copy));
|
ck_assert(tox_events_equal(sys, events, events_copy));
|
||||||
|
|
||||||
@@ -72,7 +79,9 @@ static bool await_message(Tox **toxes, const Tox_Dispatch *dispatch)
|
|||||||
// Check if tox 2 got the message from tox 1.
|
// Check if tox 2 got the message from tox 1.
|
||||||
Tox_Events *events = tox_events_iterate(toxes[1], false, nullptr);
|
Tox_Events *events = tox_events_iterate(toxes[1], false, nullptr);
|
||||||
|
|
||||||
|
if (want_dump_events) {
|
||||||
dump_events("/tmp/test.mp", events);
|
dump_events("/tmp/test.mp", events);
|
||||||
|
}
|
||||||
|
|
||||||
bool success = false;
|
bool success = false;
|
||||||
tox_dispatch_invoke(dispatch, events, toxes[1], &success);
|
tox_dispatch_invoke(dispatch, events, toxes[1], &success);
|
||||||
@@ -160,9 +169,22 @@ static void test_tox_events(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void fake_test_unpack(void)
|
||||||
|
{
|
||||||
|
// TODO(Green-Sky): add proper unpack tests and/or implement ngc events
|
||||||
|
(void)tox_group_privacy_state_unpack;
|
||||||
|
(void)tox_group_privacy_state_unpack;
|
||||||
|
(void)tox_group_voice_state_unpack;
|
||||||
|
(void)tox_group_topic_lock_unpack;
|
||||||
|
(void)tox_group_join_fail_unpack;
|
||||||
|
(void)tox_group_mod_event_unpack;
|
||||||
|
(void)tox_group_exit_type_unpack;
|
||||||
|
}
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
setvbuf(stdout, nullptr, _IONBF, 0);
|
setvbuf(stdout, nullptr, _IONBF, 0);
|
||||||
test_tox_events();
|
test_tox_events();
|
||||||
|
fake_test_unpack();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@@ -22,12 +22,23 @@ static bool await_message(Tox **toxes)
|
|||||||
Tox_Events *events = tox_events_iterate(toxes[1], false, nullptr);
|
Tox_Events *events = tox_events_iterate(toxes[1], false, nullptr);
|
||||||
|
|
||||||
if (events != nullptr) {
|
if (events != nullptr) {
|
||||||
ck_assert(tox_events_get_friend_message_size(events) == 1);
|
uint32_t events_size = tox_events_get_size(events);
|
||||||
const Tox_Event_Friend_Message *msg_event = tox_events_get_friend_message(events, 0);
|
ck_assert(events_size == 1);
|
||||||
|
|
||||||
|
const Tox_Event_Friend_Message *msg_event = nullptr;
|
||||||
|
for (uint32_t j = 0; j < events_size; ++j) {
|
||||||
|
const Tox_Event *ev = tox_events_get(events, j);
|
||||||
|
if (tox_event_get_type(ev) == TOX_EVENT_FRIEND_MESSAGE) {
|
||||||
|
msg_event = tox_event_get_friend_message(ev);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ck_assert(msg_event != nullptr);
|
||||||
ck_assert(tox_event_friend_message_get_message_length(msg_event) == sizeof("hello"));
|
ck_assert(tox_event_friend_message_get_message_length(msg_event) == sizeof("hello"));
|
||||||
const uint8_t *msg = tox_event_friend_message_get_message(msg_event);
|
const uint8_t *msg = tox_event_friend_message_get_message(msg_event);
|
||||||
ck_assert_msg(memcmp(msg, "hello", sizeof("hello")) == 0,
|
ck_assert_msg(memcmp(msg, "hello", sizeof("hello")) == 0,
|
||||||
"message was not expected 'hello' but '%s'", (const char *)msg);
|
"message was not expected 'hello' but '%s'", (const char *)msg);
|
||||||
|
|
||||||
tox_events_free(events);
|
tox_events_free(events);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@@ -13,9 +13,14 @@
|
|||||||
#include "auto_test_support.h"
|
#include "auto_test_support.h"
|
||||||
#include "check_compat.h"
|
#include "check_compat.h"
|
||||||
|
|
||||||
/* The Travis-CI container responds poorly to ::1 as a localhost address
|
#ifndef USE_IPV6
|
||||||
* You're encouraged to -D FORCE_TESTS_IPV6 on a local test */
|
#define USE_IPV6 1
|
||||||
#ifdef FORCE_TESTS_IPV6
|
#endif
|
||||||
|
|
||||||
|
#ifdef TOX_LOCALHOST
|
||||||
|
#undef TOX_LOCALHOST
|
||||||
|
#endif
|
||||||
|
#if USE_IPV6
|
||||||
#define TOX_LOCALHOST "::1"
|
#define TOX_LOCALHOST "::1"
|
||||||
#else
|
#else
|
||||||
#define TOX_LOCALHOST "127.0.0.1"
|
#define TOX_LOCALHOST "127.0.0.1"
|
||||||
|
@@ -1,62 +0,0 @@
|
|||||||
# Find and compile the GTest library.
|
|
||||||
|
|
||||||
include(CheckCXXCompilerFlag)
|
|
||||||
include(CheckIncludeFileCXX)
|
|
||||||
|
|
||||||
message(STATUS "Checking for gtest")
|
|
||||||
|
|
||||||
# Look for the sources.
|
|
||||||
find_file(GTEST_ALL_CC gtest-all.cc PATHS
|
|
||||||
${CMAKE_SOURCE_DIR}/third_party/googletest/googletest/src
|
|
||||||
/usr/src/gtest/src
|
|
||||||
NO_DEFAULT_PATH
|
|
||||||
)
|
|
||||||
|
|
||||||
if(GTEST_ALL_CC)
|
|
||||||
# ../.. from the source file is the source root.
|
|
||||||
get_filename_component(GTEST_SRC_DIR ${GTEST_ALL_CC} DIRECTORY)
|
|
||||||
get_filename_component(GTEST_SRC_ROOT ${GTEST_SRC_DIR} DIRECTORY)
|
|
||||||
|
|
||||||
# Look for the header file.
|
|
||||||
include(CheckIncludeFileCXX)
|
|
||||||
include_directories(SYSTEM ${GTEST_SRC_ROOT}/include)
|
|
||||||
check_include_file_cxx("gtest/gtest.h" HAVE_GTEST_GTEST_H)
|
|
||||||
|
|
||||||
if(HAVE_GTEST_GTEST_H)
|
|
||||||
message(STATUS "Found gtest: ${GTEST_SRC_ROOT}")
|
|
||||||
|
|
||||||
add_library(gtest
|
|
||||||
${GTEST_SRC_DIR}/gtest-all.cc
|
|
||||||
${GTEST_SRC_DIR}/gtest_main.cc)
|
|
||||||
target_include_directories(gtest PRIVATE ${GTEST_SRC_ROOT})
|
|
||||||
|
|
||||||
# Ignore all warnings for gtest. We don't care about their implementation.
|
|
||||||
check_cxx_compiler_flag("-w" HAVE_CXX_W QUIET)
|
|
||||||
if(HAVE_CXX_W)
|
|
||||||
set_target_properties(gtest PROPERTIES COMPILE_FLAGS "-w")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(HAVE_GTEST TRUE)
|
|
||||||
set(TEST_CXX_FLAGS "")
|
|
||||||
|
|
||||||
check_cxx_compiler_flag("-Wno-global-constructors" HAVE_CXX_W_NO_GLOBAL_CONSTRUCTORS QUIET)
|
|
||||||
if(HAVE_CXX_W_NO_GLOBAL_CONSTRUCTORS)
|
|
||||||
set(TEST_CXX_FLAGS "${TEST_CXX_FLAGS} -Wno-global-constructors")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
check_cxx_compiler_flag("-Wno-zero-as-null-pointer-constant" HAVE_CXX_W_NO_ZERO_AS_NULL_POINTER_CONSTANT QUIET)
|
|
||||||
if(HAVE_CXX_W_NO_ZERO_AS_NULL_POINTER_CONSTANT)
|
|
||||||
set(TEST_CXX_FLAGS "${TEST_CXX_FLAGS} -Wno-zero-as-null-pointer-constant")
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
function(unit_test subdir target)
|
|
||||||
if(HAVE_GTEST)
|
|
||||||
add_executable(unit_${target}_test ${subdir}/${target}_test.cc)
|
|
||||||
target_link_modules(unit_${target}_test toxcore gtest)
|
|
||||||
set_target_properties(unit_${target}_test PROPERTIES COMPILE_FLAGS "${TEST_CXX_FLAGS}")
|
|
||||||
add_test(NAME ${target} COMMAND ${CROSSCOMPILING_EMULATOR} unit_${target}_test)
|
|
||||||
set_property(TEST ${target} PROPERTY ENVIRONMENT "LLVM_PROFILE_FILE=${target}.profraw")
|
|
||||||
endif()
|
|
||||||
endfunction()
|
|
@@ -1,76 +1,36 @@
|
|||||||
###############################################################################
|
###############################################################################
|
||||||
#
|
#
|
||||||
# :: For UNIX-like systems that have pkg-config.
|
# :: For systems that have pkg-config.
|
||||||
#
|
#
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
include(ModulePackage)
|
find_package(PkgConfig REQUIRED)
|
||||||
|
|
||||||
find_package(Threads REQUIRED)
|
|
||||||
|
|
||||||
find_library(NSL_LIBRARIES nsl )
|
find_library(NSL_LIBRARIES nsl )
|
||||||
find_library(RT_LIBRARIES rt )
|
find_library(RT_LIBRARIES rt )
|
||||||
find_library(SOCKET_LIBRARIES socket)
|
find_library(SOCKET_LIBRARIES socket)
|
||||||
|
|
||||||
|
find_package(pthreads QUIET)
|
||||||
|
if(NOT TARGET PThreads4W::PThreads4W)
|
||||||
|
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
||||||
|
find_package(Threads REQUIRED)
|
||||||
|
endif()
|
||||||
|
|
||||||
# For toxcore.
|
# For toxcore.
|
||||||
pkg_use_module(LIBSODIUM libsodium )
|
pkg_search_module(LIBSODIUM libsodium IMPORTED_TARGET REQUIRED)
|
||||||
|
if(MSVC)
|
||||||
|
find_package(unofficial-sodium REQUIRED)
|
||||||
|
endif()
|
||||||
|
|
||||||
# For toxav.
|
# For toxav.
|
||||||
pkg_use_module(OPUS "opus;Opus" )
|
pkg_search_module(OPUS opus IMPORTED_TARGET)
|
||||||
pkg_use_module(VPX "vpx;libvpx" )
|
if(NOT OPUS_FOUND)
|
||||||
|
pkg_search_module(OPUS Opus IMPORTED_TARGET)
|
||||||
|
endif()
|
||||||
|
pkg_search_module(VPX vpx IMPORTED_TARGET)
|
||||||
|
if(NOT VPX_FOUND)
|
||||||
|
pkg_search_module(VPX libvpx IMPORTED_TARGET)
|
||||||
|
endif()
|
||||||
|
|
||||||
# For tox-bootstrapd.
|
# For tox-bootstrapd.
|
||||||
pkg_use_module(LIBCONFIG libconfig )
|
pkg_search_module(LIBCONFIG libconfig IMPORTED_TARGET)
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
#
|
|
||||||
# :: For MSVC Windows builds.
|
|
||||||
#
|
|
||||||
# These require specific installation paths of dependencies:
|
|
||||||
# - libsodium in third-party/libsodium/Win32/Release/v140/dynamic
|
|
||||||
# - pthreads in third-party/pthreads-win32/Pre-built.2
|
|
||||||
#
|
|
||||||
###############################################################################
|
|
||||||
|
|
||||||
if(MSVC)
|
|
||||||
# libsodium
|
|
||||||
# ---------
|
|
||||||
if(NOT LIBSODIUM_FOUND)
|
|
||||||
find_library(LIBSODIUM_LIBRARIES
|
|
||||||
NAMES sodium libsodium
|
|
||||||
PATHS
|
|
||||||
"third_party/libsodium/Win32/Release/v140/dynamic"
|
|
||||||
"third_party/libsodium/x64/Release/v140/dynamic"
|
|
||||||
)
|
|
||||||
if(LIBSODIUM_LIBRARIES)
|
|
||||||
include_directories("third_party/libsodium/include")
|
|
||||||
set(LIBSODIUM_FOUND TRUE)
|
|
||||||
message("libsodium: ${LIBSODIUM_LIBRARIES}")
|
|
||||||
else()
|
|
||||||
message(FATAL_ERROR "libsodium libraries not found")
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# pthreads
|
|
||||||
# --------
|
|
||||||
if(CMAKE_USE_WIN32_THREADS_INIT)
|
|
||||||
find_library(CMAKE_THREAD_LIBS_INIT
|
|
||||||
NAMES pthreadVC2
|
|
||||||
PATHS
|
|
||||||
"third_party/pthreads-win32/Pre-built.2/lib/x86"
|
|
||||||
"third_party/pthreads-win32/Pre-built.2/lib/x64"
|
|
||||||
)
|
|
||||||
if(CMAKE_THREAD_LIBS_INIT)
|
|
||||||
include_directories("third_party/pthreads-win32/Pre-built.2/include")
|
|
||||||
add_definitions(-DHAVE_STRUCT_TIMESPEC)
|
|
||||||
message("libpthreads: ${CMAKE_THREAD_LIBS_INIT}")
|
|
||||||
else()
|
|
||||||
find_package(pthreads4w)
|
|
||||||
if(NOT pthreads4w_FOUND)
|
|
||||||
message(FATAL_ERROR "libpthreads libraries not found")
|
|
||||||
endif()
|
|
||||||
include_directories(${pthreads4w_INCLUDE_DIR})
|
|
||||||
link_libraries(${pthreads4w_LIBRARIES})
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
110
external/toxcore/c-toxcore/cmake/ModulePackage.cmake
vendored
110
external/toxcore/c-toxcore/cmake/ModulePackage.cmake
vendored
@@ -19,58 +19,8 @@ if(FULLY_STATIC)
|
|||||||
set(ENABLE_STATIC ON)
|
set(ENABLE_STATIC ON)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
find_package(PkgConfig)
|
|
||||||
|
|
||||||
function(pkg_use_module mod pkgs)
|
|
||||||
foreach(pkg IN ITEMS ${pkgs})
|
|
||||||
if(PKG_CONFIG_FOUND)
|
|
||||||
pkg_search_module(${mod} ${pkg})
|
|
||||||
endif()
|
|
||||||
if(NOT ${mod}_FOUND)
|
|
||||||
find_package(${pkg} QUIET)
|
|
||||||
# This is very very ugly, but the variables are sometimes used in this scope
|
|
||||||
# and sometimes in the parent scope, so we have to set them to both places.
|
|
||||||
set(${mod}_FOUND ${${pkg}_FOUND})
|
|
||||||
set(${mod}_FOUND ${${pkg}_FOUND} PARENT_SCOPE)
|
|
||||||
set(${mod}_LIBRARIES ${${pkg}_LIBS})
|
|
||||||
set(${mod}_LIBRARIES ${${pkg}_LIBS} PARENT_SCOPE)
|
|
||||||
set(${mod}_LIBRARY_DIRS ${${pkg}_LIBRARY_DIRS})
|
|
||||||
set(${mod}_LIBRARY_DIRS ${${pkg}_LIBRARY_DIRS} PARENT_SCOPE)
|
|
||||||
set(${mod}_INCLUDE_DIRS ${${pkg}_INCLUDE_DIRS})
|
|
||||||
set(${mod}_INCLUDE_DIRS ${${pkg}_INCLUDE_DIRS} PARENT_SCOPE)
|
|
||||||
endif()
|
|
||||||
if(${mod}_FOUND)
|
|
||||||
link_directories(${${mod}_LIBRARY_DIRS})
|
|
||||||
include_directories(${${mod}_INCLUDE_DIRS})
|
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${${mod}_CFLAGS_OTHER}" PARENT_SCOPE)
|
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${${mod}_CFLAGS_OTHER}" PARENT_SCOPE)
|
|
||||||
|
|
||||||
if(NOT MSVC)
|
|
||||||
foreach(dir ${${mod}_INCLUDE_DIRS})
|
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -isystem ${dir}" PARENT_SCOPE)
|
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -isystem ${dir}" PARENT_SCOPE)
|
|
||||||
endforeach()
|
|
||||||
endif()
|
|
||||||
break()
|
|
||||||
endif()
|
|
||||||
endforeach()
|
|
||||||
endfunction()
|
|
||||||
|
|
||||||
function(add_module lib)
|
|
||||||
set(${lib}_SOURCES ${ARGN} PARENT_SCOPE)
|
|
||||||
|
|
||||||
if(ENABLE_SHARED)
|
|
||||||
add_library(${lib}_shared SHARED ${ARGN})
|
|
||||||
set_target_properties(${lib}_shared PROPERTIES OUTPUT_NAME ${lib})
|
|
||||||
endif()
|
|
||||||
if(ENABLE_STATIC)
|
|
||||||
add_library(${lib}_static STATIC ${ARGN})
|
|
||||||
set_target_properties(${lib}_static PROPERTIES OUTPUT_NAME ${lib})
|
|
||||||
endif()
|
|
||||||
endfunction()
|
|
||||||
|
|
||||||
function(install_module lib)
|
function(install_module lib)
|
||||||
if(ENABLE_SHARED)
|
if(TARGET ${lib}_shared)
|
||||||
set_target_properties(${lib}_shared PROPERTIES
|
set_target_properties(${lib}_shared PROPERTIES
|
||||||
VERSION ${SOVERSION}
|
VERSION ${SOVERSION}
|
||||||
SOVERSION ${SOVERSION_MAJOR}
|
SOVERSION ${SOVERSION_MAJOR}
|
||||||
@@ -80,7 +30,7 @@ function(install_module lib)
|
|||||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||||
endif()
|
endif()
|
||||||
if(ENABLE_STATIC)
|
if(TARGET ${lib}_static)
|
||||||
install(TARGETS ${lib}_static
|
install(TARGETS ${lib}_static
|
||||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||||
@@ -113,59 +63,3 @@ function(install_module lib)
|
|||||||
install(FILES ${header} ${ARGN})
|
install(FILES ${header} ${ARGN})
|
||||||
endforeach()
|
endforeach()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
function(target_link_modules target)
|
|
||||||
# If the target we're adding dependencies to is a shared library, add it to
|
|
||||||
# the set of targets.
|
|
||||||
if(TARGET ${target}_shared)
|
|
||||||
set(_targets ${_targets} ${target}_shared)
|
|
||||||
# Shared libraries should first try to link against other shared libraries.
|
|
||||||
set(${target}_shared_primary shared)
|
|
||||||
# If that fails (because the shared target doesn't exist), try linking
|
|
||||||
# against the static library. This requires the static library's objects to
|
|
||||||
# be PIC.
|
|
||||||
set(${target}_shared_secondary static)
|
|
||||||
endif()
|
|
||||||
# It can also be a static library at the same time.
|
|
||||||
if(TARGET ${target}_static)
|
|
||||||
set(_targets ${_targets} ${target}_static)
|
|
||||||
# Static libraries aren't actually linked, but their dependencies are
|
|
||||||
# recorded by "linking" them. If we link an executable to a static library,
|
|
||||||
# we want to also link statically against its transitive dependencies.
|
|
||||||
set(${target}_static_primary static)
|
|
||||||
# If a dependency doesn't exist as static library, we link against the
|
|
||||||
# shared one.
|
|
||||||
set(${target}_static_secondary shared)
|
|
||||||
endif()
|
|
||||||
# If it's neither, then it's an executable.
|
|
||||||
if(NOT _targets)
|
|
||||||
set(_targets ${_targets} ${target})
|
|
||||||
# Executables preferably link against static libraries, so they are
|
|
||||||
# standalone and can be shipped without any external dependencies. As a
|
|
||||||
# frame of reference: tests become roughly 600-800K binaries instead of
|
|
||||||
# 50-100K on x86_64 Linux.
|
|
||||||
set(${target}_primary static)
|
|
||||||
set(${target}_secondary shared)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
foreach(dep ${ARGN})
|
|
||||||
foreach(_target ${_targets})
|
|
||||||
if(TARGET ${dep}_${${_target}_primary})
|
|
||||||
target_link_libraries(${_target} ${dep}_${${_target}_primary})
|
|
||||||
elseif(TARGET ${dep}_${${_target}_secondary})
|
|
||||||
target_link_libraries(${_target} ${dep}_${${_target}_secondary})
|
|
||||||
else()
|
|
||||||
# We record the modules linked to this target, so that we can collect
|
|
||||||
# them later when linking a composed module.
|
|
||||||
list(FIND LINK_MODULES ${dep} _index)
|
|
||||||
if(_index EQUAL -1)
|
|
||||||
set(LINK_MODULES ${LINK_MODULES} ${dep})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
target_link_libraries(${_target} ${dep})
|
|
||||||
endif()
|
|
||||||
endforeach()
|
|
||||||
endforeach()
|
|
||||||
|
|
||||||
set(${target}_LINK_MODULES ${${target}_LINK_MODULES} ${LINK_MODULES} PARENT_SCOPE)
|
|
||||||
endfunction()
|
|
||||||
|
128
external/toxcore/c-toxcore/configure.ac
vendored
128
external/toxcore/c-toxcore/configure.ac
vendored
@@ -22,8 +22,6 @@ BUILD_AV="yes"
|
|||||||
BUILD_TESTING="yes"
|
BUILD_TESTING="yes"
|
||||||
|
|
||||||
LIBCONFIG_FOUND="no"
|
LIBCONFIG_FOUND="no"
|
||||||
WANT_NACL="no"
|
|
||||||
ADD_NACL_OBJECTS_TO_PKGCONFIG="yes"
|
|
||||||
SET_SO_VERSION="yes"
|
SET_SO_VERSION="yes"
|
||||||
|
|
||||||
AC_ARG_ENABLE([soname-versions],
|
AC_ARG_ENABLE([soname-versions],
|
||||||
@@ -38,27 +36,12 @@ AC_ARG_ENABLE([soname-versions],
|
|||||||
)
|
)
|
||||||
AM_CONDITIONAL(SET_SO_VERSION, test "x$SET_SO_VERSION" = "xyes")
|
AM_CONDITIONAL(SET_SO_VERSION, test "x$SET_SO_VERSION" = "xyes")
|
||||||
|
|
||||||
AC_ARG_ENABLE([nacl],
|
|
||||||
[AC_HELP_STRING([--enable-nacl], [use nacl instead of libsodium (default: disabled)]) ],
|
|
||||||
[
|
|
||||||
if test "x$enableval" = "xno"; then
|
|
||||||
WANT_NACL="no"
|
|
||||||
elif test "x$enableval" = "xyes"; then
|
|
||||||
WANT_NACL="yes"
|
|
||||||
fi
|
|
||||||
]
|
|
||||||
)
|
|
||||||
|
|
||||||
AC_ARG_ENABLE([randombytes-stir],
|
AC_ARG_ENABLE([randombytes-stir],
|
||||||
[AC_HELP_STRING([--enable-randombytes-stir], [use randombytes_stir() instead of sodium_init() for faster startup on android (default: disabled)]) ],
|
[AC_HELP_STRING([--enable-randombytes-stir], [use randombytes_stir() instead of sodium_init() for faster startup on android (default: disabled)]) ],
|
||||||
[
|
[
|
||||||
if test "x$enableval" = "xyes"; then
|
if test "x$enableval" = "xyes"; then
|
||||||
if test "x$WANT_NACL" = "xyes"; then
|
|
||||||
AC_MSG_WARN([randombytes_stir() is not available with NaCl library])
|
|
||||||
else
|
|
||||||
AC_DEFINE([USE_RANDOMBYTES_STIR], [1], [randombytes_stir() instead of sodium_init()])
|
AC_DEFINE([USE_RANDOMBYTES_STIR], [1], [randombytes_stir() instead of sodium_init()])
|
||||||
fi
|
fi
|
||||||
fi
|
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -171,16 +154,6 @@ if test "$use_ipv6" != "yes"; then
|
|||||||
AC_DEFINE([USE_IPV6],[0],[define to 0 to force ipv4])
|
AC_DEFINE([USE_IPV6],[0],[define to 0 to force ipv4])
|
||||||
fi
|
fi
|
||||||
|
|
||||||
AC_ARG_ENABLE([[test_network]],
|
|
||||||
[AS_HELP_STRING([[--enable-test-network[=ARG]]], [build tox for a test network incompatible with the main DHT [no]])],
|
|
||||||
[use_test_network=${enableval}],
|
|
||||||
[use_test_network='no']
|
|
||||||
)
|
|
||||||
|
|
||||||
if test "$use_test_network" == "yes"; then
|
|
||||||
AC_DEFINE([USE_TEST_NETWORK],[1],[define to 1 to enable the test network])
|
|
||||||
fi
|
|
||||||
|
|
||||||
AX_HAVE_EPOLL
|
AX_HAVE_EPOLL
|
||||||
if test "$enable_epoll" != "no"; then
|
if test "$enable_epoll" != "no"; then
|
||||||
if test "${ax_cv_have_epoll}" = "yes"; then
|
if test "${ax_cv_have_epoll}" = "yes"; then
|
||||||
@@ -197,8 +170,6 @@ fi
|
|||||||
DEPSEARCH=
|
DEPSEARCH=
|
||||||
LIBSODIUM_SEARCH_HEADERS=
|
LIBSODIUM_SEARCH_HEADERS=
|
||||||
LIBSODIUM_SEARCH_LIBS=
|
LIBSODIUM_SEARCH_LIBS=
|
||||||
NACL_SEARCH_HEADERS=
|
|
||||||
NACL_SEARCH_LIBS=
|
|
||||||
|
|
||||||
AC_ARG_WITH(dependency-search,
|
AC_ARG_WITH(dependency-search,
|
||||||
AC_HELP_STRING([--with-dependency-search=DIR],
|
AC_HELP_STRING([--with-dependency-search=DIR],
|
||||||
@@ -216,24 +187,6 @@ if test -n "$DEPSEARCH"; then
|
|||||||
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$DEPSEARCH/lib/pkgconfig
|
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$DEPSEARCH/lib/pkgconfig
|
||||||
fi
|
fi
|
||||||
|
|
||||||
AC_ARG_WITH(nacl-headers,
|
|
||||||
AC_HELP_STRING([--with-nacl-headers=DIR],
|
|
||||||
[search for nacl<F2> header files in DIR]),
|
|
||||||
[
|
|
||||||
NACL_SEARCH_HEADERS="$withval"
|
|
||||||
AC_MSG_NOTICE([will search for nacl header files in $withval])
|
|
||||||
]
|
|
||||||
)
|
|
||||||
|
|
||||||
AC_ARG_WITH(nacl-libs,
|
|
||||||
AC_HELP_STRING([--with-nacl-libs=DIR],
|
|
||||||
[search for nacl libraries in DIR]),
|
|
||||||
[
|
|
||||||
NACL_SEARCH_LIBS="$withval"
|
|
||||||
AC_MSG_NOTICE([will search for nacl libraries in $withval])
|
|
||||||
]
|
|
||||||
)
|
|
||||||
|
|
||||||
AC_ARG_WITH(libsodium-headers,
|
AC_ARG_WITH(libsodium-headers,
|
||||||
AC_HELP_STRING([--with-libsodium-headers=DIR],
|
AC_HELP_STRING([--with-libsodium-headers=DIR],
|
||||||
[search for libsodium header files in DIR]),
|
[search for libsodium header files in DIR]),
|
||||||
@@ -252,11 +205,6 @@ AC_ARG_WITH(libsodium-libs,
|
|||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
if test "x$WANT_NACL" = "xyes"; then
|
|
||||||
enable_shared=no
|
|
||||||
enable_static=yes
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Checks for programs.
|
# Checks for programs.
|
||||||
AC_PROG_CC_C99
|
AC_PROG_CC_C99
|
||||||
|
|
||||||
@@ -287,7 +235,6 @@ case $host_os in
|
|||||||
LDFLAGS="$LDFLAGS -L/usr/local/lib"
|
LDFLAGS="$LDFLAGS -L/usr/local/lib"
|
||||||
CFLAGS="$CFLAGS -I/usr/local/include"
|
CFLAGS="$CFLAGS -I/usr/local/include"
|
||||||
CPPFLAGS="$CPPFLAGS -I/usr/local/include"
|
CPPFLAGS="$CPPFLAGS -I/usr/local/include"
|
||||||
ADD_NACL_OBJECTS_TO_PKGCONFIG="no"
|
|
||||||
;;
|
;;
|
||||||
darwin*)
|
darwin*)
|
||||||
MACH=yes
|
MACH=yes
|
||||||
@@ -312,50 +259,7 @@ PKG_CHECK_MODULES([LIBSODIUM], [libsodium],
|
|||||||
LIBSODIUM_FOUND="no"
|
LIBSODIUM_FOUND="no"
|
||||||
])
|
])
|
||||||
|
|
||||||
if test "x$WANT_NACL" = "xyes"; then
|
if test "x$LIBSODIUM_FOUND" = "xno"; then
|
||||||
NACL_LIBS=
|
|
||||||
NACL_LDFLAGS=
|
|
||||||
NACL_OBJECTS=
|
|
||||||
NACL_OBJECTS_PKGCONFIG=
|
|
||||||
LDFLAGS_SAVE="$LDFLAGS"
|
|
||||||
if test -n "$NACL_SEARCH_LIBS"; then
|
|
||||||
LDFLAGS="-L$NACL_SEARCH_LIBS $LDFLAGS"
|
|
||||||
AC_CHECK_LIB(nacl, random,
|
|
||||||
[
|
|
||||||
NACL_LDFLAGS="-L$NACL_SEARCH_LIBS"
|
|
||||||
NACL_LIBS="-lnacl"
|
|
||||||
],
|
|
||||||
[
|
|
||||||
AC_MSG_ERROR([library nacl was not found in requested location $NACL_SEARCH_LIBS])
|
|
||||||
]
|
|
||||||
)
|
|
||||||
else
|
|
||||||
AC_CHECK_LIB(nacl, random,
|
|
||||||
[],
|
|
||||||
[
|
|
||||||
AC_MSG_ERROR([you enabled nacl support, but library nacl was not found on your system])
|
|
||||||
]
|
|
||||||
)
|
|
||||||
fi
|
|
||||||
|
|
||||||
if (test -f "$NACL_SEARCH_LIBS/cpucycles.o") &&
|
|
||||||
(test -f "$NACL_SEARCH_LIBS/randombytes.o"); then
|
|
||||||
NACL_OBJECTS="$NACL_SEARCH_LIBS/cpucycles.o $NACL_SEARCH_LIBS/randombytes.o"
|
|
||||||
AC_MSG_NOTICE([found extra NaCl objects: $NACL_OBJECTS])
|
|
||||||
if test "x$ADD_NACL_OBJECTS_TO_PKGCONFIG" = "xyes"; then
|
|
||||||
AC_MSG_NOTICE([adding extra NaCl objects to pkg-config file])
|
|
||||||
NACL_OBJECTS_PKGCONFIG="$NACL_OBJECTS"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
AC_MSG_ERROR([required NaCl object files cpucycles.o randombytes.o not found, please specify their location using the --with-nacl-libs parameter])
|
|
||||||
fi
|
|
||||||
|
|
||||||
LDFLAGS="$LDFLAGS_SAVE"
|
|
||||||
AC_SUBST(NACL_LIBS)
|
|
||||||
AC_SUBST(NACL_LDFLAGS)
|
|
||||||
AC_SUBST(NACL_OBJECTS)
|
|
||||||
AC_SUBST(NACL_OBJECTS_PKGCONFIG)
|
|
||||||
elif test "x$LIBSODIUM_FOUND" = "xno"; then
|
|
||||||
LIBSODIUM_LIBS=
|
LIBSODIUM_LIBS=
|
||||||
LIBSODIUM_LDFLAGS=
|
LIBSODIUM_LDFLAGS=
|
||||||
LDFLAGS_SAVE="$LDFLAGS"
|
LDFLAGS_SAVE="$LDFLAGS"
|
||||||
@@ -388,34 +292,7 @@ fi
|
|||||||
AC_CHECK_HEADERS([arpa/inet.h fcntl.h netdb.h netinet/in.h stdint.h stdlib.h string.h sys/socket.h sys/time.h unistd.h])
|
AC_CHECK_HEADERS([arpa/inet.h fcntl.h netdb.h netinet/in.h stdint.h stdlib.h string.h sys/socket.h sys/time.h unistd.h])
|
||||||
|
|
||||||
|
|
||||||
if test "x$WANT_NACL" = "xyes"; then
|
if test "x$LIBSODIUM_FOUND" = "xno"; then
|
||||||
NACL_CFLAGS=
|
|
||||||
CFLAGS_SAVE="$CFLAGS"
|
|
||||||
CPPFLAGS_SAVE="$CPPFLAGS"
|
|
||||||
if test -n "$NACL_SEARCH_HEADERS"; then
|
|
||||||
CFLAGS="-I$NACL_SEARCH_HEADERS $CFLAGS"
|
|
||||||
CPPFLAGS="-I$NACL_SEARCH_HEADERS $CPPFLAGS"
|
|
||||||
AC_CHECK_HEADER(crypto_box.h,
|
|
||||||
[
|
|
||||||
NACL_CFLAGS="-I$NACL_SEARCH_HEADERS"
|
|
||||||
],
|
|
||||||
[
|
|
||||||
AC_MSG_ERROR([header files for library nacl were not found in requested location $NACL_SEARCH_HEADERS])
|
|
||||||
]
|
|
||||||
)
|
|
||||||
else
|
|
||||||
AC_CHECK_HEADER(crypto_box.h,
|
|
||||||
[],
|
|
||||||
[
|
|
||||||
AC_MSG_ERROR([you enabled nacl support, but nacl header files were not found on your system])
|
|
||||||
]
|
|
||||||
)
|
|
||||||
fi
|
|
||||||
CFLAGS="$CFLAGS_SAVE"
|
|
||||||
CPPFLAGS="$CPPFLAGS_SAVE"
|
|
||||||
AC_SUBST(NACL_CFLAGS)
|
|
||||||
AC_DEFINE([VANILLA_NACL], [1], [use nacl instead of libsodium])
|
|
||||||
elif test "x$LIBSODIUM_FOUND" = "xno"; then
|
|
||||||
LIBSODIUM_CFLAGS=
|
LIBSODIUM_CFLAGS=
|
||||||
CFLAGS_SAVE="$CFLAGS"
|
CFLAGS_SAVE="$CFLAGS"
|
||||||
CPPFLAGS_SAVE="$CPPFLAGS"
|
CPPFLAGS_SAVE="$CPPFLAGS"
|
||||||
@@ -555,7 +432,6 @@ AM_CONDITIONAL(BUILD_DHT_BOOTSTRAP, test "x$BUILD_DHT_BOOTSTRAP" = "xyes")
|
|||||||
AM_CONDITIONAL(BUILD_TESTS, test "x$BUILD_TESTS" = "xyes")
|
AM_CONDITIONAL(BUILD_TESTS, test "x$BUILD_TESTS" = "xyes")
|
||||||
AM_CONDITIONAL(BUILD_AV, test "x$BUILD_AV" = "xyes")
|
AM_CONDITIONAL(BUILD_AV, test "x$BUILD_AV" = "xyes")
|
||||||
AM_CONDITIONAL(BUILD_TESTING, test "x$BUILD_TESTING" = "xyes")
|
AM_CONDITIONAL(BUILD_TESTING, test "x$BUILD_TESTING" = "xyes")
|
||||||
AM_CONDITIONAL(WITH_NACL, test "x$WANT_NACL" = "xyes")
|
|
||||||
AM_CONDITIONAL(WIN32, test "x$WIN32" = "xyes")
|
AM_CONDITIONAL(WIN32, test "x$WIN32" = "xyes")
|
||||||
|
|
||||||
AC_CONFIG_FILES([Makefile
|
AC_CONFIG_FILES([Makefile
|
||||||
|
@@ -49,7 +49,7 @@ The public/private key pair the TCP server uses is the same one he uses for the
|
|||||||
DHT.
|
DHT.
|
||||||
|
|
||||||
all crypto for communication with the server uses the crypto_box() function of
|
all crypto for communication with the server uses the crypto_box() function of
|
||||||
NaCl.
|
libsodium.
|
||||||
|
|
||||||
TCP doesn't have packets so what we will refer to as packets are sent this way:
|
TCP doesn't have packets so what we will refer to as packets are sent this way:
|
||||||
[[uint16_t (length of data)][data]]
|
[[uint16_t (length of data)][data]]
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
Encryption library used: http://nacl.cr.yp.to/
|
Encryption library used: https://doc.libsodium.org/
|
||||||
|
|
||||||
|
|
||||||
When running the program for the first time the crypto_box_keypair() function is used to
|
When running the program for the first time the crypto_box_keypair() function is used to
|
||||||
|
4
external/toxcore/c-toxcore/heroku.yml
vendored
4
external/toxcore/c-toxcore/heroku.yml
vendored
@@ -1,4 +0,0 @@
|
|||||||
---
|
|
||||||
build:
|
|
||||||
docker:
|
|
||||||
web: other/bootstrap_daemon/websocket/Dockerfile
|
|
2
external/toxcore/c-toxcore/libtoxcore.pc.in
vendored
2
external/toxcore/c-toxcore/libtoxcore.pc.in
vendored
@@ -7,5 +7,5 @@ Name: libtoxcore
|
|||||||
Description: Tox protocol library
|
Description: Tox protocol library
|
||||||
Requires:
|
Requires:
|
||||||
Version: @PACKAGE_VERSION@
|
Version: @PACKAGE_VERSION@
|
||||||
Libs: @NACL_OBJECTS_PKGCONFIG@ -L${libdir} -ltoxcore @NACL_LDFLAGS@ -ltoxencryptsave @NACL_LIBS@ @LIBS@ @MATH_LDFLAGS@ @PTHREAD_LDFLAGS@
|
Libs: -L${libdir} -ltoxcore -ltoxencryptsave @LIBS@ @MATH_LDFLAGS@ @PTHREAD_LDFLAGS@
|
||||||
Cflags: -I${includedir}
|
Cflags: -I${includedir}
|
||||||
|
2
external/toxcore/c-toxcore/other/BUILD.bazel
vendored
2
external/toxcore/c-toxcore/other/BUILD.bazel
vendored
@@ -21,13 +21,11 @@ cc_binary(
|
|||||||
"//c-toxcore/toxcore:Messenger",
|
"//c-toxcore/toxcore:Messenger",
|
||||||
"//c-toxcore/toxcore:TCP_server",
|
"//c-toxcore/toxcore:TCP_server",
|
||||||
"//c-toxcore/toxcore:ccompat",
|
"//c-toxcore/toxcore:ccompat",
|
||||||
"//c-toxcore/toxcore:friend_requests",
|
|
||||||
"//c-toxcore/toxcore:group_onion_announce",
|
"//c-toxcore/toxcore:group_onion_announce",
|
||||||
"//c-toxcore/toxcore:logger",
|
"//c-toxcore/toxcore:logger",
|
||||||
"//c-toxcore/toxcore:mono_time",
|
"//c-toxcore/toxcore:mono_time",
|
||||||
"//c-toxcore/toxcore:network",
|
"//c-toxcore/toxcore:network",
|
||||||
"//c-toxcore/toxcore:onion_announce",
|
"//c-toxcore/toxcore:onion_announce",
|
||||||
"//c-toxcore/toxcore:tox",
|
"//c-toxcore/toxcore:tox",
|
||||||
"//c-toxcore/toxcore:util",
|
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
38
external/toxcore/c-toxcore/other/DHT_bootstrap.c
vendored
38
external/toxcore/c-toxcore/other/DHT_bootstrap.c
vendored
@@ -16,12 +16,17 @@
|
|||||||
#include "../toxcore/DHT.h"
|
#include "../toxcore/DHT.h"
|
||||||
#include "../toxcore/LAN_discovery.h"
|
#include "../toxcore/LAN_discovery.h"
|
||||||
#include "../toxcore/ccompat.h"
|
#include "../toxcore/ccompat.h"
|
||||||
#include "../toxcore/friend_requests.h"
|
#include "../toxcore/crypto_core.h"
|
||||||
|
#include "../toxcore/forwarding.h"
|
||||||
|
#include "../toxcore/group_announce.h"
|
||||||
#include "../toxcore/group_onion_announce.h"
|
#include "../toxcore/group_onion_announce.h"
|
||||||
#include "../toxcore/logger.h"
|
#include "../toxcore/logger.h"
|
||||||
|
#include "../toxcore/mem.h"
|
||||||
#include "../toxcore/mono_time.h"
|
#include "../toxcore/mono_time.h"
|
||||||
|
#include "../toxcore/network.h"
|
||||||
|
#include "../toxcore/onion.h"
|
||||||
|
#include "../toxcore/onion_announce.h"
|
||||||
#include "../toxcore/tox.h"
|
#include "../toxcore/tox.h"
|
||||||
#include "../toxcore/util.h"
|
|
||||||
|
|
||||||
#define TCP_RELAY_ENABLED
|
#define TCP_RELAY_ENABLED
|
||||||
|
|
||||||
@@ -46,7 +51,7 @@ static const char *motd_str = ""; //Change this to anything within 256 bytes(but
|
|||||||
#define PORT 33445
|
#define PORT 33445
|
||||||
|
|
||||||
|
|
||||||
static void manage_keys(DHT *dht)
|
static bool manage_keys(DHT *dht)
|
||||||
{
|
{
|
||||||
enum { KEYS_SIZE = CRYPTO_PUBLIC_KEY_SIZE + CRYPTO_SECRET_KEY_SIZE };
|
enum { KEYS_SIZE = CRYPTO_PUBLIC_KEY_SIZE + CRYPTO_SECRET_KEY_SIZE };
|
||||||
uint8_t keys[KEYS_SIZE];
|
uint8_t keys[KEYS_SIZE];
|
||||||
@@ -60,7 +65,8 @@ static void manage_keys(DHT *dht)
|
|||||||
|
|
||||||
if (read_size != KEYS_SIZE) {
|
if (read_size != KEYS_SIZE) {
|
||||||
printf("Error while reading the key file\nExiting.\n");
|
printf("Error while reading the key file\nExiting.\n");
|
||||||
exit(1);
|
fclose(keys_file);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
dht_set_self_public_key(dht, keys);
|
dht_set_self_public_key(dht, keys);
|
||||||
@@ -73,18 +79,20 @@ static void manage_keys(DHT *dht)
|
|||||||
|
|
||||||
if (keys_file == nullptr) {
|
if (keys_file == nullptr) {
|
||||||
printf("Error opening key file in write mode.\nKeys will not be saved.\n");
|
printf("Error opening key file in write mode.\nKeys will not be saved.\n");
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fwrite(keys, sizeof(uint8_t), KEYS_SIZE, keys_file) != KEYS_SIZE) {
|
if (fwrite(keys, sizeof(uint8_t), KEYS_SIZE, keys_file) != KEYS_SIZE) {
|
||||||
printf("Error while writing the key file.\nExiting.\n");
|
printf("Error while writing the key file.\nExiting.\n");
|
||||||
exit(1);
|
fclose(keys_file);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("Keys saved successfully.\n");
|
printf("Keys saved successfully.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(keys_file);
|
fclose(keys_file);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *strlevel(Logger_Level level)
|
static const char *strlevel(Logger_Level level)
|
||||||
@@ -121,7 +129,7 @@ int main(int argc, char *argv[])
|
|||||||
if (argc == 2 && !tox_strncasecmp(argv[1], "-h", 3)) {
|
if (argc == 2 && !tox_strncasecmp(argv[1], "-h", 3)) {
|
||||||
printf("Usage (connected) : %s [--ipv4|--ipv6] IP PORT KEY\n", argv[0]);
|
printf("Usage (connected) : %s [--ipv4|--ipv6] IP PORT KEY\n", argv[0]);
|
||||||
printf("Usage (unconnected): %s [--ipv4|--ipv6]\n", argv[0]);
|
printf("Usage (unconnected): %s [--ipv4|--ipv6]\n", argv[0]);
|
||||||
exit(0);
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* let user override default by cmdline */
|
/* let user override default by cmdline */
|
||||||
@@ -129,7 +137,7 @@ int main(int argc, char *argv[])
|
|||||||
int argvoffset = cmdline_parsefor_ipv46(argc, argv, &ipv6enabled);
|
int argvoffset = cmdline_parsefor_ipv46(argc, argv, &ipv6enabled);
|
||||||
|
|
||||||
if (argvoffset < 0) {
|
if (argvoffset < 0) {
|
||||||
exit(1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Initialize networking -
|
/* Initialize networking -
|
||||||
@@ -162,14 +170,16 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
if (!(onion && forwarding && onion_a)) {
|
if (!(onion && forwarding && onion_a)) {
|
||||||
printf("Something failed to initialize.\n");
|
printf("Something failed to initialize.\n");
|
||||||
exit(1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
gca_onion_init(gc_announces_list, onion_a);
|
gca_onion_init(gc_announces_list, onion_a);
|
||||||
|
|
||||||
perror("Initialization");
|
perror("Initialization");
|
||||||
|
|
||||||
manage_keys(dht);
|
if (!manage_keys(dht)) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
printf("Public key: ");
|
printf("Public key: ");
|
||||||
|
|
||||||
#ifdef TCP_RELAY_ENABLED
|
#ifdef TCP_RELAY_ENABLED
|
||||||
@@ -179,7 +189,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
if (tcp_s == nullptr) {
|
if (tcp_s == nullptr) {
|
||||||
printf("TCP server failed to initialize.\n");
|
printf("TCP server failed to initialize.\n");
|
||||||
exit(1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -189,7 +199,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
if (file == nullptr) {
|
if (file == nullptr) {
|
||||||
printf("Could not open file \"%s\" for writing. Exiting...\n", public_id_filename);
|
printf("Could not open file \"%s\" for writing. Exiting...\n", public_id_filename);
|
||||||
exit(1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (uint32_t i = 0; i < 32; ++i) {
|
for (uint32_t i = 0; i < 32; ++i) {
|
||||||
@@ -210,7 +220,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
if (port_conv <= 0 || port_conv > UINT16_MAX) {
|
if (port_conv <= 0 || port_conv > UINT16_MAX) {
|
||||||
printf("Failed to convert \"%s\" into a valid port. Exiting...\n", argv[argvoffset + 2]);
|
printf("Failed to convert \"%s\" into a valid port. Exiting...\n", argv[argvoffset + 2]);
|
||||||
exit(1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
const uint16_t port = net_htons((uint16_t)port_conv);
|
const uint16_t port = net_htons((uint16_t)port_conv);
|
||||||
@@ -222,7 +232,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
if (!res) {
|
if (!res) {
|
||||||
printf("Failed to convert \"%s\" into an IP address. Exiting...\n", argv[argvoffset + 1]);
|
printf("Failed to convert \"%s\" into an IP address. Exiting...\n", argv[argvoffset + 1]);
|
||||||
exit(1);
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -9,16 +9,12 @@ DHT_bootstrap_SOURCES = ../other/DHT_bootstrap.c \
|
|||||||
../other/bootstrap_node_packets.c
|
../other/bootstrap_node_packets.c
|
||||||
|
|
||||||
DHT_bootstrap_CFLAGS = -I$(top_srcdir)/other \
|
DHT_bootstrap_CFLAGS = -I$(top_srcdir)/other \
|
||||||
$(LIBSODIUM_CFLAGS) \
|
$(LIBSODIUM_CFLAGS)
|
||||||
$(NACL_CFLAGS)
|
|
||||||
|
|
||||||
DHT_bootstrap_LDADD = $(LIBSODIUM_LDFLAGS) \
|
DHT_bootstrap_LDADD = $(LIBSODIUM_LDFLAGS) \
|
||||||
$(NACL_LDFLAGS) \
|
|
||||||
libmisc_tools.la \
|
libmisc_tools.la \
|
||||||
libtoxcore.la \
|
libtoxcore.la \
|
||||||
$(LIBSODIUM_LIBS) \
|
$(LIBSODIUM_LIBS) \
|
||||||
$(NACL_OBJECTS) \
|
|
||||||
$(NACL_LIBS) \
|
|
||||||
$(WINSOCK2_LIBS)
|
$(WINSOCK2_LIBS)
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
@@ -31,8 +31,8 @@ out = (subprocess.run(
|
|||||||
|
|
||||||
errors = 0
|
errors = 0
|
||||||
for line in out.split("\n"):
|
for line in out.split("\n"):
|
||||||
# other/fun can do what it wants.
|
# other/fun and mallocfail can do what they want.
|
||||||
if "/fun/" in line:
|
if "/fun/" in line or "/mallocfail/" in line:
|
||||||
continue
|
continue
|
||||||
filename, include = line.split(":", 1)
|
filename, include = line.split(":", 1)
|
||||||
# We only check headers.
|
# We only check headers.
|
||||||
|
@@ -15,7 +15,7 @@ CPPFLAGS+=("-Itoxav")
|
|||||||
CPPFLAGS+=("-Itoxencryptsave")
|
CPPFLAGS+=("-Itoxencryptsave")
|
||||||
CPPFLAGS+=("-Ithird_party/cmp")
|
CPPFLAGS+=("-Ithird_party/cmp")
|
||||||
|
|
||||||
LDFLAGS=("-lopus" "-lsodium" "-lvpx" "-lpthread" "-lconfig" "-lgtest")
|
LDFLAGS=("-lopus" "-lsodium" "-lvpx" "-lpthread" "-lconfig" "-lgmock" "-lgtest")
|
||||||
LDFLAGS+=("-fuse-ld=gold")
|
LDFLAGS+=("-fuse-ld=gold")
|
||||||
LDFLAGS+=("-Wl,--detect-odr-violations")
|
LDFLAGS+=("-Wl,--detect-odr-violations")
|
||||||
LDFLAGS+=("-Wl,--warn-common")
|
LDFLAGS+=("-Wl,--warn-common")
|
||||||
|
@@ -10,7 +10,7 @@ run() {
|
|||||||
"${CPPFLAGS[@]}" \
|
"${CPPFLAGS[@]}" \
|
||||||
"${LDFLAGS[@]}" \
|
"${LDFLAGS[@]}" \
|
||||||
"$@" \
|
"$@" \
|
||||||
-std=c++11 \
|
-std=c++17 \
|
||||||
-Werror \
|
-Werror \
|
||||||
-Weverything \
|
-Weverything \
|
||||||
-Wno-alloca \
|
-Wno-alloca \
|
||||||
|
@@ -9,7 +9,7 @@ run() {
|
|||||||
clang++ --analyze amalgamation.cc \
|
clang++ --analyze amalgamation.cc \
|
||||||
"${CPPFLAGS[@]}" \
|
"${CPPFLAGS[@]}" \
|
||||||
"$@" \
|
"$@" \
|
||||||
-std=c++11
|
-std=c++20
|
||||||
}
|
}
|
||||||
|
|
||||||
. other/analysis/variants.sh
|
. other/analysis/variants.sh
|
||||||
|
@@ -1,6 +1,64 @@
|
|||||||
#!/bin/bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
CHECKS="*"
|
CHECKS="*"
|
||||||
|
ERRORS="*"
|
||||||
|
|
||||||
|
# Need to investigate or disable and document these.
|
||||||
|
# =========================================================
|
||||||
|
|
||||||
|
# TODO(iphydf): Fix these.
|
||||||
|
ERRORS="$ERRORS,-cert-err34-c"
|
||||||
|
ERRORS="$ERRORS,-readability-suspicious-call-argument"
|
||||||
|
|
||||||
|
# TODO(iphydf): Fix once cimple 0.0.19 is released.
|
||||||
|
CHECKS="$CHECKS,-google-readability-casting"
|
||||||
|
|
||||||
|
# TODO(iphydf): Fix these.
|
||||||
|
CHECKS="$CHECKS,-bugprone-switch-missing-default-case"
|
||||||
|
|
||||||
|
# TODO(iphydf): We might want some of these. For the ones we don't want, add a
|
||||||
|
# comment explaining why not.
|
||||||
|
CHECKS="$CHECKS,-clang-analyzer-optin.performance.Padding"
|
||||||
|
CHECKS="$CHECKS,-hicpp-signed-bitwise"
|
||||||
|
|
||||||
|
# TODO(iphydf): Maybe fix these?
|
||||||
|
CHECKS="$CHECKS,-bugprone-implicit-widening-of-multiplication-result"
|
||||||
|
CHECKS="$CHECKS,-bugprone-integer-division"
|
||||||
|
CHECKS="$CHECKS,-misc-no-recursion"
|
||||||
|
|
||||||
|
# TODO(iphydf): Only happens in bootstrap_daemon. Fix it.
|
||||||
|
CHECKS="$CHECKS,-cppcoreguidelines-avoid-non-const-global-variables"
|
||||||
|
|
||||||
|
# TODO(iphydf): Probably fix these.
|
||||||
|
CHECKS="$CHECKS,-cert-err33-c"
|
||||||
|
CHECKS="$CHECKS,-cppcoreguidelines-avoid-magic-numbers"
|
||||||
|
CHECKS="$CHECKS,-readability-magic-numbers"
|
||||||
|
|
||||||
|
# TODO(iphydf): We're using a lot of macros for constants. Should we convert
|
||||||
|
# all of them to enum?
|
||||||
|
CHECKS="$CHECKS,-modernize-macro-to-enum"
|
||||||
|
|
||||||
|
# Documented disabled checks. We don't want these for sure.
|
||||||
|
# =========================================================
|
||||||
|
|
||||||
|
# https://stackoverflow.com/questions/58672959/why-does-clang-tidy-say-vsnprintf-has-an-uninitialized-va-list-argument
|
||||||
|
CHECKS="$CHECKS,-clang-analyzer-valist.Uninitialized"
|
||||||
|
|
||||||
|
# We pass a lot of ints around, so many function parameters are some kind of
|
||||||
|
# int type that can be converted from another int type. We won't be getting
|
||||||
|
# away from that anytime soon.
|
||||||
|
CHECKS="$CHECKS,-bugprone-easily-swappable-parameters"
|
||||||
|
|
||||||
|
# Callback handlers often don't use all their parameters. There's
|
||||||
|
# IgnoreVirtual, but that doesn't work for C-style callbacks.
|
||||||
|
CHECKS="$CHECKS,-misc-unused-parameters"
|
||||||
|
|
||||||
|
# We sometimes use #if 0.
|
||||||
|
CHECKS="$CHECKS,-readability-avoid-unconditional-preprocessor-if"
|
||||||
|
|
||||||
|
# We have better macro hygiene checks with tokstyle. We can never pass macro
|
||||||
|
# arguments that require parentheses inside the macro.
|
||||||
|
CHECKS="$CHECKS,-bugprone-macro-parentheses"
|
||||||
|
|
||||||
# We don't use memcpy_s.
|
# We don't use memcpy_s.
|
||||||
CHECKS="$CHECKS,-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling"
|
CHECKS="$CHECKS,-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling"
|
||||||
@@ -81,62 +139,48 @@ CHECKS="$CHECKS,-cert-dcl03-c"
|
|||||||
CHECKS="$CHECKS,-hicpp-static-assert"
|
CHECKS="$CHECKS,-hicpp-static-assert"
|
||||||
CHECKS="$CHECKS,-misc-static-assert"
|
CHECKS="$CHECKS,-misc-static-assert"
|
||||||
|
|
||||||
# TODO(iphydf): We might want some of these. For the ones we don't want, add a
|
|
||||||
# comment explaining why not.
|
|
||||||
CHECKS="$CHECKS,-clang-analyzer-optin.performance.Padding"
|
|
||||||
CHECKS="$CHECKS,-hicpp-signed-bitwise"
|
|
||||||
CHECKS="$CHECKS,-misc-unused-parameters"
|
|
||||||
CHECKS="$CHECKS,-readability-function-cognitive-complexity"
|
|
||||||
|
|
||||||
# TODO(iphydf): Maybe fix these?
|
|
||||||
CHECKS="$CHECKS,-bugprone-easily-swappable-parameters"
|
|
||||||
CHECKS="$CHECKS,-bugprone-implicit-widening-of-multiplication-result"
|
|
||||||
CHECKS="$CHECKS,-bugprone-integer-division"
|
|
||||||
CHECKS="$CHECKS,-clang-analyzer-core.NullDereference"
|
|
||||||
CHECKS="$CHECKS,-clang-analyzer-valist.Uninitialized"
|
|
||||||
CHECKS="$CHECKS,-concurrency-mt-unsafe"
|
|
||||||
CHECKS="$CHECKS,-cppcoreguidelines-avoid-non-const-global-variables"
|
|
||||||
CHECKS="$CHECKS,-misc-no-recursion"
|
|
||||||
|
|
||||||
# TODO(iphydf): Probably fix these.
|
|
||||||
CHECKS="$CHECKS,-cert-err33-c"
|
|
||||||
CHECKS="$CHECKS,-cppcoreguidelines-avoid-magic-numbers"
|
|
||||||
CHECKS="$CHECKS,-google-readability-casting"
|
|
||||||
CHECKS="$CHECKS,-modernize-macro-to-enum"
|
|
||||||
CHECKS="$CHECKS,-readability-magic-numbers"
|
|
||||||
|
|
||||||
# TODO(iphydf): These two trip on list.c. Investigate why.
|
|
||||||
CHECKS="$CHECKS,-clang-analyzer-core.NonNullParamChecker"
|
|
||||||
CHECKS="$CHECKS,-clang-analyzer-unix.Malloc"
|
|
||||||
|
|
||||||
ERRORS="*"
|
|
||||||
|
|
||||||
# TODO(iphydf): Fix these.
|
|
||||||
ERRORS="$ERRORS,-bugprone-macro-parentheses"
|
|
||||||
ERRORS="$ERRORS,-cert-err34-c"
|
|
||||||
ERRORS="$ERRORS,-cert-str34-c"
|
|
||||||
ERRORS="$ERRORS,-readability-suspicious-call-argument"
|
|
||||||
|
|
||||||
set -eux
|
set -eux
|
||||||
|
|
||||||
|
# TODO(iphydf): Add toxav.
|
||||||
|
DIRS=(
|
||||||
|
other/bootstrap_daemon/src
|
||||||
|
other
|
||||||
|
toxcore
|
||||||
|
toxcore/events
|
||||||
|
toxencryptsave
|
||||||
|
)
|
||||||
|
|
||||||
|
copy_files() {
|
||||||
|
find "${DIRS[@]}" \
|
||||||
|
-maxdepth 1 -type d -exec mkdir -p "$1/{}" \;
|
||||||
|
find "${DIRS[@]}" \
|
||||||
|
-maxdepth 1 -name "*.c" -exec cp "{}" "$1/{}" \;
|
||||||
|
}
|
||||||
|
|
||||||
run() {
|
run() {
|
||||||
echo "Running clang-tidy in variant '$*'"
|
echo "Running clang-tidy in variant '$*'"
|
||||||
EXTRA_ARGS=("$@")
|
EXTRA_ARGS=("$@")
|
||||||
for i in "${!EXTRA_ARGS[@]}"; do
|
for i in "${!EXTRA_ARGS[@]}"; do
|
||||||
EXTRA_ARGS[$i]="--extra-arg=${EXTRA_ARGS[$i]}"
|
EXTRA_ARGS[$i]="--extra-arg=${EXTRA_ARGS[$i]}"
|
||||||
done
|
done
|
||||||
clang-tidy-14 \
|
ls .clang-tidy
|
||||||
-p=_build \
|
copy_files a
|
||||||
|
if ! find "${DIRS[@]}" \
|
||||||
|
-maxdepth 1 -name "*.c" -print0 \
|
||||||
|
| xargs -0 -n15 -P"$(nproc)" clang-tidy \
|
||||||
|
-p="$PWD/_build" \
|
||||||
--extra-arg=-DMIN_LOGGER_LEVEL=LOGGER_LEVEL_TRACE \
|
--extra-arg=-DMIN_LOGGER_LEVEL=LOGGER_LEVEL_TRACE \
|
||||||
"${EXTRA_ARGS[@]}" \
|
"${EXTRA_ARGS[@]}" \
|
||||||
|
--fix \
|
||||||
--checks="$CHECKS" \
|
--checks="$CHECKS" \
|
||||||
--warnings-as-errors="$ERRORS" \
|
--warnings-as-errors="$ERRORS" \
|
||||||
--use-color \
|
--use-color; then
|
||||||
other/bootstrap_daemon/src/*.c \
|
copy_files b
|
||||||
other/*.c \
|
colordiff -ru a b
|
||||||
toxav/*.c \
|
rm -rf a b
|
||||||
toxcore/*.c \
|
false
|
||||||
toxencryptsave/*.c
|
fi
|
||||||
|
rm -rf a
|
||||||
}
|
}
|
||||||
|
|
||||||
cmake . -B_build -GNinja -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
|
cmake . -B_build -GNinja -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
|
||||||
|
@@ -8,9 +8,12 @@ set -e
|
|||||||
|
|
||||||
CPPCHECK=("--enable=all")
|
CPPCHECK=("--enable=all")
|
||||||
CPPCHECK+=("--inconclusive")
|
CPPCHECK+=("--inconclusive")
|
||||||
|
CPPCHECK+=("--check-level=exhaustive")
|
||||||
|
CPPCHECK+=("--inline-suppr")
|
||||||
|
CPPCHECK+=("--library=other/docker/cppcheck/toxcore.cfg")
|
||||||
CPPCHECK+=("--error-exitcode=1")
|
CPPCHECK+=("--error-exitcode=1")
|
||||||
# Used for VLA.
|
# We don't cast function pointers, which cppcheck suggests here.
|
||||||
CPPCHECK+=("--suppress=allocaCalled")
|
CPPCHECK+=("--suppress=constParameterCallback")
|
||||||
# False positives in switch statements.
|
# False positives in switch statements.
|
||||||
CPPCHECK+=("--suppress=knownConditionTrueFalse")
|
CPPCHECK+=("--suppress=knownConditionTrueFalse")
|
||||||
# Cppcheck does not need standard library headers to get proper results.
|
# Cppcheck does not need standard library headers to get proper results.
|
||||||
@@ -19,27 +22,24 @@ CPPCHECK+=("--suppress=missingIncludeSystem")
|
|||||||
CPPCHECK+=("--suppress=signConversion")
|
CPPCHECK+=("--suppress=signConversion")
|
||||||
# TODO(iphydf): Fixed in the toxav refactor PR.
|
# TODO(iphydf): Fixed in the toxav refactor PR.
|
||||||
CPPCHECK+=("--suppress=redundantAssignment")
|
CPPCHECK+=("--suppress=redundantAssignment")
|
||||||
# We have some redundant nullptr checks in assertions
|
|
||||||
CPPCHECK+=("--suppress=nullPointerRedundantCheck")
|
|
||||||
# Triggers a false warning in group.c
|
|
||||||
CPPCHECK+=("--suppress=AssignmentAddressToInteger")
|
|
||||||
# TODO(sudden6): This triggers a false positive, check again later to enable it
|
|
||||||
CPPCHECK+=("--suppress=arrayIndexOutOfBoundsCond")
|
|
||||||
|
|
||||||
# We're a library. This only works on whole programs.
|
|
||||||
CPPCHECK_C=("--suppress=unusedFunction")
|
|
||||||
|
|
||||||
|
# We use this for VLAs.
|
||||||
|
CPPCHECK_CXX+=("--suppress=allocaCalled")
|
||||||
# False positive in auto_tests.
|
# False positive in auto_tests.
|
||||||
CPPCHECK_CXX+=("--suppress=shadowArgument")
|
|
||||||
CPPCHECK_CXX+=("--suppress=shadowFunction")
|
CPPCHECK_CXX+=("--suppress=shadowFunction")
|
||||||
# False positive for callback functions
|
# False positive in group.c.
|
||||||
CPPCHECK_CXX+=("--suppress=constParameter")
|
# Using cppcheck-suppress claims the suppression is unused.
|
||||||
|
CPPCHECK_CXX+=("--suppress=AssignmentAddressToInteger")
|
||||||
|
# We use C style casts because we write C code.
|
||||||
|
CPPCHECK_CXX+=("--suppress=cstyleCast")
|
||||||
# Used in Messenger.c for a static_assert(...)
|
# Used in Messenger.c for a static_assert(...)
|
||||||
CPPCHECK_CXX+=("--suppress=sizeofFunctionCall")
|
CPPCHECK_CXX+=("--suppress=sizeofFunctionCall")
|
||||||
|
# This is outdated. Range-for is a good choice.
|
||||||
|
CPPCHECK_CXX+=("--suppress=useStlAlgorithm")
|
||||||
|
|
||||||
run() {
|
run() {
|
||||||
echo "Running cppcheck in variant '$*'"
|
echo "Running cppcheck in variant '$*'"
|
||||||
cppcheck "${CPPCHECK[@]}" "${CPPCHECK_C[@]}" tox*/*.[ch] tox*/*/*.[ch] "${CPPFLAGS[@]}" "$@"
|
cppcheck -j8 "${CPPCHECK[@]}" "${CPPCHECK_C[@]}" tox*/*.[ch] tox*/*/*.[ch] "${CPPFLAGS[@]}" "$@"
|
||||||
cppcheck "${CPPCHECK[@]}" "${CPPCHECK_CXX[@]}" amalgamation.cc "${CPPFLAGS[@]}" "$@"
|
cppcheck "${CPPCHECK[@]}" "${CPPCHECK_CXX[@]}" amalgamation.cc "${CPPFLAGS[@]}" "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -11,7 +11,7 @@ run() {
|
|||||||
"${CPPFLAGS[@]}" \
|
"${CPPFLAGS[@]}" \
|
||||||
"${LDFLAGS[@]}" \
|
"${LDFLAGS[@]}" \
|
||||||
"$@" \
|
"$@" \
|
||||||
-std=c++11 \
|
-std=c++17 \
|
||||||
-fdiagnostics-color=always \
|
-fdiagnostics-color=always \
|
||||||
-Wall \
|
-Wall \
|
||||||
-Wextra \
|
-Wextra \
|
||||||
|
@@ -1,25 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
# --bufferoverrun \
|
|
||||||
# --pulse \
|
|
||||||
|
|
||||||
read -r -d '' SCRIPT <<'EOF'
|
|
||||||
infer \
|
|
||||||
--report-console-limit 100 \
|
|
||||||
--jobs 8 \
|
|
||||||
--biabduction \
|
|
||||||
--loop-hoisting \
|
|
||||||
--quandary \
|
|
||||||
--racerd \
|
|
||||||
--starvation \
|
|
||||||
--uninit \
|
|
||||||
-- clang++ -fsyntax-only \
|
|
||||||
$(pkg-config --cflags libconfig libsodium opus vpx) \
|
|
||||||
/work/other/bootstrap_daemon/src/*.c \
|
|
||||||
/work/other/bootstrap_node_packets.c \
|
|
||||||
/work/toxav/*.c \
|
|
||||||
/work/toxcore/*.c \
|
|
||||||
/work/toxencryptsave/*.c
|
|
||||||
EOF
|
|
||||||
|
|
||||||
docker run --rm -it -v "$PWD:/work" toxchat/infer bash -c "$SCRIPT"
|
|
@@ -16,7 +16,6 @@
|
|||||||
--align-reference=name
|
--align-reference=name
|
||||||
|
|
||||||
# Formatting Options
|
# Formatting Options
|
||||||
--add-brackets
|
|
||||||
--convert-tabs
|
--convert-tabs
|
||||||
--max-code-length=120
|
--max-code-length=120
|
||||||
|
|
||||||
|
@@ -18,7 +18,6 @@ cc_binary(
|
|||||||
"//c-toxcore/toxcore:mono_time",
|
"//c-toxcore/toxcore:mono_time",
|
||||||
"//c-toxcore/toxcore:onion_announce",
|
"//c-toxcore/toxcore:onion_announce",
|
||||||
"//c-toxcore/toxcore:tox",
|
"//c-toxcore/toxcore:tox",
|
||||||
"//c-toxcore/toxcore:util",
|
|
||||||
"@libconfig",
|
"@libconfig",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
@@ -19,6 +19,14 @@ add_executable(tox-bootstrapd
|
|||||||
src/tox-bootstrapd.c
|
src/tox-bootstrapd.c
|
||||||
../bootstrap_node_packets.c
|
../bootstrap_node_packets.c
|
||||||
../bootstrap_node_packets.h)
|
../bootstrap_node_packets.h)
|
||||||
target_link_modules(tox-bootstrapd toxcore ${LIBCONFIG_LIBRARIES})
|
target_link_libraries(tox-bootstrapd PRIVATE ${LIBCONFIG_LIBRARIES})
|
||||||
|
target_link_directories(tox-bootstrapd PRIVATE ${LIBCONFIG_LIBRARY_DIRS})
|
||||||
|
target_include_directories(tox-bootstrapd SYSTEM PRIVATE ${LIBCONFIG_INCLUDE_DIRS})
|
||||||
|
target_compile_options(tox-bootstrapd PRIVATE ${LIBCONFIG_CFLAGS_OTHER})
|
||||||
|
if(TARGET toxcore_static)
|
||||||
|
target_link_libraries(tox-bootstrapd PRIVATE toxcore_static)
|
||||||
|
else()
|
||||||
|
target_link_libraries(tox-bootstrapd PRIVATE toxcore_shared)
|
||||||
|
endif()
|
||||||
install(TARGETS tox-bootstrapd RUNTIME DESTINATION bin)
|
install(TARGETS tox-bootstrapd RUNTIME DESTINATION bin)
|
||||||
install(FILES bash-completion/completions/tox-bootstrapd DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/bash-completion/completions")
|
install(FILES bash-completion/completions/tox-bootstrapd DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/bash-completion/completions")
|
||||||
|
@@ -259,7 +259,7 @@ docker run -d --name tox-bootstrapd --restart always \
|
|||||||
toxchat/bootstrap-node
|
toxchat/bootstrap-node
|
||||||
```
|
```
|
||||||
|
|
||||||
We create a new user and protect its home directory in order to mount it in the Docker image, so that the kyepair the daemon uses would be stored on the host system, which makes it less likely that you would loose the keypair while playing with or updating the Docker container.
|
We create a new user and protect its home directory in order to mount it in the Docker image, so that the keypair the daemon uses would be stored on the host system, which makes it less likely that you would loose the keypair while playing with or updating the Docker container.
|
||||||
|
|
||||||
You can check logs for your public key or any errors:
|
You can check logs for your public key or any errors:
|
||||||
```sh
|
```sh
|
||||||
|
@@ -1,18 +1,18 @@
|
|||||||
###########################################################
|
###########################################################
|
||||||
# Builder image: we compile the code here (static build)
|
# Builder image: we compile the code here (static build)
|
||||||
FROM alpine:3.18.5 AS build
|
FROM alpine:3.19.0 AS build
|
||||||
|
|
||||||
RUN ["apk", "--no-cache", "add",\
|
RUN ["apk", "--no-cache", "add",\
|
||||||
"build-base",\
|
"clang",\
|
||||||
"cmake",\
|
"cmake",\
|
||||||
"linux-headers",\
|
"linux-headers",\
|
||||||
"libconfig-dev",\
|
"libconfig-dev",\
|
||||||
"libconfig-static",\
|
"libconfig-static",\
|
||||||
"libsodium-dev",\
|
"libsodium-dev",\
|
||||||
"libsodium-static",\
|
"libsodium-static",\
|
||||||
|
"musl-dev",\
|
||||||
"ninja",\
|
"ninja",\
|
||||||
"python3"\
|
"python3"]
|
||||||
]
|
|
||||||
|
|
||||||
WORKDIR /src/c-toxcore
|
WORKDIR /src/c-toxcore
|
||||||
|
|
||||||
@@ -34,9 +34,9 @@ COPY CMakeLists.txt so.version ./
|
|||||||
COPY other/bootstrap_daemon/CMakeLists.txt other/bootstrap_daemon/CMakeLists.txt
|
COPY other/bootstrap_daemon/CMakeLists.txt other/bootstrap_daemon/CMakeLists.txt
|
||||||
COPY testing/CMakeLists.txt testing/CMakeLists.txt
|
COPY testing/CMakeLists.txt testing/CMakeLists.txt
|
||||||
|
|
||||||
RUN cmake -B_build -H. \
|
RUN CC=clang cmake -B_build -H. \
|
||||||
-GNinja \
|
-GNinja \
|
||||||
-DCMAKE_C_FLAGS="-DTCP_SERVER_USE_EPOLL -fstack-protector-all -fisolate-erroneous-paths-attribute" \
|
-DCMAKE_C_FLAGS="-DTCP_SERVER_USE_EPOLL -fsanitize=alignment,return,returns-nonnull-attribute,vla-bound,unreachable,float-cast-overflow,null -fsanitize-trap=all -fstack-protector-all" \
|
||||||
-DCMAKE_UNITY_BUILD=ON \
|
-DCMAKE_UNITY_BUILD=ON \
|
||||||
-DCMAKE_BUILD_TYPE=Release \
|
-DCMAKE_BUILD_TYPE=Release \
|
||||||
-DFULLY_STATIC=ON \
|
-DFULLY_STATIC=ON \
|
||||||
@@ -48,8 +48,10 @@ RUN cmake -B_build -H. \
|
|||||||
# Verify checksum from dev-built binary, so we can be sure Docker Hub doesn't
|
# Verify checksum from dev-built binary, so we can be sure Docker Hub doesn't
|
||||||
# mess with your binaries.
|
# mess with your binaries.
|
||||||
COPY other/bootstrap_daemon/docker/tox-bootstrapd.sha256 other/bootstrap_daemon/docker/
|
COPY other/bootstrap_daemon/docker/tox-bootstrapd.sha256 other/bootstrap_daemon/docker/
|
||||||
RUN sha256sum /usr/local/bin/tox-bootstrapd && \
|
RUN SHA256="$(sha256sum /usr/local/bin/tox-bootstrapd)" && \
|
||||||
sha256sum -c other/bootstrap_daemon/docker/tox-bootstrapd.sha256
|
(sha256sum -c other/bootstrap_daemon/docker/tox-bootstrapd.sha256 || \
|
||||||
|
(echo "::error file=other/bootstrap_daemon/docker/tox-bootstrapd.sha256,line=1::$SHA256" && \
|
||||||
|
false))
|
||||||
|
|
||||||
# Remove all the example bootstrap nodes from the config file.
|
# Remove all the example bootstrap nodes from the config file.
|
||||||
COPY other/bootstrap_daemon/tox-bootstrapd.conf other/bootstrap_daemon/
|
COPY other/bootstrap_daemon/tox-bootstrapd.conf other/bootstrap_daemon/
|
||||||
|
46
external/toxcore/c-toxcore/other/bootstrap_daemon/docker/fetch-sha256
vendored
Executable file
46
external/toxcore/c-toxcore/other/bootstrap_daemon/docker/fetch-sha256
vendored
Executable file
@@ -0,0 +1,46 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
import pprint
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
import urllib.request
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
SHA256_FILE = "other/bootstrap_daemon/docker/tox-bootstrapd.sha256"
|
||||||
|
|
||||||
|
with open(f"{os.environ['HOME']}/.github-token") as fh:
|
||||||
|
token = fh.read().strip()
|
||||||
|
|
||||||
|
head_sha = (subprocess.run(["git", "rev-parse", "HEAD"],
|
||||||
|
capture_output=True,
|
||||||
|
check=True).stdout.decode("utf-8").strip())
|
||||||
|
|
||||||
|
|
||||||
|
def request(url: str) -> Any:
|
||||||
|
return json.loads(
|
||||||
|
urllib.request.urlopen(
|
||||||
|
urllib.request.Request(
|
||||||
|
url,
|
||||||
|
headers={
|
||||||
|
"Accept": "application/vnd.github+json",
|
||||||
|
"Authorization": "Bearer " + token,
|
||||||
|
"X-GitHub-Api-Version": "2022-11-28",
|
||||||
|
},
|
||||||
|
)).read())
|
||||||
|
|
||||||
|
|
||||||
|
pp = pprint.PrettyPrinter(indent=2, compact=True)
|
||||||
|
annots = [
|
||||||
|
a for r in request(
|
||||||
|
f"https://api.github.com/repos/TokTok/c-toxcore/commits/{head_sha}/check-runs?per_page=100"
|
||||||
|
)["check_runs"] if r["name"] == "docker-bootstrap-node"
|
||||||
|
for a in request(r["output"]["annotations_url"])
|
||||||
|
if a["path"] == SHA256_FILE
|
||||||
|
]
|
||||||
|
if not annots:
|
||||||
|
print("could not find sha256sum output")
|
||||||
|
sys.exit(1)
|
||||||
|
with open(SHA256_FILE, "w") as fh:
|
||||||
|
fh.write(annots[0]["message"] + "\n")
|
||||||
|
print(f"updated {SHA256_FILE}")
|
@@ -1 +1 @@
|
|||||||
5aac1df4d6c1de289e8e9f646d06099c84fd4d9b80d19f45e3254eec3ece2bff /usr/local/bin/tox-bootstrapd
|
0b904988d79b9576bb88c6c7316d107b5a61bd6119a0992ebd7c1fa43db70abf /usr/local/bin/tox-bootstrapd
|
||||||
|
@@ -24,17 +24,13 @@ tox_bootstrapd_SOURCES = \
|
|||||||
tox_bootstrapd_CFLAGS = \
|
tox_bootstrapd_CFLAGS = \
|
||||||
-I$(top_srcdir)/other/bootstrap_daemon \
|
-I$(top_srcdir)/other/bootstrap_daemon \
|
||||||
$(LIBSODIUM_CFLAGS) \
|
$(LIBSODIUM_CFLAGS) \
|
||||||
$(NACL_CFLAGS) \
|
|
||||||
$(LIBCONFIG_CFLAGS)
|
$(LIBCONFIG_CFLAGS)
|
||||||
|
|
||||||
tox_bootstrapd_LDADD = \
|
tox_bootstrapd_LDADD = \
|
||||||
$(LIBSODIUM_LDFLAGS) \
|
$(LIBSODIUM_LDFLAGS) \
|
||||||
$(NACL_LDFLAGS) \
|
|
||||||
libtoxcore.la \
|
libtoxcore.la \
|
||||||
$(LIBCONFIG_LIBS) \
|
$(LIBCONFIG_LIBS) \
|
||||||
$(LIBSODIUM_LIBS) \
|
$(LIBSODIUM_LIBS)
|
||||||
$(NACL_OBJECTS) \
|
|
||||||
$(NACL_LIBS)
|
|
||||||
|
|
||||||
bashcompdir = $(datarootdir)/bash-completion/completions
|
bashcompdir = $(datarootdir)/bash-completion/completions
|
||||||
dist_bashcomp_DATA = $(top_builddir)/other/bootstrap_daemon/bash-completion/completions/tox-bootstrapd
|
dist_bashcomp_DATA = $(top_builddir)/other/bootstrap_daemon/bash-completion/completions/tox-bootstrapd
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/* SPDX-License-Identifier: GPL-3.0-or-later
|
/* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
* Copyright © 2016-2018 The TokTok team.
|
* Copyright © 2016-2024 The TokTok team.
|
||||||
* Copyright © 2015-2016 Tox project.
|
* Copyright © 2015-2016 Tox project.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -10,12 +10,12 @@
|
|||||||
#include "command_line_arguments.h"
|
#include "command_line_arguments.h"
|
||||||
|
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
|
#include "log.h"
|
||||||
|
|
||||||
#include "../../../toxcore/ccompat.h"
|
#include "../../../toxcore/ccompat.h"
|
||||||
|
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
|
||||||
@@ -24,9 +24,9 @@
|
|||||||
*/
|
*/
|
||||||
static void print_help(void)
|
static void print_help(void)
|
||||||
{
|
{
|
||||||
// 2 space ident
|
// 2 space indent
|
||||||
// make sure all lines fit into 80 columns
|
// Make sure all lines fit into 80 columns
|
||||||
// make sure options are listed in alphabetical order
|
// Make sure options are listed in alphabetical order
|
||||||
log_write(LOG_LEVEL_INFO,
|
log_write(LOG_LEVEL_INFO,
|
||||||
"Usage: tox-bootstrapd [OPTION]... --config=FILE_PATH\n"
|
"Usage: tox-bootstrapd [OPTION]... --config=FILE_PATH\n"
|
||||||
"\n"
|
"\n"
|
||||||
@@ -39,7 +39,7 @@ static void print_help(void)
|
|||||||
" (detach from the terminal) and won't use the PID file.\n"
|
" (detach from the terminal) and won't use the PID file.\n"
|
||||||
" --help Print this help message.\n"
|
" --help Print this help message.\n"
|
||||||
" --log-backend=BACKEND Specify which logging backend to use.\n"
|
" --log-backend=BACKEND Specify which logging backend to use.\n"
|
||||||
" Valid BACKEND values (case sensetive):\n"
|
" Valid BACKEND values (case sensitive):\n"
|
||||||
" syslog Writes log messages to syslog.\n"
|
" syslog Writes log messages to syslog.\n"
|
||||||
" Default option when no --log-backend is\n"
|
" Default option when no --log-backend is\n"
|
||||||
" specified.\n"
|
" specified.\n"
|
||||||
@@ -47,13 +47,14 @@ static void print_help(void)
|
|||||||
" --version Print version information.\n");
|
" --version Print version information.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void handle_command_line_arguments(int argc, char *argv[], char **cfg_file_path, LOG_BACKEND *log_backend,
|
Cli_Status handle_command_line_arguments(
|
||||||
|
int argc, char *argv[], char **cfg_file_path, LOG_BACKEND *log_backend,
|
||||||
bool *run_in_foreground)
|
bool *run_in_foreground)
|
||||||
{
|
{
|
||||||
if (argc < 2) {
|
if (argc < 2) {
|
||||||
log_write(LOG_LEVEL_ERROR, "Error: No arguments provided.\n\n");
|
log_write(LOG_LEVEL_ERROR, "Error: No arguments provided.\n\n");
|
||||||
print_help();
|
print_help();
|
||||||
exit(1);
|
return CLI_STATUS_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
opterr = 0;
|
opterr = 0;
|
||||||
@@ -89,7 +90,7 @@ void handle_command_line_arguments(int argc, char *argv[], char **cfg_file_path,
|
|||||||
|
|
||||||
case 'h':
|
case 'h':
|
||||||
print_help();
|
print_help();
|
||||||
exit(0);
|
return CLI_STATUS_DONE;
|
||||||
|
|
||||||
case 'l':
|
case 'l':
|
||||||
if (strcmp(optarg, "syslog") == 0) {
|
if (strcmp(optarg, "syslog") == 0) {
|
||||||
@@ -101,24 +102,24 @@ void handle_command_line_arguments(int argc, char *argv[], char **cfg_file_path,
|
|||||||
} else {
|
} else {
|
||||||
log_write(LOG_LEVEL_ERROR, "Error: Invalid BACKEND value for --log-backend option passed: %s\n\n", optarg);
|
log_write(LOG_LEVEL_ERROR, "Error: Invalid BACKEND value for --log-backend option passed: %s\n\n", optarg);
|
||||||
print_help();
|
print_help();
|
||||||
exit(1);
|
return CLI_STATUS_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'v':
|
case 'v':
|
||||||
log_write(LOG_LEVEL_INFO, "Version: %lu\n", DAEMON_VERSION_NUMBER);
|
log_write(LOG_LEVEL_INFO, "Version: %lu\n", DAEMON_VERSION_NUMBER);
|
||||||
exit(0);
|
return CLI_STATUS_DONE;
|
||||||
|
|
||||||
case '?':
|
case '?':
|
||||||
log_write(LOG_LEVEL_ERROR, "Error: Unrecognized option %s\n\n", argv[optind - 1]);
|
log_write(LOG_LEVEL_ERROR, "Error: Unrecognized option %s\n\n", argv[optind - 1]);
|
||||||
print_help();
|
print_help();
|
||||||
exit(1);
|
return CLI_STATUS_ERROR;
|
||||||
|
|
||||||
case ':':
|
case ':':
|
||||||
log_write(LOG_LEVEL_ERROR, "Error: No argument provided for option %s\n\n", argv[optind - 1]);
|
log_write(LOG_LEVEL_ERROR, "Error: No argument provided for option %s\n\n", argv[optind - 1]);
|
||||||
print_help();
|
print_help();
|
||||||
exit(1);
|
return CLI_STATUS_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,6 +130,8 @@ void handle_command_line_arguments(int argc, char *argv[], char **cfg_file_path,
|
|||||||
if (!cfg_file_path_set) {
|
if (!cfg_file_path_set) {
|
||||||
log_write(LOG_LEVEL_ERROR, "Error: The required --config option wasn't specified\n\n");
|
log_write(LOG_LEVEL_ERROR, "Error: The required --config option wasn't specified\n\n");
|
||||||
print_help();
|
print_help();
|
||||||
exit(1);
|
return CLI_STATUS_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return CLI_STATUS_OK;
|
||||||
}
|
}
|
||||||
|
@@ -12,6 +12,15 @@
|
|||||||
|
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
|
||||||
|
typedef enum Cli_Status {
|
||||||
|
/** Continue the program. Command line processing completed. */
|
||||||
|
CLI_STATUS_OK,
|
||||||
|
/** Stop the program with success status. */
|
||||||
|
CLI_STATUS_DONE,
|
||||||
|
/** Stop the program with error status. */
|
||||||
|
CLI_STATUS_ERROR,
|
||||||
|
} Cli_Status;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles command line arguments, setting cfg_file_path and log_backend.
|
* Handles command line arguments, setting cfg_file_path and log_backend.
|
||||||
* Terminates the application if incorrect arguments are specified.
|
* Terminates the application if incorrect arguments are specified.
|
||||||
@@ -22,7 +31,8 @@
|
|||||||
* @param log_backend Sets to the provided by the user log backend option.
|
* @param log_backend Sets to the provided by the user log backend option.
|
||||||
* @param run_in_foreground Sets to the provided by the user foreground option.
|
* @param run_in_foreground Sets to the provided by the user foreground option.
|
||||||
*/
|
*/
|
||||||
void handle_command_line_arguments(int argc, char *argv[], char **cfg_file_path, LOG_BACKEND *log_backend,
|
Cli_Status handle_command_line_arguments(
|
||||||
|
int argc, char *argv[], char **cfg_file_path, LOG_BACKEND *log_backend,
|
||||||
bool *run_in_foreground);
|
bool *run_in_foreground);
|
||||||
|
|
||||||
#endif // C_TOXCORE_OTHER_BOOTSTRAP_DAEMON_SRC_COMMAND_LINE_ARGUMENTS_H
|
#endif // C_TOXCORE_OTHER_BOOTSTRAP_DAEMON_SRC_COMMAND_LINE_ARGUMENTS_H
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/* SPDX-License-Identifier: GPL-3.0-or-later
|
/* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
* Copyright © 2016-2023 The TokTok team.
|
* Copyright © 2016-2024 The TokTok team.
|
||||||
* Copyright © 2014-2016 Tox project.
|
* Copyright © 2014-2016 Tox project.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -10,6 +10,7 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include "config_defaults.h"
|
#include "config_defaults.h"
|
||||||
|
#include "global.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -18,6 +19,10 @@
|
|||||||
|
|
||||||
#include <libconfig.h>
|
#include <libconfig.h>
|
||||||
|
|
||||||
|
#include "../../../toxcore/DHT.h"
|
||||||
|
#include "../../../toxcore/ccompat.h"
|
||||||
|
#include "../../../toxcore/crypto_core.h"
|
||||||
|
#include "../../../toxcore/network.h"
|
||||||
#include "../../bootstrap_node_packets.h"
|
#include "../../bootstrap_node_packets.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -51,7 +56,7 @@ static void parse_tcp_relay_ports_config(config_t *cfg, uint16_t **tcp_relay_por
|
|||||||
log_write(LOG_LEVEL_INFO, "Port #%zu: %u\n", i, default_ports[i]);
|
log_write(LOG_LEVEL_INFO, "Port #%zu: %u\n", i, default_ports[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// similar procedure to the one of reading config file below
|
// Similar procedure to the one of reading config file below
|
||||||
*tcp_relay_ports = (uint16_t *)malloc(default_ports_count * sizeof(uint16_t));
|
*tcp_relay_ports = (uint16_t *)malloc(default_ports_count * sizeof(uint16_t));
|
||||||
|
|
||||||
for (size_t i = 0; i < default_ports_count; ++i) {
|
for (size_t i = 0; i < default_ports_count; ++i) {
|
||||||
@@ -68,7 +73,7 @@ static void parse_tcp_relay_ports_config(config_t *cfg, uint16_t **tcp_relay_por
|
|||||||
++*tcp_relay_port_count;
|
++*tcp_relay_port_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
// the loop above skips invalid ports, so we adjust the allocated memory size
|
// The loop above skips invalid ports, so we adjust the allocated memory size
|
||||||
if ((*tcp_relay_port_count) > 0) {
|
if ((*tcp_relay_port_count) > 0) {
|
||||||
*tcp_relay_ports = (uint16_t *)realloc(*tcp_relay_ports, (*tcp_relay_port_count) * sizeof(uint16_t));
|
*tcp_relay_ports = (uint16_t *)realloc(*tcp_relay_ports, (*tcp_relay_port_count) * sizeof(uint16_t));
|
||||||
} else {
|
} else {
|
||||||
@@ -98,7 +103,7 @@ static void parse_tcp_relay_ports_config(config_t *cfg, uint16_t **tcp_relay_por
|
|||||||
config_setting_t *elem = config_setting_get_elem(ports_array, i);
|
config_setting_t *elem = config_setting_get_elem(ports_array, i);
|
||||||
|
|
||||||
if (elem == nullptr) {
|
if (elem == nullptr) {
|
||||||
// it's NULL if `ports_array` is not an array (we have that check earlier) or if `i` is out of range, which should not be
|
// It's NULL if `ports_array` is not an array (we have that check earlier) or if `i` is out of range, which should not be
|
||||||
log_write(LOG_LEVEL_WARNING, "Port #%d: Something went wrong while parsing the port. Stopping reading ports.\n", i);
|
log_write(LOG_LEVEL_WARNING, "Port #%d: Something went wrong while parsing the port. Stopping reading ports.\n", i);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -120,7 +125,7 @@ static void parse_tcp_relay_ports_config(config_t *cfg, uint16_t **tcp_relay_por
|
|||||||
++*tcp_relay_port_count;
|
++*tcp_relay_port_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
// the loop above skips invalid ports, so we adjust the allocated memory size
|
// The loop above skips invalid ports, so we adjust the allocated memory size
|
||||||
if ((*tcp_relay_port_count) > 0) {
|
if ((*tcp_relay_port_count) > 0) {
|
||||||
*tcp_relay_ports = (uint16_t *)realloc(*tcp_relay_ports, (*tcp_relay_port_count) * sizeof(uint16_t));
|
*tcp_relay_ports = (uint16_t *)realloc(*tcp_relay_ports, (*tcp_relay_port_count) * sizeof(uint16_t));
|
||||||
} else {
|
} else {
|
||||||
@@ -260,7 +265,7 @@ int get_general_config(const char *cfg_file_path, char **pid_file_path, char **k
|
|||||||
|
|
||||||
log_write(LOG_LEVEL_INFO, "'%s': %s\n", NAME_ENABLE_TCP_RELAY, *enable_tcp_relay ? "true" : "false");
|
log_write(LOG_LEVEL_INFO, "'%s': %s\n", NAME_ENABLE_TCP_RELAY, *enable_tcp_relay ? "true" : "false");
|
||||||
|
|
||||||
// show info about tcp ports only if tcp relay is enabled
|
// Show info about tcp ports only if tcp relay is enabled
|
||||||
if (*enable_tcp_relay) {
|
if (*enable_tcp_relay) {
|
||||||
if (*tcp_relay_port_count == 0) {
|
if (*tcp_relay_port_count == 0) {
|
||||||
log_write(LOG_LEVEL_ERROR, "No TCP ports could be read.\n");
|
log_write(LOG_LEVEL_ERROR, "No TCP ports could be read.\n");
|
||||||
@@ -407,7 +412,7 @@ int bootstrap_from_config(const char *cfg_file_path, DHT *dht, int enable_ipv6)
|
|||||||
log_write(LOG_LEVEL_INFO, "Successfully added bootstrap node #%d: %s:%d %s\n", i, bs_address, bs_port, bs_public_key);
|
log_write(LOG_LEVEL_INFO, "Successfully added bootstrap node #%d: %s:%d %s\n", i, bs_address, bs_port, bs_public_key);
|
||||||
|
|
||||||
next:
|
next:
|
||||||
// config_setting_lookup_string() allocates string inside and doesn't allow us to free it direcly
|
// config_setting_lookup_string() allocates string inside and doesn't allow us to free it directly
|
||||||
// though it's freed when the element is removed, so we free it right away in order to keep memory
|
// though it's freed when the element is removed, so we free it right away in order to keep memory
|
||||||
// consumption minimal
|
// consumption minimal
|
||||||
config_setting_remove_elem(node_list, 0);
|
config_setting_remove_elem(node_list, 0);
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/* SPDX-License-Identifier: GPL-3.0-or-later
|
/* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
* Copyright © 2016-2018 The TokTok team.
|
* Copyright © 2016-2024 The TokTok team.
|
||||||
* Copyright © 2014-2016 Tox project.
|
* Copyright © 2014-2016 Tox project.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -30,7 +30,7 @@ int get_general_config(const char *cfg_file_path, char **pid_file_path, char **k
|
|||||||
* Bootstraps off nodes listed in the config file.
|
* Bootstraps off nodes listed in the config file.
|
||||||
*
|
*
|
||||||
* @return 1 on success, some or no bootstrap nodes were added
|
* @return 1 on success, some or no bootstrap nodes were added
|
||||||
* 0 on failure, a error accured while parsing config file.
|
* 0 on failure, an error occurred while parsing the config file.
|
||||||
*/
|
*/
|
||||||
int bootstrap_from_config(const char *cfg_file_path, DHT *dht, int enable_ipv6);
|
int bootstrap_from_config(const char *cfg_file_path, DHT *dht, int enable_ipv6);
|
||||||
|
|
||||||
|
@@ -3,6 +3,8 @@
|
|||||||
* Copyright © 2015-2016 Tox project.
|
* Copyright © 2015-2016 Tox project.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <stdarg.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Tox DHT bootstrap daemon.
|
* Tox DHT bootstrap daemon.
|
||||||
* Logging utility with support of multiple logging backends.
|
* Logging utility with support of multiple logging backends.
|
||||||
|
@@ -9,8 +9,11 @@
|
|||||||
*/
|
*/
|
||||||
#include "log_backend_stdout.h"
|
#include "log_backend_stdout.h"
|
||||||
|
|
||||||
|
#include <stdarg.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include "log.h"
|
||||||
|
|
||||||
static FILE *log_backend_stdout_level(LOG_LEVEL level)
|
static FILE *log_backend_stdout_level(LOG_LEVEL level)
|
||||||
{
|
{
|
||||||
switch (level) {
|
switch (level) {
|
||||||
|
@@ -10,10 +10,12 @@
|
|||||||
#include "log_backend_syslog.h"
|
#include "log_backend_syslog.h"
|
||||||
|
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
|
#include "log.h"
|
||||||
|
|
||||||
#include "../../../toxcore/ccompat.h"
|
#include "../../../toxcore/ccompat.h"
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <stdarg.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <syslog.h>
|
#include <syslog.h>
|
||||||
|
@@ -23,17 +23,24 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
// toxcore
|
// toxcore
|
||||||
#include "../../../toxcore/tox.h"
|
#include "../../../toxcore/DHT.h"
|
||||||
#include "../../../toxcore/LAN_discovery.h"
|
#include "../../../toxcore/LAN_discovery.h"
|
||||||
#include "../../../toxcore/TCP_server.h"
|
#include "../../../toxcore/TCP_server.h"
|
||||||
#include "../../../toxcore/announce.h"
|
#include "../../../toxcore/announce.h"
|
||||||
|
#include "../../../toxcore/ccompat.h"
|
||||||
|
#include "../../../toxcore/crypto_core.h"
|
||||||
|
#include "../../../toxcore/forwarding.h"
|
||||||
|
#include "../../../toxcore/group_announce.h"
|
||||||
#include "../../../toxcore/group_onion_announce.h"
|
#include "../../../toxcore/group_onion_announce.h"
|
||||||
#include "../../../toxcore/logger.h"
|
#include "../../../toxcore/logger.h"
|
||||||
|
#include "../../../toxcore/mem.h"
|
||||||
#include "../../../toxcore/mono_time.h"
|
#include "../../../toxcore/mono_time.h"
|
||||||
|
#include "../../../toxcore/network.h"
|
||||||
|
#include "../../../toxcore/onion.h"
|
||||||
#include "../../../toxcore/onion_announce.h"
|
#include "../../../toxcore/onion_announce.h"
|
||||||
#include "../../../toxcore/util.h"
|
|
||||||
|
|
||||||
// misc
|
// misc
|
||||||
#include "../../bootstrap_node_packets.h"
|
#include "../../bootstrap_node_packets.h"
|
||||||
@@ -57,7 +64,7 @@ static void sleep_milliseconds(uint32_t ms)
|
|||||||
// returns 1 on success
|
// returns 1 on success
|
||||||
// 0 on failure - no keys were read or stored
|
// 0 on failure - no keys were read or stored
|
||||||
|
|
||||||
static int manage_keys(DHT *dht, char *keys_file_path)
|
static int manage_keys(DHT *dht, const char *keys_file_path)
|
||||||
{
|
{
|
||||||
enum { KEYS_SIZE = CRYPTO_PUBLIC_KEY_SIZE + CRYPTO_SECRET_KEY_SIZE };
|
enum { KEYS_SIZE = CRYPTO_PUBLIC_KEY_SIZE + CRYPTO_SECRET_KEY_SIZE };
|
||||||
uint8_t keys[KEYS_SIZE];
|
uint8_t keys[KEYS_SIZE];
|
||||||
@@ -116,7 +123,7 @@ static void print_public_key(const uint8_t *public_key)
|
|||||||
// Demonizes the process, appending PID to the PID file and closing file descriptors based on log backend
|
// Demonizes the process, appending PID to the PID file and closing file descriptors based on log backend
|
||||||
// Terminates the application if the daemonization fails.
|
// Terminates the application if the daemonization fails.
|
||||||
|
|
||||||
static void daemonize(LOG_BACKEND log_backend, char *pid_file_path)
|
static Cli_Status daemonize(LOG_BACKEND log_backend, char *pid_file_path)
|
||||||
{
|
{
|
||||||
// Check if the PID file exists
|
// Check if the PID file exists
|
||||||
FILE *pid_file = fopen(pid_file_path, "r");
|
FILE *pid_file = fopen(pid_file_path, "r");
|
||||||
@@ -131,7 +138,7 @@ static void daemonize(LOG_BACKEND log_backend, char *pid_file_path)
|
|||||||
|
|
||||||
if (pid_file == nullptr) {
|
if (pid_file == nullptr) {
|
||||||
log_write(LOG_LEVEL_ERROR, "Couldn't open the PID file for writing: %s. Exiting.\n", pid_file_path);
|
log_write(LOG_LEVEL_ERROR, "Couldn't open the PID file for writing: %s. Exiting.\n", pid_file_path);
|
||||||
exit(1);
|
return CLI_STATUS_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fork off from the parent process
|
// Fork off from the parent process
|
||||||
@@ -141,27 +148,27 @@ static void daemonize(LOG_BACKEND log_backend, char *pid_file_path)
|
|||||||
fprintf(pid_file, "%d", pid);
|
fprintf(pid_file, "%d", pid);
|
||||||
fclose(pid_file);
|
fclose(pid_file);
|
||||||
log_write(LOG_LEVEL_INFO, "Forked successfully: PID: %d.\n", pid);
|
log_write(LOG_LEVEL_INFO, "Forked successfully: PID: %d.\n", pid);
|
||||||
exit(0);
|
return CLI_STATUS_DONE;
|
||||||
} else {
|
} else {
|
||||||
fclose(pid_file);
|
fclose(pid_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pid < 0) {
|
if (pid < 0) {
|
||||||
log_write(LOG_LEVEL_ERROR, "Forking failed. Exiting.\n");
|
log_write(LOG_LEVEL_ERROR, "Forking failed. Exiting.\n");
|
||||||
exit(1);
|
return CLI_STATUS_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a new SID for the child process
|
// Create a new SID for the child process
|
||||||
if (setsid() < 0) {
|
if (setsid() < 0) {
|
||||||
log_write(LOG_LEVEL_ERROR, "SID creation failure. Exiting.\n");
|
log_write(LOG_LEVEL_ERROR, "SID creation failure. Exiting.\n");
|
||||||
exit(1);
|
return CLI_STATUS_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Change the current working directory
|
// Change the current working directory
|
||||||
if ((chdir("/")) < 0) {
|
if ((chdir("/")) < 0) {
|
||||||
log_write(LOG_LEVEL_ERROR, "Couldn't change working directory to '/'. Exiting.\n");
|
log_write(LOG_LEVEL_ERROR, "Couldn't change working directory to '/'. Exiting.\n");
|
||||||
exit(1);
|
return CLI_STATUS_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Go quiet
|
// Go quiet
|
||||||
@@ -170,6 +177,8 @@ static void daemonize(LOG_BACKEND log_backend, char *pid_file_path)
|
|||||||
close(STDIN_FILENO);
|
close(STDIN_FILENO);
|
||||||
close(STDERR_FILENO);
|
close(STDERR_FILENO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return CLI_STATUS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Logs toxcore logger message using our logger facility
|
// Logs toxcore logger message using our logger facility
|
||||||
@@ -212,11 +221,18 @@ int main(int argc, char *argv[])
|
|||||||
char *cfg_file_path = nullptr;
|
char *cfg_file_path = nullptr;
|
||||||
bool run_in_foreground = false;
|
bool run_in_foreground = false;
|
||||||
|
|
||||||
// choose backend for printing command line argument parsing output based on whether the daemon is being run from a terminal
|
// Choose backend for printing command line argument parsing output based on whether the daemon is being run from a terminal
|
||||||
LOG_BACKEND log_backend = isatty(STDOUT_FILENO) ? LOG_BACKEND_STDOUT : LOG_BACKEND_SYSLOG;
|
LOG_BACKEND log_backend = isatty(STDOUT_FILENO) ? LOG_BACKEND_STDOUT : LOG_BACKEND_SYSLOG;
|
||||||
|
|
||||||
log_open(log_backend);
|
log_open(log_backend);
|
||||||
handle_command_line_arguments(argc, argv, &cfg_file_path, &log_backend, &run_in_foreground);
|
switch (handle_command_line_arguments(argc, argv, &cfg_file_path, &log_backend, &run_in_foreground)) {
|
||||||
|
case CLI_STATUS_OK:
|
||||||
|
break;
|
||||||
|
case CLI_STATUS_DONE:
|
||||||
|
return 0;
|
||||||
|
case CLI_STATUS_ERROR:
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
log_close();
|
log_close();
|
||||||
|
|
||||||
log_open(log_backend);
|
log_open(log_backend);
|
||||||
@@ -254,7 +270,14 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!run_in_foreground) {
|
if (!run_in_foreground) {
|
||||||
daemonize(log_backend, pid_file_path);
|
switch (daemonize(log_backend, pid_file_path)) {
|
||||||
|
case CLI_STATUS_OK:
|
||||||
|
break;
|
||||||
|
case CLI_STATUS_DONE:
|
||||||
|
return 0;
|
||||||
|
case CLI_STATUS_ERROR:
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
free(pid_file_path);
|
free(pid_file_path);
|
||||||
|
@@ -12,6 +12,8 @@
|
|||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "../toxcore/network.h"
|
||||||
|
|
||||||
#define INFO_REQUEST_PACKET_LENGTH 78
|
#define INFO_REQUEST_PACKET_LENGTH 78
|
||||||
|
|
||||||
static uint32_t bootstrap_version;
|
static uint32_t bootstrap_version;
|
||||||
|
@@ -1,6 +1,28 @@
|
|||||||
################################################
|
################################################
|
||||||
# autotools-linux
|
# autotools-linux
|
||||||
FROM toxchat/nacl:latest
|
FROM ubuntu:22.04
|
||||||
|
|
||||||
|
RUN apt-get update && \
|
||||||
|
DEBIAN_FRONTEND="noninteractive" apt-get install -y --no-install-recommends \
|
||||||
|
autoconf \
|
||||||
|
automake \
|
||||||
|
ca-certificates \
|
||||||
|
curl \
|
||||||
|
libconfig-dev \
|
||||||
|
libopus-dev \
|
||||||
|
libsodium-dev \
|
||||||
|
libtool \
|
||||||
|
libvpx-dev \
|
||||||
|
make \
|
||||||
|
pkg-config \
|
||||||
|
&& apt-get clean \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
RUN groupadd -r -g 1000 builder \
|
||||||
|
&& useradd -m --no-log-init -r -g builder -u 1000 builder
|
||||||
|
USER builder
|
||||||
|
|
||||||
|
WORKDIR /home/builder
|
||||||
|
|
||||||
# Copy the sources and run the build.
|
# Copy the sources and run the build.
|
||||||
COPY --chown=builder:builder . /home/builder/c-toxcore/
|
COPY --chown=builder:builder . /home/builder/c-toxcore/
|
||||||
|
@@ -7,6 +7,7 @@ RUN apt-get update && \
|
|||||||
clang \
|
clang \
|
||||||
cmake \
|
cmake \
|
||||||
libconfig-dev \
|
libconfig-dev \
|
||||||
|
libgmock-dev \
|
||||||
libgtest-dev \
|
libgtest-dev \
|
||||||
libopus-dev \
|
libopus-dev \
|
||||||
libsodium-dev \
|
libsodium-dev \
|
||||||
|
21
external/toxcore/c-toxcore/other/docker/clang-tidy/Dockerfile
vendored
Normal file
21
external/toxcore/c-toxcore/other/docker/clang-tidy/Dockerfile
vendored
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
FROM alpine:3.19.0
|
||||||
|
|
||||||
|
RUN ["apk", "add", "--no-cache", \
|
||||||
|
"bash", \
|
||||||
|
"clang", \
|
||||||
|
"clang-extra-tools", \
|
||||||
|
"cmake", \
|
||||||
|
"colordiff", \
|
||||||
|
"libconfig-dev", \
|
||||||
|
"libsodium-dev", \
|
||||||
|
"libvpx-dev", \
|
||||||
|
"linux-headers", \
|
||||||
|
"opus-dev", \
|
||||||
|
"pkgconfig", \
|
||||||
|
"samurai"]
|
||||||
|
|
||||||
|
ENV CC=clang CXX=clang++
|
||||||
|
|
||||||
|
COPY . /c-toxcore/
|
||||||
|
WORKDIR /c-toxcore
|
||||||
|
RUN other/analysis/run-clang-tidy
|
5
external/toxcore/c-toxcore/other/docker/clang-tidy/run
vendored
Executable file
5
external/toxcore/c-toxcore/other/docker/clang-tidy/run
vendored
Executable file
@@ -0,0 +1,5 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -eux
|
||||||
|
BUILD=clang-tidy
|
||||||
|
docker build -t "toxchat/c-toxcore:$BUILD" -f "other/docker/$BUILD/Dockerfile" .
|
@@ -1,79 +1,85 @@
|
|||||||
FROM toxchat/c-toxcore:sources AS src
|
FROM toxchat/c-toxcore:sources AS src
|
||||||
FROM ubuntu:22.04 AS build
|
FROM ubuntu:20.04 AS build
|
||||||
|
|
||||||
|
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
|
||||||
|
|
||||||
RUN apt-get update && \
|
RUN apt-get update && \
|
||||||
DEBIAN_FRONTEND="noninteractive" apt-get install -y --no-install-recommends \
|
DEBIAN_FRONTEND="noninteractive" apt-get install -y --no-install-recommends \
|
||||||
clang \
|
ca-certificates \
|
||||||
|
curl \
|
||||||
|
&& apt-get clean \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
RUN echo "deb http://apt.llvm.org/focal/ llvm-toolchain-focal-17 main" >> /etc/apt/sources.list \
|
||||||
|
&& curl -L https://apt.llvm.org/llvm-snapshot.gpg.key | tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc \
|
||||||
|
&& apt-get update && \
|
||||||
|
DEBIAN_FRONTEND="noninteractive" apt-get install -y --no-install-recommends \
|
||||||
|
clang-17 \
|
||||||
cmake \
|
cmake \
|
||||||
gcc \
|
|
||||||
git \
|
git \
|
||||||
golang \
|
golang-1.18 \
|
||||||
|
libclang-rt-17-dev \
|
||||||
libconfig-dev \
|
libconfig-dev \
|
||||||
|
libgmock-dev \
|
||||||
libgtest-dev \
|
libgtest-dev \
|
||||||
libopus-dev \
|
libopus-dev \
|
||||||
libsodium-dev \
|
libsodium-dev \
|
||||||
|
libunwind-17-dev \
|
||||||
libvpx-dev \
|
libvpx-dev \
|
||||||
llvm-dev \
|
lld-17 \
|
||||||
|
llvm-17-dev \
|
||||||
make \
|
make \
|
||||||
ninja-build \
|
ninja-build \
|
||||||
pkg-config \
|
pkg-config \
|
||||||
python3-pip \
|
|
||||||
python3-pygments \
|
|
||||||
&& apt-get clean \
|
&& apt-get clean \
|
||||||
&& rm -rf /var/lib/apt/lists/* \
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
&& pip3 install --no-cache-dir gcovr
|
RUN ["curl", "-s", "https://codecov.io/bash", "-o", "/usr/local/bin/codecov"]
|
||||||
|
RUN ["chmod", "+x", "/usr/local/bin/codecov"]
|
||||||
|
|
||||||
ENV CC=clang \
|
ENV CC=clang-17 \
|
||||||
CXX=clang++ \
|
CXX=clang++-17 \
|
||||||
PYTHONUNBUFFERED=1
|
PYTHONUNBUFFERED=1 \
|
||||||
SHELL ["/bin/bash", "-c"]
|
PATH=$PATH:/usr/lib/go-1.18/bin
|
||||||
|
|
||||||
|
COPY --from=src /src/ /work/
|
||||||
|
|
||||||
WORKDIR /work
|
WORKDIR /work
|
||||||
COPY --from=src /src/ /work/
|
RUN git clone --depth=1 https://github.com/TokTok/toktok-fuzzer /work/testing/fuzzing/toktok-fuzzer
|
||||||
RUN source .github/scripts/flags-coverage.sh \
|
RUN source .github/scripts/flags-coverage.sh \
|
||||||
&& go version \
|
&& go version \
|
||||||
&& (cd other/proxy && go get github.com/things-go/go-socks5 && go build proxy_server.go) \
|
&& (cd other/proxy && go get github.com/things-go/go-socks5 && go build proxy_server.go) \
|
||||||
&& cmake -B_build -H. -GNinja \
|
&& cmake -B_build -H. -GNinja \
|
||||||
-DCMAKE_C_FLAGS="$C_FLAGS" \
|
-DCMAKE_C_FLAGS="$C_FLAGS" \
|
||||||
-DCMAKE_CXX_FLAGS="$CXX_FLAGS" \
|
-DCMAKE_CXX_FLAGS="$CXX_FLAGS" \
|
||||||
-DCMAKE_EXE_LINKER_FLAGS="$LD_FLAGS" \
|
-DCMAKE_EXE_LINKER_FLAGS="$LD_FLAGS -fuse-ld=lld" \
|
||||||
-DCMAKE_UNITY_BUILD=ON \
|
-DCMAKE_UNITY_BUILD=ON \
|
||||||
-DENABLE_SHARED=OFF \
|
-DENABLE_SHARED=OFF \
|
||||||
-DMIN_LOGGER_LEVEL=TRACE \
|
-DMIN_LOGGER_LEVEL=TRACE \
|
||||||
-DMUST_BUILD_TOXAV=ON \
|
-DMUST_BUILD_TOXAV=ON \
|
||||||
-DNON_HERMETIC_TESTS=ON \
|
-DNON_HERMETIC_TESTS=OFF \
|
||||||
-DSTRICT_ABI=ON \
|
-DSTRICT_ABI=ON \
|
||||||
-DAUTOTEST=ON \
|
-DAUTOTEST=ON \
|
||||||
-DPROXY_TEST=ON \
|
-DPROXY_TEST=ON \
|
||||||
|
-DBUILD_FUZZ_TESTS=ON \
|
||||||
-DUSE_IPV6=OFF \
|
-DUSE_IPV6=OFF \
|
||||||
-DTEST_TIMEOUT_SECONDS=30 \
|
-DTEST_TIMEOUT_SECONDS=40 \
|
||||||
&& cmake --build _build --parallel 8 --target install
|
&& cmake --build _build --parallel 8 --target install
|
||||||
|
|
||||||
WORKDIR /work/_build
|
WORKDIR /work/_build
|
||||||
RUN /work/proxy_server \
|
RUN /work/other/proxy/proxy_server \
|
||||||
& ctest -j50 --output-on-failure --rerun-failed --repeat until-pass:6
|
& (ctest -j50 --output-on-failure --rerun-failed --repeat until-pass:6 || \
|
||||||
|
ctest -j50 --output-on-failure --rerun-failed --repeat until-pass:6)
|
||||||
|
|
||||||
WORKDIR /work/mallocfail
|
WORKDIR /work/mallocfail
|
||||||
RUN ["git", "clone", "--depth=1", "https://github.com/ralight/mallocfail", "/work/mallocfail"]
|
RUN ["git", "clone", "--depth=1", "https://github.com/TokTok/mallocfail", "/work/mallocfail"]
|
||||||
COPY run_mallocfail /usr/local/bin/
|
RUN clang-17 -fuse-ld=lld -fPIC -shared -O2 -g3 -Wall -I/usr/lib/llvm-17/include -L/usr/lib/llvm-17/lib -Ideps/uthash -Ideps/sha3 deps/*/*.c src/*.c -o mallocfail.so -ldl -lunwind \
|
||||||
COPY syscall_funcs.c src/
|
|
||||||
RUN gcc -fPIC -shared -O2 -g3 -Wall -Ideps/uthash -Ideps/sha3 deps/*/*.c src/*.c -o mallocfail.so -ldl -lbacktrace \
|
|
||||||
&& install mallocfail.so /usr/local/lib/mallocfail.so
|
&& install mallocfail.so /usr/local/lib/mallocfail.so
|
||||||
|
|
||||||
WORKDIR /work/_build
|
WORKDIR /work/_build
|
||||||
RUN ["run_mallocfail", "--ctest=2", "--jobs=8"]
|
COPY other/docker/coverage/run_mallocfail /usr/local/bin/
|
||||||
RUN ["gcovr", \
|
RUN ["run_mallocfail", "--ctest=1", "--jobs=8"]
|
||||||
"--sort-percentage", \
|
RUN llvm-profdata-17 merge -sparse $(find . -name "*.profraw") -o toxcore.profdata
|
||||||
"--gcov-executable=llvm-cov gcov", \
|
RUN llvm-cov-17 show -format=text -instr-profile=toxcore.profdata -sources $(cmake --build . --target help | grep -o '[^:]*_test:' | grep -o '[^:]*' | xargs -n1 find . -type f -name | awk '{print "-object "$1}') > coverage.txt
|
||||||
"--html-details=html/", \
|
RUN llvm-cov-17 show -format=html -instr-profile=toxcore.profdata -sources $(cmake --build . --target help | grep -o '[^:]*_test:' | grep -o '[^:]*' | xargs -n1 find . -type f -name | awk '{print "-object "$1}') -output-dir=html
|
||||||
"--root=..", \
|
|
||||||
"--exclude=CMakeFiles/", \
|
|
||||||
"--exclude=_deps/", \
|
|
||||||
"--exclude=(.+/)?auto_tests/", \
|
|
||||||
"--exclude=.+_test.cc?$", \
|
|
||||||
"--exclude=(.+/)?other/", \
|
|
||||||
"--exclude=(.+/)?testing/"]
|
|
||||||
|
|
||||||
FROM nginx:alpine
|
WORKDIR /work
|
||||||
COPY --from=build /work/_build/html/coverage_details.html /usr/share/nginx/html/index.html
|
|
||||||
COPY --from=build /work/_build/html/ /usr/share/nginx/html/
|
|
||||||
|
4
external/toxcore/c-toxcore/other/docker/coverage/Dockerfile.nginx
vendored
Normal file
4
external/toxcore/c-toxcore/other/docker/coverage/Dockerfile.nginx
vendored
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
# vim:ft=dockerfile
|
||||||
|
FROM toxchat/c-toxcore:coverage AS build
|
||||||
|
FROM nginx:alpine
|
||||||
|
COPY --from=build --chown=nginx:nginx /work/_build/html/ /usr/share/nginx/html/
|
@@ -1,7 +1,9 @@
|
|||||||
#!/bin/sh
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
set -eux
|
set -eux
|
||||||
|
|
||||||
|
read -a ci_env <<<"$(bash <(curl -s https://codecov.io/env))"
|
||||||
|
|
||||||
docker build -t toxchat/c-toxcore:sources -f other/docker/sources/Dockerfile .
|
docker build -t toxchat/c-toxcore:sources -f other/docker/sources/Dockerfile .
|
||||||
docker build -t toxchat/c-toxcore:coverage other/docker/coverage
|
docker build -t toxchat/c-toxcore:coverage -f other/docker/coverage/Dockerfile .
|
||||||
docker run --name toxcore-coverage --rm -it -p "28192:80" toxchat/c-toxcore:coverage
|
docker run "${ci_env[@]}" -e CI=true --name toxcore-coverage --rm -t toxchat/c-toxcore:coverage /usr/local/bin/codecov
|
||||||
|
@@ -27,11 +27,12 @@ from typing import NoReturn
|
|||||||
from typing import Optional
|
from typing import Optional
|
||||||
from typing import Tuple
|
from typing import Tuple
|
||||||
|
|
||||||
_PRIMER = "./unit_util_test"
|
_PRIMER = "auto_tests/auto_version_test"
|
||||||
_MALLOCFAIL_SO = "/usr/local/lib/mallocfail.so"
|
_MALLOCFAIL_SO = "/usr/local/lib/mallocfail.so"
|
||||||
_HASHES = "mallocfail_hashes"
|
_HASHES = "mallocfail_hashes"
|
||||||
_HASHES_PREV = "mallocfail_hashes.prev"
|
_HASHES_PREV = "mallocfail_hashes.prev"
|
||||||
_TIMEOUT = 3.0
|
_TIMEOUT = 3.0
|
||||||
|
_BUILD_DIR = os.getcwd()
|
||||||
|
|
||||||
_ENV = {
|
_ENV = {
|
||||||
"LD_PRELOAD": _MALLOCFAIL_SO,
|
"LD_PRELOAD": _MALLOCFAIL_SO,
|
||||||
@@ -39,16 +40,25 @@ _ENV = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def run_mallocfail(tmpdir: str, timeout: float, exe: str,
|
def run_mallocfail(tmpdir: str, timeout: float, exe: str, iteration: int,
|
||||||
iteration: int) -> bool:
|
keep_going: bool) -> bool:
|
||||||
"""Run a program with mallocfail."""
|
"""Run a program with mallocfail."""
|
||||||
print(f"\x1b[1;33mmallocfail '{exe}' run #{iteration}\x1b[0m")
|
print(f"\x1b[1;33mmallocfail '{exe}' run #{iteration}\x1b[0m")
|
||||||
hashes = os.path.join(tmpdir, _HASHES)
|
hashes = os.path.join(tmpdir, _HASHES)
|
||||||
hashes_prev = os.path.join(tmpdir, _HASHES_PREV)
|
hashes_prev = os.path.join(tmpdir, _HASHES_PREV)
|
||||||
|
profraw = os.path.join(_BUILD_DIR, "mallocfail.out", exe, "%p.profraw")
|
||||||
if os.path.exists(hashes):
|
if os.path.exists(hashes):
|
||||||
shutil.copy(hashes, hashes_prev)
|
shutil.copy(hashes, hashes_prev)
|
||||||
try:
|
try:
|
||||||
proc = subprocess.run([exe], timeout=timeout, env=_ENV, cwd=tmpdir)
|
proc = subprocess.run(
|
||||||
|
[exe],
|
||||||
|
timeout=timeout,
|
||||||
|
env={
|
||||||
|
"LLVM_PROFILE_FILE": profraw,
|
||||||
|
**_ENV,
|
||||||
|
},
|
||||||
|
cwd=tmpdir,
|
||||||
|
)
|
||||||
except subprocess.TimeoutExpired:
|
except subprocess.TimeoutExpired:
|
||||||
print(f"\x1b[1;34mProgram {exe} timed out\x1b[0m")
|
print(f"\x1b[1;34mProgram {exe} timed out\x1b[0m")
|
||||||
return True
|
return True
|
||||||
@@ -65,14 +75,18 @@ def run_mallocfail(tmpdir: str, timeout: float, exe: str,
|
|||||||
# Process exited cleanly (success or failure).
|
# Process exited cleanly (success or failure).
|
||||||
pass
|
pass
|
||||||
elif proc.returncode == -6:
|
elif proc.returncode == -6:
|
||||||
# Assertion failed.
|
# abort(), we allow it.
|
||||||
|
pass
|
||||||
|
elif proc.returncode == 7:
|
||||||
|
# ck_assert failed, also fine for us.
|
||||||
pass
|
pass
|
||||||
elif proc.returncode == -14:
|
elif proc.returncode == -14:
|
||||||
print(f"\x1b[0;34mProgram '{exe}' timed out\x1b[0m")
|
print(f"\x1b[0;34mProgram '{exe}' timed out\x1b[0m")
|
||||||
else:
|
else:
|
||||||
print(
|
print(
|
||||||
f"\x1b[1;32mProgram '{exe}' failed to handle OOM situation cleanly\x1b[0m"
|
f"\x1b[1;32mProgram '{exe}' failed to handle OOM situation cleanly (code {proc.returncode})\x1b[0m"
|
||||||
)
|
)
|
||||||
|
if not keep_going:
|
||||||
raise Exception("Aborting test")
|
raise Exception("Aborting test")
|
||||||
|
|
||||||
return True
|
return True
|
||||||
@@ -95,7 +109,8 @@ def find_prog(name: str) -> Tuple[Optional[str], ...]:
|
|||||||
return path
|
return path
|
||||||
return None
|
return None
|
||||||
|
|
||||||
return (attempt(f"./unit_{name}_test"), attempt(f"./auto_{name}_test"))
|
return (attempt(f"auto_tests/auto_{name}_test"),
|
||||||
|
) # attempt(f"./unit_{name}_test"),
|
||||||
|
|
||||||
|
|
||||||
def parse_flags(args: List[str]) -> Tuple[Dict[str, str], List[str]]:
|
def parse_flags(args: List[str]) -> Tuple[Dict[str, str], List[str]]:
|
||||||
@@ -110,18 +125,25 @@ def parse_flags(args: List[str]) -> Tuple[Dict[str, str], List[str]]:
|
|||||||
return flags, exes
|
return flags, exes
|
||||||
|
|
||||||
|
|
||||||
def loop_mallocfail(tmpdir: str, timeout: float, exe: str) -> None:
|
def loop_mallocfail(tmpdir: str,
|
||||||
|
timeout: float,
|
||||||
|
exe: str,
|
||||||
|
keep_going: bool = False) -> None:
|
||||||
i = 1
|
i = 1
|
||||||
while run_mallocfail(tmpdir, timeout, exe, i):
|
while run_mallocfail(tmpdir, timeout, exe, i, keep_going):
|
||||||
i += 1
|
i += 1
|
||||||
|
|
||||||
|
|
||||||
def isolated_mallocfail(timeout: int, exe: str) -> None:
|
def isolated_mallocfail(timeout: int, exe: str) -> None:
|
||||||
with tempfile.TemporaryDirectory(prefix="mallocfail") as tmpdir:
|
with tempfile.TemporaryDirectory(prefix="mallocfail") as tmpdir:
|
||||||
print(f"\x1b[1;33mRunning for {exe} in isolated path {tmpdir}\x1b[0m")
|
print(f"\x1b[1;33mRunning for {exe} in isolated path {tmpdir}\x1b[0m")
|
||||||
|
os.mkdir(os.path.join(tmpdir, "auto_tests"))
|
||||||
shutil.copy(exe, os.path.join(tmpdir, exe))
|
shutil.copy(exe, os.path.join(tmpdir, exe))
|
||||||
shutil.copy(_HASHES, os.path.join(tmpdir, _HASHES))
|
shutil.copy(_HASHES, os.path.join(tmpdir, _HASHES))
|
||||||
loop_mallocfail(tmpdir, timeout, exe)
|
loop_mallocfail(tmpdir, timeout, exe)
|
||||||
|
profraw = os.path.join(tmpdir, "default.profraw")
|
||||||
|
if os.path.exists(profraw):
|
||||||
|
shutil.copy(profraw, exe + ".mallocfail.profraw")
|
||||||
|
|
||||||
|
|
||||||
def main(args: List[str]) -> None:
|
def main(args: List[str]) -> None:
|
||||||
@@ -144,12 +166,12 @@ def main(args: List[str]) -> None:
|
|||||||
else:
|
else:
|
||||||
jobs = 1
|
jobs = 1
|
||||||
|
|
||||||
# Start by running util_test, which allocates no memory of its own, just
|
# Start by running version_test, which allocates no memory of its own, just
|
||||||
# to prime the mallocfail hashes so it doesn't make global initialisers
|
# to prime the mallocfail hashes so it doesn't make global initialisers
|
||||||
# such as llvm_gcov_init fail.
|
# such as llvm_gcov_init fail.
|
||||||
if os.path.exists(_PRIMER):
|
if os.path.exists(_PRIMER):
|
||||||
print(f"\x1b[1;33mPriming hashes with unit_util_test\x1b[0m")
|
print(f"\x1b[1;33mPriming hashes with {_PRIMER}\x1b[0m")
|
||||||
loop_mallocfail(".", timeout, _PRIMER)
|
loop_mallocfail(os.getcwd(), timeout, _PRIMER, keep_going=True)
|
||||||
|
|
||||||
print(f"\x1b[1;33m--------------------------------\x1b[0m")
|
print(f"\x1b[1;33m--------------------------------\x1b[0m")
|
||||||
print(f"\x1b[1;33mStarting mallocfail for {len(exes)} programs:\x1b[0m")
|
print(f"\x1b[1;33mStarting mallocfail for {len(exes)} programs:\x1b[0m")
|
||||||
|
8
external/toxcore/c-toxcore/other/docker/coverage/serve
vendored
Executable file
8
external/toxcore/c-toxcore/other/docker/coverage/serve
vendored
Executable file
@@ -0,0 +1,8 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -eux
|
||||||
|
|
||||||
|
docker build -t toxchat/c-toxcore:sources -f other/docker/sources/Dockerfile .
|
||||||
|
docker build -t toxchat/c-toxcore:coverage -f other/docker/coverage/Dockerfile .
|
||||||
|
docker build -t toxchat/c-toxcore:coverage-nginx -f other/docker/coverage/Dockerfile.nginx other/docker/coverage
|
||||||
|
docker run --name toxcore-coverage --rm -it -p "28192:80" toxchat/c-toxcore:coverage-nginx
|
@@ -1,149 +0,0 @@
|
|||||||
#define _GNU_SOURCE
|
|
||||||
|
|
||||||
#include "mallocfail.h"
|
|
||||||
|
|
||||||
#include <dlfcn.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdarg.h>
|
|
||||||
#include <sys/ioctl.h>
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
|
|
||||||
static int (*libc_ioctl)(int fd, unsigned long request, ...);
|
|
||||||
static int (*libc_bind)(int sockfd, const struct sockaddr *addr,
|
|
||||||
socklen_t addrlen);
|
|
||||||
static int (*libc_getsockopt)(int sockfd, int level, int optname,
|
|
||||||
void *optval, socklen_t *optlen);
|
|
||||||
static int (*libc_setsockopt)(int sockfd, int level, int optname,
|
|
||||||
const void *optval, socklen_t optlen);
|
|
||||||
static ssize_t (*libc_recv)(int sockfd, void *buf, size_t len, int flags);
|
|
||||||
static ssize_t (*libc_recvfrom)(int sockfd, void *buf, size_t len, int flags,
|
|
||||||
struct sockaddr *src_addr, socklen_t *addrlen);
|
|
||||||
static ssize_t (*libc_send)(int sockfd, const void *buf, size_t len, int flags);
|
|
||||||
static ssize_t(*libc_sendto)(int sockfd, const void *buf, size_t len, int flags,
|
|
||||||
const struct sockaddr *dest_addr, socklen_t addrlen);
|
|
||||||
static int (*libc_socket)(int domain, int type, int protocol);
|
|
||||||
static int (*libc_listen)(int sockfd, int backlog);
|
|
||||||
|
|
||||||
__attribute__((__constructor__))
|
|
||||||
static void init(void)
|
|
||||||
{
|
|
||||||
libc_ioctl = dlsym(RTLD_NEXT, "ioctl");
|
|
||||||
libc_bind = dlsym(RTLD_NEXT, "bind");
|
|
||||||
libc_getsockopt = dlsym(RTLD_NEXT, "getsockopt");
|
|
||||||
libc_setsockopt = dlsym(RTLD_NEXT, "setsockopt");
|
|
||||||
libc_recv = dlsym(RTLD_NEXT, "recv");
|
|
||||||
libc_recvfrom = dlsym(RTLD_NEXT, "recvfrom");
|
|
||||||
libc_send = dlsym(RTLD_NEXT, "send");
|
|
||||||
libc_sendto = dlsym(RTLD_NEXT, "sendto");
|
|
||||||
libc_socket = dlsym(RTLD_NEXT, "socket");
|
|
||||||
libc_listen = dlsym(RTLD_NEXT, "listen");
|
|
||||||
}
|
|
||||||
|
|
||||||
int ioctl(int fd, unsigned long request, ...)
|
|
||||||
{
|
|
||||||
if (should_malloc_fail()) {
|
|
||||||
errno = ENOMEM;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
va_list ap;
|
|
||||||
va_start(ap, request);
|
|
||||||
const int ret = libc_ioctl(fd, SIOCGIFCONF, va_arg(ap, void *));
|
|
||||||
va_end(ap);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
int bind(int sockfd, const struct sockaddr *addr,
|
|
||||||
socklen_t addrlen)
|
|
||||||
{
|
|
||||||
// Unlike all others, if bind should fail once, it should fail always, because in toxcore we try
|
|
||||||
// many ports before giving up. If this only fails once, we'll never reach the code path where
|
|
||||||
// we give up.
|
|
||||||
static int should_fail = -1;
|
|
||||||
if (should_fail == -1) {
|
|
||||||
should_fail = should_malloc_fail();
|
|
||||||
}
|
|
||||||
if (should_fail) {
|
|
||||||
errno = ENOMEM;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
return libc_bind(sockfd, addr, addrlen);
|
|
||||||
}
|
|
||||||
|
|
||||||
int getsockopt(int sockfd, int level, int optname,
|
|
||||||
void *optval, socklen_t *optlen)
|
|
||||||
{
|
|
||||||
if (should_malloc_fail()) {
|
|
||||||
errno = ENOMEM;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
return libc_getsockopt(sockfd, level, optname, optval, optlen);
|
|
||||||
}
|
|
||||||
|
|
||||||
int setsockopt(int sockfd, int level, int optname,
|
|
||||||
const void *optval, socklen_t optlen)
|
|
||||||
{
|
|
||||||
if (should_malloc_fail()) {
|
|
||||||
errno = ENOMEM;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
return libc_setsockopt(sockfd, level, optname, optval, optlen);
|
|
||||||
}
|
|
||||||
|
|
||||||
ssize_t recv(int sockfd, void *buf, size_t len, int flags)
|
|
||||||
{
|
|
||||||
if (should_malloc_fail()) {
|
|
||||||
errno = ENOMEM;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
return libc_recv(sockfd, buf, len, flags);
|
|
||||||
}
|
|
||||||
|
|
||||||
ssize_t recvfrom(int sockfd, void *buf, size_t len, int flags,
|
|
||||||
struct sockaddr *src_addr, socklen_t *addrlen)
|
|
||||||
{
|
|
||||||
if (should_malloc_fail()) {
|
|
||||||
errno = ENOMEM;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
return libc_recvfrom(sockfd, buf, len, flags, src_addr, addrlen);
|
|
||||||
}
|
|
||||||
|
|
||||||
ssize_t send(int sockfd, const void *buf, size_t len, int flags)
|
|
||||||
{
|
|
||||||
if (should_malloc_fail()) {
|
|
||||||
errno = ENOMEM;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
return libc_send(sockfd, buf, len, flags);
|
|
||||||
}
|
|
||||||
|
|
||||||
ssize_t sendto(int sockfd, const void *buf, size_t len, int flags,
|
|
||||||
const struct sockaddr *dest_addr, socklen_t addrlen)
|
|
||||||
{
|
|
||||||
if (should_malloc_fail()) {
|
|
||||||
errno = ENOMEM;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
return libc_sendto(sockfd, buf, len, flags, dest_addr, addrlen);
|
|
||||||
}
|
|
||||||
|
|
||||||
int socket(int domain, int type, int protocol)
|
|
||||||
{
|
|
||||||
if (should_malloc_fail()) {
|
|
||||||
errno = ENOMEM;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
return libc_socket(domain, type, protocol);
|
|
||||||
}
|
|
||||||
|
|
||||||
int listen(int sockfd, int backlog)
|
|
||||||
{
|
|
||||||
if (should_malloc_fail()) {
|
|
||||||
errno = ENOMEM;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
return libc_listen(sockfd, backlog);
|
|
||||||
}
|
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user