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 . "$(dirname "$0")/autotest_lib.sh" |
18 | 18 |
19 # Script must be run inside the chroot | 19 # Script must be run inside the chroot |
20 assert_inside_chroot | 20 assert_inside_chroot |
21 | 21 |
22 DEFAULT_CONTROL=client/site_tests/setup/control | 22 DEFAULT_CONTROL=client/site_tests/setup/control |
23 | 23 |
24 DEFINE_string control "${DEFAULT_CONTROL}" \ | 24 DEFINE_string control "${DEFAULT_CONTROL}" \ |
25 "Setup control file -- path relative to the destination autotest directory" c | 25 "Setup control file -- path relative to the destination autotest directory" c |
| 26 DEFINE_string board "" \ |
| 27 "Board name for the target you are building if using portage build system" |
26 | 28 |
27 # More useful help | 29 # More useful help |
28 FLAGS_HELP="usage: $0 [flags]" | 30 FLAGS_HELP="usage: $0 [flags]" |
29 | 31 |
30 # parse the command-line | 32 # parse the command-line |
31 FLAGS "$@" || exit 1 | 33 FLAGS "$@" || exit 1 |
32 eval set -- "${FLAGS_ARGV}" | 34 eval set -- "${FLAGS_ARGV}" |
33 set -e | 35 set -e |
34 | 36 |
35 AUTOTEST_SRC="${GCLIENT_ROOT}/src/third_party/autotest/files" | 37 AUTOTEST_SRC="${GCLIENT_ROOT}/src/third_party/autotest/files" |
36 # Destination in chroot to install autotest. | 38 # Destination in chroot to install autotest. |
37 AUTOTEST_DEST="/usr/local/autotest" | 39 AUTOTEST_DEST="/usr/local/autotest" |
38 | 40 |
| 41 # If new build system flag passed, use ebuild and exit |
| 42 if [ -n "${FLAGS_board}" ]; then |
| 43 sudo GCLIENT_ROOT="${GCLIENT_ROOT}" FLAGS_control=${FLAGS_control} \ |
| 44 "emerge-${FLAGS_board}" -a chromeos-base/autotest |
| 45 exit 0 |
| 46 fi |
| 47 |
39 # Copy a local "installation" of autotest into the chroot, to avoid | 48 # Copy a local "installation" of autotest into the chroot, to avoid |
40 # polluting the src dir with tmp files, results, etc. | 49 # polluting the src dir with tmp files, results, etc. |
41 update_chroot_autotest "${CHROOT_TRUNK_DIR}/src/third_party/autotest/files" \ | 50 update_chroot_autotest "${CHROOT_TRUNK_DIR}/src/third_party/autotest/files" \ |
42 "${AUTOTEST_DEST}" | 51 "${AUTOTEST_DEST}" |
43 | 52 |
44 # Create python package init files for top level test case dirs. | 53 # Create python package init files for top level test case dirs. |
45 function touchInitPy() { | 54 function touchInitPy() { |
46 local dirs=${1} | 55 local dirs=${1} |
47 for base_dir in $dirs | 56 for base_dir in $dirs |
48 do | 57 do |
49 local sub_dirs="$(find ${base_dir} -maxdepth 1 -type d)" | 58 local sub_dirs="$(find ${base_dir} -maxdepth 1 -type d)" |
50 for sub_dir in ${sub_dirs} | 59 for sub_dir in ${sub_dirs} |
51 do | 60 do |
52 touch ${sub_dir}/__init__.py | 61 touch ${sub_dir}/__init__.py |
53 done | 62 done |
54 touch ${base_dir}/__init__.py | 63 touch ${base_dir}/__init__.py |
55 done | 64 done |
56 } | 65 } |
57 | 66 |
58 cd ${AUTOTEST_DEST} | 67 cd ${AUTOTEST_DEST} |
59 touchInitPy client/tests client/site_tests | 68 touchInitPy client/tests client/site_tests |
60 touch __init__.py | 69 touch __init__.py |
61 | 70 |
62 # Export GCLIENT_ROOT so that tests have access to the source and build trees | 71 # Export GCLIENT_ROOT so that tests have access to the source and build trees |
63 export GCLIENT_ROOT | 72 export GCLIENT_ROOT |
64 | 73 |
65 # run the magic test setup script. | 74 # run the magic test setup script. |
66 echo "Building tests using ${FLAGS_control}..." | 75 echo "Building tests using ${FLAGS_control}..." |
67 client/bin/autotest ${FLAGS_control} | 76 client/bin/autotest ${FLAGS_control} |
OLD | NEW |