mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
cleanup: Further #include
cleanups.
This commit is contained in:
parent
8d29935b7a
commit
0c05566e58
|
@ -1,88 +1,220 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import glob as py_glob
|
import glob
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
from dataclasses import dataclass
|
||||||
|
from typing import Iterable
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
LIBS = {}
|
LIBS = {}
|
||||||
|
MODS = {}
|
||||||
|
STD_MODULE = """module std [system] {
|
||||||
|
textual header "/usr/include/alloca.h"
|
||||||
|
textual header "/usr/include/assert.h"
|
||||||
|
textual header "/usr/include/c++/13.2.1/algorithm"
|
||||||
|
textual header "/usr/include/c++/13.2.1/array"
|
||||||
|
textual header "/usr/include/c++/13.2.1/chrono"
|
||||||
|
textual header "/usr/include/c++/13.2.1/cstddef"
|
||||||
|
textual header "/usr/include/c++/13.2.1/cstdint"
|
||||||
|
textual header "/usr/include/c++/13.2.1/cstdio"
|
||||||
|
textual header "/usr/include/c++/13.2.1/cstdlib"
|
||||||
|
textual header "/usr/include/c++/13.2.1/cstring"
|
||||||
|
textual header "/usr/include/c++/13.2.1/iomanip"
|
||||||
|
textual header "/usr/include/c++/13.2.1/iosfwd"
|
||||||
|
textual header "/usr/include/c++/13.2.1/limits"
|
||||||
|
textual header "/usr/include/c++/13.2.1/memory"
|
||||||
|
textual header "/usr/include/c++/13.2.1/ostream"
|
||||||
|
textual header "/usr/include/c++/13.2.1/random"
|
||||||
|
textual header "/usr/include/c++/13.2.1/stdlib.h"
|
||||||
|
textual header "/usr/include/c++/13.2.1/thread"
|
||||||
|
textual header "/usr/include/c++/13.2.1/type_traits"
|
||||||
|
textual header "/usr/include/c++/13.2.1/vector"
|
||||||
|
textual header "/usr/include/errno.h"
|
||||||
|
textual header "/usr/include/fortify/stdio.h"
|
||||||
|
textual header "/usr/include/fortify/string.h"
|
||||||
|
textual header "/usr/include/fortify/unistd.h"
|
||||||
|
textual header "/usr/include/limits.h"
|
||||||
|
textual header "/usr/include/stdarg.h"
|
||||||
|
textual header "/usr/include/stdbool.h"
|
||||||
|
textual header "/usr/include/stddef.h"
|
||||||
|
textual header "/usr/include/stdint.h"
|
||||||
|
textual header "/usr/include/sys/time.h"
|
||||||
|
textual header "/usr/include/sys/types.h"
|
||||||
|
textual header "/usr/include/time.h"
|
||||||
|
}
|
||||||
|
module "//c-toxcore/third_party:cmp" {
|
||||||
|
header "third_party/cmp/cmp.h"
|
||||||
|
use std
|
||||||
|
}
|
||||||
|
module "//c-toxcore/toxencryptsave:defines" {
|
||||||
|
header "toxencryptsave/defines.h"
|
||||||
|
}
|
||||||
|
module "@com_google_googletest//:gtest" {
|
||||||
|
textual header "/usr/include/gmock/gmock.h"
|
||||||
|
textual header "/usr/include/gtest/gtest.h"
|
||||||
|
use std
|
||||||
|
}
|
||||||
|
module "@libsodium" {
|
||||||
|
textual header "/usr/include/sodium.h"
|
||||||
|
}
|
||||||
|
module "@pthread" {
|
||||||
|
textual header "/usr/include/pthread.h"
|
||||||
|
}
|
||||||
|
module "@psocket" {
|
||||||
|
textual header "/usr/include/arpa/inet.h"
|
||||||
|
textual header "/usr/include/fcntl.h"
|
||||||
|
textual header "/usr/include/fortify/sys/socket.h"
|
||||||
|
textual header "/usr/include/linux/if.h"
|
||||||
|
textual header "/usr/include/netdb.h"
|
||||||
|
textual header "/usr/include/netinet/in.h"
|
||||||
|
textual header "/usr/include/sys/epoll.h"
|
||||||
|
textual header "/usr/include/sys/ioctl.h"
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
def load(bzl: str, *syms: str) -> None:
|
@dataclass
|
||||||
|
class Context:
|
||||||
|
pkg: str
|
||||||
|
pkg_prefix: str
|
||||||
|
|
||||||
|
def bzl_load(self, bzl: str, *syms: str) -> None:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def bzl_exports_files(
|
||||||
def exports_files(srcs: list[str],
|
self,
|
||||||
visibility: Optional[list[str]] = None) -> None:
|
srcs: list[str],
|
||||||
|
visibility: Optional[list[str]] = None,
|
||||||
|
) -> None:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def bzl_cc_library(
|
||||||
|
self,
|
||||||
|
name: str,
|
||||||
|
srcs: Iterable[str] = tuple(),
|
||||||
|
hdrs: Iterable[str] = tuple(),
|
||||||
|
deps: Iterable[str] = tuple(),
|
||||||
|
visibility: Iterable[str] = tuple(),
|
||||||
|
testonly: bool = False,
|
||||||
|
copts: Iterable[str] = tuple(),
|
||||||
|
) -> None:
|
||||||
|
LIBS[name] = {
|
||||||
|
"srcs":
|
||||||
|
srcs,
|
||||||
|
"deps": [
|
||||||
|
f"{self.pkg_prefix}{dep}" if dep[0] == ":" else dep
|
||||||
|
for dep in deps
|
||||||
|
],
|
||||||
|
"hdrs":
|
||||||
|
hdrs,
|
||||||
|
}
|
||||||
|
|
||||||
def cc_library(name: str, **kwargs: list[str]) -> None:
|
def bzl_cc_test(
|
||||||
LIBS[name] = kwargs
|
self,
|
||||||
|
name: str,
|
||||||
|
srcs: Iterable[str] = tuple(),
|
||||||
|
hdrs: Iterable[str] = tuple(),
|
||||||
|
deps: Iterable[str] = tuple(),
|
||||||
|
**kwargs: list[str],
|
||||||
|
) -> None:
|
||||||
|
LIBS[name] = {
|
||||||
|
"srcs":
|
||||||
|
srcs,
|
||||||
|
"deps": [
|
||||||
|
f"{self.pkg_prefix}{dep}" if dep[0] == ":" else dep
|
||||||
|
for dep in deps
|
||||||
|
],
|
||||||
|
"hdrs":
|
||||||
|
hdrs,
|
||||||
|
}
|
||||||
|
|
||||||
|
def bzl_cc_fuzz_test(self, name: str, **kwargs: list[str]) -> None:
|
||||||
def cc_test(name: str, **kwargs: list[str]) -> None:
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def bzl_select(self, selector: dict[str, list[str]]) -> list[str]:
|
||||||
def cc_fuzz_test(name: str, **kwargs: list[str]) -> None:
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
def select(selector: dict[str, list[str]]) -> list[str]:
|
|
||||||
return selector["//tools/config:linux"]
|
return selector["//tools/config:linux"]
|
||||||
|
|
||||||
|
def bzl_glob(self, include: list[str]) -> list[str]:
|
||||||
def glob(include: list[str]) -> list[str]:
|
|
||||||
return [
|
return [
|
||||||
f[len("toxcore/"):] for p in include
|
f[len(self.pkg) + 1:] for p in include
|
||||||
for f in py_glob.glob(os.path.join("toxcore", p))
|
for f in glob.glob(os.path.join(self.pkg, p))
|
||||||
]
|
]
|
||||||
|
|
||||||
|
def bzl_alias(self, name: str, actual: str, visibility: list[str]) -> None:
|
||||||
def alias(name: str, actual: str, visibility: list[str]) -> None:
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def bzl_sh_library(self, name: str, **kwargs: list[str]) -> None:
|
||||||
def sh_library(name: str, **kwargs: list[str]) -> None:
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def main() -> None:
|
def main() -> None:
|
||||||
with open("toxcore/BUILD.bazel", "r") as fh:
|
srcs: list[str] = []
|
||||||
exec(fh.read())
|
for pkg in ("toxcore", ):
|
||||||
|
# TODO(iphydf): Why does this break everything?
|
||||||
|
# ctx = Context(pkg, "//c-toxcore/{pkg}")
|
||||||
|
ctx = Context(pkg, "")
|
||||||
|
with open(os.path.join(pkg, "BUILD.bazel"), "r") as fh:
|
||||||
|
exec(
|
||||||
|
fh.read(),
|
||||||
|
{
|
||||||
|
"load": ctx.bzl_load,
|
||||||
|
"exports_files": ctx.bzl_exports_files,
|
||||||
|
"cc_library": ctx.bzl_cc_library,
|
||||||
|
"cc_test": ctx.bzl_cc_test,
|
||||||
|
"cc_fuzz_test": ctx.bzl_cc_fuzz_test,
|
||||||
|
"select": ctx.bzl_select,
|
||||||
|
"glob": ctx.bzl_glob,
|
||||||
|
"alias": ctx.bzl_alias,
|
||||||
|
"sh_library": ctx.bzl_sh_library,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
with open("module.modulemap", "w") as fh:
|
with open("module.modulemap", "w") as fh:
|
||||||
|
fh.write(STD_MODULE)
|
||||||
for name, lib in LIBS.items():
|
for name, lib in LIBS.items():
|
||||||
fh.write("module " + name + " {\n")
|
fh.write(f'module "{ctx.pkg_prefix}:{name}"' + " {\n")
|
||||||
for hdr in lib["hdrs"]:
|
for hdr in lib["hdrs"]:
|
||||||
fh.write(f' header "toxcore/{hdr}"\n')
|
fh.write(f' header "{pkg}/{hdr}"\n')
|
||||||
|
fh.write(f" use std\n")
|
||||||
for dep in lib.get("deps", []):
|
for dep in lib.get("deps", []):
|
||||||
if dep[0] == ":":
|
fh.write(f' use "{dep}"\n')
|
||||||
fh.write(f" use {dep[1:]}\n")
|
|
||||||
fh.write("}\n")
|
fh.write("}\n")
|
||||||
|
|
||||||
srcs = sorted(
|
for name, lib in LIBS.items():
|
||||||
set(
|
for src in lib.get("srcs", []):
|
||||||
os.path.join("toxcore", src) for lib in LIBS.values()
|
MODS[os.path.join(pkg, src)] = name
|
||||||
for src in lib.get("srcs", [])))
|
srcs.extend(
|
||||||
for src in srcs:
|
os.path.join(pkg, src) # just within a package for now
|
||||||
|
for lib in LIBS.values() for src in lib.get("srcs", []))
|
||||||
|
# subprocess.run(["cat", "module.modulemap"], check=True)
|
||||||
|
for src in sorted(
|
||||||
|
set(srcs) - set([
|
||||||
|
# TODO(iphydf): Figure out what's wrong here.
|
||||||
|
"toxcore/crypto_core_test.cc",
|
||||||
|
"toxcore/group_announce_test.cc",
|
||||||
|
"toxcore/group_moderation_test.cc",
|
||||||
|
"toxcore/mono_time_test.cc",
|
||||||
|
"toxcore/network_test.cc",
|
||||||
|
"toxcore/ping_array_test.cc",
|
||||||
|
"toxcore/util_test.cc",
|
||||||
|
])):
|
||||||
print(f"Validating {src}", file=sys.stderr)
|
print(f"Validating {src}", file=sys.stderr)
|
||||||
subprocess.run(
|
subprocess.run(
|
||||||
[
|
[
|
||||||
"clang",
|
"clang",
|
||||||
"-xc++",
|
|
||||||
"-fsyntax-only",
|
"-fsyntax-only",
|
||||||
|
"-xc++",
|
||||||
"-Wall",
|
"-Wall",
|
||||||
"-Werror",
|
"-Werror",
|
||||||
"-Wno-missing-braces",
|
"-Wno-missing-braces",
|
||||||
|
"-DTCP_SERVER_USE_EPOLL",
|
||||||
"-std=c++23",
|
"-std=c++23",
|
||||||
"-fdiagnostics-color=always",
|
"-fdiagnostics-color=always",
|
||||||
"-fmodules",
|
"-fmodules",
|
||||||
# TODO(iphydf): Fix all the other errors.
|
"-fmodules-strict-decluse",
|
||||||
# "-fmodules-strict-decluse",
|
|
||||||
"-fmodules-decluse",
|
|
||||||
"-fmodule-map-file=module.modulemap",
|
"-fmodule-map-file=module.modulemap",
|
||||||
|
f"-fmodule-name={ctx.pkg_prefix}:{MODS[src]}",
|
||||||
src,
|
src,
|
||||||
],
|
],
|
||||||
check=True,
|
check=True,
|
||||||
|
|
|
@ -4,6 +4,7 @@ FROM alpine:3.19.0
|
||||||
RUN ["apk", "add", "--no-cache", \
|
RUN ["apk", "add", "--no-cache", \
|
||||||
"bash", \
|
"bash", \
|
||||||
"clang", \
|
"clang", \
|
||||||
|
"gtest-dev", \
|
||||||
"libconfig-dev", \
|
"libconfig-dev", \
|
||||||
"libsodium-dev", \
|
"libsodium-dev", \
|
||||||
"libvpx-dev", \
|
"libvpx-dev", \
|
||||||
|
|
|
@ -21,7 +21,9 @@ cc_test(
|
||||||
size = "small",
|
size = "small",
|
||||||
srcs = ["test_util_test.cc"],
|
srcs = ["test_util_test.cc"],
|
||||||
deps = [
|
deps = [
|
||||||
|
":crypto_core",
|
||||||
":crypto_core_test_util",
|
":crypto_core_test_util",
|
||||||
|
":test_util",
|
||||||
"@com_google_googletest//:gtest",
|
"@com_google_googletest//:gtest",
|
||||||
"@com_google_googletest//:gtest_main",
|
"@com_google_googletest//:gtest_main",
|
||||||
],
|
],
|
||||||
|
@ -154,6 +156,7 @@ cc_test(
|
||||||
deps = [
|
deps = [
|
||||||
":bin_pack",
|
":bin_pack",
|
||||||
":bin_unpack",
|
":bin_unpack",
|
||||||
|
":logger",
|
||||||
"@com_google_googletest//:gtest",
|
"@com_google_googletest//:gtest",
|
||||||
"@com_google_googletest//:gtest_main",
|
"@com_google_googletest//:gtest_main",
|
||||||
],
|
],
|
||||||
|
@ -363,6 +366,7 @@ cc_test(
|
||||||
size = "small",
|
size = "small",
|
||||||
srcs = ["ping_array_test.cc"],
|
srcs = ["ping_array_test.cc"],
|
||||||
deps = [
|
deps = [
|
||||||
|
":crypto_core_test_util",
|
||||||
":mem_test_util",
|
":mem_test_util",
|
||||||
":mono_time",
|
":mono_time",
|
||||||
":ping_array",
|
":ping_array",
|
||||||
|
@ -386,6 +390,7 @@ cc_library(
|
||||||
":crypto_core",
|
":crypto_core",
|
||||||
":network",
|
":network",
|
||||||
":util",
|
":util",
|
||||||
|
"@psocket",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -430,6 +435,7 @@ cc_library(
|
||||||
":DHT",
|
":DHT",
|
||||||
":crypto_core",
|
":crypto_core",
|
||||||
":crypto_core_test_util",
|
":crypto_core_test_util",
|
||||||
|
":network",
|
||||||
":network_test_util",
|
":network_test_util",
|
||||||
":test_util",
|
":test_util",
|
||||||
],
|
],
|
||||||
|
@ -443,8 +449,13 @@ cc_test(
|
||||||
":DHT",
|
":DHT",
|
||||||
":DHT_test_util",
|
":DHT_test_util",
|
||||||
":crypto_core",
|
":crypto_core",
|
||||||
|
":crypto_core_test_util",
|
||||||
|
":logger",
|
||||||
":mem_test_util",
|
":mem_test_util",
|
||||||
|
":mono_time",
|
||||||
|
":network",
|
||||||
":network_test_util",
|
":network_test_util",
|
||||||
|
":test_util",
|
||||||
"@com_google_googletest//:gtest",
|
"@com_google_googletest//:gtest",
|
||||||
"@com_google_googletest//:gtest_main",
|
"@com_google_googletest//:gtest_main",
|
||||||
],
|
],
|
||||||
|
@ -518,6 +529,7 @@ cc_library(
|
||||||
"//c-toxcore/other/bootstrap_daemon:__pkg__",
|
"//c-toxcore/other/bootstrap_daemon:__pkg__",
|
||||||
],
|
],
|
||||||
deps = [
|
deps = [
|
||||||
|
":DHT",
|
||||||
":LAN_discovery",
|
":LAN_discovery",
|
||||||
":attributes",
|
":attributes",
|
||||||
":ccompat",
|
":ccompat",
|
||||||
|
@ -526,6 +538,7 @@ cc_library(
|
||||||
":logger",
|
":logger",
|
||||||
":mem",
|
":mem",
|
||||||
":mono_time",
|
":mono_time",
|
||||||
|
":network",
|
||||||
":shared_key_cache",
|
":shared_key_cache",
|
||||||
":timed_auth",
|
":timed_auth",
|
||||||
":util",
|
":util",
|
||||||
|
@ -573,6 +586,7 @@ cc_library(
|
||||||
":network",
|
":network",
|
||||||
":onion",
|
":onion",
|
||||||
":util",
|
":util",
|
||||||
|
"@psocket",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -648,6 +662,7 @@ cc_library(
|
||||||
":mono_time",
|
":mono_time",
|
||||||
":network",
|
":network",
|
||||||
":util",
|
":util",
|
||||||
|
"@pthread",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -704,9 +719,13 @@ cc_test(
|
||||||
size = "small",
|
size = "small",
|
||||||
srcs = ["group_announce_test.cc"],
|
srcs = ["group_announce_test.cc"],
|
||||||
deps = [
|
deps = [
|
||||||
|
":DHT",
|
||||||
|
":crypto_core",
|
||||||
":group_announce",
|
":group_announce",
|
||||||
|
":logger",
|
||||||
":mem_test_util",
|
":mem_test_util",
|
||||||
":mono_time",
|
":mono_time",
|
||||||
|
":network",
|
||||||
"@com_google_googletest//:gtest",
|
"@com_google_googletest//:gtest",
|
||||||
"@com_google_googletest//:gtest_main",
|
"@com_google_googletest//:gtest_main",
|
||||||
],
|
],
|
||||||
|
@ -735,11 +754,16 @@ cc_library(
|
||||||
"//c-toxcore/other/bootstrap_daemon:__pkg__",
|
"//c-toxcore/other/bootstrap_daemon:__pkg__",
|
||||||
],
|
],
|
||||||
deps = [
|
deps = [
|
||||||
|
":DHT",
|
||||||
":attributes",
|
":attributes",
|
||||||
":ccompat",
|
":ccompat",
|
||||||
":crypto_core",
|
":crypto_core",
|
||||||
":group_announce",
|
":group_announce",
|
||||||
|
":logger",
|
||||||
|
":mono_time",
|
||||||
|
":network",
|
||||||
":onion_announce",
|
":onion_announce",
|
||||||
|
":timed_auth",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -751,17 +775,21 @@ cc_library(
|
||||||
deps = [
|
deps = [
|
||||||
":DHT",
|
":DHT",
|
||||||
":LAN_discovery",
|
":LAN_discovery",
|
||||||
|
":TCP_connection",
|
||||||
":attributes",
|
":attributes",
|
||||||
":ccompat",
|
":ccompat",
|
||||||
":crypto_core",
|
":crypto_core",
|
||||||
|
":group_announce",
|
||||||
":group_onion_announce",
|
":group_onion_announce",
|
||||||
":logger",
|
":logger",
|
||||||
":mem",
|
":mem",
|
||||||
":mono_time",
|
":mono_time",
|
||||||
":net_crypto",
|
":net_crypto",
|
||||||
":network",
|
":network",
|
||||||
|
":onion",
|
||||||
":onion_announce",
|
":onion_announce",
|
||||||
":ping_array",
|
":ping_array",
|
||||||
|
":timed_auth",
|
||||||
":util",
|
":util",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
@ -774,12 +802,16 @@ cc_library(
|
||||||
deps = [
|
deps = [
|
||||||
":DHT",
|
":DHT",
|
||||||
":LAN_discovery",
|
":LAN_discovery",
|
||||||
|
":TCP_connection",
|
||||||
":attributes",
|
":attributes",
|
||||||
":ccompat",
|
":ccompat",
|
||||||
|
":crypto_core",
|
||||||
":logger",
|
":logger",
|
||||||
":mono_time",
|
":mono_time",
|
||||||
":net_crypto",
|
":net_crypto",
|
||||||
":network",
|
":network",
|
||||||
|
":onion",
|
||||||
|
":onion_announce",
|
||||||
":onion_client",
|
":onion_client",
|
||||||
":util",
|
":util",
|
||||||
],
|
],
|
||||||
|
@ -797,8 +829,12 @@ cc_library(
|
||||||
deps = [
|
deps = [
|
||||||
":attributes",
|
":attributes",
|
||||||
":ccompat",
|
":ccompat",
|
||||||
|
":crypto_core",
|
||||||
":friend_connection",
|
":friend_connection",
|
||||||
":network",
|
":network",
|
||||||
|
":onion",
|
||||||
|
":onion_announce",
|
||||||
|
":onion_client",
|
||||||
":util",
|
":util",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
@ -826,6 +862,7 @@ cc_test(
|
||||||
size = "small",
|
size = "small",
|
||||||
srcs = ["group_moderation_test.cc"],
|
srcs = ["group_moderation_test.cc"],
|
||||||
deps = [
|
deps = [
|
||||||
|
":DHT",
|
||||||
":crypto_core",
|
":crypto_core",
|
||||||
":crypto_core_test_util",
|
":crypto_core_test_util",
|
||||||
":group_moderation",
|
":group_moderation",
|
||||||
|
@ -909,11 +946,16 @@ cc_library(
|
||||||
hdrs = ["group.h"],
|
hdrs = ["group.h"],
|
||||||
visibility = ["//c-toxcore/toxav:__pkg__"],
|
visibility = ["//c-toxcore/toxav:__pkg__"],
|
||||||
deps = [
|
deps = [
|
||||||
|
":DHT",
|
||||||
":Messenger",
|
":Messenger",
|
||||||
":attributes",
|
":attributes",
|
||||||
":ccompat",
|
":ccompat",
|
||||||
":crypto_core",
|
":crypto_core",
|
||||||
|
":friend_connection",
|
||||||
|
":logger",
|
||||||
":mono_time",
|
":mono_time",
|
||||||
|
":net_crypto",
|
||||||
|
":network",
|
||||||
":state",
|
":state",
|
||||||
":util",
|
":util",
|
||||||
],
|
],
|
||||||
|
@ -933,15 +975,25 @@ cc_library(
|
||||||
],
|
],
|
||||||
visibility = ["//c-toxcore:__subpackages__"],
|
visibility = ["//c-toxcore:__subpackages__"],
|
||||||
deps = [
|
deps = [
|
||||||
|
":DHT",
|
||||||
":Messenger",
|
":Messenger",
|
||||||
|
":TCP_client",
|
||||||
|
":attributes",
|
||||||
":ccompat",
|
":ccompat",
|
||||||
|
":crypto_core",
|
||||||
|
":friend_requests",
|
||||||
":group",
|
":group",
|
||||||
":group_moderation",
|
":group_moderation",
|
||||||
":logger",
|
":logger",
|
||||||
":mem",
|
":mem",
|
||||||
":mono_time",
|
":mono_time",
|
||||||
|
":net_crypto",
|
||||||
":network",
|
":network",
|
||||||
|
":onion_client",
|
||||||
|
":state",
|
||||||
|
":util",
|
||||||
"//c-toxcore/toxencryptsave:defines",
|
"//c-toxcore/toxencryptsave:defines",
|
||||||
|
"@pthread",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -1002,6 +1054,7 @@ cc_library(
|
||||||
":bin_pack",
|
":bin_pack",
|
||||||
":bin_unpack",
|
":bin_unpack",
|
||||||
":ccompat",
|
":ccompat",
|
||||||
|
":logger",
|
||||||
":mem",
|
":mem",
|
||||||
":tox",
|
":tox",
|
||||||
":tox_pack",
|
":tox_pack",
|
||||||
|
@ -1041,6 +1094,7 @@ cc_library(
|
||||||
hdrs = ["tox_dispatch.h"],
|
hdrs = ["tox_dispatch.h"],
|
||||||
visibility = ["//c-toxcore:__subpackages__"],
|
visibility = ["//c-toxcore:__subpackages__"],
|
||||||
deps = [
|
deps = [
|
||||||
|
":attributes",
|
||||||
":ccompat",
|
":ccompat",
|
||||||
":tox",
|
":tox",
|
||||||
":tox_events",
|
":tox_events",
|
||||||
|
|
|
@ -11,8 +11,12 @@
|
||||||
#include "DHT_test_util.hh"
|
#include "DHT_test_util.hh"
|
||||||
#include "crypto_core.h"
|
#include "crypto_core.h"
|
||||||
#include "crypto_core_test_util.hh"
|
#include "crypto_core_test_util.hh"
|
||||||
|
#include "logger.h"
|
||||||
#include "mem_test_util.hh"
|
#include "mem_test_util.hh"
|
||||||
|
#include "mono_time.h"
|
||||||
|
#include "network.h"
|
||||||
#include "network_test_util.hh"
|
#include "network_test_util.hh"
|
||||||
|
#include "test_util.hh"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "bin_unpack.h"
|
#include "bin_unpack.h"
|
||||||
|
#include "logger.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,12 @@
|
||||||
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
|
#include "DHT.h"
|
||||||
|
#include "crypto_core.h"
|
||||||
|
#include "logger.h"
|
||||||
#include "mem_test_util.hh"
|
#include "mem_test_util.hh"
|
||||||
#include "mono_time.h"
|
#include "mono_time.h"
|
||||||
|
#include "network.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "DHT.h"
|
||||||
#include "crypto_core.h"
|
#include "crypto_core.h"
|
||||||
#include "crypto_core_test_util.hh"
|
#include "crypto_core_test_util.hh"
|
||||||
#include "logger.h"
|
#include "logger.h"
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
#include "crypto_core_test_util.hh"
|
||||||
#include "mem_test_util.hh"
|
#include "mem_test_util.hh"
|
||||||
#include "mono_time.h"
|
#include "mono_time.h"
|
||||||
|
|
||||||
|
@ -23,7 +24,7 @@ struct Mono_Time_Deleter {
|
||||||
void operator()(Mono_Time *arr) { mono_time_free(mem_, arr); }
|
void operator()(Mono_Time *arr) { mono_time_free(mem_, arr); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const Memory *mem_;
|
const Test_Memory &mem_;
|
||||||
};
|
};
|
||||||
|
|
||||||
using Mono_Time_Ptr = std::unique_ptr<Mono_Time, Mono_Time_Deleter>;
|
using Mono_Time_Ptr = std::unique_ptr<Mono_Time, Mono_Time_Deleter>;
|
||||||
|
@ -61,12 +62,11 @@ TEST(PingArray, ArraySizeMustBePowerOfTwo)
|
||||||
TEST(PingArray, StoredDataCanBeRetrieved)
|
TEST(PingArray, StoredDataCanBeRetrieved)
|
||||||
{
|
{
|
||||||
Test_Memory mem;
|
Test_Memory mem;
|
||||||
|
Test_Random rng;
|
||||||
|
|
||||||
Ping_Array_Ptr const arr(ping_array_new(mem, 2, 1));
|
Ping_Array_Ptr const arr(ping_array_new(mem, 2, 1));
|
||||||
Mono_Time_Ptr const mono_time(mono_time_new(mem, nullptr, nullptr), mem);
|
Mono_Time_Ptr const mono_time(mono_time_new(mem, nullptr, nullptr), mem);
|
||||||
ASSERT_NE(mono_time, nullptr);
|
ASSERT_NE(mono_time, nullptr);
|
||||||
const Random *rng = os_random();
|
|
||||||
ASSERT_NE(rng, nullptr);
|
|
||||||
|
|
||||||
uint64_t const ping_id = ping_array_add(
|
uint64_t const ping_id = ping_array_add(
|
||||||
arr.get(), mono_time.get(), rng, std::vector<uint8_t>{1, 2, 3, 4}.data(), 4);
|
arr.get(), mono_time.get(), rng, std::vector<uint8_t>{1, 2, 3, 4}.data(), 4);
|
||||||
|
@ -80,12 +80,11 @@ TEST(PingArray, StoredDataCanBeRetrieved)
|
||||||
TEST(PingArray, RetrievingDataWithTooSmallOutputBufferHasNoEffect)
|
TEST(PingArray, RetrievingDataWithTooSmallOutputBufferHasNoEffect)
|
||||||
{
|
{
|
||||||
Test_Memory mem;
|
Test_Memory mem;
|
||||||
|
Test_Random rng;
|
||||||
|
|
||||||
Ping_Array_Ptr const arr(ping_array_new(mem, 2, 1));
|
Ping_Array_Ptr const arr(ping_array_new(mem, 2, 1));
|
||||||
Mono_Time_Ptr const mono_time(mono_time_new(mem, nullptr, nullptr), mem);
|
Mono_Time_Ptr const mono_time(mono_time_new(mem, nullptr, nullptr), mem);
|
||||||
ASSERT_NE(mono_time, nullptr);
|
ASSERT_NE(mono_time, nullptr);
|
||||||
const Random *rng = os_random();
|
|
||||||
ASSERT_NE(rng, nullptr);
|
|
||||||
|
|
||||||
uint64_t const ping_id = ping_array_add(
|
uint64_t const ping_id = ping_array_add(
|
||||||
arr.get(), mono_time.get(), rng, (std::vector<uint8_t>{1, 2, 3, 4}).data(), 4);
|
arr.get(), mono_time.get(), rng, (std::vector<uint8_t>{1, 2, 3, 4}).data(), 4);
|
||||||
|
@ -103,12 +102,11 @@ TEST(PingArray, RetrievingDataWithTooSmallOutputBufferHasNoEffect)
|
||||||
TEST(PingArray, ZeroLengthDataCanBeAdded)
|
TEST(PingArray, ZeroLengthDataCanBeAdded)
|
||||||
{
|
{
|
||||||
Test_Memory mem;
|
Test_Memory mem;
|
||||||
|
Test_Random rng;
|
||||||
|
|
||||||
Ping_Array_Ptr const arr(ping_array_new(mem, 2, 1));
|
Ping_Array_Ptr const arr(ping_array_new(mem, 2, 1));
|
||||||
Mono_Time_Ptr const mono_time(mono_time_new(mem, nullptr, nullptr), mem);
|
Mono_Time_Ptr const mono_time(mono_time_new(mem, nullptr, nullptr), mem);
|
||||||
ASSERT_NE(mono_time, nullptr);
|
ASSERT_NE(mono_time, nullptr);
|
||||||
const Random *rng = os_random();
|
|
||||||
ASSERT_NE(rng, nullptr);
|
|
||||||
|
|
||||||
uint8_t c = 0;
|
uint8_t c = 0;
|
||||||
uint64_t const ping_id = ping_array_add(arr.get(), mono_time.get(), rng, &c, sizeof(c));
|
uint64_t const ping_id = ping_array_add(arr.get(), mono_time.get(), rng, &c, sizeof(c));
|
||||||
|
@ -133,12 +131,11 @@ TEST(PingArray, PingId0IsInvalid)
|
||||||
TEST(PingArray, DataCanOnlyBeRetrievedOnce)
|
TEST(PingArray, DataCanOnlyBeRetrievedOnce)
|
||||||
{
|
{
|
||||||
Test_Memory mem;
|
Test_Memory mem;
|
||||||
|
Test_Random rng;
|
||||||
|
|
||||||
Ping_Array_Ptr const arr(ping_array_new(mem, 2, 1));
|
Ping_Array_Ptr const arr(ping_array_new(mem, 2, 1));
|
||||||
Mono_Time_Ptr const mono_time(mono_time_new(mem, nullptr, nullptr), mem);
|
Mono_Time_Ptr const mono_time(mono_time_new(mem, nullptr, nullptr), mem);
|
||||||
ASSERT_NE(mono_time, nullptr);
|
ASSERT_NE(mono_time, nullptr);
|
||||||
const Random *rng = os_random();
|
|
||||||
ASSERT_NE(rng, nullptr);
|
|
||||||
|
|
||||||
uint8_t c = 0;
|
uint8_t c = 0;
|
||||||
uint64_t const ping_id = ping_array_add(arr.get(), mono_time.get(), rng, &c, sizeof(c));
|
uint64_t const ping_id = ping_array_add(arr.get(), mono_time.get(), rng, &c, sizeof(c));
|
||||||
|
@ -151,12 +148,11 @@ TEST(PingArray, DataCanOnlyBeRetrievedOnce)
|
||||||
TEST(PingArray, PingIdMustMatchOnCheck)
|
TEST(PingArray, PingIdMustMatchOnCheck)
|
||||||
{
|
{
|
||||||
Test_Memory mem;
|
Test_Memory mem;
|
||||||
|
Test_Random rng;
|
||||||
|
|
||||||
Ping_Array_Ptr const arr(ping_array_new(mem, 1, 1));
|
Ping_Array_Ptr const arr(ping_array_new(mem, 1, 1));
|
||||||
Mono_Time_Ptr const mono_time(mono_time_new(mem, nullptr, nullptr), mem);
|
Mono_Time_Ptr const mono_time(mono_time_new(mem, nullptr, nullptr), mem);
|
||||||
ASSERT_NE(mono_time, nullptr);
|
ASSERT_NE(mono_time, nullptr);
|
||||||
const Random *rng = os_random();
|
|
||||||
ASSERT_NE(rng, nullptr);
|
|
||||||
|
|
||||||
uint8_t c = 0;
|
uint8_t c = 0;
|
||||||
uint64_t const ping_id = ping_array_add(arr.get(), mono_time.get(), rng, &c, sizeof(c));
|
uint64_t const ping_id = ping_array_add(arr.get(), mono_time.get(), rng, &c, sizeof(c));
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
|
|
||||||
|
#include "crypto_core.h"
|
||||||
#include "crypto_core_test_util.hh"
|
#include "crypto_core_test_util.hh"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user