Skip to content

Commit 0531ab6

Browse files
grgustafJimmy Huang
authored andcommitted
[build] Add "make check" and "make quickcheck" build targets (zephyrproject-rtos#907)
The check target calls trlite with a new -l flag that makes it run on the current ZJS_BASE source tree w/o doing a git clone for a clean tree. The quickcheck calls trlite on just the Linux tests (VM zephyrproject-rtos#3). Signed-off-by: Geoff Gustafson <[email protected]>
1 parent 1229ea8 commit 0531ab6

File tree

4 files changed

+115
-64
lines changed

4 files changed

+115
-64
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,4 @@ before_script: >
4444
fi
4545
4646
script: >
47-
trlite $TARGET
47+
trlite -l $TARGET

Makefile

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,14 @@ else
115115
all: zephyr
116116
endif
117117

118+
.PHONY: check
119+
check:
120+
trlite -l
121+
122+
.PHONY: quickcheck
123+
quickcheck:
124+
trlite -l 3
125+
118126
A101BIN = outdir/arduino_101/zephyr.bin
119127
A101SSBIN = arc/outdir/arduino_101_sss/zephyr.bin
120128

@@ -363,26 +371,25 @@ help:
363371
@echo "JavaScript Runtime for Zephyr OS - Build System"
364372
@echo
365373
@echo "Build targets:"
366-
@echo " all: Build for either Zephyr or Linux depending on BOARD"
367-
@echo " zephyr: Build Zephyr for the given BOARD (A101 is default)"
368-
@echo " ide Build Zephyr in development mode for the IDE"
369-
@echo " ashell Build Zephyr in development mode for the command line"
370-
@echo " arc: Build just the ARC Zephyr target for Arduino 101"
371-
@echo " linux: Build the Linux target"
372-
@echo " dfu: Flash x86 and arc images to A101 with dfu-util"
373-
@echo " debug: Run debug server using JTAG"
374-
@echo " gdb: Run gdb to connect to debug server for x86"
375-
@echo " arcgdb: Run gdb to connect to debug server for ARC"
376-
@echo " qemu: Run QEMU after building"
377-
@echo " clean: Clean stale build objects for given BOARD"
378-
@echo " pristine: Completely remove all generated files"
374+
@echo " all: Build for either Zephyr or Linux depending on BOARD"
375+
@echo " zephyr: Build Zephyr for the given BOARD (A101 is default)"
376+
@echo " ide Build Zephyr in development mode for the IDE"
377+
@echo " ashell Build Zephyr in development mode for command line"
378+
@echo " dfu: Flash x86 and arc images to A101 with dfu-util"
379+
@echo " debug: Run debug server using JTAG"
380+
@echo " gdb: Run gdb to connect to debug server for x86"
381+
@echo " qemu: Run QEMU after building"
382+
@echo " clean: Clean stale build objects for given BOARD"
383+
@echo " pristine: Completely remove all generated files"
384+
@echo " check: Run all the automated build tests"
385+
@echo " quickcheck: Run the quick Linux subset of automated build tests"
379386
@echo
380387
@echo "Build options:"
381-
@echo " BOARD= Specify a Zephyr board to build for"
382-
@echo " JS= Specify a JS script to compile into the binary"
383-
@echo " RAM= Specify size in KB for RAM allocated to X86"
384-
@echo " ROM= Specify size in KB for X86 partition (144 - 296)"
385-
@echo " SNAPSHOT= Specify off to turn off snapshotting"
386-
@echo " TRACE= Specify 'on' for malloc tracing (off is default)"
387-
@echo " VARIANT= Specify 'debug' for extra serial output detail"
388+
@echo " BOARD= Specify a Zephyr board to build for"
389+
@echo " JS= Specify a JS script to compile into the binary"
390+
@echo " RAM= Specify size in KB for RAM allocated to X86"
391+
@echo " ROM= Specify size in KB for X86 partition (144 - 296)"
392+
@echo " SNAPSHOT= Specify off to turn off snapshotting"
393+
@echo " TRACE= Specify 'on' for malloc tracing (off is default)"
394+
@echo " VARIANT= Specify 'debug' for extra serial output detail"
388395
@echo

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,23 @@ least two plus-ones (+1) , "Look Good To Me (LGTM)" or other positive signals
236236
for the project members. Once you have gained the required signals the project
237237
maintainers will merge the PR.
238238

239+
### Travis and local sanity checking
240+
241+
We run a series of tests on each pull request and merged commit using Travis.
242+
This relies on a script in the repo called `trlite`. One easy way to run these
243+
tests on your local $ZJS_BASE git tree is to use `make check` or
244+
`make quickcheck` for a faster subset of the tests. These run with your code as
245+
it stands in your tree. This will not catch a problem like you failing to
246+
add a new file to your commit.
247+
248+
For a slightly safer sanity check, which might catch that kind of problem, you
249+
can run `trlite` directly or `trlite linux` for the "quick subset". This will
250+
clone a second copy of your git tree into a .trlite subdirectory, apply changes
251+
that `git diff` knows about, and run the build tests. Another option `trlite -j`
252+
will cause it to run four threads of tests to speed up execution; these will
253+
use four directories named `.trlite[1-4]`. If there is a test failure, the
254+
affected `.trlite*` trees are left in place so that you can investigate.
255+
239256
## Repo Organization
240257

241258
### File Descriptions

scripts/trlite

Lines changed: 70 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@
44
# Author: Geoff Gustafson <[email protected]>
55

66
# trlite - a local version of the tests we run in Travis
7-
# trlite [-j] [-nN] [-v] [vmname] [startnum] [endnum]
7+
# trlite [-l] [-j] [-nN] [-v] [vmname] [startnum] [endnum]
88
#
9-
# -nN appends N to .trlite directory name
9+
# (for now, options must appear in specified order)
10+
# -l runs tests in ZJS_BASE instead of a clean git clone
1011
# -j runs all tests, with parallel execution (4 threads currently)
12+
# -nN appends N to .trlite directory name
1113
# -v turns on verbose output
1214
# by default, runs all tests
1315
# trlite 1 or trlite zephyr runs just VM #1 "zephyr" tests
@@ -27,7 +29,15 @@ if [ ! -d "$ZJS_BASE" ]; then
2729
exit 1
2830
fi
2931

30-
TRLDIR=$ZJS_BASE/.trlite
32+
RUNLOCAL=n
33+
34+
if [ "$1" == "-l" ]; then
35+
RUNLOCAL=y
36+
shift
37+
else
38+
TRLDIR=$ZJS_BASE/.trlite
39+
fi
40+
3141
TMPFILE=/tmp/zjstest.js
3242

3343
if [ "$1" == "-h" -o "$1" == "-?" ]; then
@@ -58,6 +68,11 @@ function display_errors() # NAME, NUM
5868
}
5969

6070
if [[ $1 == -j* ]]; then
71+
if [ "$RUNLOCAL" == "y" ]; then
72+
echo Error: -j mode cannot be used with -l
73+
exit 1
74+
fi
75+
6176
LOGFILE=/tmp/trlite-log
6277

6378
echo Running all trlite tests in four parallel threads...
@@ -86,6 +101,11 @@ if [[ $1 == -j* ]]; then
86101
fi
87102

88103
if [[ $1 == -n* ]]; then
104+
if [ "$RUNLOCAL" == "y" ]; then
105+
echo Error: -n mode cannot be used with -l
106+
exit 1
107+
fi
108+
89109
TRLDIR=$TRLDIR${1:2}
90110
TMPFILE=$TMPFILE${1:2}
91111
echo TRLDIR: $TRLDIR >> /tmp/foo
@@ -121,51 +141,56 @@ if [[ "$1" =~ ^[0-9]+$ ]]; then
121141
shift
122142
fi
123143

124-
rm -rf $TRLDIR
125-
126144
echo Building ZJS tree: "$ZJS_BASE"
127-
echo Cloning git tree...
128-
git clone -l $ZJS_BASE $TRLDIR > /dev/null 2>&1
129-
130-
# we need to refer to master later for diffs
131-
cp $ZJS_BASE/.git/refs/heads/master $TRLDIR/.git/refs/heads
132-
133-
echo Cloning git submodules...
134-
cd $TRLDIR/deps
135-
for i in */; do
136-
git clone -l ../../deps/$i/.git $i > /dev/null 2>&1
137-
138-
# clone submodules of submodules
139-
if [ -d $i/deps/ ]; then
140-
cd $i/deps
141-
for j in */; do
142-
git clone -l ../../../../deps/$i/deps/$j/.git $j > /dev/null 2>&1
143-
done
144-
cd ../..
145+
146+
if [ "$RUNLOCAL" != "y" ]; then
147+
rm -rf $TRLDIR
148+
149+
echo Cloning git tree...
150+
git clone -l $ZJS_BASE $TRLDIR > /dev/null 2>&1
151+
152+
# we need to refer to master later for diffs
153+
cp $ZJS_BASE/.git/refs/heads/master $TRLDIR/.git/refs/heads
154+
155+
echo Cloning git submodules...
156+
cd $TRLDIR/deps
157+
for i in */; do
158+
git clone -l ../../deps/$i/.git $i > /dev/null 2>&1
159+
160+
# clone submodules of submodules
161+
if [ -d $i/deps/ ]; then
162+
cd $i/deps
163+
for j in */; do
164+
git clone -l ../../../../deps/$i/deps/$j/.git $j > /dev/null 2>&1
165+
done
166+
cd ../..
167+
fi
168+
done
169+
170+
echo Preserving uncommitted changes:
171+
cd $ZJS_BASE
172+
git --no-pager diff HEAD --stat
173+
git diff HEAD > $TRLDIR/uncommitted.patch
174+
cd $TRLDIR
175+
patch -p1 < uncommitted.patch > /dev/null
176+
177+
# pause to allow consideration of diffs being applied
178+
if [ -z $TRAVIS ]; then
179+
sleep 3
145180
fi
146-
done
147-
148-
echo Preserving uncommitted changes:
149-
cd $ZJS_BASE
150-
git --no-pager diff HEAD --stat
151-
git diff HEAD > $TRLDIR/uncommitted.patch
152-
cd $TRLDIR
153-
patch -p1 < uncommitted.patch > /dev/null
154-
155-
# pause to allow consideration of diffs being applied
156-
if [ -z $TRAVIS ]; then
157-
sleep 3
158-
fi
159181

160-
echo Updating submodules...
161-
make update
182+
echo Updating submodules...
183+
make update
184+
185+
source zjs-env.sh
186+
source deps/zephyr/zephyr-env.sh
187+
else
188+
cd $ZJS_BASE
189+
fi
162190

163191
echo
164192
echo Running tests...
165193

166-
source zjs-env.sh
167-
source deps/zephyr/zephyr-env.sh
168-
169194
# requires: first arg is a <=10-char label, second arg is command
170195
# effects: runs banner with label, then runs the command; if it fails, prints
171196
# label before exiting
@@ -377,7 +402,9 @@ if [ "$RUN" == "all" -o "$RUN" == "4" ]; then
377402
fi
378403

379404
# clean up on success
380-
cd $ZJS_BASE
381-
rm -rf $TRLDIR
405+
if [ "$RUNLOCAL" != "y" ]; then
406+
cd $ZJS_BASE
407+
rm -rf $TRLDIR
408+
fi
382409
exit 0
383410
}

0 commit comments

Comments
 (0)