Eunice Sun | 0a8d70e | 2022-09-15 15:42:49 +1000 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
David Lattimore | 3b6faa2 | 2022-10-18 14:10:43 +1100 | [diff] [blame] | 3 | # Copyright 2022 The ChromiumOS Authors |
Eunice Sun | 0a8d70e | 2022-09-15 15:42:49 +1000 | [diff] [blame] | 4 | # 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 | |
| 10 | RED='\033[0;31m' |
| 11 | GREEN='\033[0;32m' |
| 12 | NORMAL='\033[0m' |
| 13 | |
| 14 | set -e |
| 15 | PROJECT_ROOT=$(realpath "$(dirname "${BASH_SOURCE[0]}")"/..) |
| 16 | |
| 17 | echo -e "\n\n${RED}=======================================${NORMAL}" |
| 18 | echo -e "${GREEN}Running Renode tests${NORMAL}" |
| 19 | echo -e "${RED}=======================================${NORMAL}" |
| 20 | |
Eunice Sun | 271e9cf | 2022-09-21 10:21:33 +1000 | [diff] [blame] | 21 | release_path="rust/mcu/target/thumbv6m-none-eabi/release" |
| 22 | |
| 23 | stage0_path="\$stage0?=\$CWD/${release_path}/stage0" |
| 24 | stage1_path="\$stage1?=\$CWD/${release_path}/stage1_app" |
| 25 | resc_path="renode/hps_stage1_tests.resc" |
Eunice Sun | 0a8d70e | 2022-09-15 15:42:49 +1000 | [diff] [blame] | 26 | cd "${PROJECT_ROOT}/" |
Eunice Sun | 271e9cf | 2022-09-21 10:21:33 +1000 | [diff] [blame] | 27 | |
| 28 | renode --console -e "${stage0_path}; ${stage1_path}; include @${resc_path}" & |
Eunice Sun | 0a8d70e | 2022-09-15 15:42:49 +1000 | [diff] [blame] | 29 | renode_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 | |
| 44 | cd "${PROJECT_ROOT}/rust/target/release/" |
| 45 | sleep 60 |
| 46 | echo "Start hps-factory test at ${PROJECT_ROOT}" |
| 47 | ./hps-factory --socket /tmp/i2c.sock test-stage1 |
| 48 | factory_PID=$! |
| 49 | |
| 50 | wait "${factory_PID}" |
| 51 | status=$? |
| 52 | [ "${status}" -eq 0 ] && exit 0 |
| 53 | |
| 54 | echo "Renode test failed" |
| 55 | exit 1 |