Changeset 44437 in vbox for trunk/src/VBox/Installer/linux/testcase
- Timestamp:
- Jan 29, 2013 7:33:05 AM (12 years ago)
- svn:sync-xref-src-repo-rev:
- 83421
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Installer/linux/testcase/tstInstallInit.sh
r44119 r44437 68 68 } 69 69 70 # Create a trivial test command in temporary directory $1 with name $2. 71 test_oneshot() 72 { 73 cat > "${1}/${2}" << EOF 74 #!/bin/sh 75 if test "\${1}" = start; then 76 touch "${1}/started" 77 else 78 rm "${1}/started" 79 fi 80 exit 0 81 EOF 82 chmod u+x "${1}/${2}" 83 } 84 70 85 # Test some dodgy input values against generate_service_file. 86 # Make sure there is a substitution pattern at the end too. 71 87 print_line "generation of shell script from template." 72 input='TEST1%DESCRIPTION%%%%SERVICE_NAME% TST2 TEST %ARGUMENTS%%COMMAND%'88 input='TEST1%DESCRIPTION%%%%SERVICE_NAME%%STOP_COMMAND% TST2 TEST %ARGUMENTS%%COMMAND%' 73 89 out=`echo "${input}" | 74 90 helpers/generate_service_file --command '/usr/bin … … 82 98 world'\' 83 99 case "${out}" in ${expected}) 84 echo "SUCCESS";; 100 echo "SUCCESS (1)";; 101 *) 102 cat << EOF 103 FAILED: expected 104 ${expected} 105 but got 106 ${out} 107 EOF 108 esac 109 input='TEST%HAVE_STOP_COMMAND%%SERVICE_NAME%%STOP_COMMAND% TST2 110 TEST %COMMAND%' 111 out=`echo "${input}" | 112 helpers/generate_service_file --command '/usr/bin/hello' --format shell --description ''` 113 expected='TEST TEST '\''/usr/bin/hello'\''' 114 case "${out}" in ${expected}) 115 echo "SUCCESS (2)";; 116 *) 117 cat << EOF 118 FAILED: expected 119 ${expected} 120 but got 121 ${out} 122 EOF 123 esac 124 input='TEST%HAVE_STOP_COMMAND%%SERVICE_NAME%%STOP_COMMAND% %STOP_ARGUMENTS% TST2 125 TEST %COMMAND%' 126 out=`echo "${input}" | 127 helpers/generate_service_file --command '/usr/bin/hello' --format shell --description '' --stop-command /usr/bin/stop --stop-arguments hello` 128 expected='TESThello'\''/usr/bin/stop'\'' '\''hello'\'' TST2 129 TEST '\''/usr/bin/hello'\''' 130 case "${out}" in ${expected}) 131 echo "SUCCESS (3)";; 85 132 *) 86 133 cat << EOF … … 115 162 test_service "${tmpdir}" "service" 116 163 # And install it. 117 scripts/install_service --command "${tmpdir}/service" --arguments "test of my\ arguments" --description "My description" --prefix "${tmpdir}" --enable||164 scripts/install_service --prefix "${tmpdir}" --enable -- --command "${tmpdir}/service" --arguments "test of my\ arguments" --description "My description" || 118 165 fail_msg "\"scripts/install_service\" failed." 119 166 # Check that the main service file was created as specified. … … 159 206 fi 160 207 208 # Test an one shot init script installation. 209 print_line "installing a one shot init script." 210 failed="" 211 # Create a simulated init system layout. 212 tmpdir="${tmpbase}0" 213 create_simulated_init_tree "${tmpdir}" 214 # Create the command binary. 215 test_oneshot "${tmpdir}" "command" 216 # And install the script. 217 scripts/install_service --prefix "${tmpdir}" --enable -- --command "${tmpdir}/command" --arguments "start" --description "My description" --stop-command "${tmpdir}/command" --stop-arguments "stop" --one-shot || 218 fail_msg "\"scripts/install_service\" failed." 219 # Sanity test. 220 test -f "${tmpdir}/started" && 221 fail_msg "\"${tmpdir}/started\" already exists!" 222 # Try to start the service using the symbolic links which should have been 223 # created. 224 if "${tmpdir}/rc3.d/S20command" --prefix "${tmpdir}" --lsb-functions "" start >/dev/null 2>&1; then 225 test -f "${tmpdir}/started" || 226 fail_msg "\"${tmpdir}/rc3.d/S20command\" did not start correctly." 227 else 228 fail_msg "could not start \"${tmpdir}/rc3.d/S20command\"." 229 fi 230 # Try to stop the service using the symbolic links which should have been 231 # created. 232 if "${tmpdir}/rc.d/rc6.d/K80command" --prefix "${tmpdir}" --lsb-functions "" stop >/dev/null 2>&1; then 233 test -f "${tmpdir}/started" && 234 echo "\"${tmpdir}/rc.d/rc6.d/K80command\" did not stop correctly." 235 else 236 fail_msg "could not stop \"${tmpdir}/rc.d/rc6.d/K80command\"." 237 fi 238 # Final summary. 239 if test -n "${failed}"; then 240 echo "${failed}" 241 else 242 echo SUCCESS 243 fi 244 161 245 # Test an init script removal. 162 246 print_line "removing an init script." … … 168 252 test_service "${tmpdir}" "service" 169 253 # Install it. 170 scripts/install_service -- command "${tmpdir}/service" --arguments "test of my\ arguments" --description "My description" --prefix "${tmpdir}" --enable||254 scripts/install_service --prefix "${tmpdir}" --enable -- --command "${tmpdir}/service" --arguments "test of my\ arguments" --description "My description" || 171 255 fail_msg "\"scripts/install_service\" failed." 172 256 # And remove it again. 173 scripts/install_service -- command "${tmpdir}/service" --prefix "${tmpdir}" --remove||257 scripts/install_service --prefix "${tmpdir}" --remove -- --command "${tmpdir}/service" || 174 258 fail_msg "\"scripts/install_service\" failed." 175 259 # After uninstallation this should be the only file left in the init tree. … … 193 277 test_service "${tmpdir}" "service" 194 278 # Install it. 195 scripts/install_service -- command "${tmpdir}/service" --arguments "test of my\ arguments" --description "My description" --prefix "${tmpdir}" --enable||279 scripts/install_service --prefix "${tmpdir}" --enable -- --command "${tmpdir}/service" --arguments "test of my\ arguments" --description "My description" || 196 280 fail_msg "\"scripts/install_service\" failed." 197 281 # Install it disabled without forcing. 198 scripts/install_service -- command "${tmpdir}/service" --arguments "test of my\ arguments" --description "My description" --prefix "${tmpdir}" --disable||282 scripts/install_service --prefix "${tmpdir}" --disable -- --command "${tmpdir}/service" --arguments "test of my\ arguments" --description "My description" || 199 283 fail_msg "\"scripts/install_service\" failed." 200 284 test "x`find "${tmpdir}"/rc*.d "${tmpdir}/runlevel" -type l | wc -l`" = "x15" || … … 216 300 test_service "${tmpdir}" "service" 217 301 # Install it. 218 scripts/install_service -- command "${tmpdir}/service" --arguments "test of my\ arguments" --description "My description" --prefix "${tmpdir}" --disable||302 scripts/install_service --prefix "${tmpdir}" --disable -- --command "${tmpdir}/service" --arguments "test of my\ arguments" --description "My description" || 219 303 fail_msg "\"scripts/install_service\" failed." 220 304 # Install it disabled without forcing. 221 scripts/install_service -- command "${tmpdir}/service" --arguments "test of my\ arguments" --description "My description" --prefix "${tmpdir}" --enable||305 scripts/install_service --prefix "${tmpdir}" --enable -- --command "${tmpdir}/service" --arguments "test of my\ arguments" --description "My description" || 222 306 fail_msg "\"scripts/install_service\" failed." 223 307 test "x`find "${tmpdir}"/rc*.d "${tmpdir}/runlevel" -type l`" = "x" || … … 239 323 test_service "${tmpdir}" "service" 240 324 # Install it. 241 scripts/install_service -- command "${tmpdir}/service" --arguments "test of my\ arguments" --description "My description" --prefix "${tmpdir}" --enable||325 scripts/install_service --prefix "${tmpdir}" --enable -- --command "${tmpdir}/service" --arguments "test of my\ arguments" --description "My description" || 242 326 fail_msg "\"scripts/install_service\" failed." 243 327 # Install it disabled without forcing. 244 scripts/install_service -- command "${tmpdir}/service" --arguments "test of my\ arguments" --description "My description" --prefix "${tmpdir}" --force-disable||328 scripts/install_service --prefix "${tmpdir}" --force-disable -- --command "${tmpdir}/service" --arguments "test of my\ arguments" --description "My description" || 245 329 fail_msg "\"scripts/install_service\" failed." 246 330 test "x`find "${tmpdir}"/rc*.d "${tmpdir}/runlevel" -type l`" = "x" || … … 262 346 test_service "${tmpdir}" "service" 263 347 # Install it. 264 scripts/install_service -- command "${tmpdir}/service" --arguments "test of my\ arguments" --description "My description" --prefix "${tmpdir}" --disable||348 scripts/install_service --prefix "${tmpdir}" --disable -- --command "${tmpdir}/service" --arguments "test of my\ arguments" --description "My description" || 265 349 fail_msg "\"scripts/install_service\" failed." 266 350 # Install it disabled without forcing. 267 scripts/install_service -- command "${tmpdir}/service" --arguments "test of my\ arguments" --description "My description" --prefix "${tmpdir}" --force-enable||351 scripts/install_service --prefix "${tmpdir}" --force-enable -- --command "${tmpdir}/service" --arguments "test of my\ arguments" --description "My description" || 268 352 fail_msg "\"scripts/install_service\" failed." 269 353 test "x`find "${tmpdir}"/rc*.d "${tmpdir}/runlevel" -type l | wc -l`" = "x15" ||
Note:
See TracChangeset
for help on using the changeset viewer.