Bug 470455 - test_database_sync_embed_visits.js leaks, r=sdwilsh
[wine-gecko.git] / testing / sisyphus / tests / mozilla.org / download-page / test.sh
blob0d479743501b2a8f5b20f4c4dbaa56c29598764c
1 #!/bin/bash -e
3 if [[ -z "$TEST_DIR" ]]; then
4 cat <<EOF
5 `basename $0`: error
7 TEST_DIR, the location of the Sisyphus framework,
8 is required to be set prior to calling this script.
9 EOF
10 exit 2
13 source $TEST_DIR/bin/library.sh
15 TEST_DOWNLOAD_PAGE_TIMEOUT=${TEST_DOWNLOAD_PAGE_TIMEOUT:-60}
16 TEST_DOWNLOAD_BUILD_TIMEOUT=${TEST_DOWNLOAD_BUILD_TIMEOUT:-900}
19 # options processing
21 options="u:t:p:b:x:c:N:d:"
22 function usage()
24 cat <<EOF
25 usage:
26 $SCRIPT -u allurl -t test -p product -b branch -N profilename -x executablepath
27 -c credentials [-d datafiles]
29 variable description
30 =============== ============================================================
31 -u allurl required. location to find download "all" page.
32 -t test required. all for download page. ftp for ftp directory
33 -p product required. firefox|thunderbird
34 -b branch required. 1.8.0|1.8.1|1.9.0
35 -x executablepath required. directory-tree containing executable 'product'
36 -c credentials optional. user:password if required for authentication
37 -N profilename required. profile name
38 -d datafiles optional. one or more filenames of files containing
39 environment variable definitions to be included.
41 note that the environment variables should have the same
42 names as in the "variable" column.
45 allurl =$allurl
46 test =$test
47 product =$product
48 branch =$branch
49 profilename =$profilename
50 executablepath =$executablepath
51 credentials =$credentials
52 datafiles =$datafiles
54 EOF
55 exit 2
58 unset allurl test product branch profilename executablepath credentials datafiles
60 while getopts $options optname ;
61 do
62 case $optname in
63 u) allurl=$OPTARG;;
64 t) test=$OPTARG;;
65 p) product=$OPTARG;;
66 b) branch=$OPTARG;;
67 N) profilename=$OPTARG;;
68 x) executablepath=$OPTARG;;
69 c) credentials="-c $OPTARG";;
70 d) datafiles=$OPTARG;;
71 esac
72 done
74 # include environment variables
75 if [[ -n "$datafiles" ]]; then
76 for datafile in $datafiles; do
77 source $datafile
78 done
81 if [[ -z "$allurl" || -z "$test" || \
82 -z "$product" || -z "$branch" || -z "$profilename" || \
83 -z "$executablepath" ]]; then
84 usage
87 executable=`get_executable $product $branch $executablepath`
89 urlfile=`mktemp /tmp/URLS.XXXX`
91 if [[ "$test" == "all" ]]; then
92 $TEST_DIR/bin/timed_run.py $TEST_DOWNLOAD_PAGE_TIMEOUT "test download" \
93 $EXECUTABLE_DRIVER \
94 "$executable" -P "$profilename" -spider -start -quit \
95 -uri "$allurl" -timeout=$TEST_DOWNLOAD_PAGE_TIMEOUT \
96 -hook "http://$TEST_HTTP/tests/mozilla.org/download-page/collect-urls-userhook.js" | \
97 grep 'href: ' | sed 's/^href: //' > $urlfile
98 elif [[ "$test" == "ftp" ]]; then
99 $TEST_DIR/bin/timed_run.py $TEST_DOWNLOAD_PAGE_TIMEOUT "test download" \
100 $EXECUTABLE_DRIVER \
101 "$executable" -P "$profilename" -spider -start -quit \
102 -uri "$allurl" -timeout=$TEST_DOWNLOAD_PAGE_TIMEOUT \
103 -hook "http://$TEST_HTTP/tests/mozilla.org/download-page/userhook-ftp.js" | \
104 grep 'href: ' | sed 's/^href: //' > $urlfile
107 cat $urlfile | while read url; do
109 echo "Processing $url"
111 if [[ "$test" == "all" ]]; then
112 downloadproduct=`echo $url | sed 's|.*product=\([^\-]*\).*|\1|'`
113 downloadversion=`echo $url | sed 's|.*product=[^\-]*-\([0-9.]*\).*|\1|'`
114 elif [[ "$test" == "ftp" ]]; then
115 downloadproduct=`echo $url | sed 's|.*/\([a-zA-Z]*\)-[^/]*|\1|'`
116 downloadversion=`echo $url | sed 's|\(.*\)/\([^/]*\)|\2|' | sed 's|[a-zA-Z]*-\([0-9.]*\)\..*|\1|'`
119 echo "downloadproduct=$downloadproduct"
120 echo "downloadversion=$downloadversion"
122 case "$downloadversion" in
123 1.5*)
124 downloadbranch="1.8.0"
126 2.*)
127 downloadbranch="1.8.1"
129 3.*)
130 downloadbranch="1.9.0"
133 echo "unknown download branch: $downloadbranch"
134 exit 2
136 esac
138 filepath=`mktemp /tmp/DOWNLOAD.XXXXXX`
140 downloadexecutablepath="/tmp/download-$downloadproduct-$downloadbranch"
141 downloadprofilepath="/tmp/download-$downloadproduct-$downloadbranch-profile"
142 downloadprofilename="download-$downloadproduct-$downloadbranch-profile"
144 if ! download.sh -u "$url" -f $filepath $credentials; then
145 continue;
148 if ! install-build.sh -p "$downloadproduct" -b "$downloadbranch" \
149 -x $downloadexecutablepath \
150 -f $filepath; then
151 continue
154 rm $filepath
156 if [[ "$downloadproduct" == "thunderbird" ]]; then
157 template="-L $TEST_DIR/profiles/imap"
158 else
159 unset template
162 if ! create-profile.sh -p "$downloadproduct" -b "$downloadbranch" \
163 -x $downloadexecutablepath \
164 -D $downloadprofilepath \
165 -N $downloadprofilename \
166 -U $TEST_DIR/prefs/mail-user.js \
167 $template; then
168 continue
171 if ! install-extensions.sh -p "$downloadproduct" -b "$downloadbranch" \
172 -x $downloadexecutablepath \
173 -N $downloadprofilename \
174 -E $TEST_DIR/xpi; then
175 continue
178 if ! check-spider.sh -p "$downloadproduct" -b "$downloadbranch" \
179 -x $downloadexecutablepath \
180 -N $downloadprofilename; then
181 continue
184 downloadexecutable=`get_executable $downloadproduct $downloadbranch $downloadexecutablepath`
186 $TEST_DIR/bin/timed_run.py $TEST_DOWNLOAD_BUILD_TIMEOUT "..." \
187 $EXECUTABLE_DRIVER \
188 "$downloadexecutable" \
189 -spider -P $downloadprofilename \
190 -uri "http://$TEST_HTTP/bin/buildinfo.html" \
191 -hook "http://$TEST_HTTP/tests/mozilla.org/download-page/userhook.js" \
192 -start -quit
194 if ! uninstall-build.sh -p "$downloadproduct" -b "$downloadbranch" \
195 -x $downloadexecutablepath; then
196 continue
199 done
201 rm $urlfile