#!/bin/sh exec 3>&2 4>&1 5>output 2>&5 >&5 6>/dev/null testswffile() { echo -n "testing $1 for existence..." test -f $1 || (touch failed;echo -n "not there" >&5;return;) echo echo -n "testing $1 for wellformedness..." ./swfdump $1 | tail -n 1 | grep '\b0 END\b' >&6 2>&6 || (touch failed;echo -n "wrong end";return;) ./swfdump $1 | grep 'rfxswf|warning|error|bounds' >&6 2>&6 && (touch failed;echo -n "error";return;) ./swfdump $1 2>&1 >&6 | grep '^.*$' >&6 2>&6 && (touch failed;echo -n "swfdump stderr";./swfdump $1 >&6 2>&5;return;) echo } showresult() { test -f failed || echo ' succeeded' >&4 test -f failed && echo ' failed' >&4 } showfile() { echo '===========================' >&5 cat $1 >&5 echo '===========================' >&5 } starttest() { test=$1 echo -n "Test \"${test}\"..." >&4 echo "================== starting test ${test} ===================" >&5 rm -f failed } swfc() { file=$1 echo "running ${swfc} ${file}...">&5 shift catchsegv ${swfc} $file $@ >test.s 2>test.s2 test -s test.s2 && (touch failed;cat test.s2 >&5) grep 'Segmentation fault' test.s && (touch failed) rm -f test.s test.s2 2>&6 } swfc=./swfc starttest sprite1 rm -f output.swf cat > test.sc < test.sc < test.sc < test.sc < test.sc < test.sc <&6 2>&6 || touch failed showresult starttest nostart2 rm -f output.swf cat > test.sc < test.sc < test.sc <&5 test -f output.swf && touch failed showresult echo -n '' >&4 rm -f test.sc failed file1.swf file2.swf output.swf