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 | |
| 7 | # Load common constants. This should be the first executable line. |
| 8 | # The path to common.sh should be relative to your script's location. |
| 9 | . "$(dirname "$0")/common.sh" |
| 10 | |
| 11 | # Flags |
| 12 | DEFINE_string target "x86" \ |
| 13 | "The target architecture to test. One of { x86, arm }." |
| 14 | DEFINE_string root "" \ |
| 15 | "The root file system to check." |
| 16 | |
| 17 | # Parse command line |
| 18 | FLAGS "$@" || exit 1 |
| 19 | eval set -- "${FLAGS_ARGV}" |
| 20 | |
| 21 | # Die on any errors |
| 22 | set -e |
| 23 | |
| 24 | # Check all parts of a pipe |
| 25 | set -o pipefail |
| 26 | |
| 27 | ROOT="$FLAGS_root" |
| 28 | if [[ -z "$ROOT" ]]; then |
| 29 | echo "Error: --root is required." |
| 30 | exit 1 |
| 31 | fi |
| 32 | if [[ ! -d "$ROOT" ]]; then |
| 33 | echo "Error: Root FS does not exist ($ROOT)" |
| 34 | exit 1 |
| 35 | fi |
| 36 | |
| 37 | EXITCODE=0 |
| 38 | |
| 39 | BINARIES="$ROOT/usr/bin/Xorg |
| 40 | $ROOT/usr/bin/chromeos-wm |
| 41 | $ROOT/boot/vmlinuz |
| 42 | $ROOT/sbin/session_manager |
| 43 | $ROOT/bin/sed" |
| 44 | |
| 45 | if [[ $FLAGS_target != arm ]]; then |
| 46 | # chrome isn't present on arm |
| 47 | BINARIES="$BINARIES |
| 48 | $ROOT/opt/google/chrome/chrome" |
| 49 | fi |
| 50 | |
| 51 | for i in $BINARIES; do |
| 52 | if ! [[ -f $i ]]; then |
| 53 | echo test_image: Cannot find $i |
| 54 | EXITCODE=1 |
| 55 | fi |
| 56 | done |
| 57 | |
| 58 | LIBS="`sudo find $ROOT -type f -name '*.so*'`" |
| 59 | |
| 60 | # Check that all .so files, plus the binaries, have the appropriate dependencies |
| 61 | if ! "${SCRIPTS_DIR}/check_deps" "$ROOT" $BINARIES $LIBS; then |
| 62 | echo test_image: Failed dependency check |
| 63 | EXITCODE=1 |
| 64 | fi |
| 65 | |
| 66 | exit $EXITCODE |