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. |
11 | 11 |
12 . "$(dirname $0)/common.sh" | 12 . "$(dirname $0)/common.sh" |
13 . "$(dirname $0)/remote_access.sh" | |
14 | 13 |
15 get_default_board | 14 get_default_board |
16 | 15 |
16 DEFAULT_PRIVATE_KEY="${GCLIENT_ROOT}/src/scripts/mod_for_test_scripts/\ | |
17 ssh_keys/testing_rsa" | |
18 | |
19 DEFINE_string remote "" "remote hostname/IP of running Chromium OS instance" | |
petkov
2011/01/13 22:54:45
sort flags
| |
20 DEFINE_string private_key "$DEFAULT_PRIVATE_KEY" \ | |
21 "Private key of root account on remote host" | |
22 DEFINE_integer ssh_port 22 \ | |
23 "SSH port of the remote machine running Chromium OS instance" | |
17 DEFINE_string args "" \ | 24 DEFINE_string args "" \ |
18 "Command line arguments for test. Quoted and space separated if multiple." a | 25 "Command line arguments for test. Quoted and space separated if multiple." a |
19 DEFINE_string board "$DEFAULT_BOARD" \ | 26 DEFINE_string board "$DEFAULT_BOARD" \ |
20 "The board for which you are building autotest" | 27 "The board for which you are building autotest" |
21 DEFINE_boolean build ${FLAGS_FALSE} "Build tests while running" b | 28 DEFINE_boolean build ${FLAGS_FALSE} "Build tests while running" b |
22 DEFINE_string chroot "${DEFAULT_CHROOT_DIR}" "alternate chroot location" c | 29 DEFINE_string chroot "${DEFAULT_CHROOT_DIR}" "alternate chroot location" c |
23 DEFINE_boolean cleanup ${FLAGS_FALSE} "Clean up temp directory" | 30 DEFINE_boolean cleanup ${FLAGS_FALSE} "Clean up temp directory" |
24 DEFINE_integer iterations 1 "Iterations to run every top level test" i | 31 DEFINE_integer iterations 1 "Iterations to run every top level test" i |
25 DEFINE_string results_dir_root "" "alternate root results directory" | 32 DEFINE_string results_dir_root "" "alternate root results directory" |
26 DEFINE_boolean verbose ${FLAGS_FALSE} "Show verbose autoserv output" v | 33 DEFINE_boolean verbose ${FLAGS_FALSE} "Show verbose autoserv output" v |
27 DEFINE_boolean use_emerged ${FLAGS_FALSE} \ | 34 DEFINE_boolean use_emerged ${FLAGS_FALSE} \ |
28 "Force use of emerged autotest packages" | 35 "Force use of emerged autotest packages" |
29 | 36 |
30 RAN_ANY_TESTS=${FLAGS_FALSE} | 37 RAN_ANY_TESTS=${FLAGS_FALSE} |
31 | 38 |
39 # Ask the target what board it is | |
40 function learn_board() { | |
petkov
2011/01/13 22:54:45
any reason why you're not using the same routine f
| |
41 [ -n "${FLAGS_board}" ] && return | |
42 FLAGS_board=$(ssh -o StrictHostKeyChecking=no root@${FLAGS_remote} \ | |
43 -o UserKnownHostsFile=/dev/null \ | |
44 cat /etc/lsb-release | \ | |
45 grep CHROMEOS_RELEASE_BOARD | \ | |
46 cut -d '=' -f 2) | |
47 if [ -z "${FLAGS_board}" ]; then | |
48 error "Board required" | |
petkov
2011/01/13 22:54:45
this should just use "die"
| |
49 exit 1 | |
50 fi | |
51 info "Target reports board is ${FLAGS_board}" | |
52 } | |
53 | |
54 function cleanup_remote_access() { | |
55 # Call this function from the exit trap of the main script. | |
56 # Iff we started ssh-agent, be nice and clean it up. | |
57 # Note, only works if called from the main script - no subshells. | |
58 if [[ 1 -eq ${OWN_SSH_AGENT} ]] | |
59 then | |
60 kill ${SSH_AGENT_PID} 2>/dev/null | |
61 unset SSH_AGENT_PID SSH_AUTH_SOCK | |
62 fi | |
63 } | |
64 | |
65 function remote_access_init() { | |
petkov
2011/01/13 22:54:45
rename to something that makes it clear this is sp
| |
66 local tmp_private_key=$TMP/private_key | |
67 if [ -z "$SSH_AGENT_PID" ]; then | |
68 eval $(ssh-agent) | |
69 OWN_SSH_AGENT=1 | |
70 else | |
71 OWN_SSH_AGENT=0 | |
72 fi | |
73 cp $FLAGS_private_key $tmp_private_key | |
74 chmod 0400 $tmp_private_key | |
75 ssh-add $tmp_private_key | |
76 } | |
77 | |
32 function cleanup() { | 78 function cleanup() { |
33 # Always remove the build path in case it was used. | 79 # Always remove the build path in case it was used. |
34 [[ -n "${BUILD_DIR}" ]] && sudo rm -rf "${BUILD_DIR}" | 80 [[ -n "${BUILD_DIR}" ]] && sudo rm -rf "${BUILD_DIR}" |
35 if [[ $FLAGS_cleanup -eq ${FLAGS_TRUE} ]] || \ | 81 if [[ $FLAGS_cleanup -eq ${FLAGS_TRUE} ]] || \ |
36 [[ ${RAN_ANY_TESTS} -eq ${FLAGS_FALSE} ]]; then | 82 [[ ${RAN_ANY_TESTS} -eq ${FLAGS_FALSE} ]]; then |
37 rm -rf "${TMP}" | 83 rm -rf "${TMP}" |
38 else | 84 else |
39 echo ">>> Details stored under ${TMP}" | 85 echo ">>> Details stored under ${TMP}" |
40 fi | 86 fi |
41 cleanup_remote_access | 87 cleanup_remote_access |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
286 | 332 |
287 echo "" | 333 echo "" |
288 info "Test results:" | 334 info "Test results:" |
289 ./generate_test_report "${TMP}" --strip="${TMP}/" | 335 ./generate_test_report "${TMP}" --strip="${TMP}/" |
290 | 336 |
291 print_time_elapsed | 337 print_time_elapsed |
292 } | 338 } |
293 | 339 |
294 restart_in_chroot_if_needed "$@" | 340 restart_in_chroot_if_needed "$@" |
295 main "$@" | 341 main "$@" |
OLD | NEW |