fix crashes reported by Debian Cylab Mayhem Team
[swftools.git] / src / testswfc
blob126ccc92692aafcad8aac99624119b10ecff0f59
1 #!/bin/sh
2 exec 3>&2 4>&1 5>output 2>&5 >&5 6>/dev/null
3 testswffile() {
4 echo -n "testing $1 for existence..."
5 test -f $1 || (touch failed;echo -n "not there" >&5;return;)
6 echo
7 echo -n "testing $1 for wellformedness..."
8 ./swfdump $1 | tail -n 1 | grep '\b0 END\b' >&6 2>&6 || (touch failed;echo -n "wrong end";return;)
9 ./swfdump $1 | grep 'rfxswf|warning|error|bounds' >&6 2>&6 && (touch failed;echo -n "error";return;)
10 ./swfdump $1 2>&1 >&6 | grep '^.*$' >&6 2>&6 && (touch failed;echo -n "swfdump stderr";./swfdump $1 >&6 2>&5;return;)
11 echo
13 showresult() {
14 test -f failed || echo '\e[01;32m succeeded' >&4
15 test -f failed && echo '\e[01;31m failed' >&4
17 showfile() {
18 echo '===========================' >&5
19 cat $1 >&5
20 echo '===========================' >&5
22 starttest() {
23 test=$1
24 echo -n "\e[01;37mTest \"${test}\"..." >&4
25 echo "================== starting test ${test} ===================" >&5
26 rm -f failed
28 swfc() {
29 file=$1
30 echo "running ${swfc} ${file}...">&5
31 shift
32 catchsegv ${swfc} $file $@ >test.s 2>test.s2
33 test -s test.s2 && (touch failed;cat test.s2 >&5)
34 grep 'Segmentation fault' test.s && (touch failed)
35 rm -f test.s test.s2 2>&6
38 swfc=./swfc
40 starttest sprite1
41 rm -f output.swf
42 cat > test.sc <<EOF
43 .flash
44 .sprite s1
45 .sprite s2
46 .end
47 .end
48 .put s1
49 .end
50 EOF
51 showfile test.sc
52 swfc test.sc
53 testswffile output.swf
54 showresult
56 starttest sprite2
57 rm -f file1.swf file2.swf
58 cat > test.sc <<EOF
59 .flash name="file2.swf"
60 .sprite spr1
61 .end
62 .end
63 .swf name="file1.swf"
64 .shape monkey "file2.swf"
65 .end
66 EOF
67 showfile test.sc
68 swfc test.sc
69 testswffile file1.swf
70 testswffile file2.swf
71 showresult
73 starttest args
74 rm -f file.swf output.swf
75 cat > test.sc <<EOF
76 .flash
77 .box mybox 100 100
78 .put mybox end #should cause an error
79 .end
80 EOF
81 showfile test.sc
82 swfc test.sc
83 test -f output.swf && touch failed
84 showresult
86 starttest noend
87 rm -f file.swf output.swf
88 cat > test.sc <<EOF
89 .flash
90 EOF
91 showfile test.sc
92 swfc test.sc
93 test -f output.swf && touch failed
94 showresult
96 starttest nostart
97 rm -f file.swf output.swf
98 cat > test.sc <<EOF
99 .end
101 showfile test.sc
102 swfc test.sc
103 test -f output.swf && touch failed
104 showresult
106 starttest cws
107 rm -f output.swf
108 cat > test.sc <<EOF
109 .flash compress
110 .box mybox1 100 100
111 .box mybox2 100 100
112 .end
114 showfile test.sc
115 swfc test.sc
116 testswffile output.swf
117 ./swfdump output.swf | grep 'File is zlib compressed' >&6 2>&6 || touch failed
118 showresult
120 starttest nostart2
121 rm -f output.swf
122 cat > test.sc <<EOF
123 .box b 100 100
124 .end
126 showfile test.sc
127 swfc test.sc
128 test -f output.swf && touch failed
129 showresult
131 starttest nobrackets
132 rm -f output.swf
133 cat > test.sc <<EOF
134 .flash
135 .box box 100 100
136 .put box pin=0,0
137 .end
139 showfile test.sc
140 swfc test.sc
141 test -f output.swf && touch failed
142 showresult
144 starttest nofont
145 rm -f output.swf
146 cat > test.sc <<EOF
147 .flash
148 .font f1 "not_there.swf"
149 .text t1 font=f1 text="test"
150 .end
152 showfile test.sc
153 swfc test.sc
154 ls -l output.swf >&5
155 test -f output.swf && touch failed
156 showresult
158 echo -n '\e[00m' >&4
159 rm -f test.sc failed file1.swf file2.swf output.swf