mirror of
https://github.com/flatcar/scripts.git
synced 2025-09-26 08:01:14 +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.PerformUpdate(self.base_image_path, self.target_image_path, 'clean')
|
||||||
self.VerifyImage(percent_passed)
|
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."""
|
"""Tests what happens if we attempt to update with a truncated payload."""
|
||||||
# Preload with the version we are trying to test.
|
# Preload with the version we are trying to test.
|
||||||
self.PrepareBase(self.target_image_path)
|
self.PrepareBase(self.target_image_path)
|
||||||
@ -298,7 +299,8 @@ class AUTest(object):
|
|||||||
expected_msg = 'download_hash_data == update_check_response_hash failed'
|
expected_msg = 'download_hash_data == update_check_response_hash failed'
|
||||||
self.AttemptUpdateWithPayloadExpectedFailure(payload, expected_msg)
|
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."""
|
"""Tests what happens if we attempt to update with a corrupted payload."""
|
||||||
# Preload with the version we are trying to test.
|
# Preload with the version we are trying to test.
|
||||||
self.PrepareBase(self.target_image_path)
|
self.PrepareBase(self.target_image_path)
|
||||||
@ -629,7 +631,7 @@ def main():
|
|||||||
'testFullUpdateWipeStateful.')
|
'testFullUpdateWipeStateful.')
|
||||||
parser.add_option('-p', '--type', default='vm',
|
parser.add_option('-p', '--type', default='vm',
|
||||||
help='type of test to run: [vm, real]. 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 '
|
help='Print out rather than capture output as much as '
|
||||||
'possible.')
|
'possible.')
|
||||||
(options, leftover_args) = parser.parse_args()
|
(options, leftover_args) = parser.parse_args()
|
||||||
|
@ -15,22 +15,24 @@ DEFINE_integer ssh_port 22 \
|
|||||||
|
|
||||||
# Copies $1 to $2 on remote host
|
# Copies $1 to $2 on remote host
|
||||||
function remote_cp_to() {
|
function remote_cp_to() {
|
||||||
REMOTE_OUT=$(scp -P ${FLAGS_ssh_port} -o StrictHostKeyChecking=no -o \
|
REMOTE_OUT=$(scp -P ${FLAGS_ssh_port} -o StrictHostKeyChecking=no \
|
||||||
UserKnownHostsFile=$TMP_KNOWN_HOSTS $1 root@$FLAGS_remote:$2)
|
-o UserKnownHostsFile=$TMP_KNOWN_HOSTS -i $TMP_PRIVATE_KEY $1 \
|
||||||
|
root@$FLAGS_remote:$2)
|
||||||
return ${PIPESTATUS[0]}
|
return ${PIPESTATUS[0]}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Copies a list of remote files specified in file $1 to local location
|
# Copies a list of remote files specified in file $1 to local location
|
||||||
# $2. Directory paths in $1 are collapsed into $2.
|
# $2. Directory paths in $1 are collapsed into $2.
|
||||||
function remote_rsync_from() {
|
function remote_rsync_from() {
|
||||||
rsync -e "ssh -p ${FLAGS_ssh_port} -o StrictHostKeyChecking=no -o \
|
rsync -e "ssh -p ${FLAGS_ssh_port} -o StrictHostKeyChecking=no \
|
||||||
UserKnownHostsFile=$TMP_KNOWN_HOSTS" --no-R \
|
-o UserKnownHostsFile=$TMP_KNOWN_HOSTS -i $TMP_PRIVATE_KEY" \
|
||||||
--files-from=$1 root@${FLAGS_remote}:/ $2
|
--no-R --files-from=$1 root@${FLAGS_remote}:/ $2
|
||||||
}
|
}
|
||||||
|
|
||||||
function remote_sh() {
|
function remote_sh() {
|
||||||
REMOTE_OUT=$(ssh -p ${FLAGS_ssh_port} -o StrictHostKeyChecking=no -o \
|
REMOTE_OUT=$(ssh -p ${FLAGS_ssh_port} -o StrictHostKeyChecking=no \
|
||||||
UserKnownHostsFile=$TMP_KNOWN_HOSTS root@$FLAGS_remote "$@")
|
-o UserKnownHostsFile=$TMP_KNOWN_HOSTS -i $TMP_PRIVATE_KEY \
|
||||||
|
root@$FLAGS_remote "$@")
|
||||||
return ${PIPESTATUS[0]}
|
return ${PIPESTATUS[0]}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,15 +42,8 @@ function remote_sh_allow_changed_host_key() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function set_up_remote_access() {
|
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
|
cp $FLAGS_private_key $TMP_PRIVATE_KEY
|
||||||
chmod 0400 $TMP_PRIVATE_KEY
|
chmod 0400 $TMP_PRIVATE_KEY
|
||||||
ssh-add $TMP_PRIVATE_KEY
|
|
||||||
|
|
||||||
# Verify the client is reachable before continuing
|
# Verify the client is reachable before continuing
|
||||||
echo "Initiating first contact with remote host"
|
echo "Initiating first contact with remote host"
|
||||||
@ -121,15 +116,10 @@ function remote_reboot() {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Called by clients before exiting.
|
||||||
|
# Part of the remote_access.sh interface but now empty.
|
||||||
function cleanup_remote_access() {
|
function cleanup_remote_access() {
|
||||||
# Call this function from the exit trap of the main script.
|
true
|
||||||
# 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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function remote_access_init() {
|
function remote_access_init() {
|
||||||
|
@ -29,6 +29,30 @@ DEFINE_boolean use_emerged ${FLAGS_FALSE} \
|
|||||||
|
|
||||||
RAN_ANY_TESTS=${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() {
|
function cleanup() {
|
||||||
# Always remove the build path in case it was used.
|
# Always remove the build path in case it was used.
|
||||||
[[ -n "${BUILD_DIR}" ]] && sudo rm -rf "${BUILD_DIR}"
|
[[ -n "${BUILD_DIR}" ]] && sudo rm -rf "${BUILD_DIR}"
|
||||||
@ -38,6 +62,7 @@ function cleanup() {
|
|||||||
else
|
else
|
||||||
echo ">>> Details stored under ${TMP}"
|
echo ">>> Details stored under ${TMP}"
|
||||||
fi
|
fi
|
||||||
|
stop_ssh_agent
|
||||||
cleanup_remote_access
|
cleanup_remote_access
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -169,6 +194,8 @@ function main() {
|
|||||||
trap cleanup EXIT
|
trap cleanup EXIT
|
||||||
|
|
||||||
remote_access_init
|
remote_access_init
|
||||||
|
# autotest requires that an ssh-agent already be running
|
||||||
|
start_ssh_agent
|
||||||
|
|
||||||
learn_board
|
learn_board
|
||||||
autodetect_build
|
autodetect_build
|
||||||
|
@ -12,11 +12,22 @@
|
|||||||
. "$(dirname $0)/common.sh"
|
. "$(dirname $0)/common.sh"
|
||||||
. "$(dirname $0)/remote_access.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 board "" "Override board reported by target"
|
||||||
DEFINE_string partition "" "Override kernel partition reported by target"
|
DEFINE_string partition "" "Override kernel partition reported by target"
|
||||||
DEFINE_boolean modules false "Update modules on target"
|
DEFINE_boolean modules false "Update modules on target"
|
||||||
DEFINE_boolean firmware false "Update firmware 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 {
|
function cleanup {
|
||||||
cleanup_remote_access
|
cleanup_remote_access
|
||||||
rm -rf "${TMP}"
|
rm -rf "${TMP}"
|
||||||
@ -39,15 +50,6 @@ function learn_partition() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function main() {
|
function main() {
|
||||||
assert_outside_chroot
|
|
||||||
|
|
||||||
cd $(dirname "$0")
|
|
||||||
|
|
||||||
FLAGS "$@" || exit 1
|
|
||||||
eval set -- "${FLAGS_ARGV}"
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
trap cleanup EXIT
|
trap cleanup EXIT
|
||||||
|
|
||||||
TMP=$(mktemp -d /tmp/image_to_live.XXXX)
|
TMP=$(mktemp -d /tmp/image_to_live.XXXX)
|
||||||
@ -60,15 +62,13 @@ function main() {
|
|||||||
|
|
||||||
old_kernel="${REMOTE_OUT}"
|
old_kernel="${REMOTE_OUT}"
|
||||||
|
|
||||||
cmd="vbutil_kernel --pack new_kern.bin \
|
vbutil_kernel --pack new_kern.bin \
|
||||||
--keyblock /usr/share/vboot/devkeys/kernel.keyblock \
|
--keyblock /usr/share/vboot/devkeys/kernel.keyblock \
|
||||||
--signprivate /usr/share/vboot/devkeys/kernel_data_key.vbprivk \
|
--signprivate /usr/share/vboot/devkeys/kernel_data_key.vbprivk \
|
||||||
--version 1 \
|
--version 1 \
|
||||||
--config ../build/images/${FLAGS_board}/latest/config.txt \
|
--config ../build/images/"${FLAGS_board}"/latest/config.txt \
|
||||||
--bootloader /lib64/bootstub/bootstub.efi \
|
--bootloader /lib64/bootstub/bootstub.efi \
|
||||||
--vmlinuz /build/${FLAGS_board}/boot/vmlinuz"
|
--vmlinuz /build/"${FLAGS_board}"/boot/vmlinuz
|
||||||
|
|
||||||
./enter_chroot.sh -- ${cmd}
|
|
||||||
|
|
||||||
learn_partition
|
learn_partition
|
||||||
|
|
||||||
@ -78,8 +78,7 @@ function main() {
|
|||||||
|
|
||||||
if [[ ${FLAGS_modules} -eq ${FLAGS_TRUE} ]]; then
|
if [[ ${FLAGS_modules} -eq ${FLAGS_TRUE} ]]; then
|
||||||
echo "copying modules"
|
echo "copying modules"
|
||||||
cmd="tar -C /build/${FLAGS_board}/lib/modules -cjf new_modules.tar ."
|
tar -C /build/"${FLAGS_board}"/lib/modules -cjf new_modules.tar .
|
||||||
./enter_chroot.sh -- ${cmd}
|
|
||||||
|
|
||||||
remote_cp_to new_modules.tar /tmp/
|
remote_cp_to new_modules.tar /tmp/
|
||||||
|
|
||||||
@ -89,8 +88,7 @@ function main() {
|
|||||||
|
|
||||||
if [[ ${FLAGS_firmware} -eq ${FLAGS_TRUE} ]]; then
|
if [[ ${FLAGS_firmware} -eq ${FLAGS_TRUE} ]]; then
|
||||||
echo "copying firmware"
|
echo "copying firmware"
|
||||||
cmd="tar -C /build/${FLAGS_board}/lib/firmware -cjf new_firmware.tar ."
|
tar -C /build/"${FLAGS_board}"/lib/firmware -cjf new_firmware.tar .
|
||||||
./enter_chroot.sh -- ${cmd}
|
|
||||||
|
|
||||||
remote_cp_to new_firmware.tar /tmp/
|
remote_cp_to new_firmware.tar /tmp/
|
||||||
|
|
||||||
@ -101,9 +99,7 @@ function main() {
|
|||||||
remote_reboot
|
remote_reboot
|
||||||
|
|
||||||
remote_sh uname -r -v
|
remote_sh uname -r -v
|
||||||
|
|
||||||
info "old kernel: ${old_kernel}"
|
info "old kernel: ${old_kernel}"
|
||||||
|
|
||||||
info "new kernel: ${REMOTE_OUT}"
|
info "new kernel: ${REMOTE_OUT}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user