David James | a17e946 | 2010-03-02 15:28:58 -0800 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
| 4 | # Use of this source code is governed by a BSD-style license that can be |
| 5 | # found in the LICENSE file. |
| 6 | |
Greg Spencer | 798d75f | 2011-02-01 22:04:49 -0800 | [diff] [blame] | 7 | # --- BEGIN COMMON.SH BOILERPLATE --- |
| 8 | # Load common CrOS utilities. Inside the chroot this file is installed in |
| 9 | # /usr/lib/crosutils. Outside the chroot we find it relative to the script's |
| 10 | # location. |
| 11 | find_common_sh() { |
| 12 | local common_paths=(/usr/lib/crosutils $(dirname "$(readlink -f "$0")")) |
| 13 | local path |
| 14 | |
| 15 | SCRIPT_ROOT= |
| 16 | for path in "${common_paths[@]}"; do |
| 17 | if [ -r "${path}/common.sh" ]; then |
| 18 | SCRIPT_ROOT=${path} |
| 19 | break |
| 20 | fi |
| 21 | done |
| 22 | } |
| 23 | |
| 24 | find_common_sh |
| 25 | . "${SCRIPT_ROOT}/common.sh" || (echo "Unable to load common.sh" && exit 1) |
| 26 | # --- END COMMON.SH BOILERPLATE --- |
David James | a17e946 | 2010-03-02 15:28:58 -0800 | [diff] [blame] | 27 | |
| 28 | # Flags |
| 29 | DEFINE_string target "x86" \ |
| 30 | "The target architecture to test. One of { x86, arm }." |
| 31 | DEFINE_string root "" \ |
| 32 | "The root file system to check." |
| 33 | |
| 34 | # Parse command line |
| 35 | FLAGS "$@" || exit 1 |
| 36 | eval set -- "${FLAGS_ARGV}" |
| 37 | |
| 38 | # Die on any errors |
| 39 | set -e |
| 40 | |
| 41 | # Check all parts of a pipe |
| 42 | set -o pipefail |
| 43 | |
| 44 | ROOT="$FLAGS_root" |
| 45 | if [[ -z "$ROOT" ]]; then |
| 46 | echo "Error: --root is required." |
| 47 | exit 1 |
| 48 | fi |
| 49 | if [[ ! -d "$ROOT" ]]; then |
| 50 | echo "Error: Root FS does not exist ($ROOT)" |
| 51 | exit 1 |
| 52 | fi |
| 53 | |
| 54 | EXITCODE=0 |
| 55 | |
| 56 | BINARIES="$ROOT/usr/bin/Xorg |
| 57 | $ROOT/usr/bin/chromeos-wm |
| 58 | $ROOT/boot/vmlinuz |
| 59 | $ROOT/sbin/session_manager |
| 60 | $ROOT/bin/sed" |
| 61 | |
| 62 | if [[ $FLAGS_target != arm ]]; then |
| 63 | # chrome isn't present on arm |
| 64 | BINARIES="$BINARIES |
| 65 | $ROOT/opt/google/chrome/chrome" |
| 66 | fi |
| 67 | |
| 68 | for i in $BINARIES; do |
| 69 | if ! [[ -f $i ]]; then |
| 70 | echo test_image: Cannot find $i |
| 71 | EXITCODE=1 |
| 72 | fi |
| 73 | done |
| 74 | |
| 75 | LIBS="`sudo find $ROOT -type f -name '*.so*'`" |
| 76 | |
| 77 | # Check that all .so files, plus the binaries, have the appropriate dependencies |
| 78 | if ! "${SCRIPTS_DIR}/check_deps" "$ROOT" $BINARIES $LIBS; then |
| 79 | echo test_image: Failed dependency check |
| 80 | EXITCODE=1 |
| 81 | fi |
| 82 | |
| 83 | exit $EXITCODE |