summaryrefslogtreecommitdiff
path: root/src/VBox/Installer/linux/testcase
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@baserock.org>2014-03-26 19:21:20 +0000
committer <>2014-05-08 15:03:54 +0000
commitfb123f93f9f5ce42c8e5785d2f8e0edaf951740e (patch)
treec2103d76aec5f1f10892cd1d3a38e24f665ae5db /src/VBox/Installer/linux/testcase
parent58ed4748338f9466599adfc8a9171280ed99e23f (diff)
downloadVirtualBox-master.tar.gz
Imported from /home/lorry/working-area/delta_VirtualBox/VirtualBox-4.3.10.tar.bz2.HEADVirtualBox-4.3.10master
Diffstat (limited to 'src/VBox/Installer/linux/testcase')
-rw-r--r--src/VBox/Installer/linux/testcase/Makefile.kmk12
-rwxr-xr-xsrc/VBox/Installer/linux/testcase/tstHeadlessXOrg.sh305
-rwxr-xr-xsrc/VBox/Installer/linux/testcase/tstInstallInit.sh365
-rwxr-xr-xsrc/VBox/Installer/linux/testcase/tstInstallerLinux.sh2
4 files changed, 683 insertions, 1 deletions
diff --git a/src/VBox/Installer/linux/testcase/Makefile.kmk b/src/VBox/Installer/linux/testcase/Makefile.kmk
index 7b365f84..c1d8d8de 100644
--- a/src/VBox/Installer/linux/testcase/Makefile.kmk
+++ b/src/VBox/Installer/linux/testcase/Makefile.kmk
@@ -38,4 +38,16 @@ $$(tstInstallerLinux_0_OUTDIR)/tstInstallerLinux.sh: \
$<
$(QUIET)$(CHMOD) a+rx,u+w $@
+INSTALLS += tstHeadlessXOrg
+TESTING += tstHeadlessXOrg
+tstHeadlessXOrg_INST = $(INST_TESTCASE)
+tstHeadlessXOrg_MODE = a+rx,u+w
+tstHeadlessXOrg_SOURCES = tstHeadlessXOrg.sh
+
+INSTALLS += tstInstallInit
+TESTING += tstInstallInit
+tstInstallInit_INST = $(INST_TESTCASE)
+tstInstallInit_MODE = a+rx,u+w
+tstInstallInit_SOURCES = tstInstallInit.sh
+
include $(FILE_KBUILD_SUB_FOOTER)
diff --git a/src/VBox/Installer/linux/testcase/tstHeadlessXOrg.sh b/src/VBox/Installer/linux/testcase/tstHeadlessXOrg.sh
new file mode 100755
index 00000000..ba00e85e
--- /dev/null
+++ b/src/VBox/Installer/linux/testcase/tstHeadlessXOrg.sh
@@ -0,0 +1,305 @@
+#!/bin/sh
+# $Id: tstHeadlessXOrg.sh $
+## @file
+# VirtualBox X Server auto-start service unit test.
+#
+
+#
+# Copyright (C) 2012-2013 Oracle Corporation
+#
+# This file is part of VirtualBox Open Source Edition (OSE), as
+# available from http://www.virtualbox.org. This file is free software;
+# you can redistribute it and/or modify it under the terms of the GNU
+# General Public License (GPL) as published by the Free Software
+# Foundation, in version 2 as it comes in the "COPYING" file of the
+# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+#
+
+## The function definition at the start of every non-trivial shell script!
+abort()
+{
+ ## $@, ... Error text to output to standard error in printf format.
+ format="$1"
+ shift
+ printf "${TEST_NAME}: ${format}" "$@" >&2
+ exit 1
+}
+
+## Print a TESTING line. Takes printf arguments but without a '\n'.
+print_line()
+{
+ format="$1"
+ shift
+ printf "${TEST_NAME}: TESTING ${format}... " "$@"
+}
+
+## Expected a process to complete within a certain time and call a function if
+# it does which should check whether the test was successful and print status
+# information. The function takes the exit status as its single parameter.
+expect_exit()
+{
+ PID="$1" ## The PID we are waiting for.
+ TIME_OUT="$2" ## The time-out before we terminate the process.
+ TEST_FUNCTION="$3" ## The function to call on exit to check the test result.
+
+ # Give it time to complete.
+ { sleep "${TIME_OUT}"; kill "${PID}" 2>/dev/null; } &
+
+ wait "${PID}"
+ STATUS="$?"
+ case "${STATUS}" in
+ 143) # SIGTERM
+ printf "\nFAILED: time-out.\n"
+ ;;
+ *)
+ ${TEST_FUNCTION} "${STATUS}"
+esac
+}
+
+## Create a simple configuration file. Add items onto the end to override them
+# on an item-by-item basis.
+create_basic_configuration()
+{
+ TEST_FOLDER="${1}"
+ FILE_NAME="${TEST_FOLDER}conf" ## The name of the configuration file to create.
+ BASE_FOLDER="${TEST_FOLDER}"
+ XORG_FOLDER="${TEST_FOLDER}/xorg"
+ mkdir -p "${XORG_FOLDER}"
+ cat > "${FILE_NAME}" << EOF
+HEADLESS_X_ORG_CONFIGURATION_FOLDER="${BASE_FOLDER}/xorg"
+HEADLESS_X_ORG_LOG_FOLDER="${BASE_FOLDER}/log"
+HEADLESS_X_ORG_LOG_FILE="log"
+HEADLESS_X_ORG_RUN_FOLDER="${BASE_FOLDER}/run"
+HEADLESS_X_ORG_WAIT_FOR_PREREQUISITES="true"
+HEADLESS_X_ORG_SERVER_PRE_COMMAND=
+HEADLESS_X_ORG_SERVER_COMMAND="echo"
+EOF
+
+}
+
+# Get the directory where the script is located and the parent.
+OUR_FOLDER="$(dirname "$0")"
+OUR_FOLDER=$(cd "${OUR_FOLDER}" && pwd)
+VBOX_FOLDER=$(cd "${OUR_FOLDER}/.." && pwd)
+[ -d "${VBOX_FOLDER}" ] ||
+ abort "Failed to change to directory ${VBOX_FOLDER}.\n"
+cd "${VBOX_FOLDER}"
+
+# Get our name for output.
+TEST_NAME="$(basename "$0" .sh)"
+
+# And remember the full path.
+TEST_NAME_FULL="${OUR_FOLDER}/$(basename "$0")"
+
+# Create a temporary directory for configuration and logging.
+TEST_FOLDER_BASE="/tmp/${TEST_NAME} 99/" # Space in the name to test quoting.
+if [ -n "${TESTBOX_PATH_SCRATCH}" ]; then
+ TEST_FOLDER_BASE="${TESTBOX_PATH_SCRATCH}/${TEST_NAME} 99/"
+fi
+{
+ rm -rf "${TEST_FOLDER_BASE}" 2>/dev/null &&
+ mkdir -m 0700 "${TEST_FOLDER_BASE}" 2>/dev/null
+} || abort "Could not create test folder (${TEST_FOLDER_BASE}).\n"
+
+###############################################################################
+# Simple start-up test. #
+###############################################################################
+print_line "simple start-up test"
+create_basic_configuration "${TEST_FOLDER_BASE}simple_start-up_test/"
+touch "${XORG_FOLDER}/xorg.conf.2"
+touch "${XORG_FOLDER}/xorg.conf.4"
+
+test_simple_start_up()
+{
+ STATUS="$1"
+ case "${STATUS}" in
+ 0)
+ LOG_FOLDER="${TEST_FOLDER}/log"
+ LOG="${LOG_FOLDER}/log"
+ if grep -q "2 ${XORG_FOLDER}/xorg.conf.2 ${LOG_FOLDER}/Xorg.2.log" "${LOG}" &&
+ grep -q "4 ${XORG_FOLDER}/xorg.conf.4 ${LOG_FOLDER}/Xorg.4.log" "${LOG}"; then
+ printf "SUCCESS.\n"
+ else
+ printf "\nFAILED: incorrect log output.\n"
+ fi
+ ;;
+ *)
+ printf "\nFAILED: exit status ${STATUS}.\n"
+ esac
+}
+
+scripts/VBoxHeadlessXOrg.sh -c "${TEST_FOLDER}conf" &
+PID=$!
+expect_exit "${PID}" 5 test_simple_start_up
+
+###############################################################################
+# No configuration files. #
+###############################################################################
+create_basic_configuration "${TEST_FOLDER_BASE}no_configuration_files/"
+print_line "no configuration files"
+
+test_should_fail()
+{
+ STATUS="$1"
+ case "${STATUS}" in
+ 0)
+ printf "\nFAILED: successful exit when an error was expected.\n"
+ ;;
+ *)
+ printf "SUCCESS.\n" # At least it behaved the way we wanted.
+ esac
+}
+
+scripts/VBoxHeadlessXOrg.sh -c "${TEST_FOLDER}conf" &
+PID=$!
+expect_exit "${PID}" 5 test_should_fail
+
+###############################################################################
+# Bad configuration files. #
+###############################################################################
+print_line "bad configuration files"
+create_basic_configuration "${TEST_FOLDER_BASE}bad_configuration_files/"
+touch "${XORG_FOLDER}/xorg.conf.2"
+touch "${XORG_FOLDER}/xorg.conf.4"
+touch "${XORG_FOLDER}/xorg.conf.other"
+scripts/VBoxHeadlessXOrg.sh -c "${TEST_FOLDER}conf" &
+PID=$!
+expect_exit "${PID}" 5 test_should_fail
+
+###############################################################################
+# Long running server command. #
+###############################################################################
+
+# Set up a configuration file for a long-running command.
+create_basic_configuration "${TEST_FOLDER_BASE}long-running_command/"
+cat >> "${TEST_FOLDER}conf" << EOF
+HEADLESS_X_ORG_SERVER_COMMAND="${TEST_FOLDER}command.sh"
+EOF
+
+cat > "${TEST_FOLDER}command.sh" << EOF
+#!/bin/sh
+touch "${TEST_FOLDER}stopped"
+touch "${TEST_FOLDER}started"
+trap "touch \\"${TEST_FOLDER}stopped\\"; exit" TERM
+rm "${TEST_FOLDER}stopped"
+while true; do :; done
+EOF
+chmod a+x "${TEST_FOLDER}command.sh"
+
+print_line "long running server command"
+touch "${XORG_FOLDER}/xorg.conf.5"
+FAILURE=""
+scripts/VBoxHeadlessXOrg.sh -c "${TEST_FOLDER}conf" &
+PID="$!"
+while [ ! -f "${TEST_FOLDER}started" ]; do :; done
+while [ -f "${TEST_FOLDER}stopped" ]; do :; done
+[ -n "${PID}" ] && kill "${PID}" 2>/dev/null
+while [ ! -f "${TEST_FOLDER}stopped" ]; do :; done
+printf "SUCCESS.\n"
+
+###############################################################################
+# Pre-requisite test. #
+###############################################################################
+
+# Set up a configuration file with a pre-requisite.
+create_basic_configuration "${TEST_FOLDER_BASE}pre-requisite/"
+cat >> "${TEST_FOLDER}conf" << EOF
+HEADLESS_X_ORG_WAIT_FOR_PREREQUISITES="false"
+EOF
+
+print_line "configuration file with failed pre-requisite"
+touch "${XORG_FOLDER}/xorg.conf.2"
+touch "${XORG_FOLDER}/xorg.conf.4"
+if scripts/VBoxHeadlessXOrg.sh -c "${TEST_FOLDER}conf"; then
+ echo "\nFAILED to stop for failed pre-requisite.\n"
+else
+ echo "SUCCESS"
+fi
+
+###############################################################################
+# Pre-command test. #
+###############################################################################
+
+# Set up our pre-command test configuration file.
+create_basic_configuration "${TEST_FOLDER_BASE}pre-command/"
+
+cat >> "${TEST_FOLDER}conf" << EOF
+test_pre_command_server_pre_command()
+{
+ touch "${TEST_FOLDER}/run/pre"
+}
+test_pre_command_server_command()
+{
+ cp "${TEST_FOLDER}/run/pre" "${TEST_FOLDER}/run/pre2"
+}
+HEADLESS_X_ORG_SERVER_PRE_COMMAND="test_pre_command_server_pre_command"
+HEADLESS_X_ORG_SERVER_COMMAND="test_pre_command_server_command"
+EOF
+
+print_line "pre-command test"
+touch "${XORG_FOLDER}/xorg.conf.2"
+
+test_pre_command()
+{
+ STATUS="$1"
+ case "${STATUS}" in
+ 0)
+ LOG_FOLDER="${TEST_FOLDER}/log"
+ LOG="${LOG_FOLDER}/log"
+ if [ -e "${TEST_FOLDER}/run/pre" ] && [ -e "${TEST_FOLDER}/run/pre2" ]; then
+ printf "SUCCESS.\n"
+ else
+ printf "\nFAILED: pre-command not executed.\n"
+ fi
+ ;;
+ *)
+ printf "\nFAILED: exit status ${STATUS}.\n"
+ esac
+}
+
+rm -f "${TEST_FOLDER}/run/pre"
+scripts/VBoxHeadlessXOrg.sh -c "${TEST_FOLDER}conf" &
+PID=$!
+expect_exit "${PID}" 5 test_pre_command
+
+###############################################################################
+# Post-command test. #
+###############################################################################
+
+# Set up our post-command test configuration file.
+create_basic_configuration "${TEST_FOLDER_BASE}post-command/"
+cat >> "${TEST_FOLDER}conf" << EOF
+test_post_command_post_command()
+{
+ echo "\${1}" > "${TEST_FOLDER}/run/post"
+}
+HEADLESS_X_ORG_SERVER_POST_COMMAND="test_post_command_post_command"
+EOF
+
+print_line "post-command test"
+touch "${XORG_FOLDER}/xorg.conf.2"
+touch "${XORG_FOLDER}/xorg.conf.4"
+
+test_post_command()
+{
+ STATUS="$1"
+ case "${STATUS}" in
+ 0)
+ LOG_FOLDER="${TEST_FOLDER}/log"
+ LOG="${LOG_FOLDER}/log"
+ if grep -q "2 4" "${TEST_FOLDER}/run/post"; then
+ printf "SUCCESS.\n"
+ else
+ printf "\nFAILED: post-command not executed.\n"
+ fi
+ ;;
+ *)
+ printf "\nFAILED: exit status ${STATUS}.\n"
+ esac
+}
+
+rm -f "${TEST_FOLDER}/run/post"
+scripts/VBoxHeadlessXOrg.sh -c "${TEST_FOLDER}conf" &
+PID=$!
+expect_exit "${PID}" 5 test_post_command
diff --git a/src/VBox/Installer/linux/testcase/tstInstallInit.sh b/src/VBox/Installer/linux/testcase/tstInstallInit.sh
new file mode 100755
index 00000000..9c6c1bab
--- /dev/null
+++ b/src/VBox/Installer/linux/testcase/tstInstallInit.sh
@@ -0,0 +1,365 @@
+#!/bin/sh
+# $Id: tstInstallInit.sh $
+## @file
+# VirtualBox init file creator unit test.
+#
+
+#
+# Copyright (C) 2012-2013 Oracle Corporation
+#
+# This file is part of VirtualBox Open Source Edition (OSE), as
+# available from http://www.virtualbox.org. This file is free software;
+# you can redistribute it and/or modify it under the terms of the GNU
+# General Public License (GPL) as published by the Free Software
+# Foundation, in version 2 as it comes in the "COPYING" file of the
+# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+#
+
+# This will initially be a skeleton with a couple of tests - add more for quick
+# debugging when you suspect that something isn't working as specified.
+
+tab=" "
+tmpbase="/tmp/tstInstallInit 99" # Space in the name for a little stress...
+if [ -n "${TESTBOX_PATH_SCRATCH}" ]; then
+ tmpbase="${TESTBOX_PATH_SCRATCH}/tstInstallInit 99"
+fi
+
+## The function definition at the start of every non-trivial shell script!
+abort()
+{
+ ## $1 Error text to output to standard error in printf format.
+ cat >&2 << EOF
+${TEST_NAME}: $1
+EOF
+ exit 1
+}
+
+## Print a TESTING line.
+print_line()
+{
+ cat >&2 << EOF
+${TEST_NAME}: TESTING $1
+EOF
+}
+
+## Set the failure message if it is not yet set.
+fail_msg()
+{
+ test -z "${failed}" && failed="FAILED: ${1}"
+}
+
+# Get the directory where the script is located and the parent.
+OUR_FOLDER=`dirname "$0"`
+OUR_FOLDER=`cd "${OUR_FOLDER}" && pwd`
+VBOX_FOLDER=`cd "${OUR_FOLDER}/.." && pwd`
+[ -d "${VBOX_FOLDER}" ] ||
+ abort "Failed to change to directory ${VBOX_FOLDER}.\n"
+cd "${VBOX_FOLDER}"
+
+# Get our name for output.
+TEST_NAME="$(basename "$0" .sh)"
+
+# Create a trivial test service in temporary directory $1 with name $2.
+test_service()
+{
+ cat > "${1}/${2}" << EOF
+#!/bin/sh
+trap "touch \"${1}/stopped\"; exit" TERM
+echo "1: \${1} 2: \${2} 3: \${3}" > "${1}/started"
+while true; do true; done
+EOF
+chmod u+x "${1}/${2}"
+}
+
+# Create a trivial test command in temporary directory $1 with name $2.
+test_oneshot()
+{
+ cat > "${1}/${2}" << EOF
+#!/bin/sh
+if test "\${1}" = start; then
+ touch "${1}/started"
+else
+ rm "${1}/started"
+fi
+exit 0
+EOF
+chmod u+x "${1}/${2}"
+}
+
+# Test some dodgy input values against generate_service_file.
+# Make sure there is a substitution pattern at the end too.
+print_line "generation of shell script from template."
+input='TEST1%DESCRIPTION%%%%SERVICE_NAME%%STOP_COMMAND% TST2 TEST %ARGUMENTS%%COMMAND%'
+out=`echo "${input}" |
+ helpers/generate_service_file --command '/usr/bin
+aries/hello
+world' --arguments 'p\x0a0\n\ \t' --format shell --description ''`
+expected='TEST1%hello
+world TST2 TEST '\''p
+0
+ '"${tab}"\'\''/usr/bin
+aries/hello
+world'\'
+case "${out}" in ${expected})
+echo "SUCCESS (1)";;
+*)
+cat << EOF
+FAILED: expected
+${expected}
+but got
+${out}
+EOF
+esac
+input='TEST%HAVE_STOP_COMMAND%%SERVICE_NAME%%STOP_COMMAND% TST2
+ TEST %COMMAND%'
+out=`echo "${input}" |
+ helpers/generate_service_file --command '/usr/bin/hello' --format shell --description ''`
+expected='TEST TEST '\''/usr/bin/hello'\'''
+case "${out}" in ${expected})
+echo "SUCCESS (2)";;
+*)
+cat << EOF
+FAILED: expected
+${expected}
+but got
+${out}
+EOF
+esac
+input='TEST%HAVE_STOP_COMMAND%%SERVICE_NAME%%STOP_COMMAND% %STOP_ARGUMENTS% TST2
+ TEST %COMMAND%'
+out=`echo "${input}" |
+ helpers/generate_service_file --command '/usr/bin/hello' --format shell --description '' --stop-command /usr/bin/stop --stop-arguments hello`
+expected='TESThello'\''/usr/bin/stop'\'' '\''hello'\'' TST2
+ TEST '\''/usr/bin/hello'\'''
+case "${out}" in ${expected})
+echo "SUCCESS (3)";;
+*)
+cat << EOF
+FAILED: expected
+${expected}
+but got
+${out}
+EOF
+esac
+
+# Create a simulated init system layout.
+create_simulated_init_tree()
+{
+ tmpdir="${1}"
+ rm -rf "${tmpdir}"
+ mkdir -m 0700 "${tmpdir}" || abort "Failed to create a temporary folder."
+ mkdir -p "${tmpdir}/init.d/" "${tmpdir}/rc.d/init.d/"
+ for i in 0 1 2 3 4 5 6; do
+ mkdir "${tmpdir}/rc${i}.d/" "${tmpdir}/rc.d/rc${i}.d/"
+ done
+ mkdir -p "${tmpdir}/runlevel/default" "${tmpdir}/runlevel/boot"
+ mkdir "${tmpdir}/run"
+}
+
+# Test an init script installation.
+print_line "installing an init script."
+failed=""
+# Create a simulated init system layout.
+tmpdir="${tmpbase}0"
+create_simulated_init_tree "${tmpdir}"
+# Create the service binary.
+test_service "${tmpdir}" "service"
+# And install it.
+scripts/install_service --prefix "${tmpdir}" --enable -- --command "${tmpdir}/service" --arguments "test of my\ arguments" --description "My description" ||
+ fail_msg "\"scripts/install_service\" failed."
+# Check that the main service file was created as specified.
+if test -x "${tmpdir}/init.d/service"; then
+ grep "Short-Description: My description" "${tmpdir}/init.d/service" >/dev/null ||
+ fail_msg "Description not set in \"${tmpdir}/init.d/service\""
+else
+ fail_msg "\"${tmpdir}/init.d/service\" not correctly created."
+fi
+test -x "${tmpdir}/init.d/rc.d/service" &&
+ fail_msg "\"${tmpdir}/init.d/rc.d/service\" created but shouldn't have been."
+# Try to start the service using the symbolic links which should have been
+# created.
+if "${tmpdir}/rc3.d/S20service" --prefix "${tmpdir}" --lsb-functions "" start >/dev/null 2>&1; then
+ if grep "1: test 2: of 3: my arguments" "${tmpdir}/started" >/dev/null; then
+ test -f "${tmpdir}/stopped" &&
+ fail_msg "\"${tmpdir}/rc3.d/S20service\" stopped immediately."
+ else
+ fail_msg "\"${tmpdir}/rc3.d/S20service\" did not start correctly."
+ fi
+else
+ fail_msg "could not start \"${tmpdir}/rc3.d/S20service\"."
+fi
+# Check the status.
+"${tmpdir}/rc.d/rc5.d/S20service" --prefix "${tmpdir}" --lsb-functions "" status >/dev/null 2>&1 ||
+ fail_msg "\"${tmpdir}/rc.d/rc5.d/S20service\" reported the wrong status."
+# Try to stop the service using the symbolic links which should have been
+# created.
+if "${tmpdir}/rc.d/rc6.d/K80service" --prefix "${tmpdir}" --lsb-functions "" stop >/dev/null 2>&1; then
+ test -f "${tmpdir}/stopped" ||
+ echo "\"${tmpdir}/rc.d/rc6.d/K80service\" did not stop correctly."
+else
+ fail_msg "could not stop \"${tmpdir}/rc.d/rc6.d/K80service\"."
+fi
+# Check the status again - now it should be stopped.
+"${tmpdir}/runlevel/service" --prefix "${tmpdir}" --lsb-functions "" status >/dev/null 2>&1 &&
+ fail_msg "\"${tmpdir}/runlevel/service\" reported the wrong status."
+# Final summary.
+if test -n "${failed}"; then
+ echo "${failed}"
+else
+ echo SUCCESS
+fi
+
+# Test an one shot init script installation.
+print_line "installing a one shot init script."
+failed=""
+# Create a simulated init system layout.
+tmpdir="${tmpbase}0"
+create_simulated_init_tree "${tmpdir}"
+# Create the command binary.
+test_oneshot "${tmpdir}" "command"
+# And install the script.
+scripts/install_service --prefix "${tmpdir}" --enable -- --command "${tmpdir}/command" --arguments "start" --description "My description" --stop-command "${tmpdir}/command" --stop-arguments "stop" --one-shot ||
+ fail_msg "\"scripts/install_service\" failed."
+# Sanity test.
+test -f "${tmpdir}/started" &&
+ fail_msg "\"${tmpdir}/started\" already exists!"
+# Try to start the service using the symbolic links which should have been
+# created.
+if "${tmpdir}/rc3.d/S20command" --prefix "${tmpdir}" --lsb-functions "" start >/dev/null 2>&1; then
+ test -f "${tmpdir}/started" ||
+ fail_msg "\"${tmpdir}/rc3.d/S20command\" did not start correctly."
+else
+ fail_msg "could not start \"${tmpdir}/rc3.d/S20command\"."
+fi
+# Try to stop the service using the symbolic links which should have been
+# created.
+if "${tmpdir}/rc.d/rc6.d/K80command" --prefix "${tmpdir}" --lsb-functions "" stop >/dev/null 2>&1; then
+ test -f "${tmpdir}/started" &&
+ echo "\"${tmpdir}/rc.d/rc6.d/K80command\" did not stop correctly."
+else
+ fail_msg "could not stop \"${tmpdir}/rc.d/rc6.d/K80command\"."
+fi
+# Final summary.
+if test -n "${failed}"; then
+ echo "${failed}"
+else
+ echo SUCCESS
+fi
+
+# Test an init script removal.
+print_line "removing an init script."
+failed=""
+# Create a simulated init system layout.
+tmpdir="${tmpbase}0"
+create_simulated_init_tree "${tmpdir}"
+# Create the service binary.
+test_service "${tmpdir}" "service"
+# Install it.
+scripts/install_service --prefix "${tmpdir}" --enable -- --command "${tmpdir}/service" --arguments "test of my\ arguments" --description "My description" ||
+ fail_msg "\"scripts/install_service\" failed."
+# And remove it again.
+scripts/install_service --prefix "${tmpdir}" --remove -- --command "${tmpdir}/service" ||
+ fail_msg "\"scripts/install_service\" failed."
+# After uninstallation this should be the only file left in the init tree.
+rm "${tmpdir}/service"
+test "x`find "${tmpdir}" -type f -o -type l`" = "x" ||
+ fail_msg "not all files were removed."
+# Final summary.
+if test -n "${failed}"; then
+ echo "${failed}"
+else
+ echo SUCCESS
+fi
+
+# Test an enabled init script update with --disable.
+print_line "updating an enabled init script with --disable."
+failed=""
+# Create a simulated init system layout.
+tmpdir="${tmpbase}1"
+create_simulated_init_tree "${tmpdir}"
+# Create the service binary.
+test_service "${tmpdir}" "service"
+# Install it.
+scripts/install_service --prefix "${tmpdir}" --enable -- --command "${tmpdir}/service" --arguments "test of my\ arguments" --description "My description" ||
+ fail_msg "\"scripts/install_service\" failed."
+# Install it disabled without forcing.
+scripts/install_service --prefix "${tmpdir}" --disable -- --command "${tmpdir}/service" --arguments "test of my\ arguments" --description "My description" ||
+ fail_msg "\"scripts/install_service\" failed."
+test "x`find "${tmpdir}"/rc*.d "${tmpdir}/runlevel" -type l | wc -l`" = "x15" ||
+ fail_msg "links were removed on non-forced disable."
+# Final summary.
+if test -n "${failed}"; then
+ echo "${failed}"
+else
+ echo SUCCESS
+fi
+
+# Test updating a disabled init script with --enable.
+print_line "updating a disabled init script with --enable."
+failed=""
+# Create a simulated init system layout.
+tmpdir="${tmpbase}2"
+create_simulated_init_tree "${tmpdir}"
+# Create the service binary.
+test_service "${tmpdir}" "service"
+# Install it.
+scripts/install_service --prefix "${tmpdir}" --disable -- --command "${tmpdir}/service" --arguments "test of my\ arguments" --description "My description" ||
+ fail_msg "\"scripts/install_service\" failed."
+# Install it disabled without forcing.
+scripts/install_service --prefix "${tmpdir}" --enable -- --command "${tmpdir}/service" --arguments "test of my\ arguments" --description "My description" ||
+ fail_msg "\"scripts/install_service\" failed."
+test "x`find "${tmpdir}"/rc*.d "${tmpdir}/runlevel" -type l`" = "x" ||
+ fail_msg "files were installed on non-forced enable."
+# Final summary.
+if test -n "${failed}"; then
+ echo "${failed}"
+else
+ echo SUCCESS
+fi
+
+# Test an enabled init script update with --force-disable.
+print_line "updating an enabled init script with --force-disable."
+failed=""
+# Create a simulated init system layout.
+tmpdir="${tmpbase}3"
+create_simulated_init_tree "${tmpdir}"
+# Create the service binary.
+test_service "${tmpdir}" "service"
+# Install it.
+scripts/install_service --prefix "${tmpdir}" --enable -- --command "${tmpdir}/service" --arguments "test of my\ arguments" --description "My description" ||
+ fail_msg "\"scripts/install_service\" failed."
+# Install it disabled without forcing.
+scripts/install_service --prefix "${tmpdir}" --force-disable -- --command "${tmpdir}/service" --arguments "test of my\ arguments" --description "My description" ||
+ fail_msg "\"scripts/install_service\" failed."
+test "x`find "${tmpdir}"/rc*.d "${tmpdir}/runlevel" -type l`" = "x" ||
+ fail_msg "links were not removed on forced disable."
+# Final summary.
+if test -n "${failed}"; then
+ echo "${failed}"
+else
+ echo SUCCESS
+fi
+
+# Test updating a disabled init script with --force-enable.
+print_line "updating a disabled init script with --force-enable."
+failed=""
+# Create a simulated init system layout.
+tmpdir="${tmpbase}4"
+create_simulated_init_tree "${tmpdir}"
+# Create the service binary.
+test_service "${tmpdir}" "service"
+# Install it.
+scripts/install_service --prefix "${tmpdir}" --disable -- --command "${tmpdir}/service" --arguments "test of my\ arguments" --description "My description" ||
+ fail_msg "\"scripts/install_service\" failed."
+# Install it disabled without forcing.
+scripts/install_service --prefix "${tmpdir}" --force-enable -- --command "${tmpdir}/service" --arguments "test of my\ arguments" --description "My description" ||
+ fail_msg "\"scripts/install_service\" failed."
+test "x`find "${tmpdir}"/rc*.d "${tmpdir}/runlevel" -type l | wc -l`" = "x15" ||
+ fail_msg "files were not installed on forced enable."
+# Final summary.
+if test -n "${failed}"; then
+ echo "${failed}"
+else
+ echo SUCCESS
+fi
diff --git a/src/VBox/Installer/linux/testcase/tstInstallerLinux.sh b/src/VBox/Installer/linux/testcase/tstInstallerLinux.sh
index 1a5f0ce8..d2708ed3 100755
--- a/src/VBox/Installer/linux/testcase/tstInstallerLinux.sh
+++ b/src/VBox/Installer/linux/testcase/tstInstallerLinux.sh
@@ -83,7 +83,7 @@ extern_test_input_install_device_node_setup() {
do_install_create_usb_node_for_sysfs "$@";;
*)
echo Unknown command $command >&2; exit 1;;
- esac
+ esac
}
setup_test_input_install_device_node_setup() {