2024-01-13 00:11:07 +08:00
|
|
|
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test")
|
2022-03-23 08:46:10 +08:00
|
|
|
load("@rules_fuzzing//fuzzing:cc_defs.bzl", "cc_fuzz_test")
|
|
|
|
|
2022-03-28 01:17:53 +08:00
|
|
|
cc_library(
|
|
|
|
name = "fuzz_support",
|
2022-04-11 02:48:09 +08:00
|
|
|
srcs = [
|
|
|
|
"func_conversion.h",
|
|
|
|
"fuzz_support.cc",
|
|
|
|
],
|
2022-03-28 01:17:53 +08:00
|
|
|
hdrs = ["fuzz_support.h"],
|
|
|
|
visibility = ["//c-toxcore:__subpackages__"],
|
2022-04-03 01:10:09 +08:00
|
|
|
deps = [
|
|
|
|
"//c-toxcore/toxcore:crypto_core",
|
|
|
|
"//c-toxcore/toxcore:network",
|
|
|
|
"//c-toxcore/toxcore:tox",
|
|
|
|
],
|
2022-03-28 01:17:53 +08:00
|
|
|
)
|
|
|
|
|
2022-04-02 20:11:46 +08:00
|
|
|
cc_library(
|
|
|
|
name = "fuzz_tox",
|
|
|
|
hdrs = ["fuzz_tox.h"],
|
|
|
|
visibility = ["//c-toxcore:__subpackages__"],
|
|
|
|
deps = [":fuzz_support"],
|
|
|
|
)
|
|
|
|
|
2022-03-23 08:46:10 +08:00
|
|
|
cc_fuzz_test(
|
2022-03-28 05:45:04 +08:00
|
|
|
name = "bootstrap_fuzz_test",
|
2023-11-08 22:40:12 +08:00
|
|
|
size = "small",
|
2024-01-13 00:11:07 +08:00
|
|
|
srcs = ["bootstrap_fuzz_test.cc"],
|
2022-03-23 08:46:10 +08:00
|
|
|
copts = ["-UNDEBUG"],
|
2024-01-13 00:11:07 +08:00
|
|
|
corpus = ["//tools/toktok-fuzzer/corpus:bootstrap_fuzz_test"],
|
2022-03-29 06:42:42 +08:00
|
|
|
deps = [
|
|
|
|
":fuzz_support",
|
2022-04-16 05:08:23 +08:00
|
|
|
":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-08 22:40:12 +08:00
|
|
|
size = "small",
|
2022-04-16 05:08:23 +08: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",
|
2022-03-29 06:42:42 +08:00
|
|
|
"//c-toxcore/toxcore:tox",
|
2022-04-03 01:10:09 +08:00
|
|
|
"//c-toxcore/toxcore:tox_dispatch",
|
|
|
|
"//c-toxcore/toxcore:tox_events",
|
2022-03-29 06:42:42 +08:00
|
|
|
],
|
2022-03-23 08:46:10 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
cc_fuzz_test(
|
|
|
|
name = "toxsave_fuzz_test",
|
2023-11-08 22:40:12 +08:00
|
|
|
size = "small",
|
2024-01-13 00:11:07 +08:00
|
|
|
srcs = ["toxsave_fuzz_test.cc"],
|
2022-03-23 08:46:10 +08:00
|
|
|
copts = ["-UNDEBUG"],
|
2024-01-13 00:11:07 +08:00
|
|
|
corpus = ["//tools/toktok-fuzzer/corpus:toxsave_fuzz_test"],
|
2022-03-29 06:42:42 +08:00
|
|
|
deps = [
|
|
|
|
":fuzz_support",
|
|
|
|
"//c-toxcore/toxcore:tox",
|
|
|
|
],
|
2022-03-23 08:46:10 +08:00
|
|
|
)
|
2022-04-16 05:08:23 +08:00
|
|
|
|
|
|
|
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-13 00:11:07 +08: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"],
|
2022-04-16 05:08:23 +08:00
|
|
|
tags = ["manual"],
|
2024-01-13 00:11:07 +08: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",
|
|
|
|
],
|
2022-04-16 05:08:23 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
cc_fuzz_test(
|
|
|
|
name = "protodump_reduce",
|
2023-11-08 22:40:12 +08:00
|
|
|
size = "small",
|
2022-04-16 05:08:23 +08: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",
|
|
|
|
],
|
|
|
|
)
|