/[jscoverage]/trunk/tests/proxy.sh
ViewVC logotype

Contents of /trunk/tests/proxy.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 610 - (show annotations)
Fri Sep 24 20:35:36 2010 UTC (9 years, 2 months ago) by siliconforks
File MIME type: application/x-sh
File size: 7645 byte(s)
Remove hard-coded port numbers.

1 #!/bin/sh
2 # proxy.sh - test jscoverage-server --proxy
3 # Copyright (C) 2008, 2009, 2010 siliconforks.com
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License along
16 # with this program; if not, write to the Free Software Foundation, Inc.,
17 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18
19 set -e
20
21 shutdown() {
22 wget -q -O- --post-data= "http://127.0.0.1:${proxy_server_port}/jscoverage-shutdown" > /dev/null
23 wait $proxy_server_pid
24 }
25
26 shutdown_perl() {
27 wget -q -O- --post-data= http://127.0.0.1:${origin_server_port}/perl-shutdown > /dev/null
28 wait $origin_server_pid
29 }
30
31 cleanup() {
32 rm -fr EXPECTED ACTUAL DIR OUT
33 shutdown
34 shutdown_perl
35 }
36
37 trap 'cleanup' 0 1 2 3 15
38
39 . ./common.sh
40
41 cd recursive
42 origin_server_port=`perl ../unused-port.pl`
43 perl ../server.pl $origin_server_port > /dev/null 2> /dev/null &
44 origin_server_pid=$!
45 cd ..
46
47 rm -fr DIR
48 mkdir DIR
49 proxy_server_port=`perl unused-port.pl`
50 $VALGRIND jscoverage-server --port=$proxy_server_port --no-highlight --proxy --report-dir=DIR > OUT 2> ERR &
51 proxy_server_pid=$!
52
53 wait_for_server http://127.0.0.1:${origin_server_port}/index.html
54 wait_for_server http://127.0.0.1:${proxy_server_port}/jscoverage.html
55
56 wget -q -O- -e "http_proxy=http://127.0.0.1:${proxy_server_port}/" http://127.0.0.1:${origin_server_port}/index.html | diff recursive/index.html -
57 wget -q -O- -e "http_proxy=http://127.0.0.1:${proxy_server_port}/" http://127.0.0.1:${origin_server_port}/style.css | diff recursive/style.css -
58 wget -q -O- -e "http_proxy=http://127.0.0.1:${proxy_server_port}/" http://127.0.0.1:${origin_server_port}/unix.txt | diff recursive/unix.txt -
59 wget -q -O- -e "http_proxy=http://127.0.0.1:${proxy_server_port}/" http://127.0.0.1:${origin_server_port}/windows.txt | diff recursive/windows.txt -
60 wget -q -O- -e "http_proxy=http://127.0.0.1:${proxy_server_port}/" http://127.0.0.1:${origin_server_port}/image.png | diff recursive/image.png -
61 wget -q -O- -e "http_proxy=http://127.0.0.1:${proxy_server_port}/" http://127.0.0.1:${origin_server_port}/x | diff recursive/x -
62 wget -q -O- -e "http_proxy=http://127.0.0.1:${proxy_server_port}/" http://127.0.0.1:${origin_server_port}/1/1.html | diff recursive/1/1.html -
63 wget -q -O- -e "http_proxy=http://127.0.0.1:${proxy_server_port}/" http://127.0.0.1:${origin_server_port}/1/1.css | diff recursive/1/1.css -
64 wget -q -O- -e "http_proxy=http://127.0.0.1:${proxy_server_port}/" http://127.0.0.1:${origin_server_port}/1/2/2.html | diff recursive/1/2/2.html -
65 wget -q -O- -e "http_proxy=http://127.0.0.1:${proxy_server_port}/" http://127.0.0.1:${origin_server_port}/1/2/2.css | diff recursive/1/2/2.css -
66
67 # test localhost
68 wget -q -O- -e "http_proxy=http://127.0.0.1:${proxy_server_port}/" http://localhost:${origin_server_port}/index.html | diff recursive/index.html -
69
70 # test actual hostname
71 h=`hostname`
72 wget -q -O- -e "http_proxy=http://127.0.0.1:${proxy_server_port}/" http://${h}:${origin_server_port}/index.html | diff recursive/index.html -
73
74 # test query string
75 wget -q -O- -e "http_proxy=http://127.0.0.1:${proxy_server_port}/" http://127.0.0.1:${origin_server_port}/index.html?foo | diff recursive/index.html -
76
77 # test POST
78 wget -q -O- -e "http_proxy=http://127.0.0.1:${proxy_server_port}/" --post-file=recursive/index.html http://127.0.0.1:${origin_server_port}/ | diff recursive/index.html -
79
80 # test javascript
81 wget -q -O- -e "http_proxy=http://127.0.0.1:${proxy_server_port}/" http://127.0.0.1:${origin_server_port}/script.js > OUT
82 cat ../report.js ../header.txt ../header.js recursive.expected/script.js | sed "s/@PREFIX@/http:\/\/127.0.0.1:${origin_server_port}\//g" | diff --strip-trailing-cr - OUT
83 wget -q -O- -e "http_proxy=http://127.0.0.1:${proxy_server_port}/" http://127.0.0.1:${origin_server_port}/1/1.js > OUT
84 cat ../report.js ../header.txt ../header.js recursive.expected/1/1.js | sed "s/@PREFIX@/http:\/\/127.0.0.1:${origin_server_port}\//g" | diff --strip-trailing-cr - OUT
85 wget -q -O- -e "http_proxy=http://127.0.0.1:${proxy_server_port}/" http://127.0.0.1:${origin_server_port}/1/2/2.js > OUT
86 cat ../report.js ../header.txt ../header.js recursive.expected/1/2/2.js | sed "s/@PREFIX@/http:\/\/127.0.0.1:${origin_server_port}\//g" | diff --strip-trailing-cr - OUT
87
88 ## test jscoverage
89 wget -q -O- -e "http_proxy=http://127.0.0.1:${proxy_server_port}/" http://siliconforks.com/jscoverage.html | diff ../jscoverage.html -
90 wget -q -O- -e "http_proxy=http://127.0.0.1:${proxy_server_port}/" http://siliconforks.com/jscoverage.css | diff ../jscoverage.css -
91 wget -q -O- -e "http_proxy=http://127.0.0.1:${proxy_server_port}/" http://siliconforks.com/jscoverage-throbber.gif | diff ../jscoverage-throbber.gif -
92 wget -q -O- -e "http_proxy=http://127.0.0.1:${proxy_server_port}/" http://siliconforks.com/jscoverage.js > OUT
93 echo 'jscoverage_isServer = true;' | cat ../jscoverage.js - | diff --strip-trailing-cr - OUT
94
95 # load/store
96 wget -q -O- -e "http_proxy=http://127.0.0.1:${proxy_server_port}/" --post-data='{}' http://siliconforks.com/jscoverage-store > /dev/null
97 echo -n '{}' | diff - DIR/jscoverage.json
98 diff ../jscoverage.html DIR/jscoverage.html
99 diff ../jscoverage.css DIR/jscoverage.css
100 diff ../jscoverage-throbber.gif DIR/jscoverage-throbber.gif
101 echo 'jscoverage_isReport = true;' | cat ../jscoverage.js - | diff --strip-trailing-cr - DIR/jscoverage.js
102
103 # send it an FTP request
104 echo 400 > EXPECTED
105 ! curl -f -w '%{http_code}\n' -x 127.0.0.1:${proxy_server_port} ftp://ftp.example.com 2> /dev/null > ACTUAL
106 diff EXPECTED ACTUAL
107
108 # nonexistent domain
109 echo 504 > EXPECTED
110 ! curl -f -w '%{http_code}\n' -x 127.0.0.1:${proxy_server_port} http://nonexistent 2> /dev/null > ACTUAL
111 diff EXPECTED ACTUAL
112
113 # 404 not found
114 echo 404 > EXPECTED
115 ! curl -f -w '%{http_code}\n' -x 127.0.0.1:${proxy_server_port} http://127.0.0.1:${origin_server_port}/missing 2> /dev/null > ACTUAL
116 diff EXPECTED ACTUAL
117 echo 404 > EXPECTED
118 ! curl -f -w '%{http_code}\n' -x 127.0.0.1:${proxy_server_port} http://siliconforks.com/jscoverage-missing 2> /dev/null > ACTUAL
119 diff EXPECTED ACTUAL
120
121 ## send it a server request
122 #echo 400 > EXPECTED
123 #! curl -f -w '%{http_code}\n' http://127.0.0.1:${proxy_server_port}/ 2> /dev/null > ACTUAL
124 #diff EXPECTED ACTUAL
125
126 # kill $proxy_server_pid
127 shutdown
128
129 proxy_server_port=`perl unused-port.pl`
130 $VALGRIND jscoverage-server --no-highlight --port=$proxy_server_port --proxy --report-dir=DIR --no-instrument=http://127.0.0.1:${origin_server_port}/1/ &
131 proxy_server_pid=$!
132
133 wait_for_server http://127.0.0.1:${proxy_server_port}/jscoverage.html
134
135 wget -q -O- -e "http_proxy=http://127.0.0.1:${proxy_server_port}/" http://127.0.0.1:${origin_server_port}/script.js > OUT
136 cat ../report.js ../header.txt ../header.js recursive.expected/script.js | sed "s/@PREFIX@/http:\/\/127.0.0.1:${origin_server_port}\//g" | diff --strip-trailing-cr - OUT
137 wget -q -O- -e "http_proxy=http://127.0.0.1:${proxy_server_port}/" http://127.0.0.1:${origin_server_port}/1/1.js | diff --strip-trailing-cr recursive/1/1.js -
138 wget -q -O- -e "http_proxy=http://127.0.0.1:${proxy_server_port}/" http://127.0.0.1:${origin_server_port}/1/2/2.js | diff --strip-trailing-cr recursive/1/2/2.js -

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.24