2020-12-03 18:00:47 +00:00
|
|
|
#!/bin/bash
|
|
|
|
# Copyright 2021 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.
|
|
|
|
|
2021-02-02 23:18:10 +00:00
|
|
|
# Clean scratch directory if requested.
|
|
|
|
if [ "$1" = "--clean" ]; then
|
|
|
|
shift
|
|
|
|
echo "Cleaning scratch directory..."
|
|
|
|
rm -rf /workspace/scratch/*
|
|
|
|
fi
|
|
|
|
|
2020-12-03 18:00:47 +00:00
|
|
|
echo "Building ChromeOS dependencies..."
|
|
|
|
if ! make -j $(nproc) -C ci/build_environment \
|
2021-02-02 23:18:10 +00:00
|
|
|
>/workspace/logs/build_environment.log 2>&1; then
|
2020-12-03 18:00:47 +00:00
|
|
|
echo "Failed to build ChromeOS dependencies"
|
2021-02-02 23:18:10 +00:00
|
|
|
cat /workspace/logs/build_environment.log
|
|
|
|
# Drop into an interactive shell for debugging.
|
|
|
|
if [[ $# -eq 0 ]]; then
|
|
|
|
/bin/bash
|
|
|
|
fi
|
2020-12-03 18:00:47 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2021-01-21 19:06:44 +00:00
|
|
|
if [ "$1" = "--vm" ]; then
|
|
|
|
shift
|
|
|
|
echo "Starting testing vm..."
|
|
|
|
(cd /workspace/vm && screen -Sdm vm ./start_vm)
|
|
|
|
export CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER="\
|
2021-02-22 22:40:08 +00:00
|
|
|
/workspace/src/platform/crosvm/ci/vm_tools/exec_binary_in_vm"
|
|
|
|
|
|
|
|
if [[ $# -eq 0 ]]; then
|
|
|
|
test_target="Virtual Machine (See 'screen -r vm' or 'ssh vm')"
|
|
|
|
else
|
|
|
|
test_target="Virtual Machine"
|
|
|
|
fi
|
2021-01-21 19:06:44 +00:00
|
|
|
export CROSVM_USE_VM=1
|
|
|
|
else
|
|
|
|
test_target="Native execution"
|
|
|
|
fi
|
|
|
|
|
2020-12-03 18:00:47 +00:00
|
|
|
echo ""
|
2021-01-21 19:06:44 +00:00
|
|
|
echo "crosvm builder is ready:"
|
2020-12-03 18:00:47 +00:00
|
|
|
echo " Cargo version: $(cargo --version)"
|
2021-01-21 19:06:44 +00:00
|
|
|
echo " Test target: ${test_target}"
|
2020-12-03 18:00:47 +00:00
|
|
|
echo ""
|
|
|
|
|
2021-01-21 19:06:44 +00:00
|
|
|
# Run user provided command or interactive shell
|
|
|
|
if [[ $# -eq 0 ]]; then
|
|
|
|
/bin/bash
|
|
|
|
else
|
|
|
|
echo "$ $@"
|
2021-02-02 23:18:10 +00:00
|
|
|
/bin/bash -c "$@"
|
2021-01-21 19:06:44 +00:00
|
|
|
fi
|