Files
OpenCellular/tests/test_using_qemu.sh
Randall Spangler e061a25654 Convert common tests from shell scripts to running directly
So they can run under qemu.

Also, mount /proc and /dev before running qemu in the chroot.

BUG=chromium-os:37916
BRANCH=none
TEST=manual

make runtests
sudo FEATURES=test emerge vboot_reference
FEATURES=test emerge-daisy vboot_reference
FEATURES=test emerge-link vboot_reference

Change-Id: I940ce370bd149621e666250b07cf9219f9e22bac
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/41786
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2013-01-23 12:40:15 -08:00

41 lines
1.0 KiB
Bash
Executable File

#!/bin/bash
#
# Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
#
# Script to run a test under qemu
#
# Usage:
# test_using_qemu.sh (command line to run)
#
# Required environment variables:
# BUILD_RUN - path to build directory inside chroot
# HOME - home directory inside chroot
# QEMU_RUN - path to QEMU binary inside chroot
# SYSROOT - path to root for target platform, outside chroot
set -e
# Set up mounts
sudo mkdir -p "${SYSROOT}/proc" "${SYSROOT}/dev"
sudo mount --bind /proc "${SYSROOT}/proc"
sudo mount --bind /dev "${SYSROOT}/dev"
# Don't exit on error, so we can capture the error code
set +e
sudo chroot ${SYSROOT} ${QEMU_RUN} -drop-ld-preload \
-E LD_LIBRARY_PATH=/lib64:/lib:/usr/lib64:/usr/lib \
-E HOME=${HOME} \
-E BUILD=${BUILD_RUN} \
-- $*
exit_code=$?
set -e
# Clean up mounts
sudo umount -l "${SYSROOT}/proc"
sudo umount -l "${SYSROOT}/dev"
# Pass through exit code from command
exit $exit_code