OSDN Git Service

fate: Add --ignore-tests configure option for omitting specific FATE tests
[android-x86/external-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 : ${branch:=master}
23
24 lock(){
25     lock=$1/fate.lock
26     (set -C; exec >$lock) 2>/dev/null || return
27     trap 'rm $lock' EXIT
28 }
29
30 checkout(){
31     case "$repo" in
32         file:*|/*) src="${repo#file:}"      ;;
33         git:*)     git clone --quiet --branch "$branch" "$repo" "$src" ;;
34     esac
35 }
36
37 update()(
38     cd ${src} || return
39     case "$repo" in
40         git:*) git fetch --quiet --force; git reset --quiet --hard "origin/$branch" ;;
41     esac
42 )
43
44 configure()(
45     cd ${build} || return
46     ${src}/configure                                                    \
47         --prefix="${inst}"                                              \
48         --samples="${samples}"                                          \
49         --enable-gpl                                                    \
50         ${ignore_tests:+--ignore-tests="$ignore_tests"}                 \
51         ${arch:+--arch=$arch}                                           \
52         ${cpu:+--cpu="$cpu"}                                            \
53         ${toolchain:+--toolchain="$toolchain"}                          \
54         ${cross_prefix:+--cross-prefix="$cross_prefix"}                 \
55         ${as:+--as="$as"}                                               \
56         ${cc:+--cc="$cc"}                                               \
57         ${ld:+--ld="$ld"}                                               \
58         ${target_os:+--target-os="$target_os"}                          \
59         ${sysroot:+--sysroot="$sysroot"}                                \
60         ${target_exec:+--target-exec="$target_exec"}                    \
61         ${target_path:+--target-path="$target_path"}                    \
62         ${target_samples:+--target-samples="$target_samples"}           \
63         ${extra_cflags:+--extra-cflags="$extra_cflags"}                 \
64         ${extra_ldflags:+--extra-ldflags="$extra_ldflags"}              \
65         ${extra_libs:+--extra-libs="$extra_libs"}                       \
66         ${extra_conf}
67 )
68
69 compile()(
70     cd ${build} || return
71     ${make} ${makeopts} && ${make} install
72 )
73
74 fate()(
75     test "$build_only" = "yes" && return
76     cd ${build} || return
77     ${make} ${makeopts_fate-${makeopts}} -k fate
78 )
79
80 clean(){
81     rm -rf ${build} ${inst}
82 }
83
84 report(){
85     date=$(date -u +%Y%m%d%H%M%S)
86     echo "fate:1:${date}:${slot}:${version}:$1:$2:${branch}:${comment}" >report
87     cat ${build}/avbuild/config.fate ${build}/tests/data/fate/*.rep >> report 2> /dev/null
88     test -n "$fate_recv" && $tar report *.log | gzip | $fate_recv
89 }
90
91 fail(){
92     report "$@"
93     clean
94     exit
95 }
96
97 mkdir -p ${workdir} || die "Error creating ${workdir}"
98 lock ${workdir}     || die "${workdir} locked"
99 cd ${workdir}       || die "cd ${workdir} failed"
100
101 src=${workdir}/src
102 : ${build:=${workdir}/build}
103 : ${inst:=${workdir}/install}
104
105 test -d "$src" && update || checkout || die "Error fetching source"
106
107 cd ${workdir}
108
109 version=$(${src}/avbuild/version.sh ${src})
110 test "$version" = "$(cat version-$slot 2>/dev/null)" && exit 0
111 echo ${version} >version-$slot
112
113 rm -rf "${build}" *.log
114 mkdir -p ${build}
115
116 configure >configure.log 2>&1 || fail $? "error configuring"
117 compile   >compile.log   2>&1 || fail $? "error compiling"
118 fate      >test.log      2>&1 || fail $? "error testing"
119 report 0 success
120 clean