2024-01-14 21:51:01 +01:00
|
|
|
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test")
|
2023-07-25 11:53:09 +02:00
|
|
|
load("@rules_fuzzing//fuzzing:cc_defs.bzl", "cc_fuzz_test")
|
|
|
|
|
|
|
|
cc_library(
|
|
|
|
name = "fuzz_support",
|
|
|
|
srcs = [
|
|
|
|
"func_conversion.h",
|
|
|
|
"fuzz_support.cc",
|
|
|
|
],
|
|
|
|
hdrs = ["fuzz_support.h"],
|
|
|
|
visibility = ["//c-toxcore:__subpackages__"],
|
|
|
|
deps = [
|
|
|
|
"//c-toxcore/toxcore:crypto_core",
|
|
|
|
"//c-toxcore/toxcore:network",
|
|
|
|
"//c-toxcore/toxcore:tox",
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
cc_library(
|
|
|
|
name = "fuzz_tox",
|
|
|
|
hdrs = ["fuzz_tox.h"],
|
|
|
|
visibility = ["//c-toxcore:__subpackages__"],
|
|
|
|
deps = [":fuzz_support"],
|
|
|
|
)
|
|
|
|
|
|
|
|
cc_fuzz_test(
|
|
|
|
name = "bootstrap_fuzz_test",
|
2023-11-13 14:02:43 +01:00
|
|
|
size = "small",
|
2024-01-14 21:51:01 +01:00
|
|
|
srcs = ["bootstrap_fuzz_test.cc"],
|
2023-07-25 11:53:09 +02:00
|
|
|
copts = ["-UNDEBUG"],
|
2024-01-14 21:51:01 +01:00
|
|
|
corpus = ["//tools/toktok-fuzzer/corpus:bootstrap_fuzz_test"],
|
2023-07-25 11:53:09 +02:00
|
|
|
deps = [
|
|
|
|
":fuzz_support",
|
|
|
|
":fuzz_tox",
|
|
|
|
"//c-toxcore/toxcore:tox",
|
|
|
|
"//c-toxcore/toxcore:tox_dispatch",
|
|
|
|
"//c-toxcore/toxcore:tox_events",
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
cc_fuzz_test(
|
|
|
|
name = "e2e_fuzz_test",
|
2023-11-13 14:02:43 +01:00
|
|
|
size = "small",
|
2023-07-25 11:53:09 +02:00
|
|
|
srcs = ["e2e_fuzz_test.cc"],
|
|
|
|
copts = ["-UNDEBUG"],
|
|
|
|
corpus = ["//tools/toktok-fuzzer/corpus:e2e_fuzz_test"],
|
|
|
|
data = ["//tools/toktok-fuzzer/init:e2e_fuzz_test.dat"],
|
|
|
|
deps = [
|
|
|
|
":fuzz_support",
|
|
|
|
":fuzz_tox",
|
|
|
|
"//c-toxcore/toxcore:tox",
|
|
|
|
"//c-toxcore/toxcore:tox_dispatch",
|
|
|
|
"//c-toxcore/toxcore:tox_events",
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
cc_fuzz_test(
|
|
|
|
name = "toxsave_fuzz_test",
|
2023-11-13 14:02:43 +01:00
|
|
|
size = "small",
|
2024-01-14 21:51:01 +01:00
|
|
|
srcs = ["toxsave_fuzz_test.cc"],
|
2023-07-25 11:53:09 +02:00
|
|
|
copts = ["-UNDEBUG"],
|
2024-01-14 21:51:01 +01:00
|
|
|
corpus = ["//tools/toktok-fuzzer/corpus:toxsave_fuzz_test"],
|
2023-07-25 11:53:09 +02:00
|
|
|
deps = [
|
|
|
|
":fuzz_support",
|
|
|
|
"//c-toxcore/toxcore:tox",
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
cc_binary(
|
|
|
|
name = "protodump",
|
|
|
|
srcs = ["protodump.cc"],
|
|
|
|
copts = ["-UNDEBUG"],
|
|
|
|
deps = [
|
|
|
|
":fuzz_support",
|
|
|
|
"//c-toxcore/toxcore:tox",
|
|
|
|
"//c-toxcore/toxcore:tox_dispatch",
|
|
|
|
"//c-toxcore/toxcore:tox_events",
|
|
|
|
"//c-toxcore/toxcore:util",
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
2024-01-14 21:51:01 +01:00
|
|
|
genrule(
|
|
|
|
name = "e2e_fuzz_test_init",
|
|
|
|
outs = [
|
|
|
|
"e2e_fuzz_test_init.dat",
|
|
|
|
"e2e_fuzz_test_bootstrap.dat",
|
|
|
|
],
|
|
|
|
cmd = "$(location :protodump) $(location e2e_fuzz_test_init.dat) $(location e2e_fuzz_test_bootstrap.dat)",
|
|
|
|
tags = ["manual"],
|
|
|
|
tools = [":protodump"],
|
|
|
|
)
|
|
|
|
|
|
|
|
# bazel test --config=asan-libfuzzer //c-toxcore/testing/fuzzing:protodump_reduce_test
|
|
|
|
cc_test(
|
|
|
|
name = "protodump_reduce_test",
|
|
|
|
size = "small",
|
|
|
|
srcs = ["protodump_reduce.cc"],
|
|
|
|
args = ["$(location :e2e_fuzz_test_init.dat)"],
|
|
|
|
copts = ["-UNDEBUG"],
|
|
|
|
data = [":e2e_fuzz_test_init.dat"],
|
2023-07-25 11:53:09 +02:00
|
|
|
tags = ["manual"],
|
2024-01-14 21:51:01 +01:00
|
|
|
deps = [
|
|
|
|
":fuzz_support",
|
|
|
|
":fuzz_tox",
|
|
|
|
"//c-toxcore/toxcore:tox",
|
|
|
|
"//c-toxcore/toxcore:tox_dispatch",
|
|
|
|
"//c-toxcore/toxcore:tox_events",
|
|
|
|
"@rules_fuzzing//fuzzing:cc_engine",
|
|
|
|
],
|
2023-07-25 11:53:09 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
cc_fuzz_test(
|
|
|
|
name = "protodump_reduce",
|
2023-11-13 14:02:43 +01:00
|
|
|
size = "small",
|
2023-07-25 11:53:09 +02:00
|
|
|
srcs = ["protodump_reduce.cc"],
|
|
|
|
copts = ["-UNDEBUG"],
|
|
|
|
deps = [
|
|
|
|
":fuzz_support",
|
|
|
|
":fuzz_tox",
|
|
|
|
"//c-toxcore/toxcore:tox",
|
|
|
|
"//c-toxcore/toxcore:tox_dispatch",
|
|
|
|
"//c-toxcore/toxcore:tox_events",
|
|
|
|
],
|
|
|
|
)
|