blob: cf4fbd8ed9b21996dbd0df71880dc750198af07b [file] [log] [blame]
#!/bin/bash
# Copyright 2022 The ChromiumOS Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# Runs firmware tests without hardware.
# This will run for roughly 2.5mins.
RED='\033[0;31m'
GREEN='\033[0;32m'
NORMAL='\033[0m'
set -e
PROJECT_ROOT=$(realpath "$(dirname "${BASH_SOURCE[0]}")"/..)
echo -e "\n\n${RED}=======================================${NORMAL}"
echo -e "${GREEN}Running Renode tests${NORMAL}"
echo -e "${RED}=======================================${NORMAL}"
release_path="rust/mcu/target/thumbv6m-none-eabi/release"
stage0_path="\$stage0?=\$CWD/${release_path}/stage0"
stage1_path="\$stage1?=\$CWD/${release_path}/stage1_app"
resc_path="renode/hps_stage1_tests.resc"
cd "${PROJECT_ROOT}/"
renode --console -e "${stage0_path}; ${stage1_path}; include @${resc_path}" &
renode_PID=$!
{
for _ in {1..150}
do
if ! ps -p "${renode_PID}" >/dev/null
then
exit 0
else
sleep 1
fi
done
einfo "Renode process still exists" && kill "${renode_PID}" && exit 0;
} &
cd "${PROJECT_ROOT}/rust/target/release/"
sleep 60
echo "Start hps-factory test at ${PROJECT_ROOT}"
./hps-factory --socket /tmp/i2c.sock test-stage1
factory_PID=$!
wait "${factory_PID}"
status=$?
[ "${status}" -eq 0 ] && exit 0
echo "Renode test failed"
exit 1