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 # This script makes autotest client tests inside an Ubuntu chroot | 7 # This script makes autotest client tests inside an Ubuntu chroot |
8 # environment. The idea is to compile any platform-dependent autotest | 8 # environment. The idea is to compile any platform-dependent autotest |
9 # client tests in the build environment, since client systems under | 9 # client tests in the build environment, since client systems under |
10 # test lack the proper toolchain. | 10 # test lack the proper toolchain. |
11 # | 11 # |
12 # The user can later run autotest against an ssh enabled test client system, or | 12 # The user can later run autotest against an ssh enabled test client system, or |
13 # install the compiled client tests directly onto the rootfs image, using | 13 # install the compiled client tests directly onto the rootfs image, using |
14 # mod_image_for_test.sh. | 14 # mod_image_for_test.sh. |
15 | 15 |
16 . "$(dirname "$0")/common.sh" | 16 . "$(dirname "$0")/common.sh" |
| 17 . "$(dirname "$0")/autotest_lib.sh" |
17 | 18 |
18 # Script must be run inside the chroot | 19 # Script must be run inside the chroot |
19 assert_inside_chroot | 20 assert_inside_chroot |
20 | 21 |
21 DEFAULT_CONTROL=client/site_tests/setup/control | 22 DEFAULT_CONTROL=client/site_tests/setup/control |
22 | 23 |
23 DEFINE_string control "${DEFAULT_CONTROL}" \ | 24 DEFINE_string control "${DEFAULT_CONTROL}" \ |
24 "Setup control file -- path relative to the destination autotest directory" c | 25 "Setup control file -- path relative to the destination autotest directory" c |
25 | 26 |
26 # More useful help | 27 # More useful help |
27 FLAGS_HELP="usage: $0 [flags]" | 28 FLAGS_HELP="usage: $0 [flags]" |
28 | 29 |
29 # parse the command-line | 30 # parse the command-line |
30 FLAGS "$@" || exit 1 | 31 FLAGS "$@" || exit 1 |
31 eval set -- "${FLAGS_ARGV}" | 32 eval set -- "${FLAGS_ARGV}" |
32 set -e | 33 set -e |
33 | 34 |
34 AUTOTEST_SRC="${GCLIENT_ROOT}/src/third_party/autotest/files" | 35 AUTOTEST_SRC="${GCLIENT_ROOT}/src/third_party/autotest/files" |
35 # Destination in chroot to install autotest. | 36 # Destination in chroot to install autotest. |
36 AUTOTEST_DEST="/usr/local/autotest" | 37 AUTOTEST_DEST="/usr/local/autotest" |
37 | 38 |
38 # Copy a local "installation" of autotest into the chroot, to avoid | 39 # Copy a local "installation" of autotest into the chroot, to avoid |
39 # polluting the src dir with tmp files, results, etc. | 40 # polluting the src dir with tmp files, results, etc. |
40 echo "Installing Autotest..." | 41 update_chroot_autotest "${CHROOT_TRUNK_DIR}/src/third_party/autotest/files" |
41 sudo mkdir -p ${AUTOTEST_DEST} | |
42 sudo chmod 777 ${AUTOTEST_DEST} | |
43 cd ${CHROOT_TRUNK_DIR}/src/third_party/autotest/files | |
44 cp -fpru {client,conmux,server,tko,utils,global_config.ini,shadow_config.ini} \ | |
45 ${AUTOTEST_DEST} | |
46 | 42 |
47 # Create python package init files for top level test case dirs. | 43 # Create python package init files for top level test case dirs. |
48 function touchInitPy() { | 44 function touchInitPy() { |
49 local dirs=${1} | 45 local dirs=${1} |
50 for base_dir in $dirs | 46 for base_dir in $dirs |
51 do | 47 do |
52 local sub_dirs="$(find ${base_dir} -maxdepth 1 -type d)" | 48 local sub_dirs="$(find ${base_dir} -maxdepth 1 -type d)" |
53 for sub_dir in ${sub_dirs} | 49 for sub_dir in ${sub_dirs} |
54 do | 50 do |
55 touch ${sub_dir}/__init__.py | 51 touch ${sub_dir}/__init__.py |
56 done | 52 done |
57 touch ${base_dir}/__init__.py | 53 touch ${base_dir}/__init__.py |
58 done | 54 done |
59 } | 55 } |
60 | 56 |
61 cd ${AUTOTEST_DEST} | 57 cd ${AUTOTEST_DEST} |
62 touchInitPy client/tests client/site_tests | 58 touchInitPy client/tests client/site_tests |
63 touch __init__.py | 59 touch __init__.py |
64 | 60 |
65 # Export GCLIENT_ROOT so that tests have access to the source and build trees | 61 # Export GCLIENT_ROOT so that tests have access to the source and build trees |
66 export GCLIENT_ROOT | 62 export GCLIENT_ROOT |
67 | 63 |
68 # run the magic test setup script. | 64 # run the magic test setup script. |
69 echo "Building tests using ${FLAGS_control}..." | 65 echo "Building tests using ${FLAGS_control}..." |
70 client/bin/autotest ${FLAGS_control} | 66 client/bin/autotest ${FLAGS_control} |
OLD | NEW |