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

Annotation of /trunk/tests/proxy.sh

Parent Directory Parent Directory | Revision Log Revision Log


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

1 siliconforks 114 #!/bin/sh
2     # proxy.sh - test jscoverage-server --proxy
3 siliconforks 505 # Copyright (C) 2008, 2009, 2010 siliconforks.com
4 siliconforks 114 #
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 siliconforks 130 shutdown() {
22 siliconforks 114 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 siliconforks 130 shutdown_perl() {
27 siliconforks 610 wget -q -O- --post-data= http://127.0.0.1:${origin_server_port}/perl-shutdown > /dev/null
28 siliconforks 126 wait $origin_server_pid
29     }
30    
31 siliconforks 130 cleanup() {
32 siliconforks 114 rm -fr EXPECTED ACTUAL DIR OUT
33     shutdown
34 siliconforks 126 shutdown_perl
35 siliconforks 114 }
36    
37     trap 'cleanup' 0 1 2 3 15
38    
39 siliconforks 570 . ./common.sh
40 siliconforks 114
41     cd recursive
42 siliconforks 610 origin_server_port=`perl ../unused-port.pl`
43     perl ../server.pl $origin_server_port > /dev/null 2> /dev/null &
44 siliconforks 126 origin_server_pid=$!
45 siliconforks 114 cd ..
46    
47     rm -fr DIR
48     mkdir DIR
49 siliconforks 610 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 siliconforks 114 proxy_server_pid=$!
52    
53 siliconforks 610 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 siliconforks 114
56 siliconforks 610 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 siliconforks 114
67 siliconforks 250 # test localhost
68 siliconforks 610 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 siliconforks 250
70     # test actual hostname
71     h=`hostname`
72 siliconforks 610 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 siliconforks 250
74 siliconforks 114 # test query string
75 siliconforks 610 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 siliconforks 114
77     # test POST
78 siliconforks 610 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 siliconforks 114
80     # test javascript
81 siliconforks 610 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 siliconforks 114
88     ## test jscoverage
89 siliconforks 610 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 siliconforks 442 echo 'jscoverage_isServer = true;' | cat ../jscoverage.js - | diff --strip-trailing-cr - OUT
94 siliconforks 114
95     # load/store
96 siliconforks 610 wget -q -O- -e "http_proxy=http://127.0.0.1:${proxy_server_port}/" --post-data='{}' http://siliconforks.com/jscoverage-store > /dev/null
97 siliconforks 114 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 siliconforks 442 echo 'jscoverage_isReport = true;' | cat ../jscoverage.js - | diff --strip-trailing-cr - DIR/jscoverage.js
102 siliconforks 114
103 siliconforks 250 # send it an FTP request
104     echo 400 > EXPECTED
105 siliconforks 610 ! curl -f -w '%{http_code}\n' -x 127.0.0.1:${proxy_server_port} ftp://ftp.example.com 2> /dev/null > ACTUAL
106 siliconforks 250 diff EXPECTED ACTUAL
107 siliconforks 114
108 siliconforks 250 # nonexistent domain
109     echo 504 > EXPECTED
110 siliconforks 610 ! curl -f -w '%{http_code}\n' -x 127.0.0.1:${proxy_server_port} http://nonexistent 2> /dev/null > ACTUAL
111 siliconforks 250 diff EXPECTED ACTUAL
112    
113 siliconforks 114 # 404 not found
114     echo 404 > EXPECTED
115 siliconforks 610 ! 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 siliconforks 114 diff EXPECTED ACTUAL
117     echo 404 > EXPECTED
118 siliconforks 610 ! curl -f -w '%{http_code}\n' -x 127.0.0.1:${proxy_server_port} http://siliconforks.com/jscoverage-missing 2> /dev/null > ACTUAL
119 siliconforks 114 diff EXPECTED ACTUAL
120    
121     ## send it a server request
122     #echo 400 > EXPECTED
123 siliconforks 610 #! curl -f -w '%{http_code}\n' http://127.0.0.1:${proxy_server_port}/ 2> /dev/null > ACTUAL
124 siliconforks 114 #diff EXPECTED ACTUAL
125    
126     # kill $proxy_server_pid
127     shutdown
128    
129 siliconforks 610 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 siliconforks 114 proxy_server_pid=$!
132    
133 siliconforks 610 wait_for_server http://127.0.0.1:${proxy_server_port}/jscoverage.html
134 siliconforks 114
135 siliconforks 610 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