Add new certificateProvider extension API.
[chromium-blink-merge.git] / chrome / installer / mac / keystone_install_test.sh
blobbc49c3271cf7f18c899d4042deece7de13b810a9
1 #!/bin/bash
3 # Copyright (c) 2009 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file.
7 # Test of the Mac Chrome installer.
10 # Where I am
11 DIR=$(dirname "${0}")
13 # My installer to test
14 INSTALLER="${DIR}"/keystone_install.sh
15 if [ ! -f "${INSTALLER}" ]; then
16 echo "Can't find scripts." >& 2
17 exit 1
20 # What I test
21 PRODNAME="Google Chrome"
22 APPNAME="${PRODNAME}.app"
23 FWKNAME="${PRODNAME} Framework.framework"
25 # The version number for fake ksadmin to pretend to be
26 KSADMIN_VERSION_LIE="1.0.7.1306"
28 # Temp directory to be used as the disk image (source)
29 TEMPDIR=$(mktemp -d -t $(basename ${0}))
30 PATH=$PATH:"${TEMPDIR}"
32 # Clean up the temp directory
33 function cleanup_tempdir() {
34 chmod u+w "${TEMPDIR}"
35 rm -rf "${TEMPDIR}"
38 # Run the installer and make sure it fails.
39 # If it succeeds, we fail.
40 # Arg0: string to print
41 function fail_installer() {
42 echo $1
43 "${INSTALLER}" "${TEMPDIR}" >& /dev/null
44 RETURN=$?
45 if [ $RETURN -eq 0 ]; then
46 echo "Did not fail (which is a failure)" >& 2
47 cleanup_tempdir
48 exit 1
49 else
50 echo "Returns $RETURN"
54 # Make sure installer works!
55 # Arg0: string to print
56 function pass_installer() {
57 echo $1
58 "${INSTALLER}" "${TEMPDIR}" >& /dev/null
59 RETURN=$?
60 if [ $RETURN -ne 0 ]; then
61 echo "FAILED; returned $RETURN but should have worked" >& 2
62 cleanup_tempdir
63 exit 1
64 else
65 echo "worked"
69 # Make an old-style destination directory, to test updating from old-style
70 # versions to new-style versions.
71 function make_old_dest() {
72 DEST="${TEMPDIR}"/Dest.app
73 rm -rf "${DEST}"
74 mkdir -p "${DEST}"/Contents
75 defaults write "${DEST}/Contents/Info" KSVersion 0
76 cat >"${TEMPDIR}"/ksadmin <<EOF
77 #!/bin/sh
78 if [ "\${1}" = "--ksadmin-version" ] ; then
79 echo "${KSADMIN_VERSION_LIE}"
80 exit 0
82 if [ -z "\${FAKE_SYSTEM_TICKET}" ] && [ "\${1}" = "-S" ] ; then
83 echo no system tix! >& 2
84 exit 1
86 echo " xc=<KSPathExistenceChecker:0x45 path=${DEST}>"
87 exit 0
88 EOF
89 chmod u+x "${TEMPDIR}"/ksadmin
92 # Make a new-style destination directory, to test updating between new-style
93 # versions.
94 function make_new_dest() {
95 DEST="${TEMPDIR}"/Dest.app
96 rm -rf "${DEST}"
97 defaults write "${DEST}/Contents/Info" CFBundleShortVersionString 0
98 defaults write "${DEST}/Contents/Info" KSVersion 0
99 cat >"${TEMPDIR}"/ksadmin <<EOF
100 #!/bin/sh
101 if [ "\${1}" = "--ksadmin-version" ] ; then
102 echo "${KSADMIN_VERSION_LIE}"
103 exit 0
105 if [ -z "\${FAKE_SYSTEM_TICKET}" ] && [ "\${1}" = "-S" ] ; then
106 echo no system tix! >& 2
107 exit 1
109 echo " xc=<KSPathExistenceChecker:0x45 path=${DEST}>"
110 exit 0
112 chmod u+x "${TEMPDIR}"/ksadmin
115 # Make a simple source directory - the update that is to be applied
116 function make_src() {
117 chmod ugo+w "${TEMPDIR}"
118 rm -rf "${TEMPDIR}/${APPNAME}"
119 RSRCDIR="${TEMPDIR}/${APPNAME}/Contents/Versions/1/${FWKNAME}/Resources"
120 mkdir -p "${RSRCDIR}"
121 defaults write "${TEMPDIR}/${APPNAME}/Contents/Info" \
122 CFBundleShortVersionString "1"
123 defaults write "${TEMPDIR}/${APPNAME}/Contents/Info" \
124 KSProductID "com.google.Chrome"
125 defaults write "${TEMPDIR}/${APPNAME}/Contents/Info" \
126 KSVersion "2"
129 function make_basic_src_and_dest() {
130 make_src
131 make_new_dest
134 fail_installer "No source anything"
136 mkdir "${TEMPDIR}"/"${APPNAME}"
137 fail_installer "No source bundle"
139 make_basic_src_and_dest
140 chmod ugo-w "${TEMPDIR}"
141 fail_installer "Writable dest directory"
143 make_basic_src_and_dest
144 fail_installer "Was no KSUpdateURL in dest after copy"
146 make_basic_src_and_dest
147 defaults write "${TEMPDIR}/${APPNAME}/Contents/Info" KSUpdateURL "http://foobar"
148 export FAKE_SYSTEM_TICKET=1
149 fail_installer "User and system ticket both present"
150 export -n FAKE_SYSTEM_TICKET
152 make_src
153 make_old_dest
154 defaults write "${TEMPDIR}/${APPNAME}/Contents/Info" KSUpdateURL "http://foobar"
155 pass_installer "Old-style update"
157 make_basic_src_and_dest
158 defaults write "${TEMPDIR}/${APPNAME}/Contents/Info" KSUpdateURL "http://foobar"
159 pass_installer "ALL"
161 cleanup_tempdir