Update git submodules
[LibreOffice.git] / bin / fuzzfiles
blobed0432d2371cce40ab87814c1ea81cf76058d52d
1 #! /bin/bash
3 # This file is part of the LibreOffice project.
5 # This Source Code Form is subject to the terms of the Mozilla Public
6 # License, v. 2.0. If a copy of the MPL was not distributed with this
7 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 #check that zzuf is installed
11 hash zzuf &> /dev/null
12 if [ $? -eq 1 ];then
13 echo >&2 "zzuf not found. Please install and/or fix the PATH environment variable. Aborting"
14 exit -1
17 #check that file(s) to fuzz are mentioned
18 if [[ $# -eq 0 ]]; then
19 echo "Usage: fuzzfiles.sh <list of seed files to fuzz>"
20 echo "The generated fuzzed files will be output to the current working directory"
21 echo "The fuzzed files will be named XYZ-ratio-NNNN where:"
22 echo -e "\tXYZ: the original file name"
23 echo -e "\tratio: the fuzz ratio (what % of bytes were fuzzed)"
24 echo -e "\tNNNN: the mutation # for that file and ratio combo"
25 exit -1
28 for file in $@; do
29 if [ -d $file ]; then
30 echo "$file is a directory. Only files are allowed"
31 elif [ -e $file ]; then
32 basename=${file##*/}
33 #Sequence from 0.001 to 0.5
34 for ratio in `seq -w 1 2 500 | sed -e 's/^/0./'`; do
35 echo "Fuzzing $file with ratio $ratio"
36 for i in {1..1000}; do
37 zzuf -r $ratio < $file > "$basename-$ratio-$i"
38 done #end of for i in {1..
39 done #end of for ratio in ...
40 fi #end if of file validity check
41 done #end for file in $@