2021-01-21 19:06:44 +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-22 22:40:08 +00:00
|
|
|
# Uploads and executes a file in the VM. This script can be set as a runner
|
|
|
|
# for cargo to execute tests inside the VM.
|
2021-01-21 19:06:44 +00:00
|
|
|
|
2021-02-22 22:40:08 +00:00
|
|
|
${0%/*}/wait_for_vm_with_timeout || exit 1
|
2021-01-21 19:06:44 +00:00
|
|
|
|
|
|
|
if [ "$1" = "--no-sync" ]; then
|
|
|
|
shift
|
|
|
|
else
|
2021-02-22 22:40:08 +00:00
|
|
|
echo "Syncing dependencies..."
|
|
|
|
${0%/*}/sync_deps || exit 1
|
2021-01-21 19:06:44 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
filepath=$1
|
|
|
|
filename=$(basename $filepath)
|
|
|
|
|
2021-02-02 23:18:10 +00:00
|
|
|
echo "Executing $filename ${@:2}"
|
|
|
|
scp -q $filepath vm:/tmp/$filename
|
2021-02-22 22:40:08 +00:00
|
|
|
ssh vm -q -t "cd /tmp && sudo ./$filename ${@:2}"
|
|
|
|
|
2021-01-21 19:06:44 +00:00
|
|
|
# Make sure to preserve the exit code of $filename after cleaning up the file.
|
|
|
|
ret=$?
|
2021-02-02 23:18:10 +00:00
|
|
|
ssh vm -q -t "rm /tmp/$filename"
|
2021-01-21 19:06:44 +00:00
|
|
|
exit $ret
|