blob: 171393b69d6d0940b0b037b9cc35fc26789b260c [file] [log] [blame]
Zdenek Behan12ad1c52010-08-03 16:34:37 -07001# Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
2# Distributed under the terms of the GNU General Public License v2
3
4#
5# Original Author: The Chromium OS Authors <chromium-os-dev@chromium.org>
6# Purpose: Eclass for handling autotest test packages
7#
8
Zdenek Behan9e98f322010-08-26 18:56:54 -07009RDEPEND="( autotest? ( >=chromeos-base/autotest-0.0.1-r3 ) )"
Zdenek Behan12ad1c52010-08-03 16:34:37 -070010
Zdenek Behan302e7482011-02-01 21:58:52 +010011IUSE="+buildcheck autotest opengles"
Zdenek Behan12ad1c52010-08-03 16:34:37 -070012
13# Ensure the configures run by autotest pick up the right config.site
Zdenek Behan99bf5842010-08-04 17:23:38 -070014export CONFIG_SITE="/usr/share/config.site"
15export AUTOTEST_WORKDIR="${WORKDIR}/autotest-work"
Zdenek Behan12ad1c52010-08-03 16:34:37 -070016
Zdenek Behancd997a32010-08-20 12:55:44 -070017# @ECLASS-VARIABLE: AUTOTEST_CLIENT_*
18# @DESCRIPTION:
19# Location of the appropriate test directory inside ${S}
20: ${AUTOTEST_CLIENT_TESTS:=client/tests}
21: ${AUTOTEST_CLIENT_SITE_TESTS:=client/site_tests}
22: ${AUTOTEST_SERVER_TESTS:=server/tests}
23: ${AUTOTEST_SERVER_SITE_TESTS:=server/site_tests}
Zdenek Behan41463c92010-08-23 12:12:31 -070024: ${AUTOTEST_CONFIG:=client/config}
25: ${AUTOTEST_DEPS:=client/deps}
26: ${AUTOTEST_PROFILERS:=client/profilers}
27
28# @ECLASS-VARIABLE: AUTOTEST_*_LIST
29# @DESCRIPTION:
30# The list of deps/configs/profilers provided with this package
Chris Sosa6bde1602012-03-15 23:19:57 -070031: ${AUTOTEST_CONFIG_LIST:=}
32: ${AUTOTEST_DEPS_LIST:=}
33: ${AUTOTEST_PROFILERS_LIST:=}
Zdenek Behancd997a32010-08-20 12:55:44 -070034
Zdenek Behand012b762010-09-01 21:22:26 -070035# @ECLASS-VARIABLE: AUTOTEST_FORCE_LIST
36# @DESCRIPTION:
37# Sometimes we just want to forget about useflags and build what's inside
38: ${AUTOTEST_FORCE_TEST_LIST:=}
39
Zdenek Behanb1f7c892010-09-22 12:25:38 -070040# @ECLASS-VARIABLE: AUTOTEST_FILE_MASK
41# @DESCRIPTION:
42# The list of 'find' expressions to find in the resulting image and delete
43: ${AUTOTEST_FILE_MASK:=}
44
Chris Sosa6bde1602012-03-15 23:19:57 -070045fast_cp() {
Zdenek Behan7922d132010-09-24 14:18:05 -070046 cp -l "$@" || cp "$@"
47}
48
Chris Sosa6bde1602012-03-15 23:19:57 -070049get_test_list() {
Zdenek Behand012b762010-09-01 21:22:26 -070050 if [ -n "${AUTOTEST_FORCE_TEST_LIST}" ]; then
51 # list forced
52 echo "${AUTOTEST_FORCE_TEST_LIST}"
53 return
54 fi
55
56 # we cache the result of this operation in AUTOTEST_TESTS,
57 # because it's expensive and does not change over the course of one ebuild run
Chris Sosa43b6cde2012-03-22 14:32:23 -070058 local result="${IUSE_TESTS[*]//[+-]tests_/}"
Zdenek Behand012b762010-09-01 21:22:26 -070059 result="${result//tests_/}"
60
61 result=$(for test in ${result}; do use tests_${test} && echo -n "${test} "; done)
62 echo "${result}"
63}
64
Chris Sosa6bde1602012-03-15 23:19:57 -070065# Pythonify the list of packages by doing the equivalent of ','.join(args)
66pythonify_test_list() {
67 local result=$(printf '%s,' "$@")
68 echo ${result%,}
Zdenek Behan12ad1c52010-08-03 16:34:37 -070069}
70
71# Create python package init files for top level test case dirs.
Chris Sosa6bde1602012-03-15 23:19:57 -070072touch_init_py() {
Zdenek Behan12ad1c52010-08-03 16:34:37 -070073 local dirs=${1}
74 for base_dir in $dirs
75 do
76 local sub_dirs="$(find ${base_dir} -maxdepth 1 -type d)"
77 for sub_dir in ${sub_dirs}
78 do
79 touch ${sub_dir}/__init__.py
80 done
81 touch ${base_dir}/__init__.py
82 done
83}
84
Zdenek Behan361d8142012-03-19 04:30:45 +010085# Exports a CROS_WORKON_SUBDIRS_TO_COPY variable to ensure that only the
86# necessary files will be copied. This cannot be applied globally, as some
87# ebuilds may not have tests only.
88autotest_restrict_workon_subdirs() {
89 CROS_WORKON_SUBDIRS_TO_COPY=()
90 local var
91 for var in AUTOTEST_{CLIENT,SERVER}_{TESTS,SITE_TESTS} \
92 AUTOTEST_{CONFIG,DEPS,PROFILERS}; do
93 CROS_WORKON_SUBDIRS_TO_COPY+=( ${!var} )
94 done
95}
96
Chris Sosa6bde1602012-03-15 23:19:57 -070097setup_cross_toolchain() {
Mike Frysingerb1eda9e2012-03-08 14:56:18 -050098 tc-export CC CXX AR RANLIB LD NM STRIP PKG_CONFIG
99 export CCFLAGS="$CFLAGS"
Zdenek Behan12ad1c52010-08-03 16:34:37 -0700100
101 # TODO(fes): Check for /etc/hardened for now instead of the hardened
102 # use flag because we aren't enabling hardened on the target board.
103 # Rather, right now we're using hardened only during toolchain compile.
104 # Various tests/etc. use %ebx in here, so we have to turn off PIE when
105 # using the hardened compiler
106 if use x86 ; then
107 if use hardened ; then
108 #CC="${CC} -nopie"
109 append-flags -nopie
110 fi
111 fi
112}
113
Chris Sosa6bde1602012-03-15 23:19:57 -0700114create_autotest_workdir() {
Zdenek Behan12ad1c52010-08-03 16:34:37 -0700115 local dst=${1}
116
117 # create a working enviroment for pre-building
Chris Masone21512432010-11-15 16:18:57 -0800118 ln -sf "${SYSROOT}"/usr/local/autotest/{conmux,tko,global_config.ini,shadow_config.ini} "${dst}"/
Zdenek Behan99bf5842010-08-04 17:23:38 -0700119
Zdenek Behan12ad1c52010-08-03 16:34:37 -0700120 # NOTE: in order to make autotest not notice it's running from /usr/local/, we need
121 # to make sure the binaries are real, because they do the path magic
122 local root_path base_path
Chris Masone21512432010-11-15 16:18:57 -0800123 for base_path in utils server; do
124 root_path="${SYSROOT}/usr/local/autotest/${base_path}"
125 mkdir -p "${dst}/${base_path}"
126 for entry in $(ls "${root_path}"); do
Zdenek Behan7e9e32f2012-02-28 03:15:46 +0100127 # Take all important binaries from SYSROOT install, make a copy.
128 if [ -d "${root_path}/${entry}" ]; then
129 # Ignore anything that has already been put in place by
130 # something else. This will typically be server/{site_tests,tests}.
131 if ! [ -e "${dst}/${base_path}/${entry}" ]; then
132 ln -sf "${root_path}/${entry}" "${dst}/${base_path}/"
133 fi
Chris Masone21512432010-11-15 16:18:57 -0800134 else
135 cp -f ${root_path}/${entry} ${dst}/${base_path}/
136 fi
137 done
138 done
Zdenek Behan12ad1c52010-08-03 16:34:37 -0700139 for base_path in client client/bin; do
140 root_path="${SYSROOT}/usr/local/autotest/${base_path}"
141 mkdir -p "${dst}/${base_path}"
142
Zdenek Behan451e07f2010-08-06 11:25:37 -0700143 # Skip bin, because it is processed separately, and test-provided dirs
144 # Also don't symlink to packages, because that kills the build
Zdenek Behan41463c92010-08-23 12:12:31 -0700145 for entry in $(ls "${root_path}" | \
146 grep -v "\(bin\|tests\|site_tests\|config\|deps\|profilers\|packages\)$"); do
Zdenek Behan12ad1c52010-08-03 16:34:37 -0700147 ln -sf "${root_path}/${entry}" "${dst}/${base_path}/"
148 done
149 done
150 # replace the important binaries with real copies
151 for base_path in autotest autotest_client; do
152 root_path="${SYSROOT}/usr/local/autotest/client/bin/${base_path}"
153 rm "${dst}/client/bin/${base_path}"
154 cp -f ${root_path} "${dst}/client/bin/${base_path}"
155 done
Zdenek Behan448ddaa2010-08-24 11:18:50 -0700156
157 # Selectively pull in deps that are not provided by the current test package
158 for base_path in config deps profilers; do
159 for dir in "${SYSROOT}/usr/local/autotest/client/${base_path}"/*; do
160 if [ -d "${dir}" ] && \
161 ! [ -d "${AUTOTEST_WORKDIR}/client/${base_path}/$(basename ${dir})" ]; then
162 # directory does not exist, create a symlink
163 ln -sf "${dir}" "${AUTOTEST_WORKDIR}/client/${base_path}/$(basename ${dir})"
164 fi
165 done
166 done
Zdenek Behan12ad1c52010-08-03 16:34:37 -0700167}
168
Chris Sosa6bde1602012-03-15 23:19:57 -0700169print_test_dirs() {
Zdenek Behan12ad1c52010-08-03 16:34:37 -0700170 local testroot="${1}"
Chris Sosa6bde1602012-03-15 23:19:57 -0700171 local ignore_test_contents="${2}"
Zdenek Behan12ad1c52010-08-03 16:34:37 -0700172
173 pushd "${testroot}" 1> /dev/null
174 for test in *; do
Chris Sosa6bde1602012-03-15 23:19:57 -0700175 if [ -d "${test}" ] && [ -n "${ignore_test_contents}" -o \
176 -f "${test}/${test}".py ]; then
Zdenek Behan12ad1c52010-08-03 16:34:37 -0700177 echo "${test}"
178 fi
179 done
180 popd 1> /dev/null
181}
182
Zdenek Behaneee7bc22010-08-20 18:33:13 -0700183# checks IUSE_TESTS and sees if at least one of these is enabled
Chris Sosa6bde1602012-03-15 23:19:57 -0700184are_we_used() {
Zdenek Behan14ae4892010-08-26 15:25:30 -0700185 if ! use autotest; then
186 # unused
187 return 1
188 fi
189
Zdenek Behand012b762010-09-01 21:22:26 -0700190 [ -n "$(get_test_list)" ] && return 0
Zdenek Behaneee7bc22010-08-20 18:33:13 -0700191
192 # unused
193 return 1
194}
195
Chris Sosa6bde1602012-03-15 23:19:57 -0700196autotest_src_prepare() {
Zdenek Behaneee7bc22010-08-20 18:33:13 -0700197 are_we_used || return 0
198 einfo "Preparing tests"
199
200 # FIXME: These directories are needed, autotest quietly dies if
201 # they don't even exist. They may, however, stay empty.
Zdenek Behanc02fc472010-08-13 12:55:07 -0700202 mkdir -p "${AUTOTEST_WORKDIR}"/client/tests
203 mkdir -p "${AUTOTEST_WORKDIR}"/client/site_tests
Zdenek Behan41463c92010-08-23 12:12:31 -0700204 mkdir -p "${AUTOTEST_WORKDIR}"/client/config
205 mkdir -p "${AUTOTEST_WORKDIR}"/client/deps
206 mkdir -p "${AUTOTEST_WORKDIR}"/client/profilers
Zdenek Behanc02fc472010-08-13 12:55:07 -0700207 mkdir -p "${AUTOTEST_WORKDIR}"/server/tests
208 mkdir -p "${AUTOTEST_WORKDIR}"/server/site_tests
Zdenek Behan12ad1c52010-08-03 16:34:37 -0700209
Zdenek Behand012b762010-09-01 21:22:26 -0700210 TEST_LIST=$(get_test_list)
211
Zdenek Behan448ddaa2010-08-24 11:18:50 -0700212 # Pull in the individual test cases.
Zdenek Behan31315b32010-08-05 16:34:39 -0700213 for l1 in client server; do
214 for l2 in site_tests tests; do
Zdenek Behancd997a32010-08-20 12:55:44 -0700215 # pick up the indicated location of test sources
216 eval srcdir=${WORKDIR}/${P}/\${AUTOTEST_${l1^^*}_${l2^^*}}
217
Zdenek Behand012b762010-09-01 21:22:26 -0700218 # test does have this directory
219 for test in ${TEST_LIST}; do
220 if [ -d "${srcdir}/${test}" ]; then
Zdenek Behan7922d132010-09-24 14:18:05 -0700221 fast_cp -fpr "${srcdir}/${test}" "${AUTOTEST_WORKDIR}/${l1}/${l2}"/ || die
Zdenek Behand012b762010-09-01 21:22:26 -0700222 fi
223 done
Zdenek Behan31315b32010-08-05 16:34:39 -0700224 done
225 done
Zdenek Behan99bf5842010-08-04 17:23:38 -0700226
Zdenek Behan448ddaa2010-08-24 11:18:50 -0700227 # Pull in all the deps provided by this package, selectively.
Zdenek Behan41463c92010-08-23 12:12:31 -0700228 for l2 in config deps profilers; do
229 # pick up the indicated location of test sources
230 eval srcdir=${WORKDIR}/${P}/\${AUTOTEST_${l2^^*}}
231
232 if [ -d "${srcdir}" ]; then # test does have this directory
233 pushd "${srcdir}" 1> /dev/null
234 eval deplist=\${AUTOTEST_${l2^^*}_LIST}
235
236 if [ "${deplist}" = "*" ]; then
Zdenek Behan7922d132010-09-24 14:18:05 -0700237 fast_cp -fpr * "${AUTOTEST_WORKDIR}/client/${l2}"
Zdenek Behan41463c92010-08-23 12:12:31 -0700238 else
239 for dir in ${deplist}; do
Zdenek Behan7922d132010-09-24 14:18:05 -0700240 fast_cp -fpr "${dir}" "${AUTOTEST_WORKDIR}/client/${l2}"/ || die
Zdenek Behan41463c92010-08-23 12:12:31 -0700241 done
242 fi
243 popd 1> /dev/null
244 fi
245 done
246
Zdenek Behan474fbae2010-08-20 21:13:22 -0700247 # FIXME: We'd like if this were not necessary, and autotest supported out-of-tree build
Zdenek Behan99bf5842010-08-04 17:23:38 -0700248 create_autotest_workdir "${AUTOTEST_WORKDIR}"
Zdenek Behaneee7bc22010-08-20 18:33:13 -0700249
Zdenek Behanf93c208a2010-09-21 18:53:58 -0700250 # Each test directory needs to be visited and have an __init__.py created.
251 # However, that only applies to the directories which have a main .py file.
Zdenek Behanedb527a2010-09-22 12:24:14 -0700252 pushd "${AUTOTEST_WORKDIR}" > /dev/null || die "AUTOTEST_WORKDIR does not exist?!"
Zdenek Behanf93c208a2010-09-21 18:53:58 -0700253 for dir in client/tests client/site_tests server/tests server/site_tests; do
Zdenek Behanedb527a2010-09-22 12:24:14 -0700254 pushd "${dir}" > /dev/null || continue
Zdenek Behanf93c208a2010-09-21 18:53:58 -0700255 for sub in *; do
256 [ -f "${sub}/${sub}.py" ] || continue
Zdenek Behan1ec164a2010-08-17 19:06:31 -0700257
Zdenek Behanf93c208a2010-09-21 18:53:58 -0700258 touch_init_py ${sub}
259 done
Zdenek Behanedb527a2010-09-22 12:24:14 -0700260 popd > /dev/null
Zdenek Behan1ec164a2010-08-17 19:06:31 -0700261 done
Zdenek Behanedb527a2010-09-22 12:24:14 -0700262 popd > /dev/null
Zdenek Behan12ad1c52010-08-03 16:34:37 -0700263
264 # Cleanup checked-in binaries that don't support the target architecture
265 [[ ${E_MACHINE} == "" ]] && return 0;
Zdenek Behan092f4632010-09-21 19:34:01 -0700266 rm -fv $( scanelf -RmyBF%a "${AUTOTEST_WORKDIR}" | grep -v -e ^${E_MACHINE} )
Zdenek Behan12ad1c52010-08-03 16:34:37 -0700267}
268
Chris Sosa6bde1602012-03-15 23:19:57 -0700269autotest_src_compile() {
Zdenek Behan48096a82010-09-23 19:39:26 -0700270 if ! are_we_used; then
271 ewarn "***************************************************************"
272 ewarn "* Not building any tests, because the requested list is empty *"
273 ewarn "***************************************************************"
274 return 0
275 fi
Zdenek Behaneee7bc22010-08-20 18:33:13 -0700276 einfo "Compiling tests"
277
Zdenek Behan31315b32010-08-05 16:34:39 -0700278 pushd "${AUTOTEST_WORKDIR}" 1> /dev/null
Zdenek Behan99bf5842010-08-04 17:23:38 -0700279
Zdenek Behan12ad1c52010-08-03 16:34:37 -0700280 setup_cross_toolchain
281
282 if use opengles ; then
283 graphics_backend=OPENGLES
284 else
285 graphics_backend=OPENGL
286 fi
287
Zdenek Behan9e979bb2010-09-23 17:32:05 -0700288 # HACK: Some of the autotests depend on SYSROOT being defined, and die
289 # a gruesome death if it isn't. But SYSROOT does not need to exist, for
290 # example on the host, it doesn't. Let's define a compatible variable
291 # here in case we have none.
292 export SYSROOT=${SYSROOT:-"/"}
293
Zdenek Behan8ad65252010-09-07 12:35:19 -0700294 # This only prints the tests that have the associated .py
295 # (and therefore a setup function)
296 local prebuild_test_dirs="
297 client/tests client/site_tests
298 server/tests server/site_tests"
299 TESTS=$(\
300 for dir in ${prebuild_test_dirs}; do
301 print_test_dirs "${AUTOTEST_WORKDIR}/${dir}"
Chris Sosa6bde1602012-03-15 23:19:57 -0700302 done | sort -u)
Zdenek Behan9afd0a32011-01-21 01:47:02 +0100303 NR_TESTS=$(echo ${TESTS}|wc -w)
304 if ! [ "${NR_TESTS}" = "0" ]; then
305 einfo "Building tests (${NR_TESTS}):"
306 einfo "${TESTS}"
Zdenek Behan12ad1c52010-08-03 16:34:37 -0700307
Zdenek Behan9afd0a32011-01-21 01:47:02 +0100308 NORMAL=$(echo -e "\e[0m")
309 GREEN=$(echo -e "\e[1;32m")
310 RED=$(echo -e "\e[1;31m")
Zdenek Behan402fea02010-09-14 13:50:09 -0700311
Zdenek Behan9afd0a32011-01-21 01:47:02 +0100312 # Call autotest to prebuild all test cases.
313 # Parse output through a colorifying sed script
314 ( GRAPHICS_BACKEND="$graphics_backend" LOGNAME=${SUDO_USER} \
315 client/bin/autotest_client --quiet \
316 --client_test_setup=$(pythonify_test_list ${TESTS}) \
317 || ! use buildcheck || die "Tests failed to build."
318 ) | sed -e "s/\(INFO:root:setup\)/${GREEN}* \1${NORMAL}/" \
319 -e "s/\(ERROR:root:\[.*\]\)/${RED}\1${NORMAL}/"
320 else
321 einfo "No tests to prebuild, skipping"
322 fi
Zdenek Behan12ad1c52010-08-03 16:34:37 -0700323
324 # Cleanup some temp files after compiling
Zdenek Behan7c162bb2012-05-14 18:42:15 +0200325 for mask in '*.[do]' '*.pyc' ${AUTOTEST_FILE_MASK}; do
Zdenek Behanb1f7c892010-09-22 12:25:38 -0700326 einfo "Purging ${mask}"
327 find . -name "${mask}" -delete
328 done
Zdenek Behan31315b32010-08-05 16:34:39 -0700329
330 popd 1> /dev/null
Zdenek Behan12ad1c52010-08-03 16:34:37 -0700331}
332
Chris Sosa6bde1602012-03-15 23:19:57 -0700333autotest_src_install() {
Zdenek Behaneee7bc22010-08-20 18:33:13 -0700334 are_we_used || return 0
335 einfo "Installing tests"
336
Zdenek Behan448ddaa2010-08-24 11:18:50 -0700337 # Install all test cases, after setup has been called on them.
338 # We install everything, because nothing else is copied into the
339 # testcase directories besides what this package provides.
Zdenek Behan1ec164a2010-08-17 19:06:31 -0700340 local instdirs="
341 client/tests
342 client/site_tests
Zdenek Behan1ec164a2010-08-17 19:06:31 -0700343 server/tests
344 server/site_tests"
345
346 for dir in ${instdirs}; do
Zdenek Behancd997a32010-08-20 12:55:44 -0700347 [ -d "${AUTOTEST_WORKDIR}/${dir}" ] || continue
Zdenek Behan1ec164a2010-08-17 19:06:31 -0700348
349 insinto /usr/local/autotest/$(dirname ${dir})
350 doins -r "${AUTOTEST_WORKDIR}/${dir}"
351 done
352
Zdenek Behan448ddaa2010-08-24 11:18:50 -0700353 # Install the deps, configs, profilers.
354 # Difference from above is, we don't install the whole thing, just
355 # the stuff provided by this package, by looking at AUTOTEST_*_LIST.
356 instdirs="
357 config
358 deps
359 profilers"
360
361 for dir in ${instdirs}; do
362 [ -d "${AUTOTEST_WORKDIR}/client/${dir}" ] || continue
363
364 insinto /usr/local/autotest/client/${dir}
365
366 eval provided=\${AUTOTEST_${dir^^*}_LIST}
367 # * means provided all, figure out the list from ${S}
368 if [ "${provided}" = "*" ]; then
369 if eval pushd "${WORKDIR}/${P}/\${AUTOTEST_${dir^^*}}" &> /dev/null; then
370 provided=$(ls)
371 popd 1> /dev/null
372 else
373 provided=""
374 fi
375 fi
376
377 for item in ${provided}; do
378 doins -r "${AUTOTEST_WORKDIR}/client/${dir}/${item}"
379 done
380 done
381
Zdenek Behan1ec164a2010-08-17 19:06:31 -0700382 # TODO: Not all needs to be executable, but it's hard to pick selectively.
383 # The source repo should already contain stuff with the right permissions.
384 chmod -R a+x "${D}"/usr/local/autotest/*
Zdenek Behan12ad1c52010-08-03 16:34:37 -0700385}
386
Chris Sosa6bde1602012-03-15 23:19:57 -0700387autotest_pkg_postinst() {
388 local root_autotest_dir="${ROOT}/usr/local/autotest"
389 local path_to_image="${D}/usr/local/autotest"
390 # Should only happen when running emerge on a DUT.
391 if [ ! -d "${root_autotest_dir}" ]; then
392 einfo "Skipping packaging as no autotest installation detected."
393 return 0
394 fi
Chris Masone21512432010-11-15 16:18:57 -0800395
Chris Sosa6bde1602012-03-15 23:19:57 -0700396 # Gather the artifacts we want autotest to package.
397 local test_opt dep_opt prof_opt
Chris Sosaccb6c8b2012-03-09 10:47:32 -0800398
Chris Sosa6bde1602012-03-15 23:19:57 -0700399 # Only client tests can be packaged.
400 local tests_to_package_dirs="client/tests client/site_tests"
401 local client_tests=$(\
402 for dir in ${tests_to_package_dirs}; do
403 print_test_dirs "${path_to_image}/${dir}" yes
404 done | sort -u)
405
406 if [ -n "${client_tests}" ] && [ "${client_tests}" != "myfaketest" ]; then
407 # Check for test_count. The packager performs poorly when
408 # too many arguments are specified vs. --all. This should be fixed in
409 # autotest (crosbug.com/28173).
410 test_count=$(echo ${client_tests} | wc -w)
411 if [ ${test_count} -gt 10 ]; then
412 test_opt="--all"
413 else
414 test_opt="--test=$(pythonify_test_list ${client_tests})"
415 fi
416 fi
417
418 if [ "{test_opt}" != "--all" ]; then
419 if [ -n "${AUTOTEST_DEPS_LIST}" ]; then
420 dep_opt="--dep=$(pythonify_test_list ${AUTOTEST_DEPS_LIST})"
421 fi
422
423 # For *, we must generate the list of profilers.
424 if [ "${AUTOTEST_PROFILERS_LIST}" = "*" ]; then
425 AUTOTEST_PROFILERS_LIST=$(\
426 print_test_dirs "${path_to_image}/client/profilers" yes | sort -u)
427 prof_opt="--profiler=$(pythonify_test_list ${AUTOTEST_PROFILERS_LIST})"
428 fi
429 fi
430
431 if [ -n "${test_opt}" -o -n "${dep_opt}" -o -n "${prof_opt}" ]; then
432 einfo "Running packager with options ${test_opt} ${dep_opt} ${prof_opt}"
433 flock "${root_autotest_dir}/packages" \
Zdenek Behan7c162bb2012-05-14 18:42:15 +0200434 -c "python -B ${root_autotest_dir}/utils/packager.py \
Chris Sosa6bde1602012-03-15 23:19:57 -0700435 -r ${root_autotest_dir}/packages \
436 ${test_opt} ${dep_opt} ${prof_opt} upload"
437 else
438 einfo "Packager not run as nothing was found to package."
439 fi
Chris Masone21512432010-11-15 16:18:57 -0800440}
441
Zdenek Behan361d8142012-03-19 04:30:45 +0100442if [[ "${CROS_WORKON_PROJECT}" == "chromiumos/third_party/autotest" ]]; then
443 # Using main autotest repo. Automatically restricting checkout.
444 # Note that this does not happen if the inherit is done prior to setting
445 # CROS_WORKON_* variables.
446 autotest_restrict_workon_subdirs
447fi
448
Chris Sosaccb6c8b2012-03-09 10:47:32 -0800449EXPORT_FUNCTIONS src_compile src_prepare src_install pkg_postinst