1#!/bin/sh 2# 3# * Copyright (C) 2018 Michael Niedermayer (michaelni@gmx.at) 4# * 5# * This file is part of FFmpeg. 6# * 7# * FFmpeg is free software; you can redistribute it and/or modify 8# * it under the terms of the GNU General Public License as published by 9# * the Free Software Foundation; either version 2 of the License, or 10# * (at your option) any later version. 11# * 12# * FFmpeg is distributed in the hope that it will be useful, 13# * but WITHOUT ANY WARRANTY; without even the implied warranty of 14# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15# * GNU General Public License for more details. 16# * 17# * You should have received a copy of the GNU General Public License 18# * along with FFmpeg; if not, write to the Free Software 19# * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 21set -e 22 23LC_ALL=C 24export LC_ALL 25 26LIST=target_dec_fate.list 27 28show_help(){ 29 cat <<EOF 30Usage: ./target_dec_fate.sh <directory> [<test to run>] 31 32directory the directory into which sample files will be downloaded 33test to run the number of the issue to test 34Note, some test samples may not yet be available to the public, also this 35script will not download samples which are already in the directory. So you 36may want to preserve its content between runs. 37EOF 38 exit 0 39} 40 41test -z "$1" && show_help 42test ! -d "$1" && echo $1 is not an accessable directory && show_help 43test ! -f target_dec_fate.sh && echo $0 Must be run from its location && show_help 44grep 'CONFIG_OSSFUZZ 0' ../config.h && echo not configured for ossfuzz && show_help 45 46#Download testcases 47while read -r LINE; do 48 ISSUE_NUM=`echo $LINE | sed 's#/.*##'` 49 FILE_ID=`echo $LINE | sed 's#.*/clusterfuzz-testcase[a-zA-Z0-9_-]*-\([0-9]*\).*#\1#'` 50 FILE=`echo $LINE | sed 's# .*##'` 51 if test -f "$1/$FILE" ; then 52 echo exists $FILE 53 elif echo "$ISSUE_NUM" | grep '#' >/dev/null ; then 54 echo disabled $FILE 55 else 56 echo downloading $FILE 57 mkdir -p "$1/$ISSUE_NUM" 58 wget -O "$1/$FILE" "https://oss-fuzz.com/download?testcase_id=$FILE_ID" || rm "$1/$FILE" 59 fi 60done < "$LIST" 61 62#Find which fuzzers we need to build 63TOOLS= 64while read -r LINE; do 65 TOOL_ID=`echo $LINE | sed 's#[^ ]* ##'` 66 TOOLS="$TOOLS tools/$TOOL_ID" 67done < "$LIST" 68 69cd .. 70#Build fuzzers 71make -j4 $TOOLS 72 73#Run testcases 74while read -r LINE; do 75 TOOL_ID=`echo $LINE | sed 's#[^ ]* ##'` 76 FILE=`echo $LINE | sed 's# .*##'` 77 if ! test -f "$1/$FILE" ; then 78 continue 79 fi 80 tools/$TOOL_ID $1/$FILE 81done < "tools/$LIST" 82 83echo OK 84