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

Contents of /trunk/tests/charset.sh

Parent Directory Parent Directory | Revision Log Revision Log


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

1 #!/bin/sh
2 # charset.sh - test jscoverage-server with different charset values
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 cleanup() {
27 shutdown
28 kill -9 $origin_server_pid
29 }
30
31 trap 'cleanup' 0 1 2 3 15
32
33 . ./common.sh
34
35 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 proxy_server_port=`perl unused-port.pl`
43 $VALGRIND jscoverage-server --port=$proxy_server_port --proxy --no-highlight > OUT 2> ERR &
44 proxy_server_pid=$!
45
46 origin_server_port=`perl unused-port.pl`
47 ./http-server-charset $origin_server_port &
48 origin_server_pid=$!
49
50 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
53 case "$character_encoding_support" in
54 yes)
55 rm -fr TMP
56 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 add_header_to_file TMP EXPECTED
58 cat ../report.js EXPECTED > TMP
59 mv TMP EXPECTED
60 curl -s -x 127.0.0.1:${proxy_server_port} http://127.0.0.1:${origin_server_port}/utf-8.js > ACTUAL
61 diff EXPECTED ACTUAL
62 ;;
63 *)
64 echo 500 > EXPECTED
65 ! 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 diff EXPECTED ACTUAL
67 ;;
68 esac
69
70 shutdown
71
72 proxy_server_port=`perl unused-port.pl`
73 $VALGRIND jscoverage-server --port=$proxy_server_port --proxy > OUT 2> ERR &
74 proxy_server_pid=$!
75
76 wait_for_server http://127.0.0.1:${proxy_server_port}/jscoverage.html
77
78 case "$character_encoding_support" in
79 yes)
80 rm -fr TMP
81 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 add_header_to_file TMP EXPECTED
83 cat ../report.js EXPECTED > TMP
84 mv TMP EXPECTED
85 curl -s -x 127.0.0.1:${proxy_server_port} http://127.0.0.1:${origin_server_port}/iso-8859-1.js > ACTUAL
86 diff EXPECTED ACTUAL
87 ;;
88 *)
89 echo 500 > EXPECTED
90 ! 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 diff EXPECTED ACTUAL
92 ;;
93 esac
94
95 # bogus charset
96 echo 500 > EXPECTED
97 ! 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 diff EXPECTED ACTUAL
99
100 # malformed encoding
101 case "$character_encoding_support" in
102 yes)
103 status=502
104 ;;
105 *)
106 status=500
107 ;;
108 esac
109 echo $status > EXPECTED
110 ! 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 diff EXPECTED ACTUAL

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.24