blob: 96919fe12c8c752afe3407394878ec72101d2172 [file] [log] [blame]
# Copyright (c) 2010 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.
description "Semi Automated Firmware Test support"
author "chromium-os-dev@chromium.org"
# Checks if SAFT (Semi Automated Firmware Test) is in progress. If it is -
# runs it through the next step.
#for_test start on starting system-services
script
SAFT_LOG='/tmp/saft.log'
SAFT_SCRIPT='/var/saft.sh'
exec > "${SAFT_LOG}" 2>&1
get_flash_dev() {
# see if the flash device has been already detected. It shows up in
# the message log as a string of partition names with the same base
# and different indices, as in
#
# [timestamp] sdb1 sdb2 sdb3 ... sdb12
#
# If found - return the base device name (with the index stripped)
dmesg | egrep '(sd[b-z][1-9] ){9}' | awk '{print substr($5, 0, 3)}'
}
retry=0
dev=$(get_flash_dev)
while [ -z "${dev}" -o ! -e "/sys/block/${dev}" ]
do
if [ "${retry}" = "15" ]; then
echo 'USB flash drive not found'
exit 1
fi
sleep 1
if [ -z "${dev}" ]; then
dev=$(get_flash_dev)
fi
retry=$((retry + 1))
done
echo "Found ${dev} after ${retry} seconds"
# Mount stateful partition for SAFT processing.
mount_point='/tmp/saft_stateful_partition'
mkdir "${mount_point}"
mount "/dev/${dev}1" "${mount_point}"
saft_script="${mount_point}${SAFT_SCRIPT}"
if [ -f "${saft_script}" -a -x "${saft_script}" ]; then
# Saft shell script is present, this indicates that SAFT is in
# progress. Execute the script.
${saft_script} "${dev}"
else
umount "${mount_point}"
rmdir "${mount_point}"
echo "No SAFT in progress"
fi
end script