VirtualBox

Changeset 43795 in vbox


Ignore:
Timestamp:
Nov 2, 2012 11:37:09 AM (12 years ago)
Author:
vboxsync
Message:

Installer/linux: fix two headless X.Org tests.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Installer/linux/testcase/tstHeadlessXOrg.sh

    r43704 r43795  
    7474}
    7575
    76 # Get the directory where the script is located and change to the parent.
    77 VBOX_FOLDER="$(dirname "$0")/.."
    78 VBOX_FOLDER=$(cd "${VBOX_FOLDER}" && pwd)
     76# Get the directory where the script is located and the parent.
     77OUR_FOLDER="$(dirname "$0")"
     78OUR_FOLDER=$(cd "${OUR_FOLDER}" && pwd)
     79VBOX_FOLDER=$(cd "${OUR_FOLDER}/.." && pwd)
    7980[ -d "${VBOX_FOLDER}" ] ||
    8081  abort "Failed to change to directory ${VBOX_FOLDER}.\n"
     
    8384# Get our name for output.
    8485TEST_NAME="$(basename "$0" .sh)"
     86
     87# And remember the full path.
     88TEST_NAME_FULL="${OUR_FOLDER}/$(basename "$0")"
     89
     90# We use this to test a long-running process
     91[ x"$1" = "x--test-sleep" ] &&
     92  while true; do true; done
    8593
    8694# Create a temporary directory for configuration and logging.
     
    158166create_basic_configuration_file "${TEST_FOLDER}/conf" "${TEST_FOLDER}"
    159167cat >> "${TEST_FOLDER}/conf" << EOF
    160 HEADLESS_X_ORG_SERVER_COMMAND="echo $$ > ${TEST_FOLDER}/pid.\\\${screen}; cat"
     168HEADLESS_X_ORG_SERVER_COMMAND="\"${TEST_NAME_FULL}\" --test-sleep \\\${screen}"
    161169EOF
    162170
    163171# Long running server command.
    164 print_line "long running server command"
     172print_line "long running server command (sleeps)"
    165173touch "${XORG_FOLDER}/xorg.conf.1"
    166174touch "${XORG_FOLDER}/xorg.conf.5"
    167175FAILURE=""
    168 ./VBoxHeadlessXOrg.sh -c "${TEST_FOLDER}/conf"
     176./VBoxHeadlessXOrg.sh -c "${TEST_FOLDER}/conf" &
    169177PID="$!"
    170 [ -r "${TEST_FOLDER}/pid.1" ] &&
    171   [ -r "${TEST_FOLDER}/pid.5" ] &&
    172   ps -p "$(cat "${TEST_FOLDER}/pid.1")" >/dev/null 2>&1 &&
    173   ps -p "$(cat "${TEST_FOLDER}/pid.5")" >/dev/null 2>&1 ||
    174   FAILURE="\nFAILED to start servers.\n"
    175 [ -n "${PID}" ] && kill "${PID}"
    176 { [ -r "${TEST_FOLDER}/pid.1" ] &&
    177     ps -p "$(cat "${TEST_FOLDER}/pid.1")" >/dev/null 2>&1; } ||
    178 { [ -r "${TEST_FOLDER}/pid.5" ] &&
    179     ps -p "$(cat "${TEST_FOLDER}/pid.5")" >/dev/null 2>&1; } &&
    180   FAILURE="\nFAILED to stop servers.\n"  # To terminate or not to terminate?
     178STARTED=""
     179for i in 1 2 3 4 5; do
     180  sleep 1  # Make sure it runs for at least one second.
     181  if ps -a -f | grep "${TEST_NAME}.*1" | grep -q -v grep &&
     182    ps -a -f | grep "${TEST_NAME}.*5" | grep -q -v grep; then
     183    STARTED="true"
     184    break
     185  fi
     186done
     187[ -n "${STARTED}" ] || FAILURE="\nFAILED to start servers.\n"
     188[ -n "${PID}" ] && kill "${PID}" 2>/dev/null
     189STOPPED=""
    181190if [ -z "${FAILURE}" ]; then
     191  for i in 1 2 3 4 5; do
     192    if ! ps -a -f | grep "${TEST_NAME}.*1" | grep -q -v grep &&
     193      ! ps -a -f | grep "${TEST_NAME}.*5" | grep -q -v grep; then
     194      STOPPED="true"
     195      break;
     196    fi
     197    sleep 1
     198  done
     199  [ -n "${STOPPED}" ] ||
     200    FAILURE="\nFAILED to stop servers.\n"  # To terminate or not to terminate?
     201fi
     202if [ -n "${FAILURE}" ]; then
    182203  printf "${FAILURE}"
    183204else
     
    185206fi
    186207rm "${XORG_FOLDER}/"xorg.conf.*
    187 rm -f "${TEST_FOLDER}/pid.1" "${TEST_FOLDER}/pid.5"
    188208
    189209# Set up a configuration file with a pre-requisite.
     
    214234cat >> "${TEST_FOLDER}/conf" << EOF
    215235HEADLESS_X_ORG_SERVER_PRE_COMMAND="touch \"${TEST_FOLDER}/run/pre\""
     236HEADLESS_X_ORG_SERVER_COMMAND="cp \"${TEST_FOLDER}/run/pre\" \"${TEST_FOLDER}/run/pre2\""
    216237EOF
    217238
     
    219240print_line "pre-command test"
    220241touch "${XORG_FOLDER}/xorg.conf.2"
    221 touch "${XORG_FOLDER}/xorg.conf.4"
    222242
    223243test_pre_command()
     
    228248    LOG_FOLDER="${TEST_FOLDER}/log"
    229249    LOG="${LOG_FOLDER}/log"
    230     if [ -e "${TEST_FOLDER}/run/pre" ]; then
     250    if [ -e "${TEST_FOLDER}/run/pre" ] && [ -e "${TEST_FOLDER}/run/pre2" ]; then
    231251      printf "SUCCESS.\n"
    232252    else
     
    243263PID=$!
    244264expect_exit "${PID}" 5 test_pre_command
    245 rm -f "${XORG_FOLDER}"/xorg.conf.* "${TEST_FOLDER}/run/pre"
     265rm -f "${XORG_FOLDER}"/xorg.conf.* "${TEST_FOLDER}"/run/pre*
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette