-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathrunExamples.sh
199 lines (181 loc) · 5.38 KB
/
runExamples.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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
#!/bin/bash
clear
EXAMPLES="ex_readmisc ex_callbacks_edm_wifi"
UNITTESTS="test_at_peer test_getgeneral test_getsystem test_mock_ati9 test_send test_at_wifi test_tokenizer"
MANUALTESTS="test_ati9 test_datamode test_edm_at test_edm_at_read"
FILES="cb_tokenizer.c cb_string.c cb_at_util.c ucxh_mode.c ucxh_poll.c ucxh_wait.c ucxh_parser.c ucxh_wifi.c ucxh_edm_parser.c ucxh_send.c ucxh_edm.c ucxh_urc.c"
SERIAL="windows/ucxh_serial_win.c"
SERIAL_MOCK="../test/ucxh_serial_mock.c"
TEST_FILES="../test/test_tools.c"
INCLUDES="-I../include -I../examples -I../resources"
# CFLAGS_OPT="-Os -flto -DNDEBUG"
CFLAGS_DEBUG="-Og -g"
POSITIONAL=()
while [[ $# -gt 0 ]]
do
key="$1"
case $key in
--no-examples)
NO_EXAMPLES=y
;;
--no-quick-tests)
NO_QUICK_TESTS=y
;;
--no-unit-tests)
NO_UNIT_TESTS=y
;;
--no-manual-tests)
NO_MANUAL_TESTS=y
;;
--run)
NO_DOCUMENTATION=y
NO_QUICK_TESTS=y
PROGRAM="$2"
NO_RUN=
RUN=y
shift
;;
--help)
echo "To build and run all examples, tests, and generate documentation:"
echo " runExamples.sh [<exclude-steps>]"
echo " exclude-steps:"
echo " --no-examples"
echo " --no-no-quick-tests"
echo " --no-no-unit-tests"
echo " --no-manual-tests"
echo " --no-documentation"
echo
echo "To build and run a specific example or test:"
echo " runExamples.sh --run <name>"
echo
echo "To only build a specific example or test:"
echo " runExamples.sh --build <name>"
echo
echo "Available examples and test:"
ls test examples | sed -e s/\\.c//g | grep -v "\." | grep -v makefile | grep -v ucxh | grep -v ":" | sed -e "s/^/ /g"
exit
;;
--build)
NO_DOCUMENTATION=y
NO_QUICK_TESTS=y
if [ -z "$RUN" ]
then
NO_RUN=y
fi
PROGRAM="$2"
shift
;;
--no-documentation)
NO_DOCUMENTATION=y
;;
*) # unknown option
POSITIONAL+=("$1") # save it in an array for later
shift # past argument
;;
esac
shift # past argument
done
set -- "${POSITIONAL[@]}" # restore positional parameters
echo About to run example application and tests using the u-connectXpress Host Library.
echo
echo You will need to make some configurations:
echo
echo "* Ensure there is a NINA-W15 or NINA-W13 connected to the COM port defined"
echo " in include/ucxh_config.h"
echo "* Ensure your AP is configured with the SSID and password defined"
echo " in examples/ex_config.h"
echo "* Make sure you have a TCP server listening at the IP adress and port"
echo " also defined in examples/ex_config.h"
if [ -z "$NO_EXAMPLES" ]
then
for i in $EXAMPLES
do
if [ -z "$PROGRAM" ] || [ "$PROGRAM" = "$i" ]
then
echo
echo Running example $i:
rm -f $i.exe $i.exe.stackdump
cd src && \
gcc $CFLAGS_DEBUG $CFLAGS_OPT $CFLAGS $INCLUDES $COVERAGE $FILES $SERIAL \
../examples/$i.c -o ../$i
cd -
if [ -z "$NO_RUN" ]
then
./$i.exe
fi
fi
done
fi
if [ -z "$NO_QUICK_TESTS" ]
then
echo Quick unittests:
cd test
make test_edm && \
./test_edm.exe
cd -
fi
if [ -z "$NO_UNIT_TESTS" ]
then
for i in $UNITTESTS
do
if [ -z "$PROGRAM" ] || [ "$PROGRAM" = "$i" ]
then
echo
echo Unit-testing $i:
rm -f $i.exe $i.exe.stackdump
cd src && \
gcc $CFLAGS_DEBUG $CFLAGS -DCONFIG_USE_MOCKED_SERIAL $INCLUDES $COVERAGE $FILES $SERIAL_MOCK $TEST_FILES \
../test/$i.c -o ../$i
cd -
if [ -z "$NO_RUN" ]
then
./$i.exe
fi
fi
done
fi
# Needs manual verfification and access to module
if [ -z "$NO_MANUAL_TESTS" ]
then
for i in $MANUALTESTS
do
if [ -z "$PROGRAM" ] || [ "$PROGRAM" = "$i" ]
then
if [ -z "$WARNING_EMITTED" ]
then
echo
echo
echo
echo
echo
echo
echo
echo
echo
echo
echo "******************************************************************************"
echo The following tests needs manual attention in one way or another:
echo "******************************************************************************"
echo
echo
WARNING_EMITTED=y
fi
echo
echo Testing $i:
rm -f $i.exe $i.exe.stackdump
cd src && \
gcc $CFLAGS_DEBUG $CFLAGS $INCLUDES $COVERAGE $FILES $SERIAL $TEST_FILES \
../test/$i.c -o ../$i
cd -
if [ -z "$NO_RUN" ]
then
./$i.exe
fi
fi
done
fi
if [ -z "$NO_DOCUMENTATION" ]
then
# Re-generate the documentation
./mkdocs.sh
fi