mirror of
https://github.com/flatcar/scripts.git
synced 2025-09-25 23:51:07 +02:00
Merge branch 'master' of ssh://gitrw.chromium.org:9222/crosutils
This commit is contained in:
commit
cc4a3f5b28
@ -281,7 +281,8 @@ class AUTest(object):
|
||||
self.PerformUpdate(self.base_image_path, self.target_image_path, 'clean')
|
||||
self.VerifyImage(percent_passed)
|
||||
|
||||
def testPartialUpdate(self):
|
||||
# TODO(sosa): Get test to work with verbose.
|
||||
def NotestPartialUpdate(self):
|
||||
"""Tests what happens if we attempt to update with a truncated payload."""
|
||||
# Preload with the version we are trying to test.
|
||||
self.PrepareBase(self.target_image_path)
|
||||
@ -298,7 +299,8 @@ class AUTest(object):
|
||||
expected_msg = 'download_hash_data == update_check_response_hash failed'
|
||||
self.AttemptUpdateWithPayloadExpectedFailure(payload, expected_msg)
|
||||
|
||||
def testCorruptedUpdate(self):
|
||||
# TODO(sosa): Get test to work with verbose.
|
||||
def NotestCorruptedUpdate(self):
|
||||
"""Tests what happens if we attempt to update with a corrupted payload."""
|
||||
# Preload with the version we are trying to test.
|
||||
self.PrepareBase(self.target_image_path)
|
||||
@ -629,7 +631,7 @@ def main():
|
||||
'testFullUpdateWipeStateful.')
|
||||
parser.add_option('-p', '--type', default='vm',
|
||||
help='type of test to run: [vm, real]. Default: vm.')
|
||||
parser.add_option('--verbose', default=False, action='store_true',
|
||||
parser.add_option('--verbose', default=True, action='store_true',
|
||||
help='Print out rather than capture output as much as '
|
||||
'possible.')
|
||||
(options, leftover_args) = parser.parse_args()
|
||||
|
@ -15,22 +15,24 @@ DEFINE_integer ssh_port 22 \
|
||||
|
||||
# Copies $1 to $2 on remote host
|
||||
function remote_cp_to() {
|
||||
REMOTE_OUT=$(scp -P ${FLAGS_ssh_port} -o StrictHostKeyChecking=no -o \
|
||||
UserKnownHostsFile=$TMP_KNOWN_HOSTS $1 root@$FLAGS_remote:$2)
|
||||
REMOTE_OUT=$(scp -P ${FLAGS_ssh_port} -o StrictHostKeyChecking=no \
|
||||
-o UserKnownHostsFile=$TMP_KNOWN_HOSTS -i $TMP_PRIVATE_KEY $1 \
|
||||
root@$FLAGS_remote:$2)
|
||||
return ${PIPESTATUS[0]}
|
||||
}
|
||||
|
||||
# Copies a list of remote files specified in file $1 to local location
|
||||
# $2. Directory paths in $1 are collapsed into $2.
|
||||
function remote_rsync_from() {
|
||||
rsync -e "ssh -p ${FLAGS_ssh_port} -o StrictHostKeyChecking=no -o \
|
||||
UserKnownHostsFile=$TMP_KNOWN_HOSTS" --no-R \
|
||||
--files-from=$1 root@${FLAGS_remote}:/ $2
|
||||
rsync -e "ssh -p ${FLAGS_ssh_port} -o StrictHostKeyChecking=no \
|
||||
-o UserKnownHostsFile=$TMP_KNOWN_HOSTS -i $TMP_PRIVATE_KEY" \
|
||||
--no-R --files-from=$1 root@${FLAGS_remote}:/ $2
|
||||
}
|
||||
|
||||
function remote_sh() {
|
||||
REMOTE_OUT=$(ssh -p ${FLAGS_ssh_port} -o StrictHostKeyChecking=no -o \
|
||||
UserKnownHostsFile=$TMP_KNOWN_HOSTS root@$FLAGS_remote "$@")
|
||||
REMOTE_OUT=$(ssh -p ${FLAGS_ssh_port} -o StrictHostKeyChecking=no \
|
||||
-o UserKnownHostsFile=$TMP_KNOWN_HOSTS -i $TMP_PRIVATE_KEY \
|
||||
root@$FLAGS_remote "$@")
|
||||
return ${PIPESTATUS[0]}
|
||||
}
|
||||
|
||||
@ -40,15 +42,8 @@ function remote_sh_allow_changed_host_key() {
|
||||
}
|
||||
|
||||
function set_up_remote_access() {
|
||||
if [ -z "$SSH_AGENT_PID" ]; then
|
||||
eval $(ssh-agent)
|
||||
OWN_SSH_AGENT=1
|
||||
else
|
||||
OWN_SSH_AGENT=0
|
||||
fi
|
||||
cp $FLAGS_private_key $TMP_PRIVATE_KEY
|
||||
chmod 0400 $TMP_PRIVATE_KEY
|
||||
ssh-add $TMP_PRIVATE_KEY
|
||||
|
||||
# Verify the client is reachable before continuing
|
||||
echo "Initiating first contact with remote host"
|
||||
@ -121,15 +116,10 @@ function remote_reboot() {
|
||||
done
|
||||
}
|
||||
|
||||
# Called by clients before exiting.
|
||||
# Part of the remote_access.sh interface but now empty.
|
||||
function cleanup_remote_access() {
|
||||
# Call this function from the exit trap of the main script.
|
||||
# Iff we started ssh-agent, be nice and clean it up.
|
||||
# Note, only works if called from the main script - no subshells.
|
||||
if [[ 1 -eq ${OWN_SSH_AGENT} ]]
|
||||
then
|
||||
kill ${SSH_AGENT_PID} 2>/dev/null
|
||||
unset SSH_AGENT_PID SSH_AUTH_SOCK
|
||||
fi
|
||||
true
|
||||
}
|
||||
|
||||
function remote_access_init() {
|
||||
|
@ -29,6 +29,30 @@ DEFINE_boolean use_emerged ${FLAGS_FALSE} \
|
||||
|
||||
RAN_ANY_TESTS=${FLAGS_FALSE}
|
||||
|
||||
function stop_ssh_agent() {
|
||||
# Call this function from the exit trap of the main script.
|
||||
# Iff we started ssh-agent, be nice and clean it up.
|
||||
# Note, only works if called from the main script - no subshells.
|
||||
if [[ 1 -eq ${OWN_SSH_AGENT} ]]
|
||||
then
|
||||
kill ${SSH_AGENT_PID} 2>/dev/null
|
||||
unset OWN_SSH_AGENT SSH_AGENT_PID SSH_AUTH_SOCK
|
||||
fi
|
||||
}
|
||||
|
||||
function start_ssh_agent() {
|
||||
local tmp_private_key=$TMP/autotest_key
|
||||
if [ -z "$SSH_AGENT_PID" ]; then
|
||||
eval $(ssh-agent)
|
||||
OWN_SSH_AGENT=1
|
||||
else
|
||||
OWN_SSH_AGENT=0
|
||||
fi
|
||||
cp $FLAGS_private_key $tmp_private_key
|
||||
chmod 0400 $tmp_private_key
|
||||
ssh-add $tmp_private_key
|
||||
}
|
||||
|
||||
function cleanup() {
|
||||
# Always remove the build path in case it was used.
|
||||
[[ -n "${BUILD_DIR}" ]] && sudo rm -rf "${BUILD_DIR}"
|
||||
@ -38,6 +62,7 @@ function cleanup() {
|
||||
else
|
||||
echo ">>> Details stored under ${TMP}"
|
||||
fi
|
||||
stop_ssh_agent
|
||||
cleanup_remote_access
|
||||
}
|
||||
|
||||
@ -169,6 +194,8 @@ function main() {
|
||||
trap cleanup EXIT
|
||||
|
||||
remote_access_init
|
||||
# autotest requires that an ssh-agent already be running
|
||||
start_ssh_agent
|
||||
|
||||
learn_board
|
||||
autodetect_build
|
||||
|
@ -12,11 +12,22 @@
|
||||
. "$(dirname $0)/common.sh"
|
||||
. "$(dirname $0)/remote_access.sh"
|
||||
|
||||
# Script must be run inside the chroot.
|
||||
restart_in_chroot_if_needed $*
|
||||
|
||||
DEFINE_string board "" "Override board reported by target"
|
||||
DEFINE_string partition "" "Override kernel partition reported by target"
|
||||
DEFINE_boolean modules false "Update modules on target"
|
||||
DEFINE_boolean firmware false "Update firmware on target"
|
||||
|
||||
# Parse command line.
|
||||
FLAGS "$@" || exit 1
|
||||
eval set -- "${FLAGS_ARGV}"
|
||||
|
||||
# Only now can we die on error. shflags functions leak non-zero error codes,
|
||||
# so will die prematurely if 'set -e' is specified before now.
|
||||
set -e
|
||||
|
||||
function cleanup {
|
||||
cleanup_remote_access
|
||||
rm -rf "${TMP}"
|
||||
@ -39,15 +50,6 @@ function learn_partition() {
|
||||
}
|
||||
|
||||
function main() {
|
||||
assert_outside_chroot
|
||||
|
||||
cd $(dirname "$0")
|
||||
|
||||
FLAGS "$@" || exit 1
|
||||
eval set -- "${FLAGS_ARGV}"
|
||||
|
||||
set -e
|
||||
|
||||
trap cleanup EXIT
|
||||
|
||||
TMP=$(mktemp -d /tmp/image_to_live.XXXX)
|
||||
@ -60,15 +62,13 @@ function main() {
|
||||
|
||||
old_kernel="${REMOTE_OUT}"
|
||||
|
||||
cmd="vbutil_kernel --pack new_kern.bin \
|
||||
--keyblock /usr/share/vboot/devkeys/kernel.keyblock \
|
||||
--signprivate /usr/share/vboot/devkeys/kernel_data_key.vbprivk \
|
||||
--version 1 \
|
||||
--config ../build/images/${FLAGS_board}/latest/config.txt \
|
||||
--bootloader /lib64/bootstub/bootstub.efi \
|
||||
--vmlinuz /build/${FLAGS_board}/boot/vmlinuz"
|
||||
|
||||
./enter_chroot.sh -- ${cmd}
|
||||
vbutil_kernel --pack new_kern.bin \
|
||||
--keyblock /usr/share/vboot/devkeys/kernel.keyblock \
|
||||
--signprivate /usr/share/vboot/devkeys/kernel_data_key.vbprivk \
|
||||
--version 1 \
|
||||
--config ../build/images/"${FLAGS_board}"/latest/config.txt \
|
||||
--bootloader /lib64/bootstub/bootstub.efi \
|
||||
--vmlinuz /build/"${FLAGS_board}"/boot/vmlinuz
|
||||
|
||||
learn_partition
|
||||
|
||||
@ -78,8 +78,7 @@ function main() {
|
||||
|
||||
if [[ ${FLAGS_modules} -eq ${FLAGS_TRUE} ]]; then
|
||||
echo "copying modules"
|
||||
cmd="tar -C /build/${FLAGS_board}/lib/modules -cjf new_modules.tar ."
|
||||
./enter_chroot.sh -- ${cmd}
|
||||
tar -C /build/"${FLAGS_board}"/lib/modules -cjf new_modules.tar .
|
||||
|
||||
remote_cp_to new_modules.tar /tmp/
|
||||
|
||||
@ -89,8 +88,7 @@ function main() {
|
||||
|
||||
if [[ ${FLAGS_firmware} -eq ${FLAGS_TRUE} ]]; then
|
||||
echo "copying firmware"
|
||||
cmd="tar -C /build/${FLAGS_board}/lib/firmware -cjf new_firmware.tar ."
|
||||
./enter_chroot.sh -- ${cmd}
|
||||
tar -C /build/"${FLAGS_board}"/lib/firmware -cjf new_firmware.tar .
|
||||
|
||||
remote_cp_to new_firmware.tar /tmp/
|
||||
|
||||
@ -101,9 +99,7 @@ function main() {
|
||||
remote_reboot
|
||||
|
||||
remote_sh uname -r -v
|
||||
|
||||
info "old kernel: ${old_kernel}"
|
||||
|
||||
info "new kernel: ${REMOTE_OUT}"
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user