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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ jobs:
ca-certificates
clang
cmake
curl
git
libbenchmark-dev
libconfig-dev
Expand All @@ -84,7 +85,11 @@ jobs:
libvpx-dev
llvm-dev
ninja-build
pkg-config
nlohmann-json3-dev
pkg-config &&
curl -L -o ftxui.deb https://github.com/ArthurSonzogni/FTXUI/releases/download/v6.1.9/ftxui-6.1.9-Linux.deb &&
apt-get install -y ./ftxui.deb &&
rm ftxui.deb
- run:
apt-get install -y --no-install-recommends
ca-certificates
Expand Down
12 changes: 12 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ if(BOOTSTRAP_DAEMON AND WIN32)
endif()

option(BUILD_FUZZ_TESTS "Build fuzzing harnesses" OFF)
option(BUILD_NETPROF "Build netprof utility" OFF)

if(MSVC)
option(MSVC_STATIC_SODIUM "Whether to link libsodium statically for MSVC" OFF)
Expand Down Expand Up @@ -693,6 +694,17 @@ if(BOOTSTRAP_DAEMON)
endif()
endif()

if(BUILD_NETPROF)
if(NOT FTXUI_FOUND)
message(WARNING "Option BUILD_NETPROF is enabled but required library FTXUI was not found.")
set(BUILD_NETPROF OFF CACHE BOOL "" FORCE)
endif()
if(NOT NLOHMANN_JSON_FOUND)
message(WARNING "Option BUILD_NETPROF is enabled but required library NLOHMANN_JSON was not found.")
set(BUILD_NETPROF OFF CACHE BOOL "" FORCE)
endif()
endif()

if(BUILD_FUN_UTILS)
add_subdirectory(other/fun)
endif()
Expand Down
31 changes: 31 additions & 0 deletions cmake/Dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,34 @@ endif()

# For tox-bootstrapd.
pkg_search_module(LIBCONFIG libconfig IMPORTED_TARGET)

# For netprof.
if(BUILD_NETPROF)
pkg_search_module(FTXUI ftxui IMPORTED_TARGET)
if(FTXUI_FOUND)
string(REGEX MATCH "^([0-9]+)" FTXUI_VERSION_MAJOR "${FTXUI_VERSION}")
else()
pkg_search_module(FTXUI_SCREEN ftxui-screen IMPORTED_TARGET)
pkg_search_module(FTXUI_DOM ftxui-dom IMPORTED_TARGET)
pkg_search_module(FTXUI_COMPONENT ftxui-component IMPORTED_TARGET)
if(FTXUI_SCREEN_FOUND AND FTXUI_DOM_FOUND AND FTXUI_COMPONENT_FOUND)
set(FTXUI_FOUND TRUE)
string(REGEX MATCH "^([0-9]+)" FTXUI_VERSION_MAJOR "${FTXUI_SCREEN_VERSION}")
endif()
endif()

if(NOT FTXUI_FOUND)
find_package(ftxui QUIET)
if(TARGET ftxui::screen AND TARGET ftxui::dom AND TARGET ftxui::component)
set(FTXUI_FOUND TRUE)
endif()
endif()

pkg_search_module(NLOHMANN_JSON nlohmann_json IMPORTED_TARGET)
if(NOT NLOHMANN_JSON_FOUND)
find_package(nlohmann_json QUIET)
if(TARGET nlohmann_json::nlohmann_json)
set(NLOHMANN_JSON_FOUND TRUE)
endif()
endif()
endif()
3 changes: 3 additions & 0 deletions other/analysis/gen-file.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ CPPFLAGS+=("-Iother")
CPPFLAGS+=("-Iother/bootstrap_daemon/src")
CPPFLAGS+=("-Iother/fun")
CPPFLAGS+=("-Itesting")
CPPFLAGS+=("-Itesting/netprof")
CPPFLAGS+=("-Itesting/netprof/views")
CPPFLAGS+=("-Itesting/fuzzing")
CPPFLAGS+=("-Itesting/support")
CPPFLAGS+=("-Itesting/support/doubles")
Expand Down Expand Up @@ -61,6 +63,7 @@ COMMON_EXCLUDES="$COMMON_EXCLUDES -and -not -wholename './_build/*'"
COMMON_EXCLUDES="$COMMON_EXCLUDES -and -not -wholename './other/docker/*'"
COMMON_EXCLUDES="$COMMON_EXCLUDES -and -not -wholename './super_donators/*'"
COMMON_EXCLUDES="$COMMON_EXCLUDES -and -not -wholename './testing/fuzzing/*'"
COMMON_EXCLUDES="$COMMON_EXCLUDES -and -not -wholename './testing/netprof/*'"
COMMON_EXCLUDES="$COMMON_EXCLUDES -and -not -wholename './third_party/cmp/examples/*'"
COMMON_EXCLUDES="$COMMON_EXCLUDES -and -not -wholename './third_party/cmp/test/*'"

