blob: d3f7f5a894608394c84513b2aa5431c2ce78ce53 [file] [log] [blame]
Jaewan Kim3ad58c32024-06-13 08:59:29 +00001#!/bin/bash
2
3# Copyright 2024 Google Inc. All rights reserved.
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16
17
18## Precondition checks for running ferrochrome
19## Used by CI for skipping tests.
20
21REQUIRED_DISK_SPACE=7340032 # Requires 7G, while image is 6.5G
22
23# `adb root` always returns exit code 0
24if [[ "$(adb root)" == *"cannot"* ]]; then
25 >&2 echo "Failed to run adb root"
26 exit 1
27fi
28
29# `pm resolve-activity` always returns exit code 0
30resolved_activity=$(adb shell pm resolve-activity -a android.virtualization.VM_LAUNCHER)
31if [[ "${resolved_activity}" == "No activity found" ]]; then
32 >&2 echo "Failed to find vmlauncher"
33 exit 1
34fi
35
36free_space=$(adb shell df /data/local | tail -1 | awk '{print $4}')
37if [[ ${free_space} -lt ${REQUIRED_DISK_SPACE} ]]; then
38 >&2 echo "Insufficient space on DUT. Need ${REQUIRED_DISK_SPACE}, but was ${free_space}"
39 exit 1
40fi
41
42free_space=$(df /tmp | tail -1 | awk '{print $4}')
43if [[ ${free_space} -lt ${REQUIRED_DISK_SPACE} ]]; then
44 >&2 echo "Insufficient space on host. Need ${REQUIRED_DISK_SPACE}, but was ${free_space}"
45 exit 1
46fi
47
48cpu_abi=$(adb shell getprop ro.product.cpu.abi)
49if [[ "${cpu_abi}" != "arm64"* ]]; then
50 >&2 echo "Unsupported architecture. Requires arm64, but was ${cpu_abi}"
51 exit 1
52fi
53
54device=$(adb shell getprop ro.product.vendor.device)
55if [[ "${device}" == "vsock_"* ]]; then
56 >&2 echo "Unsupported device. Cuttlefish isn't supported"
57 exit 1
58fi