Zdenek Behan | 12ad1c5 | 2010-08-03 16:34:37 -0700 | [diff] [blame] | 1 | # 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 Behan | 9e98f32 | 2010-08-26 18:56:54 -0700 | [diff] [blame] | 9 | RDEPEND="( autotest? ( >=chromeos-base/autotest-0.0.1-r3 ) )" |
Zdenek Behan | 14ae489 | 2010-08-26 15:25:30 -0700 | [diff] [blame] | 10 | # HACK: all packages should get autotest-deps for now |
| 11 | if ! [ "${PN}" = "autotest-deps" ]; then |
| 12 | RDEPEND="${RDEPEND} ( autotest? ( chromeos-base/autotest-deps ) )" |
| 13 | fi |
Zdenek Behan | 12ad1c5 | 2010-08-03 16:34:37 -0700 | [diff] [blame] | 14 | DEPEND="${RDEPEND}" |
| 15 | |
Zdenek Behan | 14ae489 | 2010-08-26 15:25:30 -0700 | [diff] [blame] | 16 | IUSE="buildcheck autotest" |
Zdenek Behan | 12ad1c5 | 2010-08-03 16:34:37 -0700 | [diff] [blame] | 17 | |
| 18 | # Ensure the configures run by autotest pick up the right config.site |
Zdenek Behan | 99bf584 | 2010-08-04 17:23:38 -0700 | [diff] [blame] | 19 | export CONFIG_SITE="/usr/share/config.site" |
| 20 | export AUTOTEST_WORKDIR="${WORKDIR}/autotest-work" |
Zdenek Behan | 12ad1c5 | 2010-08-03 16:34:37 -0700 | [diff] [blame] | 21 | |
Zdenek Behan | cd997a3 | 2010-08-20 12:55:44 -0700 | [diff] [blame] | 22 | # @ECLASS-VARIABLE: AUTOTEST_CLIENT_* |
| 23 | # @DESCRIPTION: |
| 24 | # Location of the appropriate test directory inside ${S} |
| 25 | : ${AUTOTEST_CLIENT_TESTS:=client/tests} |
| 26 | : ${AUTOTEST_CLIENT_SITE_TESTS:=client/site_tests} |
| 27 | : ${AUTOTEST_SERVER_TESTS:=server/tests} |
| 28 | : ${AUTOTEST_SERVER_SITE_TESTS:=server/site_tests} |
Zdenek Behan | 41463c9 | 2010-08-23 12:12:31 -0700 | [diff] [blame] | 29 | : ${AUTOTEST_CONFIG:=client/config} |
| 30 | : ${AUTOTEST_DEPS:=client/deps} |
| 31 | : ${AUTOTEST_PROFILERS:=client/profilers} |
| 32 | |
| 33 | # @ECLASS-VARIABLE: AUTOTEST_*_LIST |
| 34 | # @DESCRIPTION: |
| 35 | # The list of deps/configs/profilers provided with this package |
| 36 | : ${AUTOTEST_CONFIG_LIST:=*} |
| 37 | : ${AUTOTEST_DEPS_LIST:=*} |
| 38 | : ${AUTOTEST_PROFILERS_LIST:=*} |
Zdenek Behan | cd997a3 | 2010-08-20 12:55:44 -0700 | [diff] [blame] | 39 | |
Zdenek Behan | d012b76 | 2010-09-01 21:22:26 -0700 | [diff] [blame] | 40 | # @ECLASS-VARIABLE: AUTOTEST_FORCE_LIST |
| 41 | # @DESCRIPTION: |
| 42 | # Sometimes we just want to forget about useflags and build what's inside |
| 43 | : ${AUTOTEST_FORCE_TEST_LIST:=} |
| 44 | |
Zdenek Behan | b1f7c89 | 2010-09-22 12:25:38 -0700 | [diff] [blame] | 45 | # @ECLASS-VARIABLE: AUTOTEST_FILE_MASK |
| 46 | # @DESCRIPTION: |
| 47 | # The list of 'find' expressions to find in the resulting image and delete |
| 48 | : ${AUTOTEST_FILE_MASK:=} |
| 49 | |
Zdenek Behan | 7922d13 | 2010-09-24 14:18:05 -0700 | [diff] [blame] | 50 | function fast_cp() { |
| 51 | cp -l "$@" || cp "$@" |
| 52 | } |
| 53 | |
Zdenek Behan | d012b76 | 2010-09-01 21:22:26 -0700 | [diff] [blame] | 54 | function get_test_list() { |
| 55 | if [ -n "${AUTOTEST_FORCE_TEST_LIST}" ]; then |
| 56 | # list forced |
| 57 | echo "${AUTOTEST_FORCE_TEST_LIST}" |
| 58 | return |
| 59 | fi |
| 60 | |
| 61 | # we cache the result of this operation in AUTOTEST_TESTS, |
| 62 | # because it's expensive and does not change over the course of one ebuild run |
| 63 | local result="${IUSE_TESTS//[+-]tests_/}" |
| 64 | result="${result//tests_/}" |
| 65 | |
| 66 | result=$(for test in ${result}; do use tests_${test} && echo -n "${test} "; done) |
| 67 | echo "${result}" |
| 68 | } |
| 69 | |
Zdenek Behan | 12ad1c5 | 2010-08-03 16:34:37 -0700 | [diff] [blame] | 70 | # Pythonify the list of packages |
| 71 | function pythonify_test_list() { |
| 72 | local result |
Zdenek Behan | d012b76 | 2010-09-01 21:22:26 -0700 | [diff] [blame] | 73 | result=$(for test in $*; do echo -n "${test},"; done) |
Zdenek Behan | 31315b3 | 2010-08-05 16:34:39 -0700 | [diff] [blame] | 74 | echo ${result} |
Zdenek Behan | 12ad1c5 | 2010-08-03 16:34:37 -0700 | [diff] [blame] | 75 | } |
| 76 | |
| 77 | # Create python package init files for top level test case dirs. |
| 78 | function touch_init_py() { |
| 79 | local dirs=${1} |
| 80 | for base_dir in $dirs |
| 81 | do |
| 82 | local sub_dirs="$(find ${base_dir} -maxdepth 1 -type d)" |
| 83 | for sub_dir in ${sub_dirs} |
| 84 | do |
| 85 | touch ${sub_dir}/__init__.py |
| 86 | done |
| 87 | touch ${base_dir}/__init__.py |
| 88 | done |
| 89 | } |
| 90 | |
| 91 | function setup_cross_toolchain() { |
| 92 | if tc-is-cross-compiler ; then |
| 93 | tc-export CC CXX AR RANLIB LD NM STRIP |
| 94 | export PKG_CONFIG_PATH="${ROOT}/usr/lib/pkgconfig/" |
| 95 | export CCFLAGS="$CFLAGS" |
| 96 | fi |
| 97 | |
| 98 | # TODO(fes): Check for /etc/hardened for now instead of the hardened |
| 99 | # use flag because we aren't enabling hardened on the target board. |
| 100 | # Rather, right now we're using hardened only during toolchain compile. |
| 101 | # Various tests/etc. use %ebx in here, so we have to turn off PIE when |
| 102 | # using the hardened compiler |
| 103 | if use x86 ; then |
| 104 | if use hardened ; then |
| 105 | #CC="${CC} -nopie" |
| 106 | append-flags -nopie |
| 107 | fi |
| 108 | fi |
| 109 | } |
| 110 | |
| 111 | function create_autotest_workdir() { |
| 112 | local dst=${1} |
| 113 | |
| 114 | # create a working enviroment for pre-building |
Chris Masone | 2151243 | 2010-11-15 16:18:57 -0800 | [diff] [blame^] | 115 | ln -sf "${SYSROOT}"/usr/local/autotest/{conmux,tko,global_config.ini,shadow_config.ini} "${dst}"/ |
Zdenek Behan | 99bf584 | 2010-08-04 17:23:38 -0700 | [diff] [blame] | 116 | |
Zdenek Behan | 12ad1c5 | 2010-08-03 16:34:37 -0700 | [diff] [blame] | 117 | # NOTE: in order to make autotest not notice it's running from /usr/local/, we need |
| 118 | # to make sure the binaries are real, because they do the path magic |
| 119 | local root_path base_path |
Chris Masone | 2151243 | 2010-11-15 16:18:57 -0800 | [diff] [blame^] | 120 | for base_path in utils server; do |
| 121 | root_path="${SYSROOT}/usr/local/autotest/${base_path}" |
| 122 | mkdir -p "${dst}/${base_path}" |
| 123 | for entry in $(ls "${root_path}"); do |
| 124 | if [ -d ${entry} ]; then |
| 125 | ln -sf "${root_path}/${entry}" "${dst}/${base_path}/" |
| 126 | else |
| 127 | cp -f ${root_path}/${entry} ${dst}/${base_path}/ |
| 128 | fi |
| 129 | done |
| 130 | done |
Zdenek Behan | 12ad1c5 | 2010-08-03 16:34:37 -0700 | [diff] [blame] | 131 | for base_path in client client/bin; do |
| 132 | root_path="${SYSROOT}/usr/local/autotest/${base_path}" |
| 133 | mkdir -p "${dst}/${base_path}" |
| 134 | |
Zdenek Behan | 451e07f | 2010-08-06 11:25:37 -0700 | [diff] [blame] | 135 | # Skip bin, because it is processed separately, and test-provided dirs |
| 136 | # Also don't symlink to packages, because that kills the build |
Zdenek Behan | 41463c9 | 2010-08-23 12:12:31 -0700 | [diff] [blame] | 137 | for entry in $(ls "${root_path}" | \ |
| 138 | grep -v "\(bin\|tests\|site_tests\|config\|deps\|profilers\|packages\)$"); do |
Zdenek Behan | 12ad1c5 | 2010-08-03 16:34:37 -0700 | [diff] [blame] | 139 | ln -sf "${root_path}/${entry}" "${dst}/${base_path}/" |
| 140 | done |
| 141 | done |
| 142 | # replace the important binaries with real copies |
| 143 | for base_path in autotest autotest_client; do |
| 144 | root_path="${SYSROOT}/usr/local/autotest/client/bin/${base_path}" |
| 145 | rm "${dst}/client/bin/${base_path}" |
| 146 | cp -f ${root_path} "${dst}/client/bin/${base_path}" |
| 147 | done |
Zdenek Behan | 448ddaa | 2010-08-24 11:18:50 -0700 | [diff] [blame] | 148 | |
| 149 | # Selectively pull in deps that are not provided by the current test package |
| 150 | for base_path in config deps profilers; do |
| 151 | for dir in "${SYSROOT}/usr/local/autotest/client/${base_path}"/*; do |
| 152 | if [ -d "${dir}" ] && \ |
| 153 | ! [ -d "${AUTOTEST_WORKDIR}/client/${base_path}/$(basename ${dir})" ]; then |
| 154 | # directory does not exist, create a symlink |
| 155 | ln -sf "${dir}" "${AUTOTEST_WORKDIR}/client/${base_path}/$(basename ${dir})" |
| 156 | fi |
| 157 | done |
| 158 | done |
Zdenek Behan | 12ad1c5 | 2010-08-03 16:34:37 -0700 | [diff] [blame] | 159 | } |
| 160 | |
| 161 | function print_test_dirs() { |
| 162 | local testroot="${1}" |
| 163 | |
| 164 | pushd "${testroot}" 1> /dev/null |
| 165 | for test in *; do |
| 166 | if [ -d "${test}" ] && [ -f "${test}/${test}".py ]; then |
| 167 | echo "${test}" |
| 168 | fi |
| 169 | done |
| 170 | popd 1> /dev/null |
| 171 | } |
| 172 | |
Zdenek Behan | eee7bc2 | 2010-08-20 18:33:13 -0700 | [diff] [blame] | 173 | # checks IUSE_TESTS and sees if at least one of these is enabled |
| 174 | function are_we_used() { |
Zdenek Behan | 14ae489 | 2010-08-26 15:25:30 -0700 | [diff] [blame] | 175 | if ! use autotest; then |
| 176 | # unused |
| 177 | return 1 |
| 178 | fi |
| 179 | |
Zdenek Behan | d012b76 | 2010-09-01 21:22:26 -0700 | [diff] [blame] | 180 | [ -n "$(get_test_list)" ] && return 0 |
Zdenek Behan | eee7bc2 | 2010-08-20 18:33:13 -0700 | [diff] [blame] | 181 | |
| 182 | # unused |
| 183 | return 1 |
| 184 | } |
| 185 | |
Zdenek Behan | 99bf584 | 2010-08-04 17:23:38 -0700 | [diff] [blame] | 186 | function autotest_src_prepare() { |
Zdenek Behan | eee7bc2 | 2010-08-20 18:33:13 -0700 | [diff] [blame] | 187 | are_we_used || return 0 |
| 188 | einfo "Preparing tests" |
| 189 | |
| 190 | # FIXME: These directories are needed, autotest quietly dies if |
| 191 | # they don't even exist. They may, however, stay empty. |
Zdenek Behan | c02fc47 | 2010-08-13 12:55:07 -0700 | [diff] [blame] | 192 | mkdir -p "${AUTOTEST_WORKDIR}"/client/tests |
| 193 | mkdir -p "${AUTOTEST_WORKDIR}"/client/site_tests |
Zdenek Behan | 41463c9 | 2010-08-23 12:12:31 -0700 | [diff] [blame] | 194 | mkdir -p "${AUTOTEST_WORKDIR}"/client/config |
| 195 | mkdir -p "${AUTOTEST_WORKDIR}"/client/deps |
| 196 | mkdir -p "${AUTOTEST_WORKDIR}"/client/profilers |
Zdenek Behan | c02fc47 | 2010-08-13 12:55:07 -0700 | [diff] [blame] | 197 | mkdir -p "${AUTOTEST_WORKDIR}"/server/tests |
| 198 | mkdir -p "${AUTOTEST_WORKDIR}"/server/site_tests |
Zdenek Behan | 12ad1c5 | 2010-08-03 16:34:37 -0700 | [diff] [blame] | 199 | |
Zdenek Behan | d012b76 | 2010-09-01 21:22:26 -0700 | [diff] [blame] | 200 | TEST_LIST=$(get_test_list) |
| 201 | |
Zdenek Behan | 448ddaa | 2010-08-24 11:18:50 -0700 | [diff] [blame] | 202 | # Pull in the individual test cases. |
Zdenek Behan | 31315b3 | 2010-08-05 16:34:39 -0700 | [diff] [blame] | 203 | for l1 in client server; do |
| 204 | for l2 in site_tests tests; do |
Zdenek Behan | cd997a3 | 2010-08-20 12:55:44 -0700 | [diff] [blame] | 205 | # pick up the indicated location of test sources |
| 206 | eval srcdir=${WORKDIR}/${P}/\${AUTOTEST_${l1^^*}_${l2^^*}} |
| 207 | |
Zdenek Behan | d012b76 | 2010-09-01 21:22:26 -0700 | [diff] [blame] | 208 | # test does have this directory |
| 209 | for test in ${TEST_LIST}; do |
| 210 | if [ -d "${srcdir}/${test}" ]; then |
Zdenek Behan | 7922d13 | 2010-09-24 14:18:05 -0700 | [diff] [blame] | 211 | fast_cp -fpr "${srcdir}/${test}" "${AUTOTEST_WORKDIR}/${l1}/${l2}"/ || die |
Zdenek Behan | d012b76 | 2010-09-01 21:22:26 -0700 | [diff] [blame] | 212 | fi |
| 213 | done |
Zdenek Behan | 31315b3 | 2010-08-05 16:34:39 -0700 | [diff] [blame] | 214 | done |
| 215 | done |
Zdenek Behan | 99bf584 | 2010-08-04 17:23:38 -0700 | [diff] [blame] | 216 | |
Zdenek Behan | 448ddaa | 2010-08-24 11:18:50 -0700 | [diff] [blame] | 217 | # Pull in all the deps provided by this package, selectively. |
Zdenek Behan | 41463c9 | 2010-08-23 12:12:31 -0700 | [diff] [blame] | 218 | for l2 in config deps profilers; do |
| 219 | # pick up the indicated location of test sources |
| 220 | eval srcdir=${WORKDIR}/${P}/\${AUTOTEST_${l2^^*}} |
| 221 | |
| 222 | if [ -d "${srcdir}" ]; then # test does have this directory |
| 223 | pushd "${srcdir}" 1> /dev/null |
| 224 | eval deplist=\${AUTOTEST_${l2^^*}_LIST} |
| 225 | |
| 226 | if [ "${deplist}" = "*" ]; then |
Zdenek Behan | 7922d13 | 2010-09-24 14:18:05 -0700 | [diff] [blame] | 227 | fast_cp -fpr * "${AUTOTEST_WORKDIR}/client/${l2}" |
Zdenek Behan | 41463c9 | 2010-08-23 12:12:31 -0700 | [diff] [blame] | 228 | else |
| 229 | for dir in ${deplist}; do |
Zdenek Behan | 7922d13 | 2010-09-24 14:18:05 -0700 | [diff] [blame] | 230 | fast_cp -fpr "${dir}" "${AUTOTEST_WORKDIR}/client/${l2}"/ || die |
Zdenek Behan | 41463c9 | 2010-08-23 12:12:31 -0700 | [diff] [blame] | 231 | done |
| 232 | fi |
| 233 | popd 1> /dev/null |
| 234 | fi |
| 235 | done |
| 236 | |
Zdenek Behan | 474fbae | 2010-08-20 21:13:22 -0700 | [diff] [blame] | 237 | # FIXME: We'd like if this were not necessary, and autotest supported out-of-tree build |
Zdenek Behan | 99bf584 | 2010-08-04 17:23:38 -0700 | [diff] [blame] | 238 | create_autotest_workdir "${AUTOTEST_WORKDIR}" |
Zdenek Behan | eee7bc2 | 2010-08-20 18:33:13 -0700 | [diff] [blame] | 239 | |
Zdenek Behan | f93c208a | 2010-09-21 18:53:58 -0700 | [diff] [blame] | 240 | # Each test directory needs to be visited and have an __init__.py created. |
| 241 | # However, that only applies to the directories which have a main .py file. |
Zdenek Behan | edb527a | 2010-09-22 12:24:14 -0700 | [diff] [blame] | 242 | pushd "${AUTOTEST_WORKDIR}" > /dev/null || die "AUTOTEST_WORKDIR does not exist?!" |
Zdenek Behan | f93c208a | 2010-09-21 18:53:58 -0700 | [diff] [blame] | 243 | for dir in client/tests client/site_tests server/tests server/site_tests; do |
Zdenek Behan | edb527a | 2010-09-22 12:24:14 -0700 | [diff] [blame] | 244 | pushd "${dir}" > /dev/null || continue |
Zdenek Behan | f93c208a | 2010-09-21 18:53:58 -0700 | [diff] [blame] | 245 | for sub in *; do |
| 246 | [ -f "${sub}/${sub}.py" ] || continue |
Zdenek Behan | 1ec164a | 2010-08-17 19:06:31 -0700 | [diff] [blame] | 247 | |
Zdenek Behan | f93c208a | 2010-09-21 18:53:58 -0700 | [diff] [blame] | 248 | touch_init_py ${sub} |
| 249 | done |
Zdenek Behan | edb527a | 2010-09-22 12:24:14 -0700 | [diff] [blame] | 250 | popd > /dev/null |
Zdenek Behan | 1ec164a | 2010-08-17 19:06:31 -0700 | [diff] [blame] | 251 | done |
Zdenek Behan | edb527a | 2010-09-22 12:24:14 -0700 | [diff] [blame] | 252 | popd > /dev/null |
Zdenek Behan | 12ad1c5 | 2010-08-03 16:34:37 -0700 | [diff] [blame] | 253 | |
| 254 | # Cleanup checked-in binaries that don't support the target architecture |
| 255 | [[ ${E_MACHINE} == "" ]] && return 0; |
Zdenek Behan | 092f463 | 2010-09-21 19:34:01 -0700 | [diff] [blame] | 256 | rm -fv $( scanelf -RmyBF%a "${AUTOTEST_WORKDIR}" | grep -v -e ^${E_MACHINE} ) |
Zdenek Behan | 12ad1c5 | 2010-08-03 16:34:37 -0700 | [diff] [blame] | 257 | } |
| 258 | |
| 259 | function autotest_src_compile() { |
Zdenek Behan | 48096a8 | 2010-09-23 19:39:26 -0700 | [diff] [blame] | 260 | if ! are_we_used; then |
| 261 | ewarn "***************************************************************" |
| 262 | ewarn "* Not building any tests, because the requested list is empty *" |
| 263 | ewarn "***************************************************************" |
| 264 | return 0 |
| 265 | fi |
Zdenek Behan | eee7bc2 | 2010-08-20 18:33:13 -0700 | [diff] [blame] | 266 | einfo "Compiling tests" |
| 267 | |
Zdenek Behan | 31315b3 | 2010-08-05 16:34:39 -0700 | [diff] [blame] | 268 | pushd "${AUTOTEST_WORKDIR}" 1> /dev/null |
Zdenek Behan | 99bf584 | 2010-08-04 17:23:38 -0700 | [diff] [blame] | 269 | |
Zdenek Behan | 12ad1c5 | 2010-08-03 16:34:37 -0700 | [diff] [blame] | 270 | setup_cross_toolchain |
| 271 | |
| 272 | if use opengles ; then |
| 273 | graphics_backend=OPENGLES |
| 274 | else |
| 275 | graphics_backend=OPENGL |
| 276 | fi |
| 277 | |
Zdenek Behan | 9e979bb | 2010-09-23 17:32:05 -0700 | [diff] [blame] | 278 | # HACK: Some of the autotests depend on SYSROOT being defined, and die |
| 279 | # a gruesome death if it isn't. But SYSROOT does not need to exist, for |
| 280 | # example on the host, it doesn't. Let's define a compatible variable |
| 281 | # here in case we have none. |
| 282 | export SYSROOT=${SYSROOT:-"/"} |
| 283 | |
Zdenek Behan | 8ad6525 | 2010-09-07 12:35:19 -0700 | [diff] [blame] | 284 | # This only prints the tests that have the associated .py |
| 285 | # (and therefore a setup function) |
| 286 | local prebuild_test_dirs=" |
| 287 | client/tests client/site_tests |
| 288 | server/tests server/site_tests" |
| 289 | TESTS=$(\ |
| 290 | for dir in ${prebuild_test_dirs}; do |
| 291 | print_test_dirs "${AUTOTEST_WORKDIR}/${dir}" |
| 292 | done | sort | uniq |
| 293 | ) |
| 294 | einfo "Building tests ($(echo ${TESTS}|wc -w)):" |
| 295 | einfo "${TESTS}" |
Zdenek Behan | 12ad1c5 | 2010-08-03 16:34:37 -0700 | [diff] [blame] | 296 | |
Zdenek Behan | 402fea0 | 2010-09-14 13:50:09 -0700 | [diff] [blame] | 297 | NORMAL=$(echo -e "\e[0m") |
| 298 | GREEN=$(echo -e "\e[1;32m") |
| 299 | RED=$(echo -e "\e[1;31m") |
| 300 | |
Zdenek Behan | 448ddaa | 2010-08-24 11:18:50 -0700 | [diff] [blame] | 301 | # Call autotest to prebuild all test cases. |
Zdenek Behan | 402fea0 | 2010-09-14 13:50:09 -0700 | [diff] [blame] | 302 | # Parse output through a colorifying sed script |
| 303 | ( GRAPHICS_BACKEND="$graphics_backend" LOGNAME=${SUDO_USER} \ |
Zdenek Behan | d012b76 | 2010-09-01 21:22:26 -0700 | [diff] [blame] | 304 | client/bin/autotest_client --quiet \ |
| 305 | --client_test_setup=$(pythonify_test_list ${TESTS}) \ |
Zdenek Behan | 12ad1c5 | 2010-08-03 16:34:37 -0700 | [diff] [blame] | 306 | || ! use buildcheck || die "Tests failed to build." |
Zdenek Behan | 402fea0 | 2010-09-14 13:50:09 -0700 | [diff] [blame] | 307 | ) | sed -e "s/\(INFO:root:setup\)/${GREEN}* \1${NORMAL}/" \ |
| 308 | -e "s/\(ERROR:root:\[.*\]\)/${RED}\1${NORMAL}/" |
Zdenek Behan | 12ad1c5 | 2010-08-03 16:34:37 -0700 | [diff] [blame] | 309 | |
| 310 | # Cleanup some temp files after compiling |
Zdenek Behan | b1f7c89 | 2010-09-22 12:25:38 -0700 | [diff] [blame] | 311 | for mask in '*.[do]' ${AUTOTEST_FILE_MASK}; do |
| 312 | einfo "Purging ${mask}" |
| 313 | find . -name "${mask}" -delete |
| 314 | done |
Zdenek Behan | 31315b3 | 2010-08-05 16:34:39 -0700 | [diff] [blame] | 315 | |
| 316 | popd 1> /dev/null |
Zdenek Behan | 12ad1c5 | 2010-08-03 16:34:37 -0700 | [diff] [blame] | 317 | } |
| 318 | |
| 319 | function autotest_src_install() { |
Zdenek Behan | eee7bc2 | 2010-08-20 18:33:13 -0700 | [diff] [blame] | 320 | are_we_used || return 0 |
| 321 | einfo "Installing tests" |
| 322 | |
Zdenek Behan | 448ddaa | 2010-08-24 11:18:50 -0700 | [diff] [blame] | 323 | # Install all test cases, after setup has been called on them. |
| 324 | # We install everything, because nothing else is copied into the |
| 325 | # testcase directories besides what this package provides. |
Zdenek Behan | 1ec164a | 2010-08-17 19:06:31 -0700 | [diff] [blame] | 326 | local instdirs=" |
| 327 | client/tests |
| 328 | client/site_tests |
Zdenek Behan | 1ec164a | 2010-08-17 19:06:31 -0700 | [diff] [blame] | 329 | server/tests |
| 330 | server/site_tests" |
| 331 | |
| 332 | for dir in ${instdirs}; do |
Zdenek Behan | cd997a3 | 2010-08-20 12:55:44 -0700 | [diff] [blame] | 333 | [ -d "${AUTOTEST_WORKDIR}/${dir}" ] || continue |
Zdenek Behan | 1ec164a | 2010-08-17 19:06:31 -0700 | [diff] [blame] | 334 | |
| 335 | insinto /usr/local/autotest/$(dirname ${dir}) |
| 336 | doins -r "${AUTOTEST_WORKDIR}/${dir}" |
| 337 | done |
| 338 | |
Zdenek Behan | 448ddaa | 2010-08-24 11:18:50 -0700 | [diff] [blame] | 339 | # Install the deps, configs, profilers. |
| 340 | # Difference from above is, we don't install the whole thing, just |
| 341 | # the stuff provided by this package, by looking at AUTOTEST_*_LIST. |
| 342 | instdirs=" |
| 343 | config |
| 344 | deps |
| 345 | profilers" |
| 346 | |
| 347 | for dir in ${instdirs}; do |
| 348 | [ -d "${AUTOTEST_WORKDIR}/client/${dir}" ] || continue |
| 349 | |
| 350 | insinto /usr/local/autotest/client/${dir} |
| 351 | |
| 352 | eval provided=\${AUTOTEST_${dir^^*}_LIST} |
| 353 | # * means provided all, figure out the list from ${S} |
| 354 | if [ "${provided}" = "*" ]; then |
| 355 | if eval pushd "${WORKDIR}/${P}/\${AUTOTEST_${dir^^*}}" &> /dev/null; then |
| 356 | provided=$(ls) |
| 357 | popd 1> /dev/null |
| 358 | else |
| 359 | provided="" |
| 360 | fi |
| 361 | fi |
| 362 | |
| 363 | for item in ${provided}; do |
| 364 | doins -r "${AUTOTEST_WORKDIR}/client/${dir}/${item}" |
| 365 | done |
| 366 | done |
| 367 | |
Zdenek Behan | 1ec164a | 2010-08-17 19:06:31 -0700 | [diff] [blame] | 368 | # TODO: Not all needs to be executable, but it's hard to pick selectively. |
| 369 | # The source repo should already contain stuff with the right permissions. |
| 370 | chmod -R a+x "${D}"/usr/local/autotest/* |
Zdenek Behan | 12ad1c5 | 2010-08-03 16:34:37 -0700 | [diff] [blame] | 371 | } |
| 372 | |
Chris Masone | 2151243 | 2010-11-15 16:18:57 -0800 | [diff] [blame^] | 373 | function autotest_prepackage() { |
| 374 | are_we_used || return 0 |
| 375 | TEST_DEP="${1}" |
| 376 | einfo "Pre-packaging test dep ${TEST_DEP}" |
| 377 | |
| 378 | dodir /usr/local/autotest-pkgs |
| 379 | "${AUTOTEST_WORKDIR}"/utils/packager.py -d "${TEST_DEP}" \ |
| 380 | -r "${D}"/usr/local/autotest-pkgs upload \ |
| 381 | || die "Can't preinstall ${1}" |
| 382 | } |
| 383 | |
Zdenek Behan | 474fbae | 2010-08-20 21:13:22 -0700 | [diff] [blame] | 384 | EXPORT_FUNCTIONS src_compile src_prepare src_install |