forked from ArduPilot/mavlink
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.sh
executable file
·91 lines (83 loc) · 2.14 KB
/
test.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/usr/bin/env bash
set -e
SRC_DIR=$(pwd)
# NOTE: we must do all testing on the installed python package, not
# on the build tree. Otherwise the testing is invalid and may not
# indicate the code actually works
test_format() {
# check format
sep="##############################################"
echo $sep
echo "FORMAT TEST"
echo $sep
cd "$SRC_DIR"
./scripts/format_xml.sh -c
echo PASS
}
generate_mavlink() {
echo $sep
echo "GENERATING MAVLINK " \
"protocol:${wire_protocol} language:${lang}"
echo "DEFINITION : " "$msg_def"
echo $sep
outdir="/tmp/mavlink_${wire_protocol}_${lang}"
pymavlink/tools/mavgen.py --lang="${lang}" \
--wire-protocol "${wire_protocol}" \
--strict-units \
--output="${outdir}" "${msg_def}"
echo PASS
}
test_py() {
cd "$SRC_DIR"
for msg_def in message_definitions/v1.0/*.xml
do
[ -e "$msg_def" ] || continue
wire_protocol="1.0"
for lang in Python C CS WLua Java
do
generate_mavlink
done
wire_protocol="2.0"
for lang in Python C C++11 CS WLua Java
do
generate_mavlink
done
done
}
test_node() {
# Avoid `spurious errors` caused by ~/.npm permission issues
# ref: https://github.com/travis-ci/travis-ci/issues/2244
# ref: https://github.com/npm/npm/issues/4815
# Does it already exist? Who owns? What permissions?
ls -lah ~/.npm || mkdir ~/.npm
# Make sure we own it
# $USER references the current user in Travis env
chown -R "$USER" ~/.npm
if [ -f /usr/bin/nodejs ]
then
mkdir -p ~/bin
ln -sf /usr/bin/nodejs ~/bin/node
. ~/.bashrc
fi
cd "$SRC_DIR/pymavlink/" && ./test_gen_js.sh
cd "generator/javascript" && npm test
}
if [ "$#" -eq 1 ]; then
if [ "$1" == "format" ]; then
test_format
elif [ "$1" == "py" ]; then
test_py
elif [ "$1" == "node" ]; then
test_node
else
echo "Error: unknown argument '$1'"
echo ""
echo "Usage:"
echo " $0 [py|node|format]"
exit 1
fi
else
test_format
test_py
test_node
fi