| 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 | 17 |
| 18 # Script must be run inside the chroot | 18 # Script must be run inside the chroot |
| 19 assert_inside_chroot | 19 assert_inside_chroot |
| 20 | 20 |
| 21 DEFAULT_CONTROL=client/site_tests/setup/control |
| 22 |
| 23 DEFINE_string control "${DEFAULT_CONTROL}" \ |
| 24 "Setup control file -- path relative to the destination autotest directory" c |
| 25 |
| 21 # More useful help | 26 # More useful help |
| 22 FLAGS_HELP="usage: $0 [flags]" | 27 FLAGS_HELP="usage: $0 [flags]" |
| 23 | 28 |
| 24 # parse the command-line | 29 # parse the command-line |
| 25 FLAGS "$@" || exit 1 | 30 FLAGS "$@" || exit 1 |
| 26 eval set -- "${FLAGS_ARGV}" | 31 eval set -- "${FLAGS_ARGV}" |
| 27 set -e | 32 set -e |
| 28 | 33 |
| 29 AUTOTEST_SRC="${GCLIENT_ROOT}/src/third_party/autotest/files" | 34 AUTOTEST_SRC="${GCLIENT_ROOT}/src/third_party/autotest/files" |
| 30 # Destination in chroot to install autotest. | 35 # Destination in chroot to install autotest. |
| 31 AUTOTEST_DEST="/usr/local/autotest" | 36 AUTOTEST_DEST="/usr/local/autotest" |
| 32 | 37 |
| 33 # Copy a local "installation" of autotest into the chroot, to avoid | 38 # Copy a local "installation" of autotest into the chroot, to avoid |
| 34 # polluting the src dir with tmp files, results, etc. | 39 # polluting the src dir with tmp files, results, etc. |
| 35 echo -n "Installing Autotest... " | 40 echo "Installing Autotest..." |
| 36 sudo mkdir -p ${AUTOTEST_DEST} | 41 sudo mkdir -p ${AUTOTEST_DEST} |
| 37 sudo chmod 777 ${AUTOTEST_DEST} | 42 sudo chmod 777 ${AUTOTEST_DEST} |
| 38 cd ${CHROOT_TRUNK_DIR}/src/third_party/autotest/files | 43 cd ${CHROOT_TRUNK_DIR}/src/third_party/autotest/files |
| 39 cp -fpru {client,conmux,server,tko,utils,global_config.ini,shadow_config.ini} \ | 44 cp -fpru {client,conmux,server,tko,utils,global_config.ini,shadow_config.ini} \ |
| 40 ${AUTOTEST_DEST} | 45 ${AUTOTEST_DEST} |
| 41 | 46 |
| 42 # Create python package init files for top level test case dirs. | 47 # Create python package init files for top level test case dirs. |
| 43 function touchInitPy() { | 48 function touchInitPy() { |
| 44 local dirs=${1} | 49 local dirs=${1} |
| 45 for base_dir in $dirs | 50 for base_dir in $dirs |
| 46 do | 51 do |
| 47 local sub_dirs="$(find ${base_dir} -maxdepth 1 -type d)" | 52 local sub_dirs="$(find ${base_dir} -maxdepth 1 -type d)" |
| 48 for sub_dir in ${sub_dirs} | 53 for sub_dir in ${sub_dirs} |
| 49 do | 54 do |
| 50 touch ${sub_dir}/__init__.py | 55 touch ${sub_dir}/__init__.py |
| 51 done | 56 done |
| 52 touch ${base_dir}/__init__.py | 57 touch ${base_dir}/__init__.py |
| 53 done | 58 done |
| 54 } | 59 } |
| 55 | 60 |
| 56 cd ${AUTOTEST_DEST} | 61 cd ${AUTOTEST_DEST} |
| 57 touchInitPy client/tests client/site_tests | 62 touchInitPy client/tests client/site_tests |
| 58 touch __init__.py | 63 touch __init__.py |
| 59 | 64 |
| 60 # Export GCLIENT_ROOT so that tests have access to the source and build trees | 65 # Export GCLIENT_ROOT so that tests have access to the source and build trees |
| 61 export GCLIENT_ROOT | 66 export GCLIENT_ROOT |
| 62 | 67 |
| 63 # run the magic test setup script. | 68 # run the magic test setup script. |
| 64 client/bin/autotest client/site_tests/setup/control | 69 echo "Building tests using ${FLAGS_control}..." |
| 70 client/bin/autotest ${FLAGS_control} |
| OLD | NEW |