1#!/bin/bash 2# Copyright 2021 The Chromium OS Authors. All rights reserved. 3# Use of this source code is governed by a BSD-style license that can be 4# found in the LICENSE file. 5# 6# Uploads and executes a file in the VM. This script can be set as a runner 7# for cargo to execute tests inside the VM. 8 9${0%/*}/wait_for_vm_with_timeout || exit 1 10 11if [ "$1" = "--no-sync" ]; then 12 shift 13else 14 echo "Syncing dependencies..." 15 ${0%/*}/sync_deps || exit 1 16fi 17 18filepath=$1 19filename=$(basename $filepath) 20 21echo "Executing $filename ${@:2}" 22scp -q $filepath vm:/tmp/$filename 23ssh vm -q -t "cd /tmp && sudo ./$filename ${@:2}" 24 25# Make sure to preserve the exit code of $filename after cleaning up the file. 26ret=$? 27ssh vm -q -t "rm /tmp/$filename" 28exit $ret 29