WC3/xan: move palette handling to decoder, avoiding need for
[ffmpeg.git] / tests / fate.sh
1 #! /bin/sh
2
3 config=$1
4
5 die(){
6     echo "$@"
7     exit 1
8 }
9
10 test -r "$config"  || die "usage: fate.sh <config>"
11
12 workdir=$(cd $(dirname $config) && pwd)
13 make=make
14 tar='tar c'
15
16 . "$config"
17
18 test -n "$slot"    || die "slot not specified"
19 test -n "$repo"    || die "repo not specified"
20 test -d "$samples" || die "samples location not specified"
21
22 lock(){
23     lock=$1/fate.lock
24     (set -C; exec >$lock) 2>/dev/null || return
25     trap 'rm $lock' EXIT
26 }
27
28 checkout(){
29     case "$repo" in
30         file:*|/*) src="${repo#file:}"      ;;
31         git:*)     git clone "$repo" "$src" ;;
32         svn:*)     svn co    "$repo" "$src" ;;
33     esac
34 }
35
36 update()(
37     cd ${src} || return
38     case "$repo" in
39         git:*) git pull ;;
40         svn:*) svn up   ;;
41     esac
42 )
43
44 configure()(
45     cd ${build} || return
46     ${src}/configure                                                    \
47         --prefix="${inst}"                                              \
48         --samples="${samples}"                                          \
49         --enable-gpl                                                    \
50         ${arch:+--arch=$arch}                                           \
51         ${cpu:+--cpu="$cpu"}                                            \
52         ${cross_prefix:+--cross-prefix="$cross_prefix"}                 \
53         ${cc:+--cc="$cc"}                                               \
54         ${target_os:+--target-os="$target_os"}                          \
55         ${sysroot:+--sysroot="$sysroot"}                                \
56         ${target_exec:+--target-exec="$target_exec"}                    \
57         ${target_path:+--target-path="$target_path"}                    \
58         ${extra_cflags:+--extra-cflags="$extra_cflags"}                 \
59         ${extra_ldflags:+--extra-ldflags="$extra_ldflags"}              \
60         ${extra_libs:+--extra-libs="$extra_libs"}                       \
61         ${extra_conf}
62 )
63
64 compile()(
65     cd ${build} || return
66     ${make} ${makeopts} && ${make} install
67 )
68
69 fate()(
70     cd ${build} || return
71     ${make} ${makeopts} -k fate
72 )
73
74 clean(){
75     rm -r ${build} ${inst}
76 }
77
78 report(){
79     date=$(date -u +%Y%m%d%H%M%S)
80     echo "fate:0:${date}:${slot}:${version}:$1:$2" >report
81     cat ${build}/config.fate ${build}/tests/data/fate/*.rep >>report
82     test -n "$fate_recv" && $tar report *.log | gzip | $fate_recv
83 }
84
85 fail(){
86     report "$@"
87     clean
88     exit
89 }
90
91 mkdir -p ${workdir} || die "Error creating ${workdir}"
92 lock ${workdir}     || die "${workdir} locked"
93 cd ${workdir}       || die "cd ${workdir} failed"
94
95 src=${workdir}/src
96 build=${workdir}/build
97 inst=${workdir}/install
98
99 test -d "$src" && update || checkout || die "Error fetching source"
100
101 cd ${workdir}
102
103 version=$(${src}/version.sh ${src})
104 test "$version" = "$(cat version-$slot 2>/dev/null)" && exit 0
105 echo ${version} >version-$slot
106
107 rm -rf "${build}" *.log
108 mkdir -p ${build}
109
110 configure >configure.log 2>&1 || fail $? "error configuring"
111 compile   >compile.log   2>&1 || fail $? "error compiling"
112 fate      >test.log      2>&1 || fail $? "error testing"
113 report 0 success
114 clean