Skip to content

Commit

Permalink
[build] Add "make check" and "make quickcheck" build targets (zephyrp…
Browse files Browse the repository at this point in the history
…roject-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 <geoff@linux.intel.com>
  • Loading branch information
grgustaf authored and Jimmy Huang committed Mar 28, 2017
1 parent 1229ea8 commit 0531ab6
Show file tree
Hide file tree
Showing 4 changed files with 115 additions and 64 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ before_script: >
fi
script: >
trlite $TARGET
trlite -l $TARGET
47 changes: 27 additions & 20 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,14 @@ else
all: zephyr
endif

.PHONY: check
check:
trlite -l

.PHONY: quickcheck
quickcheck:
trlite -l 3

A101BIN = outdir/arduino_101/zephyr.bin
A101SSBIN = arc/outdir/arduino_101_sss/zephyr.bin

Expand Down Expand Up @@ -363,26 +371,25 @@ help:
@echo "JavaScript Runtime for Zephyr OS - Build System"
@echo
@echo "Build targets:"
@echo " all: Build for either Zephyr or Linux depending on BOARD"
@echo " zephyr: Build Zephyr for the given BOARD (A101 is default)"
@echo " ide Build Zephyr in development mode for the IDE"
@echo " ashell Build Zephyr in development mode for the command line"
@echo " arc: Build just the ARC Zephyr target for Arduino 101"
@echo " linux: Build the Linux target"
@echo " dfu: Flash x86 and arc images to A101 with dfu-util"
@echo " debug: Run debug server using JTAG"
@echo " gdb: Run gdb to connect to debug server for x86"
@echo " arcgdb: Run gdb to connect to debug server for ARC"
@echo " qemu: Run QEMU after building"
@echo " clean: Clean stale build objects for given BOARD"
@echo " pristine: Completely remove all generated files"
@echo " all: Build for either Zephyr or Linux depending on BOARD"
@echo " zephyr: Build Zephyr for the given BOARD (A101 is default)"
@echo " ide Build Zephyr in development mode for the IDE"
@echo " ashell Build Zephyr in development mode for command line"
@echo " dfu: Flash x86 and arc images to A101 with dfu-util"
@echo " debug: Run debug server using JTAG"
@echo " gdb: Run gdb to connect to debug server for x86"
@echo " qemu: Run QEMU after building"
@echo " clean: Clean stale build objects for given BOARD"
@echo " pristine: Completely remove all generated files"
@echo " check: Run all the automated build tests"
@echo " quickcheck: Run the quick Linux subset of automated build tests"
@echo
@echo "Build options:"
@echo " BOARD= Specify a Zephyr board to build for"
@echo " JS= Specify a JS script to compile into the binary"
@echo " RAM= Specify size in KB for RAM allocated to X86"
@echo " ROM= Specify size in KB for X86 partition (144 - 296)"
@echo " SNAPSHOT= Specify off to turn off snapshotting"
@echo " TRACE= Specify 'on' for malloc tracing (off is default)"
@echo " VARIANT= Specify 'debug' for extra serial output detail"
@echo " BOARD= Specify a Zephyr board to build for"
@echo " JS= Specify a JS script to compile into the binary"
@echo " RAM= Specify size in KB for RAM allocated to X86"
@echo " ROM= Specify size in KB for X86 partition (144 - 296)"
@echo " SNAPSHOT= Specify off to turn off snapshotting"
@echo " TRACE= Specify 'on' for malloc tracing (off is default)"
@echo " VARIANT= Specify 'debug' for extra serial output detail"
@echo
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,23 @@ least two plus-ones (+1) , "Look Good To Me (LGTM)" or other positive signals
for the project members. Once you have gained the required signals the project
maintainers will merge the PR.

### Travis and local sanity checking

We run a series of tests on each pull request and merged commit using Travis.
This relies on a script in the repo called `trlite`. One easy way to run these
tests on your local $ZJS_BASE git tree is to use `make check` or
`make quickcheck` for a faster subset of the tests. These run with your code as
it stands in your tree. This will not catch a problem like you failing to
add a new file to your commit.

For a slightly safer sanity check, which might catch that kind of problem, you
can run `trlite` directly or `trlite linux` for the "quick subset". This will
clone a second copy of your git tree into a .trlite subdirectory, apply changes
that `git diff` knows about, and run the build tests. Another option `trlite -j`
will cause it to run four threads of tests to speed up execution; these will
use four directories named `.trlite[1-4]`. If there is a test failure, the
affected `.trlite*` trees are left in place so that you can investigate.

## Repo Organization

### File Descriptions
Expand Down
113 changes: 70 additions & 43 deletions scripts/trlite
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
# Author: Geoff Gustafson <geoff@linux.intel.com>

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

TRLDIR=$ZJS_BASE/.trlite
RUNLOCAL=n

if [ "$1" == "-l" ]; then
RUNLOCAL=y
shift
else
TRLDIR=$ZJS_BASE/.trlite
fi

TMPFILE=/tmp/zjstest.js

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

if [[ $1 == -j* ]]; then
if [ "$RUNLOCAL" == "y" ]; then
echo Error: -j mode cannot be used with -l
exit 1
fi

LOGFILE=/tmp/trlite-log

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

if [[ $1 == -n* ]]; then
if [ "$RUNLOCAL" == "y" ]; then
echo Error: -n mode cannot be used with -l
exit 1
fi

TRLDIR=$TRLDIR${1:2}
TMPFILE=$TMPFILE${1:2}
echo TRLDIR: $TRLDIR >> /tmp/foo
Expand Down Expand Up @@ -121,51 +141,56 @@ if [[ "$1" =~ ^[0-9]+$ ]]; then
shift
fi

rm -rf $TRLDIR

echo Building ZJS tree: "$ZJS_BASE"
echo Cloning git tree...
git clone -l $ZJS_BASE $TRLDIR > /dev/null 2>&1

# we need to refer to master later for diffs
cp $ZJS_BASE/.git/refs/heads/master $TRLDIR/.git/refs/heads

echo Cloning git submodules...
cd $TRLDIR/deps
for i in */; do
git clone -l ../../deps/$i/.git $i > /dev/null 2>&1

# clone submodules of submodules
if [ -d $i/deps/ ]; then
cd $i/deps
for j in */; do
git clone -l ../../../../deps/$i/deps/$j/.git $j > /dev/null 2>&1
done
cd ../..

if [ "$RUNLOCAL" != "y" ]; then
rm -rf $TRLDIR

echo Cloning git tree...
git clone -l $ZJS_BASE $TRLDIR > /dev/null 2>&1

# we need to refer to master later for diffs
cp $ZJS_BASE/.git/refs/heads/master $TRLDIR/.git/refs/heads

echo Cloning git submodules...
cd $TRLDIR/deps
for i in */; do
git clone -l ../../deps/$i/.git $i > /dev/null 2>&1

# clone submodules of submodules
if [ -d $i/deps/ ]; then
cd $i/deps
for j in */; do
git clone -l ../../../../deps/$i/deps/$j/.git $j > /dev/null 2>&1
done
cd ../..
fi
done

echo Preserving uncommitted changes:
cd $ZJS_BASE
git --no-pager diff HEAD --stat
git diff HEAD > $TRLDIR/uncommitted.patch
cd $TRLDIR
patch -p1 < uncommitted.patch > /dev/null

# pause to allow consideration of diffs being applied
if [ -z $TRAVIS ]; then
sleep 3
fi
done

echo Preserving uncommitted changes:
cd $ZJS_BASE
git --no-pager diff HEAD --stat
git diff HEAD > $TRLDIR/uncommitted.patch
cd $TRLDIR
patch -p1 < uncommitted.patch > /dev/null

# pause to allow consideration of diffs being applied
if [ -z $TRAVIS ]; then
sleep 3
fi

echo Updating submodules...
make update
echo Updating submodules...
make update

source zjs-env.sh
source deps/zephyr/zephyr-env.sh
else
cd $ZJS_BASE
fi

echo
echo Running tests...

source zjs-env.sh
source deps/zephyr/zephyr-env.sh

# requires: first arg is a <=10-char label, second arg is command
# effects: runs banner with label, then runs the command; if it fails, prints
# label before exiting
Expand Down Expand Up @@ -377,7 +402,9 @@ if [ "$RUN" == "all" -o "$RUN" == "4" ]; then
fi

# clean up on success
cd $ZJS_BASE
rm -rf $TRLDIR
if [ "$RUNLOCAL" != "y" ]; then
cd $ZJS_BASE
rm -rf $TRLDIR
fi
exit 0
}

0 comments on commit 0531ab6

Please sign in to comment.