Changeset 44063 in vbox for trunk/src/VBox/Installer/linux/testcase
- Timestamp:
- Dec 7, 2012 2:58:52 PM (12 years ago)
- svn:sync-xref-src-repo-rev:
- 82549
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Installer/linux/testcase/tstHeadlessXOrg.sh
r43832 r44063 58 58 ## Create a simple configuration file. Add items onto the end to override them 59 59 # on an item-by-item basis. 60 create_basic_configuration_file() 61 { 62 FILE_NAME="$1" ## The name of the configuration file to create. 63 BASE_FOLDER="$2" ## The basic folder for creating things under. 60 create_basic_configuration() 61 { 62 TEST_FOLDER="${1}" 63 FILE_NAME="${TEST_FOLDER}conf" ## The name of the configuration file to create. 64 BASE_FOLDER="${TEST_FOLDER}" 65 XORG_FOLDER="${TEST_FOLDER}/xorg" 66 mkdir -p "${XORG_FOLDER}" 64 67 cat > "${FILE_NAME}" << EOF 65 68 HEADLESS_X_ORG_CONFIGURATION_FOLDER="${BASE_FOLDER}/xorg" … … 67 70 HEADLESS_X_ORG_LOG_FILE="log" 68 71 HEADLESS_X_ORG_RUN_FOLDER="${BASE_FOLDER}/run" 69 HEADLESS_X_ORG_ CHECK_PREREQUISITES=72 HEADLESS_X_ORG_WAIT_FOR_PREREQUISITES="true" 70 73 HEADLESS_X_ORG_SERVER_PRE_COMMAND= 71 74 HEADLESS_X_ORG_SERVER_COMMAND="echo" … … 88 91 TEST_NAME_FULL="${OUR_FOLDER}/$(basename "$0")" 89 92 90 # We use this to test a long-running process91 [ x"$1" = "x--test-sleep" ] &&92 while true; do true; done93 94 93 # Create a temporary directory for configuration and logging. 95 for i in 0 1 2 3 4 5 6 7 8 9; do 96 TEST_FOLDER="/tmp/${TEST_NAME} ${i}" # Space in the name to test quoting. 97 mkdir -m 0700 "${TEST_FOLDER}" 2>/dev/null && break 98 done 99 [ -d "${TEST_FOLDER}" ] || abort "Failed to create a temporary folder\n" 100 # Clean up. Small race here, but probably not important. 101 trap "rm -r \"${TEST_FOLDER}\" 2>/dev/null" EXIT HUP INT QUIT ABRT TERM 102 # Server configuration folder. 103 XORG_FOLDER="${TEST_FOLDER}/xorg" 104 mkdir -p "${XORG_FOLDER}" 94 TEST_FOLDER_BASE="/tmp/${TEST_NAME} 99/" # Space in the name to test quoting. 95 { 96 rm -rf "${TEST_FOLDER_BASE}" 2>/dev/null && 97 mkdir -m 0700 "${TEST_FOLDER_BASE}" 2>/dev/null 98 } || abort "Could not create test folder.\n" 105 99 106 100 ############################################################################### … … 108 102 ############################################################################### 109 103 print_line "simple start-up test" 110 create_basic_configuration _file "${TEST_FOLDER}/conf" "${TEST_FOLDER}"104 create_basic_configuration "${TEST_FOLDER_BASE}simple_start-up_test/" 111 105 touch "${XORG_FOLDER}/xorg.conf.2" 112 106 touch "${XORG_FOLDER}/xorg.conf.4" … … 131 125 } 132 126 133 ./VBoxHeadlessXOrg.sh -c "${TEST_FOLDER}/conf" &127 scripts/VBoxHeadlessXOrg.sh -c "${TEST_FOLDER}conf" & 134 128 PID=$! 135 129 expect_exit "${PID}" 5 test_simple_start_up 136 rm "${XORG_FOLDER}"/xorg.conf.*137 130 138 131 ############################################################################### 139 132 # No configuration files. # 140 133 ############################################################################### 134 create_basic_configuration "${TEST_FOLDER_BASE}no_configuration_files/" 141 135 print_line "no configuration files" 142 136 … … 153 147 } 154 148 155 ./VBoxHeadlessXOrg.sh -c "${TEST_FOLDER}/conf" &149 scripts/VBoxHeadlessXOrg.sh -c "${TEST_FOLDER}conf" & 156 150 PID=$! 157 151 expect_exit "${PID}" 5 test_should_fail … … 161 155 ############################################################################### 162 156 print_line "bad configuration files" 157 create_basic_configuration "${TEST_FOLDER_BASE}bad_configuration_files/" 163 158 touch "${XORG_FOLDER}/xorg.conf.2" 164 159 touch "${XORG_FOLDER}/xorg.conf.4" 165 160 touch "${XORG_FOLDER}/xorg.conf.other" 166 ./VBoxHeadlessXOrg.sh -c "${TEST_FOLDER}/conf" &161 scripts/VBoxHeadlessXOrg.sh -c "${TEST_FOLDER}conf" & 167 162 PID=$! 168 163 expect_exit "${PID}" 5 test_should_fail 169 rm "${XORG_FOLDER}/"xorg.conf.*170 164 171 165 ############################################################################### … … 174 168 175 169 # Set up a configuration file for a long-running command. 176 create_basic_configuration_file "${TEST_FOLDER}/conf" "${TEST_FOLDER}" 177 cat >> "${TEST_FOLDER}/conf" << EOF 178 HEADLESS_X_ORG_SERVER_COMMAND="\"${TEST_NAME_FULL}\" --test-sleep" 179 EOF 180 181 print_line "long running server command (sleeps)" 182 touch "${XORG_FOLDER}/xorg.conf.1" 170 create_basic_configuration "${TEST_FOLDER_BASE}long-running_command/" 171 cat >> "${TEST_FOLDER}conf" << EOF 172 HEADLESS_X_ORG_SERVER_COMMAND="${TEST_FOLDER}command.sh" 173 EOF 174 175 cat > "${TEST_FOLDER}command.sh" << EOF 176 #!/bin/sh 177 touch "${TEST_FOLDER}stopped" 178 touch "${TEST_FOLDER}started" 179 trap "touch \\"${TEST_FOLDER}stopped\\"; exit" TERM 180 rm "${TEST_FOLDER}stopped" 181 while true; do :; done 182 EOF 183 chmod a+x "${TEST_FOLDER}command.sh" 184 185 print_line "long running server command" 183 186 touch "${XORG_FOLDER}/xorg.conf.5" 184 187 FAILURE="" 185 ./VBoxHeadlessXOrg.sh -c "${TEST_FOLDER}/conf" &188 scripts/VBoxHeadlessXOrg.sh -c "${TEST_FOLDER}conf" & 186 189 PID="$!" 187 STARTED="" 188 for i in 1 2 3 4 5; do 189 sleep 1 # Make sure it runs for at least one second. 190 if ps -a -f | grep "${TEST_NAME}.*1" | grep -q -v grep && 191 ps -a -f | grep "${TEST_NAME}.*5" | grep -q -v grep; then 192 STARTED="true" 193 break 194 fi 195 done 196 [ -n "${STARTED}" ] || FAILURE="\nFAILED to start servers.\n" 190 while [ ! -f "${TEST_FOLDER}started" ]; do :; done 191 while [ -f "${TEST_FOLDER}stopped" ]; do :; done 197 192 [ -n "${PID}" ] && kill "${PID}" 2>/dev/null 198 STOPPED="" 199 if [ -z "${FAILURE}" ]; then 200 for i in 1 2 3 4 5; do 201 if ! ps -a -f | grep "${TEST_NAME}.*1" | grep -q -v grep && 202 ! ps -a -f | grep "${TEST_NAME}.*5" | grep -q -v grep; then 203 STOPPED="true" 204 break; 205 fi 206 sleep 1 207 done 208 [ -n "${STOPPED}" ] || 209 FAILURE="\nFAILED to stop servers.\n" # To terminate or not to terminate? 193 while [ ! -f "${TEST_FOLDER}stopped" ]; do :; done 194 printf "SUCCESS.\n" 195 196 ############################################################################### 197 # Pre-requisite test. # 198 ############################################################################### 199 200 # Set up a configuration file with a pre-requisite. 201 create_basic_configuration "${TEST_FOLDER_BASE}pre-requisite/" 202 cat >> "${TEST_FOLDER}conf" << EOF 203 HEADLESS_X_ORG_WAIT_FOR_PREREQUISITES="false" 204 EOF 205 206 print_line "configuration file with failed pre-requisite" 207 touch "${XORG_FOLDER}/xorg.conf.2" 208 touch "${XORG_FOLDER}/xorg.conf.4" 209 if scripts/VBoxHeadlessXOrg.sh -c "${TEST_FOLDER}conf"; then 210 echo "\nFAILED to stop for failed pre-requisite.\n" 211 else 212 echo "SUCCESS" 210 213 fi 211 if [ -n "${FAILURE}" ]; then212 printf "${FAILURE}"213 else214 printf "SUCCESS.\n"215 fi216 rm "${XORG_FOLDER}/"xorg.conf.*217 218 ###############################################################################219 # Pre-requisite test. #220 ###############################################################################221 222 # Set up a configuration file with a pre-requisite.223 create_basic_configuration_file "${TEST_FOLDER}/conf" "${TEST_FOLDER}"224 cat >> "${TEST_FOLDER}/conf" << EOF225 HEADLESS_X_ORG_CHECK_PREREQUISITES="[ -e \\"${TEST_FOLDER}/run/prereq\\" ]"226 EOF227 228 print_line "configuration file with pre-requisite (sleeps)"229 touch "${XORG_FOLDER}/xorg.conf.2"230 touch "${XORG_FOLDER}/xorg.conf.4"231 FAILURE=""232 ./VBoxHeadlessXOrg.sh -c "${TEST_FOLDER}/conf" &233 PID="$!"234 sleep 1235 ps -p "${PID}" > /dev/null 2>&1 || FAILURE="\nFAILED to wait for pre-requisite.\n"236 touch "${TEST_FOLDER}/run/prereq"237 if [ -z "${FAILURE}" ]; then238 expect_exit "${PID}" 10 test_simple_start_up239 else240 printf "${FAILURE}"241 fi242 rm -r "${XORG_FOLDER}"/xorg.conf.* "${TEST_FOLDER}/run"243 214 244 215 ############################################################################### … … 247 218 248 219 # Set up our pre-command test configuration file. 249 create_basic_configuration_file "${TEST_FOLDER}/conf" "${TEST_FOLDER}" 250 251 cat >> "${TEST_FOLDER}/conf" << EOF 220 create_basic_configuration "${TEST_FOLDER_BASE}pre-command/" 221 222 cat >> "${TEST_FOLDER}conf" << EOF 223 test_pre_command_server_pre_command() 224 { 225 touch "${TEST_FOLDER}/run/pre" 226 } 252 227 test_pre_command_server_command() 253 228 { 254 229 cp "${TEST_FOLDER}/run/pre" "${TEST_FOLDER}/run/pre2" 255 230 } 256 HEADLESS_X_ORG_SERVER_PRE_COMMAND="t ouch \"${TEST_FOLDER}/run/pre\""231 HEADLESS_X_ORG_SERVER_PRE_COMMAND="test_pre_command_server_pre_command" 257 232 HEADLESS_X_ORG_SERVER_COMMAND="test_pre_command_server_command" 258 233 EOF … … 280 255 281 256 rm -f "${TEST_FOLDER}/run/pre" 282 ./VBoxHeadlessXOrg.sh -c "${TEST_FOLDER}/conf" &257 scripts/VBoxHeadlessXOrg.sh -c "${TEST_FOLDER}conf" & 283 258 PID=$! 284 259 expect_exit "${PID}" 5 test_pre_command 285 rm -f "${XORG_FOLDER}"/xorg.conf.* "${TEST_FOLDER}"/run/pre*286 260 287 261 ############################################################################### … … 290 264 291 265 # Set up our post-command test configuration file. 292 create_basic_configuration _file "${TEST_FOLDER}/conf" "${TEST_FOLDER}"293 cat >> "${TEST_FOLDER} /conf" << EOF266 create_basic_configuration "${TEST_FOLDER_BASE}post-command/" 267 cat >> "${TEST_FOLDER}conf" << EOF 294 268 test_post_command_post_command() 295 269 { … … 322 296 323 297 rm -f "${TEST_FOLDER}/run/post" 324 ./VBoxHeadlessXOrg.sh -c "${TEST_FOLDER}/conf" &298 scripts/VBoxHeadlessXOrg.sh -c "${TEST_FOLDER}conf" & 325 299 PID=$! 326 300 expect_exit "${PID}" 5 test_post_command 327 rm -f "${XORG_FOLDER}"/xorg.conf.* "${TEST_FOLDER}/run/post"
Note:
See TracChangeset
for help on using the changeset viewer.