1#!/bin/bash 2# 3# Copyright (c) 2013 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# Script to run a test under qemu 8# 9# Usage: 10# test_using_qemu.sh (command line to run) 11# 12# Required environment variables: 13# BUILD_RUN - path to build directory inside chroot 14# HOME - home directory inside chroot 15# QEMU_RUN - path to QEMU binary inside chroot 16# SYSROOT - path to root for target platform, outside chroot 17 18set -e 19 20# Set up mounts 21sudo mkdir -p "${SYSROOT}/proc" "${SYSROOT}/dev" 22sudo mount --bind /proc "${SYSROOT}/proc" 23sudo mount --bind /dev "${SYSROOT}/dev" 24 25# Don't exit on error, so we can capture the error code 26set +e 27sudo chroot ${SYSROOT} ${QEMU_RUN} -drop-ld-preload \ 28 -E LD_LIBRARY_PATH=/lib64:/lib:/usr/lib64:/usr/lib \ 29 -E HOME=${HOME} \ 30 -E BUILD=${BUILD_RUN} \ 31 -- $* 32exit_code=$? 33set -e 34 35# Clean up mounts 36sudo umount -l "${SYSROOT}/proc" 37sudo umount -l "${SYSROOT}/dev" 38 39# Pass through exit code from command 40exit $exit_code 41