]> git.sesse.net Git - ffmpeg/blob - tools/target_dec_fate.sh
avutil/mem: Also poison new av_realloc-allocated blocks
[ffmpeg] / tools / target_dec_fate.sh
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
21 set -e
22
23 LC_ALL=C
24 export LC_ALL
25
26 LIST=target_dec_fate.list
27
28 show_help(){
29     cat <<EOF
30 Usage: ./target_dec_fate.sh <directory> [<test to run>]
31
32 directory       the directory into which sample files will be downloaded
33 test to run     the number of the issue to test
34 Note, some test samples may not yet be available to the public, also this
35 script will not download samples which are already in the directory. So you
36 may want to preserve its content between runs.
37 EOF
38     exit 0
39 }
40
41 test -z "$1"  && show_help
42 test ! -d "$1"  && echo $1 is not an accessable directory && show_help
43 test ! -f target_dec_fate.sh && echo $0 Must be run from its location && show_help
44 grep 'CONFIG_OSSFUZZ 0' ../config.h && echo not configured for ossfuzz && show_help
45
46 #Download testcases
47 while 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
60 done < "$LIST"
61
62 #Find which fuzzers we need to build
63 TOOLS=
64 while read -r LINE; do
65     TOOL_ID=`echo $LINE | sed 's#[^ ]* ##'`
66     TOOLS="$TOOLS tools/$TOOL_ID"
67 done < "$LIST"
68
69 cd ..
70 #Build fuzzers
71 make -j4 $TOOLS
72
73 #Run testcases
74 while 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
81 done < "tools/$LIST"
82
83 echo OK