CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
Ardupilot

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

GitHub Repository: Ardupilot/ardupilot
Path: blob/master/Tools/scripts/build_autotest.sh
Views: 1798
1
#!/usr/bin/env bash
2
3
export PATH=$HOME/.local/bin:/usr/local/bin:$HOME/prefix/bin:$HOME/gcc/active/bin:$PATH
4
export PYTHONUNBUFFERED=1
5
6
cd $HOME/APM || exit 1
7
8
test -n "$FORCEBUILD" || {
9
(cd APM && git fetch > /dev/null 2>&1)
10
11
newtags=$(cd APM && git fetch --tags --force | wc -l)
12
oldhash=$(cd APM && git rev-parse origin/master)
13
newhash=$(cd APM && git rev-parse HEAD)
14
15
if [ "$oldhash" = "$newhash" -a "$newtags" = "0" ]; then
16
echo "$(date) no change $oldhash $newhash" >> build.log
17
exit 0
18
fi
19
echo "$(date) Build triggered $oldhash $newhash $newtags" >> build.log
20
}
21
22
############################
23
# grab a lock file. Not atomic, but close :)
24
# tries to cope with NFS
25
lock_file() {
26
lck="$1"
27
pid=`cat "$lck" 2> /dev/null`
28
29
if test -f "$lck" && kill -0 $pid 2> /dev/null; then
30
LOCKAGE=$(($(date +%s) - $(stat -c '%Y' "build.lck")))
31
test $LOCKAGE -gt 80000 && {
32
echo "old lock file $lck is valid for $pid with age $LOCKAGE seconds"
33
}
34
return 1
35
fi
36
/bin/rm -f "$lck"
37
echo "$$" > "$lck"
38
return 0
39
}
40
41
42
lock_file build.lck || {
43
exit 1
44
}
45
46
47
#ulimit -m 500000
48
#ulimit -s 500000
49
#ulimit -t 1800
50
#ulimit -v 500000
51
52
(
53
date
54
55
oldhash=$(cd APM && git rev-parse HEAD)
56
57
echo "Updating APM"
58
pushd APM
59
git checkout -f master
60
git fetch origin
61
git reset --hard origin/master
62
Tools/gittools/submodule-sync.sh
63
git clean -f -f -x -d -d
64
git tag autotest-$(date '+%Y-%m-%d-%H%M%S') -m "test tag `date`"
65
popd
66
67
rsync -a APM/Tools/autotest/web-firmware/ buildlogs/binaries/
68
69
echo "Updating MAVProxy"
70
pushd MAVProxy
71
git fetch origin
72
git reset --hard origin/master
73
git show
74
python3 -m pip install --user .
75
popd
76
77
echo "Updating pymavlink"
78
pushd APM/modules/mavlink/pymavlink
79
git show
80
python3 -m pip install --user .
81
popd
82
83
githash=$(cd APM && git rev-parse HEAD)
84
hdate=$(date +"%Y-%m-%d-%H:%m")
85
86
(cd APM && Tools/scripts/build_parameters.sh)
87
88
(cd APM && Tools/scripts/build_log_message_documentation.sh)
89
90
(cd APM && Tools/scripts/build_docs.sh)
91
92
killall -9 JSBSim || /bin/true
93
94
# raise core limit
95
ulimit -c 10000000
96
97
# build in home dir, as on faster storage
98
export BUILD_BINARIES_PATH=$HOME/build/tmp
99
100
# exit on panic so we don't waste time waiting around
101
export SITL_PANIC_EXIT=1
102
103
timelimit 144000 python3 APM/Tools/autotest/autotest.py --autotest-server --timeout=143000 > buildlogs/autotest-output.txt 2>&1
104
105
mkdir -p "buildlogs/history/$hdate"
106
107
(cd buildlogs && cp -f *.txt *.flashlog *.tlog *.km[lz] *.gpx *.html *.png *.bin *.BIN *.elf "history/$hdate/")
108
echo $githash > "buildlogs/history/$hdate/githash.txt"
109
110
) >> build.log 2>&1
111
112
# autotest done, let's mark GTD flags
113
touch /tmp/.autotest.done
114
115
116