blob: cf4fbd8ed9b21996dbd0df71880dc750198af07b [file] [log] [blame]
Eunice Sun0a8d70e2022-09-15 15:42:49 +10001#!/bin/bash
2
David Lattimore3b6faa22022-10-18 14:10:43 +11003# Copyright 2022 The ChromiumOS Authors
Eunice Sun0a8d70e2022-09-15 15:42:49 +10004# Use of this source code is governed by a BSD-style license that can be
5# found in the LICENSE file.
6
7# Runs firmware tests without hardware.
8# This will run for roughly 2.5mins.
9
10RED='\033[0;31m'
11GREEN='\033[0;32m'
12NORMAL='\033[0m'
13
14set -e
15PROJECT_ROOT=$(realpath "$(dirname "${BASH_SOURCE[0]}")"/..)
16
17echo -e "\n\n${RED}=======================================${NORMAL}"
18echo -e "${GREEN}Running Renode tests${NORMAL}"
19echo -e "${RED}=======================================${NORMAL}"
20
Eunice Sun271e9cf2022-09-21 10:21:33 +100021release_path="rust/mcu/target/thumbv6m-none-eabi/release"
22
23stage0_path="\$stage0?=\$CWD/${release_path}/stage0"
24stage1_path="\$stage1?=\$CWD/${release_path}/stage1_app"
25resc_path="renode/hps_stage1_tests.resc"
Eunice Sun0a8d70e2022-09-15 15:42:49 +100026cd "${PROJECT_ROOT}/"
Eunice Sun271e9cf2022-09-21 10:21:33 +100027
28renode --console -e "${stage0_path}; ${stage1_path}; include @${resc_path}" &
Eunice Sun0a8d70e2022-09-15 15:42:49 +100029renode_PID=$!
30
31{
32 for _ in {1..150}
33 do
34 if ! ps -p "${renode_PID}" >/dev/null
35 then
36 exit 0
37 else
38 sleep 1
39 fi
40 done
41 einfo "Renode process still exists" && kill "${renode_PID}" && exit 0;
42} &
43
44cd "${PROJECT_ROOT}/rust/target/release/"
45sleep 60
46echo "Start hps-factory test at ${PROJECT_ROOT}"
47./hps-factory --socket /tmp/i2c.sock test-stage1
48factory_PID=$!
49
50wait "${factory_PID}"
51status=$?
52[ "${status}" -eq 0 ] && exit 0
53
54echo "Renode test failed"
55exit 1