Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Ardupilot
GitHub Repository: Ardupilot/ardupilot
Path: blob/master/Tools/scripts/build_autotest.sh
9552 views
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
ARDUPILOT_ROOT="$PWD/APM"
9
10
test -n "$FORCEBUILD" || {
11
pushd APM
12
git fetch > /dev/null 2>&1
13
newtags=$(git fetch --tags --force | wc -l)
14
oldhash=$(git rev-parse origin/master)
15
newhash=$(git rev-parse HEAD)
16
popd
17
18
if [ "$oldhash" = "$newhash" -a "$newtags" = "0" ]; then
19
echo "$(date) no change $oldhash $newhash" >> build.log
20
exit 0
21
fi
22
echo "$(date) Build triggered $oldhash $newhash $newtags" >> build.log
23
}
24
25
############################
26
# grab a lock file. Not atomic, but close :)
27
# tries to cope with NFS
28
lock_file() {
29
lck="$1"
30
pid=`cat "$lck" 2> /dev/null`
31
32
if test -f "$lck" && kill -0 $pid 2> /dev/null; then
33
LOCKAGE=$(($(date +%s) - $(stat -c '%Y' "build.lck")))
34
test $LOCKAGE -gt 80000 && {
35
echo "old lock file $lck is valid for $pid with age $LOCKAGE seconds"
36
}
37
return 1
38
fi
39
rm -f "$lck"
40
echo "$$" > "$lck"
41
return 0
42
}
43
44
45
lock_file build.lck || {
46
exit 1
47
}
48
49
50
#ulimit -m 500000
51
#ulimit -s 500000
52
#ulimit -t 1800
53
#ulimit -v 500000
54
55
(
56
set -x
57
58
date
59
60
echo "Updating ArduPilot repository"
61
pushd "$ARDUPILOT_ROOT"
62
git checkout -f master
63
git fetch origin
64
git reset --hard origin/master
65
Tools/gittools/submodule-sync.sh
66
git clean -f -f -x -d -d
67
git tag autotest-$(date '+%Y-%m-%d-%H%M%S') -m "test tag `date`"
68
popd
69
70
rsync -a APM/Tools/autotest/web-firmware/ buildlogs/binaries/
71
72
echo "Updating MAVProxy"
73
pushd MAVProxy
74
git fetch origin
75
git reset --hard origin/master
76
git show
77
python3 -m pip install --user .
78
popd
79
80
echo "Updating pymavlink"
81
pushd APM/modules/mavlink/pymavlink
82
git show
83
python3 -m pip install --user .
84
popd
85
86
githash=$(cd APM && git rev-parse HEAD)
87
hdate=$(date +"%Y-%m-%d-%H:%m")
88
89
pushd $ARDUPILOT_ROOT
90
Tools/scripts/build_parameters.sh
91
Tools/scripts/build_log_message_documentation.sh
92
Tools/scripts/build_docs.sh
93
popd
94
95
killall -9 JSBSim || /bin/true
96
97
# raise core limit
98
ulimit -c 10000000
99
100
# build in home dir, as on faster storage
101
export BUILD_BINARIES_PATH=$HOME/build/tmp
102
103
# exit on panic so we don't waste time waiting around
104
export SITL_PANIC_EXIT=1
105
106
# we run the timelimit shell command to kill autotest if it behaves badly:
107
TIMELIMIT_TIME_LIMIT=144000
108
# we pass this into autotest.py to get it to time limit itself
109
AUTOTEST_TIME_LIMIT=143000
110
111
# the autotest python script:
112
AUTOTEST="$ARDUPILOT_ROOT/Tools/autotest/autotest.py"
113
114
# decide which timelimit command we are working with. The autotest
115
# server has a binary of unknown lineage in
116
# /home/autotest/bin/timelimit . We should move to using the
117
# apt-installable version
118
119
if timelimit 2>&1 | grep -q SIGQUIT; then
120
TIMELIMIT_CMD="timelimit $TIMELIMIT_TIME_LIMIT"
121
else
122
TIMELIMIT_CMD="timelimit -s 9 -t $TIMELIMIT_TIME_LIMIT"
123
fi
124
125
AUTOTEST_LOG="buildlogs/autotest-output.txt"
126
echo "AutoTest log file is ($AUTOTEST_LOG)"
127
$TIMELIMIT_CMD python3 $AUTOTEST --autotest-server --timeout=$AUTOTEST_TIME_LIMIT > "$AUTOTEST_LOG" 2>&1
128
129
mkdir -p "buildlogs/history/$hdate"
130
131
(cd buildlogs && cp -f *.txt *.flashlog *.tlog *.km[lz] *.gpx *.html *.png *.bin *.BIN *.elf "history/$hdate/")
132
echo $githash > "buildlogs/history/$hdate/githash.txt"
133
134
) >> build.log 2>&1
135
136
# autotest done, let's mark GTD flags
137
touch /tmp/.autotest.done
138
139
140