Skip to content

Commit 1cfbada

Browse files
committed
integrating comments
1 parent c7ce907 commit 1cfbada

File tree

9 files changed

+20
-29
lines changed

9 files changed

+20
-29
lines changed

.gitmodules

+4
Original file line numberDiff line numberDiff line change
@@ -332,12 +332,16 @@
332332
[submodule "third_party/abseil-cpp/src"]
333333
path = third_party/abseil-cpp/src
334334
url = https://github.com/abseil/abseil-cpp.git
335+
platforms = linux,darwin
335336
[submodule "third_party/fuzztest"]
336337
path = third_party/fuzztest
337338
url = https://github.com/google/fuzztest.git
339+
platforms = linux,darwin
338340
[submodule "third_party/googletest"]
339341
path = third_party/googletest
340342
url = https://github.com/google/googletest
343+
platforms = linux,darwin
341344
[submodule "third_party/re2/src"]
342345
path = third_party/re2/src
343346
url = https://github.com/google/re2.git
347+
platforms = linux,darwin

build/chip/fuzz_test.gni

+4-15
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,9 @@ template("chip_fuzz_target") {
7272
}
7373
}
7474

75-
# Define a fuzz target for chip using pw_fuzzer and Google FuzzTest Framework.
75+
# Define a fuzz target for Matter using pw_fuzzer and Google FuzzTest Framework.
7676
#
77-
# Fuzz generally only apply on the following environments:
78-
# - linux and mac host builds when using clang
77+
# Google FuzzTest is only supported on Linux and MacOS using Clang:
7978
#
8079
# Sample usage
8180
#
@@ -91,16 +90,6 @@ template("chip_fuzz_target") {
9190
#
9291
#
9392
template("chip_pw_fuzz_target") {
94-
if (!defined(invoker.sources)) {
95-
sources = []
96-
}
97-
if (!defined(invoker.public_deps)) {
98-
public_deps = []
99-
}
100-
if (!defined(invoker.deps)) {
101-
deps = []
102-
}
103-
10493
if (defined(invoker.test_source)) {
10594
_test_output_dir = "${root_out_dir}/tests"
10695

@@ -118,7 +107,7 @@ template("chip_pw_fuzz_target") {
118107
"remove_configs",
119108
])
120109

121-
# TODO: remove this after pw_fuzzer implementation its integration with OSS-Fuzz is complete
110+
# TODO: remove this after pw_fuzzer's integration with OSS-Fuzz is complete.
122111
#just a test for running FuzzTest with libfuzzer-compatibility mode, since this is the mode supported by OSS-fuzz
123112
# defines = [
124113
# "FUZZTEST_COMPATIBILITY_MODE=libfuzzer",
@@ -128,7 +117,7 @@ template("chip_pw_fuzz_target") {
128117
sources = invoker.test_source
129118
output_dir = _test_output_dir
130119

131-
deps += [ "$dir_pw_fuzzer:fuzztest" ]
120+
deps = [ "$dir_pw_fuzzer:fuzztest" ]
132121

133122
# this is necessary so FuzzTest is compiled into an executable in third_party/pigweed/repo/pw_unit_test/test.gni
134123
# otherwise it will be built successfully but with FuzzTarget.DISABLED.ninja and no executable.

build/config/BUILDCONFIG.gn

-2
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@ _chip_defaults = {
4747
declare_args() {
4848
# Toolchain to use for host. This is usually set by default.
4949
host_toolchain = ""
50-
51-
is_pw_fuzz = false
5250
}
5351

5452
if (host_toolchain == "") {

build/toolchain/pw_fuzzer/BUILD.gn

+5-5
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ gcc_toolchain("chip_pw_fuzztest") {
2626
forward_variables_from(pw_target_toolchain_host.clang_fuzz, "*", [ "name" ])
2727

2828
toolchain_args = {
29-
#This is needed to have the defaults passed from pw_target_toolchain_host.clang_fuzz to the current scope
29+
# This is needed to have the defaults passed from pw_target_toolchain_host.clang_fuzz to the current scope
3030
forward_variables_from(defaults, "*")
3131

3232
pw_unit_test_MAIN = "$dir_pw_fuzzer:fuzztest_main"
3333
pw_unit_test_BACKEND = "$dir_pw_fuzzer:gtest"
3434

35-
# below three lines are needed by gcc_toolchain template
35+
# The next three lines are needed by the gcc_toolchain template
3636
current_os = host_os
3737
current_cpu = host_cpu
3838
is_clang = true
@@ -43,7 +43,7 @@ gcc_toolchain("chip_pw_fuzztest") {
4343
# discussion on: https://discord.com/channels/691686718377558037/1275092695764959232
4444
remove_default_configs = [ "$dir_pw_toolchain/host_clang:linux_sysroot" ]
4545

46-
#when is_debug = True, we pass -O0 to cflags and ldflags, while upstream pw_fuzzer toolchain defines "optimize_speed" config that passes -O2.
46+
# when is_debug = true, we pass -O0 to cflags and ldflags, while upstream pw_fuzzer toolchain defines "optimize_speed" config that passes -O2.
4747
# This condition was added to prevent mixing the flags
4848
if (is_debug) {
4949
remove_default_configs += [ "$dir_pw_build:optimize_speed" ]
@@ -63,8 +63,8 @@ gcc_toolchain("chip_pw_fuzztest") {
6363
dir_pw_third_party_fuzztest = "//third_party/fuzztest"
6464
dir_pw_third_party_googletest = "//third_party/googletest"
6565

66-
# TODO: Seems that re2 support within FuzzTest was deprecated, keeping it defined is giving warning
67-
#Remove if re2 is indeed not needed
66+
# TODO: Seems that re2 support within FuzzTest was deprecated, keeping it defined is triggering warning
67+
# Remove if re2 is indeed not needed
6868
# dir_pw_third_party_re2 = "//third_party/re2/src"
6969
}
7070
}

docs/guides/BUILDING.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -392,8 +392,8 @@ executed manually.
392392
./scripts/build/build_examples.py --target linux-x64-tests-clang-pw-fuzztest build
393393
```
394394
395-
NOTE: `asan` is enabled by default in FuzzTest, so adding to build_examples
396-
target does not make a difference.
395+
NOTE: `asan` is enabled by default in FuzzTest, so please do not add it in
396+
build_examples.py invocation.
397397
398398
Tests will be located in:
399399
`out/linux-x64-tests-clang-pw-fuzztest/chip_pw_fuzztest/tests/` where

docs/testing/fuzz_testing.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ FUZZ_TEST(MinimalmDNS, TxtResponderFuzz).WithDomains(Arbitrary<vector<uint8_t>>(
9898
invocation. Example:
9999

100100
```cpp
101-
AnyProtocolID()
101+
auto AnyProtocolID()
102102
{
103103
return ElementOf({ chip::Protocols::SecureChannel::Id, chip::Protocols::InteractionModel::Id, chip::Protocols::BDX::Id,
104104
chip::Protocols::UserDirectedCommissioning::Id });

scripts/build/build/targets.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def BuildHostFakeTarget():
7878
target.AppendModifier("ossfuzz", fuzzing_type=HostFuzzingType.OSS_FUZZ).OnlyIfRe(
7979
"-clang").ExceptIfRe('-libfuzzer')
8080
target.AppendModifier("pw-fuzztest", fuzzing_type=HostFuzzingType.PW_FUZZTEST).OnlyIfRe(
81-
"-clang").ExceptIfRe('-(libfuzzer|ossfuzz)')
81+
"-clang").ExceptIfRe('-(libfuzzer|ossfuzz|asan)')
8282
target.AppendModifier('coverage', use_coverage=True).OnlyIfRe(
8383
'-(chip-tool|all-clusters)')
8484
target.AppendModifier('dmalloc', use_dmalloc=True)
@@ -181,7 +181,7 @@ def BuildHostTarget():
181181
target.AppendModifier("ossfuzz", fuzzing_type=HostFuzzingType.OSS_FUZZ).OnlyIfRe(
182182
"-clang").ExceptIfRe('-libfuzzer')
183183
target.AppendModifier("pw-fuzztest", fuzzing_type=HostFuzzingType.PW_FUZZTEST).OnlyIfRe(
184-
"-clang").ExceptIfRe('-(libfuzzer|ossfuzz)')
184+
"-clang").ExceptIfRe('-(libfuzzer|ossfuzz|asan)')
185185
target.AppendModifier('coverage', use_coverage=True).OnlyIfRe(
186186
'-(chip-tool|all-clusters|tests)')
187187
target.AppendModifier('dmalloc', use_dmalloc=True)

scripts/build/builders/host.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ def __init__(self, root, runner, app: HostApp, board=HostBoard.NATIVE,
381381
elif fuzzing_type == HostFuzzingType.OSS_FUZZ:
382382
self.extra_gn_options.append('oss_fuzz=true')
383383
elif fuzzing_type == HostFuzzingType.PW_FUZZTEST:
384-
self.extra_gn_options.append('is_pw_fuzz=true pw_enable_fuzz_test_targets=true')
384+
self.extra_gn_options.append('pw_enable_fuzz_test_targets=true')
385385

386386
if imgui_ui:
387387
self.extra_gn_options.append('chip_examples_enable_imgui_ui=true')

src/credentials/tests/FuzzChipCertPW.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ void ChipCertFuzzer(const std::vector<std::uint8_t> & bytes)
5656
}
5757

5858
{
59-
// TODO: #34352 To Move this to a Fixture once Errors related to FuzzTest Fixtures are resolved
59+
// TODO: #35369 Move this to a Fixture once Errors related to FuzzTest Fixtures are resolved
6060
ASSERT_EQ(chip::Platform::MemoryInit(), CHIP_NO_ERROR);
6161
ValidateChipRCAC(span);
6262
chip::Platform::MemoryShutdown();

0 commit comments

Comments
 (0)