test_using_qemu.sh 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. set -e
  18. # Set up mounts
  19. sudo mkdir -p "${SYSROOT}/proc" "${SYSROOT}/dev"
  20. sudo mount --bind /proc "${SYSROOT}/proc"
  21. sudo mount --bind /dev "${SYSROOT}/dev"
  22. # Don't exit on error, so we can capture the error code
  23. set +e
  24. sudo chroot ${SYSROOT} ${QEMU_RUN} -drop-ld-preload \
  25. -E LD_LIBRARY_PATH=/lib64:/lib:/usr/lib64:/usr/lib \
  26. -E HOME=${HOME} \
  27. -E BUILD=${BUILD_RUN} \
  28. -- $*
  29. exit_code=$?
  30. set -e
  31. # Clean up mounts
  32. sudo umount -l "${SYSROOT}/proc"
  33. sudo umount -l "${SYSROOT}/dev"
  34. # Pass through exit code from command
  35. exit $exit_code