Changeset 43795 in vbox
- Timestamp:
- Nov 2, 2012 11:37:09 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Installer/linux/testcase/tstHeadlessXOrg.sh
r43704 r43795 74 74 } 75 75 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. 77 OUR_FOLDER="$(dirname "$0")" 78 OUR_FOLDER=$(cd "${OUR_FOLDER}" && pwd) 79 VBOX_FOLDER=$(cd "${OUR_FOLDER}/.." && pwd) 79 80 [ -d "${VBOX_FOLDER}" ] || 80 81 abort "Failed to change to directory ${VBOX_FOLDER}.\n" … … 83 84 # Get our name for output. 84 85 TEST_NAME="$(basename "$0" .sh)" 86 87 # And remember the full path. 88 TEST_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 85 93 86 94 # Create a temporary directory for configuration and logging. … … 158 166 create_basic_configuration_file "${TEST_FOLDER}/conf" "${TEST_FOLDER}" 159 167 cat >> "${TEST_FOLDER}/conf" << EOF 160 HEADLESS_X_ORG_SERVER_COMMAND=" echo $$ > ${TEST_FOLDER}/pid.\\\${screen}; cat"168 HEADLESS_X_ORG_SERVER_COMMAND="\"${TEST_NAME_FULL}\" --test-sleep \\\${screen}" 161 169 EOF 162 170 163 171 # Long running server command. 164 print_line "long running server command "172 print_line "long running server command (sleeps)" 165 173 touch "${XORG_FOLDER}/xorg.conf.1" 166 174 touch "${XORG_FOLDER}/xorg.conf.5" 167 175 FAILURE="" 168 ./VBoxHeadlessXOrg.sh -c "${TEST_FOLDER}/conf" 176 ./VBoxHeadlessXOrg.sh -c "${TEST_FOLDER}/conf" & 169 177 PID="$!" 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? 178 STARTED="" 179 for 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 186 done 187 [ -n "${STARTED}" ] || FAILURE="\nFAILED to start servers.\n" 188 [ -n "${PID}" ] && kill "${PID}" 2>/dev/null 189 STOPPED="" 181 190 if [ -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? 201 fi 202 if [ -n "${FAILURE}" ]; then 182 203 printf "${FAILURE}" 183 204 else … … 185 206 fi 186 207 rm "${XORG_FOLDER}/"xorg.conf.* 187 rm -f "${TEST_FOLDER}/pid.1" "${TEST_FOLDER}/pid.5"188 208 189 209 # Set up a configuration file with a pre-requisite. … … 214 234 cat >> "${TEST_FOLDER}/conf" << EOF 215 235 HEADLESS_X_ORG_SERVER_PRE_COMMAND="touch \"${TEST_FOLDER}/run/pre\"" 236 HEADLESS_X_ORG_SERVER_COMMAND="cp \"${TEST_FOLDER}/run/pre\" \"${TEST_FOLDER}/run/pre2\"" 216 237 EOF 217 238 … … 219 240 print_line "pre-command test" 220 241 touch "${XORG_FOLDER}/xorg.conf.2" 221 touch "${XORG_FOLDER}/xorg.conf.4"222 242 223 243 test_pre_command() … … 228 248 LOG_FOLDER="${TEST_FOLDER}/log" 229 249 LOG="${LOG_FOLDER}/log" 230 if [ -e "${TEST_FOLDER}/run/pre" ] ; then250 if [ -e "${TEST_FOLDER}/run/pre" ] && [ -e "${TEST_FOLDER}/run/pre2" ]; then 231 251 printf "SUCCESS.\n" 232 252 else … … 243 263 PID=$! 244 264 expect_exit "${PID}" 5 test_pre_command 245 rm -f "${XORG_FOLDER}"/xorg.conf.* "${TEST_FOLDER} /run/pre"265 rm -f "${XORG_FOLDER}"/xorg.conf.* "${TEST_FOLDER}"/run/pre*
Note:
See TracChangeset
for help on using the changeset viewer.