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 a chroot environment. The idea |
8 # environment. The idea is to compile any platform-dependent autotest | 8 # is to compile any platform-dependent autotest client tests in the build |
9 # client tests in the build environment, since client systems under | 9 # environment, since client systems under test lack the proper toolchain. |
10 # test lack the proper toolchain. | |
11 # | 10 # |
12 # The user can later run autotest against an ssh enabled test client system, or | 11 # 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 | 12 # install the compiled client tests directly onto the rootfs image. |
14 # mod_image_for_test.sh. | |
15 | 13 |
16 . "$(dirname "$0")/common.sh" | 14 . "$(dirname "$0")/common.sh" |
17 . "$(dirname "$0")/autotest_lib.sh" | |
18 | 15 |
19 # Script must be run inside the chroot | 16 # Script must be run inside the chroot |
20 assert_inside_chroot | 17 assert_inside_chroot |
21 | 18 |
22 DEFAULT_CONTROL=client/site_tests/setup/control | 19 DEFAULT_TESTS_LIST="all" |
23 | |
24 DEFINE_string control "${DEFAULT_CONTROL}" \ | |
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" | |
28 | 20 |
29 DEFINE_string board "" \ | 21 DEFINE_string board "" \ |
30 "The board for which you are building autotest" | 22 "The board for which you are building autotest" |
| 23 DEFINE_string build "${DEFAULT_TESTS_LIST}" \ |
| 24 "a comma seperated list of autotest client tests to be prebuilt." b |
| 25 DEFINE_boolean prompt $FLAGS_TRUE "Prompt user when building all tests" |
31 | 26 |
32 # More useful help | 27 # More useful help |
33 FLAGS_HELP="usage: $0 [flags]" | 28 FLAGS_HELP="usage: $0 [flags]" |
34 | 29 |
35 # parse the command-line | 30 # parse the command-line |
36 FLAGS "$@" || exit 1 | 31 FLAGS "$@" || exit 1 |
37 eval set -- "${FLAGS_ARGV}" | 32 eval set -- "${FLAGS_ARGV}" |
38 set -e | 33 set -e |
39 | 34 |
40 AUTOTEST_SRC="${GCLIENT_ROOT}/src/third_party/autotest/files" | |
41 # Destination in chroot to install autotest. | |
42 AUTOTEST_DEST="/usr/local/autotest/${FLAGS_board}" | |
43 | 35 |
44 # If new build system flag passed, use ebuild and exit | 36 if [ -z ${FLAGS_board} ] |
45 if [ -n "${FLAGS_board}" ]; then | 37 then |
46 sudo GCLIENT_ROOT="${GCLIENT_ROOT}" FLAGS_control=${FLAGS_control} \ | 38 echo "You are required to specify a board name from the command line." |
47 "emerge-${FLAGS_board}" -a chromeos-base/autotest | 39 echo "Supported boards are:" |
| 40 for board in ../overlays/overlay-* |
| 41 do |
| 42 echo ${board:20} |
| 43 done |
48 exit 0 | 44 exit 0 |
49 fi | 45 fi |
50 | 46 |
51 # Copy a local "installation" of autotest into the chroot, to avoid | |
52 # polluting the src dir with tmp files, results, etc. | |
53 update_chroot_autotest "${CHROOT_TRUNK_DIR}/src/third_party/autotest/files" \ | |
54 "${AUTOTEST_DEST}" | |
55 | 47 |
56 # Create python package init files for top level test case dirs. | 48 # build default pre-compile client tests list. |
57 function touchInitPy() { | 49 ALL_TESTS="compilebench,dbench,disktest,ltp,unixbench" |
58 local dirs=${1} | 50 for SITE_TEST in ../third_party/autotest/files/client/site_tests/* |
59 for base_dir in $dirs | 51 do |
60 do | 52 if [ -d ${SITE_TEST} ] |
61 local sub_dirs="$(find ${base_dir} -maxdepth 1 -type d)" | 53 then |
62 for sub_dir in ${sub_dirs} | 54 ALL_TESTS="${ALL_TESTS},${SITE_TEST:48}" |
63 do | 55 fi |
64 touch ${sub_dir}/__init__.py | 56 done |
65 done | |
66 touch ${base_dir}/__init__.py | |
67 done | |
68 } | |
69 | 57 |
70 cd ${AUTOTEST_DEST} | 58 if [ ${FLAGS_build} == ${DEFAULT_TESTS_LIST} ] |
71 touchInitPy client/tests client/site_tests | 59 then |
72 touch __init__.py | 60 if [ ${FLAGS_prompt} -eq ${FLAGS_TRUE} ] |
| 61 then |
| 62 echo -n "You want to prebuild all client tests and it may take a long time " |
| 63 echo "to finish. " |
| 64 read -p "Are you sure you want to continue?(N/y)" answer |
| 65 answer=${answer:0:1} |
| 66 if [ "${answer}" != "Y" ] && [ "${answer}" != "y" ] |
| 67 then |
| 68 echo "Use --build to specify tests you like to pre-compile." |
| 69 echo -n "E.g.: ./enter_chroot.sh \"./build_autotest.sh " |
| 70 echo "--build=system_SAT\"" |
| 71 exit 0 |
| 72 fi |
| 73 fi |
| 74 TEST_LIST=${ALL_TESTS} |
| 75 else |
| 76 TEST_LIST=${FLAGS_build} |
| 77 fi |
73 | 78 |
74 # Export GCLIENT_ROOT so that tests have access to the source and build trees | 79 GCLIENT_ROOT="${GCLIENT_ROOT}" TEST_LIST=${TEST_LIST} \ |
75 export GCLIENT_ROOT | 80 "emerge-${FLAGS_board}" chromeos-base/autotest |
76 | |
77 # run the magic test setup script. | |
78 echo "Building tests using ${FLAGS_control}..." | |
79 client/bin/autotest ${FLAGS_control} | |
OLD | NEW |