oss-fuzz-copy.sh 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #!/usr/bin/env bash
  2. set -e
  3. # --------------------------------------------------------------------
  4. # Copies all the corpus files, dict and options to the $OUT directory.
  5. # This script is only used on oss-fuzz directly
  6. # --------------------------------------------------------------------
  7. fuzzerFiles=$(find $SRC/open62541/tests/fuzz/ -name "*.cc")
  8. for F in $fuzzerFiles; do
  9. fuzzerName=$(basename $F .cc)
  10. if [ -d "$SRC/open62541/tests/fuzz/${fuzzerName}_corpus" ]; then
  11. # first combine any files in subfolders to one single binary file
  12. subDirs=$(find $SRC/open62541/tests/fuzz/${fuzzerName}_corpus -maxdepth 1 -mindepth 1 -type d)
  13. for dirPath in $subDirs; do
  14. dir=$(basename $dirPath)
  15. dirPathTmp=$SRC/open62541/tests/fuzz/${fuzzerName}_corpus/${dir}_tmp
  16. if [ -d $dirPathTmp ]; then
  17. rm -r $dirPathTmp
  18. fi
  19. mkdir $dirPathTmp
  20. # copy the files to get unique names
  21. binFiles=$(find $dirPath -name "*.bin")
  22. for binFile in $binFiles; do
  23. binFileName=$(basename $binFile .bin)
  24. cp $binFile $dirPathTmp/${dir}_${binFileName}.bin
  25. done
  26. outPath=$dirPathTmp/$dir.bin
  27. cat $dirPath/*.bin > $outPath
  28. zip -j $OUT/${fuzzerName}_seed_corpus.zip $dirPathTmp/*
  29. rm -r $dirPathTmp
  30. done
  31. zip -j $OUT/${fuzzerName}_seed_corpus.zip $SRC/open62541/tests/fuzz/${fuzzerName}_corpus/*
  32. fi
  33. done
  34. cp $SRC/open62541/tests/fuzz/*.dict $SRC/open62541/tests/fuzz/*.options $OUT/