blob: f4b079a9d4811f416476033e98fa3be2cb1ad543 [file] [log] [blame]
David Jamesa17e9462010-03-02 15:28:58 -08001#!/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 Spencer798d75f2011-02-01 22:04:49 -08007# --- 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.
11find_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
24find_common_sh
25. "${SCRIPT_ROOT}/common.sh" || (echo "Unable to load common.sh" && exit 1)
26# --- END COMMON.SH BOILERPLATE ---
David Jamesa17e9462010-03-02 15:28:58 -080027
28# Flags
29DEFINE_string target "x86" \
30 "The target architecture to test. One of { x86, arm }."
31DEFINE_string root "" \
32 "The root file system to check."
33
34# Parse command line
35FLAGS "$@" || exit 1
36eval set -- "${FLAGS_ARGV}"
37
38# Die on any errors
39set -e
40
41# Check all parts of a pipe
42set -o pipefail
43
44ROOT="$FLAGS_root"
45if [[ -z "$ROOT" ]]; then
46 echo "Error: --root is required."
47 exit 1
48fi
49if [[ ! -d "$ROOT" ]]; then
50 echo "Error: Root FS does not exist ($ROOT)"
51 exit 1
52fi
53
54EXITCODE=0
55
56BINARIES="$ROOT/usr/bin/Xorg
57 $ROOT/usr/bin/chromeos-wm
58 $ROOT/boot/vmlinuz
59 $ROOT/sbin/session_manager
60 $ROOT/bin/sed"
61
62if [[ $FLAGS_target != arm ]]; then
63 # chrome isn't present on arm
64 BINARIES="$BINARIES
65 $ROOT/opt/google/chrome/chrome"
66fi
67
68for i in $BINARIES; do
69 if ! [[ -f $i ]]; then
70 echo test_image: Cannot find $i
71 EXITCODE=1
72 fi
73done
74
75LIBS="`sudo find $ROOT -type f -name '*.so*'`"
76
77# Check that all .so files, plus the binaries, have the appropriate dependencies
78if ! "${SCRIPTS_DIR}/check_deps" "$ROOT" $BINARIES $LIBS; then
79 echo test_image: Failed dependency check
80 EXITCODE=1
81fi
82
83exit $EXITCODE