OLD | NEW |
---|---|
1 #!/bin/bash | 1 #!/bin/bash |
2 | 2 |
3 # Copyright (c) 2009 The Chromium OS Authors. All rights reserved. | 3 # Copyright (c) 2009 The Chromium OS Authors. All rights reserved. |
4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 | 6 |
7 # Script to run client or server tests on a live remote image. | 7 # Script to run client or server tests on a live remote image. |
8 | 8 |
9 # Load common constants. This should be the first executable line. | 9 # Load common constants. This should be the first executable line. |
10 # The path to common.sh should be relative to your script's location. | 10 # The path to common.sh should be relative to your script's location. |
(...skipping 24 matching lines...) Expand all Loading... | |
35 get_default_board | 35 get_default_board |
36 | 36 |
37 DEFINE_string args "" \ | 37 DEFINE_string args "" \ |
38 "Command line arguments for test. Quoted and space separated if multiple." a | 38 "Command line arguments for test. Quoted and space separated if multiple." a |
39 DEFINE_string board "$DEFAULT_BOARD" \ | 39 DEFINE_string board "$DEFAULT_BOARD" \ |
40 "The board for which you are building autotest" | 40 "The board for which you are building autotest" |
41 DEFINE_boolean build ${FLAGS_FALSE} "Build tests while running" b | 41 DEFINE_boolean build ${FLAGS_FALSE} "Build tests while running" b |
42 DEFINE_string chroot "${DEFAULT_CHROOT_DIR}" "alternate chroot location" c | 42 DEFINE_string chroot "${DEFAULT_CHROOT_DIR}" "alternate chroot location" c |
43 DEFINE_boolean cleanup ${FLAGS_FALSE} "Clean up temp directory" | 43 DEFINE_boolean cleanup ${FLAGS_FALSE} "Clean up temp directory" |
44 DEFINE_integer iterations 1 "Iterations to run every top level test" i | 44 DEFINE_integer iterations 1 "Iterations to run every top level test" i |
45 DEFINE_boolean quiet ${FLAGS_FALSE} "Hide most test logs on success" | |
sosa
2011/02/15 22:16:47
maybe hide_info?
| |
45 DEFINE_string results_dir_root "" "alternate root results directory" | 46 DEFINE_string results_dir_root "" "alternate root results directory" |
46 DEFINE_boolean verbose ${FLAGS_FALSE} "Show verbose autoserv output" v | 47 DEFINE_boolean verbose ${FLAGS_FALSE} "Show verbose autoserv output" v |
47 DEFINE_boolean use_emerged ${FLAGS_FALSE} \ | 48 DEFINE_boolean use_emerged ${FLAGS_FALSE} \ |
48 "Force use of emerged autotest packages" | 49 "Force use of emerged autotest packages" |
49 | 50 |
50 RAN_ANY_TESTS=${FLAGS_FALSE} | 51 RAN_ANY_TESTS=${FLAGS_FALSE} |
51 | 52 |
52 function stop_ssh_agent() { | 53 function stop_ssh_agent() { |
53 # Call this function from the exit trap of the main script. | 54 # Call this function from the exit trap of the main script. |
54 # Iff we started ssh-agent, be nice and clean it up. | 55 # Iff we started ssh-agent, be nice and clean it up. |
55 # Note, only works if called from the main script - no subshells. | 56 # Note, only works if called from the main script - no subshells. |
56 if [[ 1 -eq ${OWN_SSH_AGENT} ]]; then | 57 if [[ 1 -eq ${OWN_SSH_AGENT} ]]; then |
57 kill ${SSH_AGENT_PID} 2>/dev/null | 58 kill ${SSH_AGENT_PID} 2>/dev/null |
58 unset OWN_SSH_AGENT SSH_AGENT_PID SSH_AUTH_SOCK | 59 unset OWN_SSH_AGENT SSH_AGENT_PID SSH_AUTH_SOCK |
59 fi | 60 fi |
60 } | 61 } |
61 | 62 |
62 function start_ssh_agent() { | 63 function start_ssh_agent() { |
63 local tmp_private_key=$TMP/autotest_key | 64 local tmp_private_key=$TMP/autotest_key |
64 if [ -z "$SSH_AGENT_PID" ]; then | 65 if [ -z "$SSH_AGENT_PID" ]; then |
65 eval $(ssh-agent) | 66 eval $(ssh-agent) |
66 OWN_SSH_AGENT=1 | 67 OWN_SSH_AGENT=1 |
67 else | 68 else |
68 OWN_SSH_AGENT=0 | 69 OWN_SSH_AGENT=0 |
69 fi | 70 fi |
70 cp $FLAGS_private_key $tmp_private_key | 71 cp $FLAGS_private_key $tmp_private_key |
71 chmod 0400 $tmp_private_key | 72 chmod 0400 $tmp_private_key |
72 ssh-add $tmp_private_key | 73 |
74 # Run this way to capture normal stderr output but only display it | |
75 # on failure. | |
76 result="$(ssh-add $tmp_private_key 2>&1)" || die "$result" | |
73 } | 77 } |
74 | 78 |
75 function cleanup() { | 79 function cleanup() { |
76 # Always remove the build path in case it was used. | 80 # Always remove the build path in case it was used. |
77 [[ -n "${BUILD_DIR}" ]] && sudo rm -rf "${BUILD_DIR}" | 81 [[ -n "${BUILD_DIR}" ]] && sudo rm -rf "${BUILD_DIR}" |
78 if [[ $FLAGS_cleanup -eq ${FLAGS_TRUE} ]] || \ | 82 if [[ $FLAGS_cleanup -eq ${FLAGS_TRUE} ]] || \ |
79 [[ ${RAN_ANY_TESTS} -eq ${FLAGS_FALSE} ]]; then | 83 [[ ${RAN_ANY_TESTS} -eq ${FLAGS_FALSE} ]]; then |
80 rm -rf "${TMP}" | 84 rm -rf "${TMP}" |
81 else | 85 else |
82 echo ">>> Details stored under ${TMP}" | 86 echo ">>> Details stored under ${TMP}" |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
312 fi | 316 fi |
313 | 317 |
314 local autoserv_args="-m ${FLAGS_remote} --ssh-port ${FLAGS_ssh_port} \ | 318 local autoserv_args="-m ${FLAGS_remote} --ssh-port ${FLAGS_ssh_port} \ |
315 ${option} ${control_file} -r ${results_dir} ${verbose}" | 319 ${option} ${control_file} -r ${results_dir} ${verbose}" |
316 if [ -n "${FLAGS_args}" ]; then | 320 if [ -n "${FLAGS_args}" ]; then |
317 autoserv_args="${autoserv_args} --args=${FLAGS_args}" | 321 autoserv_args="${autoserv_args} --args=${FLAGS_args}" |
318 fi | 322 fi |
319 | 323 |
320 sudo chmod a+w ./server/{tests,site_tests} | 324 sudo chmod a+w ./server/{tests,site_tests} |
321 echo ./server/autoserv ${autoserv_args} | 325 echo ./server/autoserv ${autoserv_args} |
326 | |
327 # run autoserv in subshell, capture it's output, and only display output | |
328 # on error. | |
329 if [ ${FLAGS_build} -eq ${FLAGS_TRUE} ]; then | |
330 result="$(. ${BUILD_ENV} && tc-export CC CXX PKG_CONFIG && | |
331 ./server/autoserv ${autoserv_args} 2>&1)" | |
332 else | |
333 result="$(./server/autoserv ${autoserv_args} 2>&1)" | |
sosa
2011/02/15 22:16:47
I'm not sure this'll work with || to some var ...
| |
334 fi | |
322 | 335 |
323 if [ ${FLAGS_build} -eq ${FLAGS_TRUE} ]; then | 336 if [ $? -ne 0 -o ${FLAGS_quiet} -eq ${FLAGS_FALSE} ]; then |
324 # run autoserv in subshell | 337 echo |
325 (. ${BUILD_ENV} && tc-export CC CXX PKG_CONFIG && | 338 echo "$result" |
326 ./server/autoserv ${autoserv_args}) | |
327 else | |
328 ./server/autoserv ${autoserv_args} | |
329 fi | 339 fi |
330 done | 340 done |
331 popd > /dev/null | 341 popd > /dev/null |
332 | 342 |
333 echo "" | 343 echo "" |
334 info "Test results:" | 344 info "Test results:" |
335 ./generate_test_report "${TMP}" --strip="${TMP}/" | 345 ./generate_test_report "${TMP}" --strip="${TMP}/" |
336 | 346 |
337 print_time_elapsed | 347 print_time_elapsed |
338 } | 348 } |
339 | 349 |
340 restart_in_chroot_if_needed "$@" | 350 restart_in_chroot_if_needed "$@" |
341 main "$@" | 351 main "$@" |
OLD | NEW |