Skip to content

Commit

Permalink
CI: Improve error-prone support
Browse files Browse the repository at this point in the history
The timeout for 'expect' script is reduced to 90 seconds, which should
be reasonable for testing purpose.
  • Loading branch information
jserv committed Jan 20, 2024
1 parent a309d9e commit 78ec6f7
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions .ci/autorun.sh
Original file line number Diff line number Diff line change
@@ -1,24 +1,40 @@
#!/usr/bin/env bash

pkill -9 semu
function cleanup {
sleep 1
pkill -9 semu
}

expect <<DONE
set timeout 120
function ASSERT {
$*
local RES=$?
if [ $RES -ne 0 ]; then
echo 'Assert failed: "' $* '"'
exit $RES
fi
}

cleanup

ASSERT expect <<DONE
set timeout 90
spawn make check
expect "buildroot login:" { send "root\n" } timeout { exit 1 }
expect "# " { send "uname -a\n" } timeout { exit 2 }
expect "riscv32 GNU/Linux" { send "\x01"; send "x" } timeout { exit 3 }
DONE

ret=$?
pkill -9 semu
echo
cleanup

MESSAGES=("OK!" \
"Fail to boot" \
"Fail to login" \
"Fail to run commands" \
)

echo "${MESSAGES[$ret]}"
COLOR_G='\e[32;01m' # Green
COLOR_N='\e[0m'
printf "\n[ ${COLOR_G}${MESSAGES[$ret]}${COLOR_N} ]\n"

exit ${ret}

0 comments on commit 78ec6f7

Please sign in to comment.