mirror of
https://github.com/lupyuen/nuttx-riscv64.git
synced 2025-01-12 23:28:28 +08:00
task-nsh64 tested OK
This commit is contained in:
parent
109d42e064
commit
fc280d4d59
9 changed files with 203 additions and 6 deletions
|
@ -28,7 +28,7 @@ jobs:
|
|||
set -x # Echo commands
|
||||
|
||||
## TODO: Paste the GitHub Repo and Branch
|
||||
source=https://github.com/rushabhvg/nuttx/tree/qemu-riscv-driver
|
||||
source=https://github.com/apache/nuttx/tree/master
|
||||
|
||||
## Match `https://github.com/user/repo/tree/branch`
|
||||
pattern='\(.*\)\/tree\/\(.*\)'
|
||||
|
|
|
@ -28,7 +28,7 @@ jobs:
|
|||
set -x # Echo commands
|
||||
|
||||
## TODO: Paste the GitHub Repo and Branch
|
||||
source=https://github.com/rushabhvg/nuttx/tree/qemu-riscv-driver
|
||||
source=https://github.com/apache/nuttx/tree/master
|
||||
|
||||
## Match `https://github.com/user/repo/tree/branch`
|
||||
pattern='\(.*\)\/tree\/\(.*\)'
|
||||
|
|
2
.github/workflows/special-qemu-riscv-nsh.yml
vendored
2
.github/workflows/special-qemu-riscv-nsh.yml
vendored
|
@ -28,7 +28,7 @@ jobs:
|
|||
set -x # Echo commands
|
||||
|
||||
## TODO: Paste the GitHub Repo and Branch
|
||||
source=https://github.com/rushabhvg/nuttx/tree/qemu-riscv-driver
|
||||
source=https://github.com/apache/nuttx/tree/master
|
||||
|
||||
## Match `https://github.com/user/repo/tree/branch`
|
||||
pattern='\(.*\)\/tree\/\(.*\)'
|
||||
|
|
|
@ -28,7 +28,7 @@ jobs:
|
|||
set -x # Echo commands
|
||||
|
||||
## TODO: Paste the GitHub Repo and Branch
|
||||
source=https://github.com/rushabhvg/nuttx/tree/qemu-riscv-driver
|
||||
source=https://github.com/apache/nuttx/tree/master
|
||||
|
||||
## Match `https://github.com/user/repo/tree/branch`
|
||||
pattern='\(.*\)\/tree\/\(.*\)'
|
||||
|
|
|
@ -58,7 +58,7 @@ cd $tmp_path
|
|||
set -x # Echo commands
|
||||
|
||||
## TODO: Paste the GitHub Repo and Branch
|
||||
source=https://github.com/rushabhvg/nuttx/tree/qemu-riscv-driver
|
||||
source=https://github.com/apache/nuttx/tree/master
|
||||
|
||||
## Match `https://github.com/user/repo/tree/branch`
|
||||
pattern='\(.*\)\/tree\/\(.*\)'
|
||||
|
|
|
@ -58,7 +58,7 @@ cd $tmp_path
|
|||
set -x # Echo commands
|
||||
|
||||
## TODO: Paste the GitHub Repo and Branch
|
||||
source=https://github.com/rushabhvg/nuttx/tree/qemu-riscv-driver
|
||||
source=https://github.com/apache/nuttx/tree/master
|
||||
|
||||
## Match `https://github.com/user/repo/tree/branch`
|
||||
pattern='\(.*\)\/tree\/\(.*\)'
|
||||
|
|
76
task/task-nsh64.sh
Executable file
76
task/task-nsh64.sh
Executable file
|
@ -0,0 +1,76 @@
|
|||
#!/usr/bin/env bash
|
||||
## Background Task for Automated Testing of Apache NuttX RTOS for QEMU RISC-V 64-bit Flat Build
|
||||
|
||||
set -e ## Exit when any command fails
|
||||
set -x ## Echo commands
|
||||
|
||||
## Default Build Prefix
|
||||
if [ "$BUILD_PREFIX" == '' ]; then
|
||||
export BUILD_PREFIX=qemu-riscv-nsh64
|
||||
fi
|
||||
|
||||
## Get the Script Directory
|
||||
SCRIPT_PATH="${BASH_SOURCE}"
|
||||
SCRIPT_DIR="$(cd -P "$(dirname -- "${SCRIPT_PATH}")" >/dev/null 2>&1 && pwd)"
|
||||
|
||||
## Wait for GitHub Release, then test NuttX on SBC
|
||||
function test_nuttx {
|
||||
|
||||
## If NuttX Build already downloaded, quit
|
||||
local date=$1
|
||||
NUTTX_ZIP=/tmp/$BUILD_PREFIX-$date-nuttx.zip
|
||||
if [ -e $NUTTX_ZIP ]
|
||||
then
|
||||
return
|
||||
fi
|
||||
|
||||
echo "----- Download the NuttX Build"
|
||||
wget -q \
|
||||
https://github.com/lupyuen/nuttx-riscv64/releases/download/$BUILD_PREFIX-$date/nuttx.zip \
|
||||
-O $NUTTX_ZIP \
|
||||
|| true
|
||||
|
||||
## If build doesn't exist, quit
|
||||
FILESIZE=$(wc -c $NUTTX_ZIP | cut -d/ -f1)
|
||||
if [ "$FILESIZE" -eq "0" ]; then
|
||||
rm $NUTTX_ZIP
|
||||
return
|
||||
fi
|
||||
|
||||
echo "----- Run the NuttX Test"
|
||||
$SCRIPT_DIR/test-nsh64.sh \
|
||||
| tee /tmp/release-$BUILD_PREFIX.log \
|
||||
2>&1
|
||||
|
||||
## Trim to first 1500 lines
|
||||
head -n 1500 /tmp/release-$BUILD_PREFIX.log \
|
||||
>/tmp/release2-$BUILD_PREFIX.log
|
||||
mv /tmp/release2-$BUILD_PREFIX.log \
|
||||
/tmp/release-$BUILD_PREFIX.log
|
||||
|
||||
echo "----- Upload the Test Log"
|
||||
$SCRIPT_DIR/upload-nsh64.sh \
|
||||
/tmp/release-$BUILD_PREFIX.tag \
|
||||
/tmp/release-$BUILD_PREFIX.log
|
||||
|
||||
echo test_nuttx OK!
|
||||
}
|
||||
|
||||
## If Build Date is specified: Run once and quit
|
||||
if [ "$BUILD_DATE" != '' ]; then
|
||||
test_nuttx $BUILD_DATE
|
||||
exit
|
||||
fi
|
||||
|
||||
## Wait for GitHub Release, then test NuttX on SBC
|
||||
for (( ; ; ))
|
||||
do
|
||||
## Default Build Date is today (YYYY-MM-DD)
|
||||
BUILD_DATE=$(date +'%Y-%m-%d')
|
||||
test_nuttx $BUILD_DATE
|
||||
|
||||
## Wait a while
|
||||
date
|
||||
sleep 600
|
||||
done
|
||||
echo Done!
|
42
task/test-nsh64.sh
Executable file
42
task/test-nsh64.sh
Executable file
|
@ -0,0 +1,42 @@
|
|||
#!/usr/bin/env bash
|
||||
## Automated Testing of Apache NuttX RTOS on Sophgo SG2000 SoC / Milk-V Duo S SBC
|
||||
|
||||
set -e ## Exit when any command fails
|
||||
set -x ## Echo commands
|
||||
|
||||
## Default Build Prefix
|
||||
if [ "$BUILD_PREFIX" == '' ]; then
|
||||
export BUILD_PREFIX=qemu-riscv-nsh64
|
||||
fi
|
||||
|
||||
## Default Build Date is today (YYYY-MM-DD)
|
||||
if [ "$BUILD_DATE" == '' ]; then
|
||||
export BUILD_DATE=$(date +'%Y-%m-%d')
|
||||
fi
|
||||
|
||||
rm -rf /tmp/$BUILD_PREFIX
|
||||
mkdir /tmp/$BUILD_PREFIX
|
||||
cd /tmp/$BUILD_PREFIX
|
||||
|
||||
set +x ## Disable echo
|
||||
echo "----- Download the latest NuttX build for $BUILD_DATE"
|
||||
set -x ## Enable echo
|
||||
wget -q https://github.com/lupyuen/nuttx-riscv64/releases/download/$BUILD_PREFIX-$BUILD_DATE/nuttx.zip
|
||||
unzip -o nuttx.zip
|
||||
set +x ## Disable echo
|
||||
|
||||
## Print the Commit Hashes
|
||||
if [ -f nuttx.hash ]; then
|
||||
cat nuttx.hash
|
||||
fi
|
||||
|
||||
## Write the Release Tag for populating the Release Log later
|
||||
echo "$BUILD_PREFIX-$BUILD_DATE" >/tmp/release-$BUILD_PREFIX.tag
|
||||
|
||||
script=qemu-riscv-nsh64
|
||||
wget https://raw.githubusercontent.com/lupyuen/nuttx-riscv64/main/$script.exp
|
||||
chmod +x $script.exp
|
||||
ls -l
|
||||
cat nuttx.hash
|
||||
qemu-system-riscv64 --version
|
||||
./$script.exp
|
79
task/upload-nsh64.sh
Executable file
79
task/upload-nsh64.sh
Executable file
|
@ -0,0 +1,79 @@
|
|||
#!/usr/bin/env bash
|
||||
## Upload Test Log to GitHub Release Notes.
|
||||
## Parameters: Release Tag, Test Log
|
||||
|
||||
repo=lupyuen/nuttx-riscv64
|
||||
tag=$1
|
||||
log=$2
|
||||
|
||||
set -e ## Exit when any command fails
|
||||
|
||||
rm -f /tmp/upload-nsh64.log
|
||||
|
||||
## Preserve the Auto-Generated GitHub Release Notes.
|
||||
## Fetch the current GitHub Release Notes and extract the body text.
|
||||
set -x ## Echo commands
|
||||
gh release view \
|
||||
`cat $tag` \
|
||||
--json body \
|
||||
--jq '.body' \
|
||||
--repo $repo \
|
||||
>/tmp/upload-nsh64.old
|
||||
set +x ## Don't echo commands
|
||||
|
||||
## Find the position of the Previous Test Log, starting with "```"
|
||||
set +e ## Don't exit when any command fails
|
||||
cat /tmp/upload-nsh64.old \
|
||||
| grep '```' --max-count=1 --byte-offset \
|
||||
| sed 's/:.*//g' \
|
||||
>/tmp/upload-nsh64-previous-log.txt
|
||||
set -e ## Exit when any command fails
|
||||
prev=`cat /tmp/upload-nsh64-previous-log.txt`
|
||||
|
||||
## If Previous Test Log exists, discard it
|
||||
if [ "$prev" != '' ]; then
|
||||
cat /tmp/upload-nsh64.old \
|
||||
| head --bytes=$prev \
|
||||
>>/tmp/upload-nsh64.log
|
||||
else
|
||||
## Else copy the entire Release Notes
|
||||
cat /tmp/upload-nsh64.old \
|
||||
>>/tmp/upload-nsh64.log
|
||||
echo "" >>/tmp/upload-nsh64.log
|
||||
fi
|
||||
|
||||
## Show the Test Status
|
||||
set +e ## Don't exit when any command fails
|
||||
grep "^===== " $log \
|
||||
| colrm 1 6 \
|
||||
>>/tmp/upload-nsh64.log
|
||||
set -e ## Exit when any command fails
|
||||
|
||||
## Enquote the Test Log without Carriage Return and Terminal Control Characters
|
||||
## TODO: The long pattern for sed doesn't work on macOS
|
||||
## https://stackoverflow.com/questions/17998978/removing-colors-from-output
|
||||
echo '```text' >>/tmp/upload-nsh64.log
|
||||
cat $log \
|
||||
| tr -d '\r' \
|
||||
| tr -d '\r' \
|
||||
| sed 's/\x08/ /g' \
|
||||
| sed 's/\x1B(B//g' \
|
||||
| sed 's/\x1B\[K//g' \
|
||||
| sed 's/\x1B[<=>]//g' \
|
||||
| sed 's/\x1B\[[0-9:;<=>?]*[!]*[A-Za-z]//g' \
|
||||
| sed 's/\x1B[@A-Z\\\]^_]\|\x1B\[[0-9:;<=>?]*[-!"#$%&'"'"'()*+,.\/]*[][\\@A-Z^_`a-z{|}~]//g' \
|
||||
>>/tmp/upload-nsh64.log
|
||||
echo '```' >>/tmp/upload-nsh64.log
|
||||
|
||||
## Upload the Test Log to the GitHub Release Notes
|
||||
set -x ## Echo commands
|
||||
gh release edit \
|
||||
`cat $tag` \
|
||||
--notes-file /tmp/upload-nsh64.log \
|
||||
--repo $repo
|
||||
set +x ## Don't echo commands
|
||||
|
||||
## Show the Test Status
|
||||
set +e ## Don't exit when any command fails
|
||||
grep "^===== " $log
|
||||
set -e ## Exit when any command fails
|
Loading…
Reference in a new issue