Expand Down
1 change: 1 addition & 0 deletions other/event_tooling/generate_event_c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -721,6 +721,7 @@ int main(int argc, char** argv) {
{
"Dht_Nodes_Response",
{
EventTypeByteArray{"responder_public_key", "TOX_PUBLIC_KEY_SIZE"},
EventTypeByteArray{"public_key", "TOX_PUBLIC_KEY_SIZE"},
EventTypeByteRange{"ip", "ip_length", "ip_length", "char", "uint32_t", true},
EventTypeTrivial{"uint16_t", "port"},
Expand Down
4 changes: 4 additions & 0 deletions testing/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,7 @@ endif()
if(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/support")
add_subdirectory(support)
endif()

if(BUILD_NETPROF)
add_subdirectory(netprof)
endif()
211 changes: 211 additions & 0 deletions testing/netprof/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,211 @@
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test")

cc_library(
name = "constants",
hdrs = ["constants.hh"],
visibility = ["//c-toxcore/testing/netprof:__subpackages__"],
)

cc_library(
name = "layout_engine",
srcs = ["layout_engine.cc"],
hdrs = ["layout_engine.hh"],
deps = [":constants"],
)

cc_library(
name = "model",
hdrs = ["model.hh"],
visibility = ["//c-toxcore/testing/netprof:__subpackages__"],
deps = [
":constants",
"//c-toxcore/toxcore:tox",
],
)

cc_library(
name = "model_utils",
srcs = ["model_utils.cc"],
hdrs = ["model_utils.hh"],
visibility = ["//c-toxcore/testing/netprof:__subpackages__"],
deps = [
":model",
"//c-toxcore/toxcore:tox",
],
)

cc_library(
name = "packet_utils",
srcs = ["packet_utils.cc"],
hdrs = ["packet_utils.hh"],
visibility = ["//c-toxcore/testing/netprof:__subpackages__"],
deps = [
"//c-toxcore/toxcore:tox",
],
)

cc_library(
name = "node_wrapper",
srcs = ["node_wrapper.cc"],
hdrs = ["node_wrapper.hh"],
deps = [
":constants",
":model",
"//c-toxcore/testing/support",
"//c-toxcore/toxcore:tox",
"//c-toxcore/toxcore:tox_events",
"//c-toxcore/toxcore:tox_options",
],
)

cc_library(
name = "simulation_manager",
srcs = ["simulation_manager.cc"],
hdrs = ["simulation_manager.hh"],
deps = [
":constants",
":model_utils",
":node_wrapper",
"//c-toxcore/testing/support",
"//c-toxcore/toxcore:tox",
"//c-toxcore/toxcore:tox_events",
"//c-toxcore/toxcore:tox_options",
"@json",
],
)

cc_library(
name = "ui",
srcs = [
"command_registry.cc",
"ui.cc",
],
hdrs = [
"command_registry.hh",
"ui.hh",
],
deps = [
":constants",
":layout_engine",
":model",
":model_utils",
"//c-toxcore/testing/netprof/views",
"//c-toxcore/toxcore:tox",
"//c-toxcore/toxcore:tox_events",
"@ftxui//:component",
"@ftxui//:dom",
"@ftxui//:screen",
],
)

cc_library(
name = "ui_test_support",
testonly = True,
srcs = ["ui_test_support.cc"],
hdrs = ["ui_test_support.hh"],
visibility = ["//c-toxcore/testing/netprof:__subpackages__"],
deps = [
":ui",
"@com_google_googletest//:gtest",
"@ftxui//:dom",
"@ftxui//:screen",
],
)

cc_library(
name = "app",
srcs = ["app.cc"],
hdrs = ["app.hh"],
deps = [
":constants",
":model",
":model_utils",
":packet_utils",
":simulation_manager",
":ui",
"//c-toxcore/toxcore:tox",
],
)

cc_binary(
name = "netprof",
srcs = [
"main.cc",
],
deps = [
":app",
":packet_utils",
":simulation_manager",
":ui",
"//c-toxcore/testing/support",
"//c-toxcore/toxcore:tox",
"//c-toxcore/toxcore:tox_events",
"@ftxui//:component",
"@ftxui//:dom",
"@ftxui//:screen",
"@json",
],
)

cc_test(
name = "app_test",
srcs = ["app_test.cc"],
deps = [
":app",
"@com_google_googletest//:gtest",
"@com_google_googletest//:gtest_main",
],
)

cc_test(
name = "ui_test",
srcs = ["ui_test.cc"],
deps = [
":ui",
":ui_test_support",
"@com_google_googletest//:gtest",
"@com_google_googletest//:gtest_main",
],
)

cc_test(
name = "model_utils_test",
srcs = ["model_utils_test.cc"],
deps = [
":model_utils",
"@com_google_googletest//:gtest",
"@com_google_googletest//:gtest_main",
],
)

cc_test(
name = "simulation_manager_test",
srcs = ["simulation_manager_test.cc"],
deps = [
":simulation_manager",
"//c-toxcore/testing/support",
"@com_google_googletest//:gtest",
"@com_google_googletest//:gtest_main",
],
)

cc_test(
name = "node_wrapper_test",
srcs = ["node_wrapper_test.cc"],
deps = [
":node_wrapper",
"//c-toxcore/testing/support",
"@com_google_googletest//:gtest",
"@com_google_googletest//:gtest_main",
],
)

cc_test(
name = "layout_engine_test",
srcs = ["layout_engine_test.cc"],
deps = [
":layout_engine",
"@com_google_googletest//:gtest",
"@com_google_googletest//:gtest_main",
],
)
Loading
Loading