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 a chroot environment. The idea | 7 # This script makes autotest client tests inside a chroot environment. The idea |
8 # is to compile any platform-dependent autotest client tests in the build | 8 # is to compile any platform-dependent autotest client tests in the build |
9 # environment, since client systems under test lack the proper toolchain. | 9 # environment, since client systems under test lack the proper toolchain. |
10 # | 10 # |
11 # 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 |
12 # install the compiled client tests directly onto the rootfs image. | 12 # install the compiled client tests directly onto the rootfs image. |
13 | 13 |
14 # Includes common already | 14 # Includes common already |
15 . "$(dirname $0)/autotest_lib.sh" | 15 ./autotest --build=all $@ |
16 | 16 |
17 # Script must be run inside the chroot | |
18 assert_inside_chroot | |
19 | |
20 DEFAULT_TESTS_LIST="all" | |
21 | |
22 DEFINE_string build "${DEFAULT_TESTS_LIST}" \ | |
23 "a comma seperated list of autotest client tests to be prebuilt." b | |
24 DEFINE_boolean prompt $FLAGS_TRUE "Prompt user when building all tests." | |
25 DEFINE_boolean autox $FLAGS_TRUE "Build autox along with autotest" | |
26 DEFINE_boolean buildcheck $FLAGS_TRUE "Fail if tests fail to build" | |
27 DEFINE_integer jobs -1 "How many packages to build in parallel at maximum." | |
28 | |
29 # More useful help | |
30 FLAGS_HELP="usage: $0 [flags]" | |
31 | |
32 # parse the command-line | |
33 FLAGS "$@" || exit 1 | |
34 eval set -- "${FLAGS_ARGV}" | |
35 set -e | |
36 | |
37 check_board | |
38 | |
39 if [[ "${FLAGS_jobs}" -ne -1 ]]; then | |
40 EMERGE_JOBS="--jobs=${FLAGS_jobs}" | |
41 fi | |
42 | |
43 # build default pre-compile client tests list. | |
44 ALL_TESTS="compilebench,dbench,disktest,ltp,netperf2,unixbench" | |
45 CLIENT_TEST_PATH="../third_party/autotest/files/client/site_tests" | |
46 for SITE_TEST in ${CLIENT_TEST_PATH}/* | |
47 do | |
48 if [ -d ${SITE_TEST} ] | |
49 then | |
50 ALL_TESTS="${ALL_TESTS},${SITE_TEST##${CLIENT_TEST_PATH}/}" | |
51 fi | |
52 done | |
53 | |
54 # Load the overlay specific blacklist and remove any matching tests. | |
55 BOARD_BASENAME=$(echo "${FLAGS_board}" |cut -d '_' -f 1) | |
56 PRIMARY_BOARD_OVERLAY="${SRC_ROOT}/overlays/overlay-${BOARD_BASENAME}" | |
57 BLACKLIST_FILE="${PRIMARY_BOARD_OVERLAY}/autotest-blacklist" | |
58 if [ -r "${BLACKLIST_FILE}" ] | |
59 then | |
60 BLACKLISTED_TESTS=$(cat ${BLACKLIST_FILE}) | |
61 | |
62 for TEST in ${BLACKLISTED_TESTS} | |
63 do | |
64 ALL_TESTS=${ALL_TESTS/#${TEST},/} # match first test (test,...) | |
65 ALL_TESTS=${ALL_TESTS/,${TEST},/,} # match middle tests (...,test,...) | |
66 ALL_TESTS=${ALL_TESTS/%,${TEST}/} # match last test (...,test) | |
67 done | |
68 fi | |
69 | |
70 if [ ${FLAGS_build} == ${DEFAULT_TESTS_LIST} ] | |
71 then | |
72 if [ ${FLAGS_prompt} -eq ${FLAGS_TRUE} ] | |
73 then | |
74 echo -n "You want to pre-build all client tests and it may take a long time" | |
75 echo " to finish. " | |
76 read -p "Are you sure you want to continue?(N/y)" answer | |
77 answer=${answer:0:1} | |
78 if [ "${answer}" != "Y" ] && [ "${answer}" != "y" ] | |
79 then | |
80 echo "Use --build to specify tests you like to pre-compile." | |
81 echo -n "E.g.: ./enter_chroot.sh \"./build_autotest.sh " | |
82 echo "--build=system_SAT\"" | |
83 exit 0 | |
84 fi | |
85 fi | |
86 TEST_LIST=${ALL_TESTS} | |
87 else | |
88 TEST_LIST=${FLAGS_build} | |
89 fi | |
90 | |
91 # Decide on USE flags based on options | |
92 USE= | |
93 [ $FLAGS_autox -eq "$FLAGS_FALSE" ] && USE="${USE} -autox" | |
94 [ $FLAGS_buildcheck -eq "$FLAGS_TRUE" ] && USE="${USE} buildcheck" | |
95 | |
96 GCLIENT_ROOT="${GCLIENT_ROOT}" TEST_LIST=${TEST_LIST} \ | |
97 FEATURES="${FEATURES} -buildpkg -collision-protect" \ | |
98 USE="$USE" "emerge-${FLAGS_board}" \ | |
99 chromeos-base/autotest ${EMERGE_JOBS} \ | |
100 || die "build_autotest failed." | |
OLD | NEW |