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

Annotation of /trunk/tests/charset.sh

Parent Directory Parent Directory | Revision Log Revision Log


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

1 siliconforks 251 #!/bin/sh
2     # charset.sh - test jscoverage-server with different charset values
3 siliconforks 505 # Copyright (C) 2008, 2009, 2010 siliconforks.com
4 siliconforks 251 #
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     cleanup() {
27     shutdown
28     kill -9 $origin_server_pid
29     }
30    
31     trap 'cleanup' 0 1 2 3 15
32    
33 siliconforks 529 . ./common.sh
34 siliconforks 251
35 siliconforks 314 if jscoverage-server --version | grep -q 'iconv\|MultiByteToWideChar'
36     then
37     character_encoding_support=yes
38     else
39     character_encoding_support=no
40     fi
41    
42 siliconforks 610 proxy_server_port=`perl unused-port.pl`
43     $VALGRIND jscoverage-server --port=$proxy_server_port --proxy --no-highlight > OUT 2> ERR &
44 siliconforks 251 proxy_server_pid=$!
45    
46 siliconforks 610 origin_server_port=`perl unused-port.pl`
47     ./http-server-charset $origin_server_port &
48 siliconforks 251 origin_server_pid=$!
49    
50 siliconforks 610 wait_for_server http://127.0.0.1:${origin_server_port}/utf-8.js
51     wait_for_server http://127.0.0.1:${proxy_server_port}/jscoverage.html
52 siliconforks 251
53 siliconforks 314 case "$character_encoding_support" in
54     yes)
55 siliconforks 529 rm -fr TMP
56 siliconforks 610 cat javascript-utf-8.expected/javascript-utf-8.js | sed "s/javascript-utf-8.js/http:\/\/127.0.0.1:${origin_server_port}\/utf-8.js/g" > TMP
57 siliconforks 529 add_header_to_file TMP EXPECTED
58     cat ../report.js EXPECTED > TMP
59     mv TMP EXPECTED
60 siliconforks 610 curl -s -x 127.0.0.1:${proxy_server_port} http://127.0.0.1:${origin_server_port}/utf-8.js > ACTUAL
61 siliconforks 314 diff EXPECTED ACTUAL
62     ;;
63     *)
64     echo 500 > EXPECTED
65 siliconforks 610 ! curl -f -w '%{http_code}\n' -x 127.0.0.1:${proxy_server_port} http://127.0.0.1:${origin_server_port}/utf-8.js 2> /dev/null > ACTUAL
66 siliconforks 314 diff EXPECTED ACTUAL
67     ;;
68     esac
69 siliconforks 251
70     shutdown
71    
72 siliconforks 610 proxy_server_port=`perl unused-port.pl`
73     $VALGRIND jscoverage-server --port=$proxy_server_port --proxy > OUT 2> ERR &
74 siliconforks 251 proxy_server_pid=$!
75    
76 siliconforks 610 wait_for_server http://127.0.0.1:${proxy_server_port}/jscoverage.html
77 siliconforks 251
78 siliconforks 314 case "$character_encoding_support" in
79     yes)
80 siliconforks 529 rm -fr TMP
81 siliconforks 610 cat javascript.expected/javascript-iso-8859-1.js | sed "s/javascript-iso-8859-1.js/http:\/\/127.0.0.1:${origin_server_port}\/iso-8859-1.js/g" > TMP
82 siliconforks 529 add_header_to_file TMP EXPECTED
83     cat ../report.js EXPECTED > TMP
84     mv TMP EXPECTED
85 siliconforks 610 curl -s -x 127.0.0.1:${proxy_server_port} http://127.0.0.1:${origin_server_port}/iso-8859-1.js > ACTUAL
86 siliconforks 314 diff EXPECTED ACTUAL
87     ;;
88     *)
89     echo 500 > EXPECTED
90 siliconforks 610 ! curl -f -w '%{http_code}\n' -x 127.0.0.1:${proxy_server_port} http://127.0.0.1:${origin_server_port}/iso-8859-1.js 2> /dev/null > ACTUAL
91 siliconforks 314 diff EXPECTED ACTUAL
92     ;;
93     esac
94 siliconforks 256
95     # bogus charset
96 siliconforks 314 echo 500 > EXPECTED
97 siliconforks 610 ! curl -f -w '%{http_code}\n' -x 127.0.0.1:${proxy_server_port} http://127.0.0.1:${origin_server_port}/bogus.js 2> /dev/null > ACTUAL
98 siliconforks 256 diff EXPECTED ACTUAL
99    
100     # malformed encoding
101 siliconforks 314 case "$character_encoding_support" in
102     yes)
103     status=502
104     ;;
105     *)
106     status=500
107     ;;
108     esac
109     echo $status > EXPECTED
110 siliconforks 610 ! curl -f -w '%{http_code}\n' -x 127.0.0.1:${proxy_server_port} http://127.0.0.1:${origin_server_port}/malformed.js 2> /dev/null > ACTUAL
111 siliconforks 256 diff EXPECTED ACTUAL

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.24