forked from lupyuen/remote-bl602
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
task.sh
executable file
·75 lines (61 loc) · 1.62 KB
/
task.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/usr/bin/env bash
## Background Task for Automated Testing of Apache NuttX RTOS
set -e ## Exit when any command fails
set -x ## Echo commands
## Default Build Prefix is "nuttx-sg2000"
if [ "$BUILD_PREFIX" == '' ]; then
export BUILD_PREFIX=nuttx-sg2000
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 "----- ${BASH_SOURCE}"
echo "----- Download the NuttX Build"
wget -q \
https://github.com/lupyuen/nuttx-sg2000/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.sh \
| tee /tmp/release.log \
2>&1
## Trim to first 100000 bytes
head -c 100000 /tmp/release.log \
>/tmp/release2.log
mv /tmp/release2.log \
/tmp/release.log
echo "----- Upload the Test Log"
$SCRIPT_DIR/upload.sh
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 1800
done
echo Done!