CMakeLists.txt 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. # Copyright 2018 Google LLC
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. # Builds all fuzzing targets using firebase_ios_add_fuzz_test build rule, which
  15. # copies the provided dictionary and corpus to the destination directory. A
  16. # fuzzing target that tests xyz must be called 'firestore_xyz_fuzzer'. The copied
  17. # dictionary will be called 'firestore_xyz_fuzzer.dict' and its corpus
  18. # 'firestore_xyz_fuzzer_seed_corpus'. See cc_rules.cmake for more information.
  19. if(NOT FUZZING)
  20. return()
  21. endif()
  22. # Finds the fuzzer library that is either provided by OSS Fuzz or libFuzzer that
  23. # is manually built from sources.
  24. find_package(Fuzzer REQUIRED)
  25. # Use the fuzzing resources directory from the iOS fuzz tests.
  26. set(
  27. fuzzing_resources
  28. ${FIREBASE_SOURCE_DIR}/Firestore/Example/FuzzTests/FuzzingResources
  29. )
  30. link_libraries(firestore_core)
  31. # Serializer fuzzing target.
  32. # TODO(minafarid): Do not define a CORPUS in this target, but rather generate
  33. # the serializer corpus by converting the text protos from the serializer
  34. # corpus in the iOS FuzzingResources to binary protos. This conversion requires
  35. # the protoc binary that is not currently available.
  36. firebase_ios_add_fuzz_test(
  37. firestore_serializer_fuzzer
  38. DICTIONARY ${fuzzing_resources}/Serializer/serializer.dictionary
  39. CORPUS ${fuzzing_resources}/Serializer/Corpus/BinaryProtos
  40. serializer_fuzzer.cc
  41. )
  42. # FieldPath fuzzing target.
  43. firebase_ios_add_fuzz_test(
  44. firestore_fieldpath_fuzzer
  45. DICTIONARY ${fuzzing_resources}/FieldPath/fieldpath.dictionary
  46. CORPUS ${fuzzing_resources}/FieldPath/Corpus
  47. fieldpath_fuzzer.cc
  48. )
  49. # ResourcePath fuzzing target. Use the same corpus and dict as FieldPath.
  50. firebase_ios_add_fuzz_test(
  51. firestore_resourcepath_fuzzer
  52. DICTIONARY ${fuzzing_resources}/FieldPath/fieldpath.dictionary
  53. CORPUS ${fuzzing_resources}/FieldPath/Corpus
  54. resourcepath_fuzzer.cc
  55. )
  56. # LevelDB fuzzer.
  57. firebase_ios_add_fuzz_test(
  58. firestore_leveldb_fuzzer
  59. DICTIONARY ${fuzzing_resources}/LevelDb/leveldb.dictionary
  60. leveldb_fuzzer.cc
  61. )