Adapt prev 4f78696117ebe4f729880b5d9bfc2f5817b73543 to 3.5 rtl::OUString
[LibreOffice.git] / bin / fuzzfiles
blobc6e509ea77939608efc9db0cc2d43c1074ef7cc0
1 #! /bin/bash
3 # Version: MPL 1.1 / GPLv3+ / LGPLv3+
5 # The contents of this file are subject to the Mozilla Public License Version
6 # 1.1 (the "License"); you may not use this file except in compliance with
7 # the License or as specified alternatively below. You may obtain a copy of
8 # the License at http://www.mozilla.org/MPL/
10 # Software distributed under the License is distributed on an "AS IS" basis,
11 # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 # for the specific language governing rights and limitations under the
13 # License.
15 # Major Contributor(s):
16 # Copyright (C) 2011 Tata Consultancy Services, Ltd. Marc-Andre Laverdiere <marc-andre@atc.tcs.com> (initial developer)
18 # All Rights Reserved.
20 # For minor contributions see the git repository.
22 # Alternatively, the contents of this file may be used under the terms of
23 # either the GNU General Public License Version 3 or later (the "GPLv3+"), or
24 # the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
25 # in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
26 # instead of those above.
28 #check that zzuf is installed
29 hash zzuf &> /dev/null
30 if [ $? -eq 1 ];then
31 echo >&2 "zzuf not found. Please install and/or fix the PATH environement variable. Aborting"
32 exit -1
35 #check that file(s) to fuzz are mentioned
36 if [[ $# -eq 0 ]]; then
37 echo "Usage: fuzzfiles.sh <list of seed files to fuzz>"
38 echo "The generated fuzzed files will be output to the current working directory"
39 echo "The fuzzed files will be named XYZ-ratio-NNNN where:"
40 echo -e "\tXYZ: the original file name"
41 echo -e "\tratio: the fuzz ratio (what % of bytes were fuzzed)"
42 echo -e "\tNNNN: the mutation # for that file and ratio combo"
43 exit -1
46 for file in $@; do
47 if [ -d $file ]; then
48 echo "$file is a directory. Only files are allowed"
49 elif [ -e $file ]; then
50 basename=${file##*/}
51 #Sequence from 0.001 to 0.5
52 for ratio in `seq -w 1 2 500 | sed -e 's/^/0./'`; do
53 echo "Fuzzing $file with ratio $ratio"
54 for i in {1..1000}; do
55 zzuf -r $ratio < $file > "$basename-$ratio-$i"
56 done #end of for i in {1..
57 done #end of for ratio in ...
58 fi #end if of file vailidity check
59 done #end for file in $@