Skip to content

Commit 41edab3

Browse files
committed
Added travis script to build and run jerryscript with zephyr
Travis will build jerryscript against zephyr and run the "test" command in the virtual console, using named pipe. The output is directed to log.txt which is then checked to see if the command was successfull. JerryScript-DCO-1.0-Signed-off-by: Adrian Moldovan [email protected]
1 parent 836a14e commit 41edab3

File tree

4 files changed

+104
-0
lines changed

4 files changed

+104
-0
lines changed

.travis.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ before_install:
88
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then tools/apt-get-install-deps.sh; fi
99
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then tools/apt-get-install-qemu-arm.sh; fi
1010
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then tools/brew-install-deps.sh; fi
11+
- if [[ "$TARGET" == "build-zephyr" ]]; then tools/apt-get-install-zephyr-deps.sh; fi
1112

1213
install:
1314

@@ -26,5 +27,8 @@ matrix:
2627
env: TARGET="build.darwin test-js"
2728
- os: osx
2829
env: TARGET=test-unit
30+
- os: linux
31+
env: TARGET=build-zephyr
2932
allow_failures:
3033
- os: osx
34+
- env: TARGET=build-zephyr

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,10 @@ clean:
343343
check-signed-off:
344344
$(Q) ./tools/check-signed-off.sh
345345

346+
.PHONY: check-signed-off
347+
build-zephyr:
348+
$(Q) ./tools/build-zephyr.sh
349+
346350
.PHONY: check-vera
347351
check-vera:
348352
$(Q) $(call SHLOG,./tools/check-vera.sh,$(OUT_DIR)/vera.log,Vera++)

tools/apt-get-install-zephyr-deps.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
3+
# Copyright © 2016 Intel Corporation
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
sudo apt-get update -q
18+
sudo apt-get install -q -y \
19+
gcc gcc-multilib g++ g++-multilib libc6-dev-i386 \
20+
python3-ply linux-libc-dev build-essential

tools/build-zephyr.sh

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
#!/bin/bash
2+
3+
# Copyright © 2016 Intel Corporation
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
# clone zephyr repo
18+
git clone https://gerrit.zephyrproject.org/r/zephyr
19+
cd zephyr
20+
21+
# download the zephyr_sdk installer script
22+
wget https://nexus.zephyrproject.org/content/repositories/releases/org/\
23+
zephyrproject/zephyr-sdk/0.8-i686/zephyr-sdk-0.8-i686-setup.run
24+
25+
# extract the zephyr-sdk installer
26+
chmod +x zephyr-sdk-0.8-i686-setup.run
27+
mkdir zephyr_sdk_installer && cd zephyr_sdk_installer
28+
../zephyr-sdk-0.8-i686-setup.run --target $(pwd) --noexec
29+
30+
# install the zephyr_sdk
31+
mkdir ../zephyr_sdk && cd ../zephyr_sdk
32+
export ZEPHYR_SDK_INSTALL_DIR=$(pwd)
33+
cd ../zephyr_uncompressed
34+
./setup.sh -d $ZEPHYR_SDK_INSTALL_DIR
35+
36+
# source the zephyr required environment variables
37+
source ../zephyr-env.sh
38+
export ZEPHYR_GCC_VARIANT=zephyr
39+
40+
# back to jerryscript dir
41+
cd ../..
42+
43+
# link asm-generic to asm (otherwise there will be errors with include headers)
44+
sudo ln -s /usr/include/asm-generic /usr/include/asm
45+
46+
# build jerryscript for qemu
47+
make -f ./targets/arduino_101/Makefile.arduino_101 BOARD=qemu_x86
48+
49+
# create 2 named pipes to input jerryscript commands and evaluate the output
50+
mkfifo path.in path.out
51+
52+
# run the qemu executable in background using the named pipes
53+
./zephyr/zephyr_sdk/sysroots/i686-pokysdk-linux/usr/bin/qemu-system-i386 -m 32 \
54+
-cpu qemu32 -no-reboot -nographic -vga none -display none -net none -clock dynticks \
55+
-no-acpi -balloon none -L ./zephyr/zephyr_sdk/sysroots/i686-pokysdk-linux/usr/share/qemu \
56+
-bios bios.bin -machine type=pc-0.14 -pidfile qemu.pid -serial pipe:path \
57+
-kernel ./build/qemu_x86/zephyr/zephyr.elf & sleep 5
58+
59+
# listen for any output and direct it to log for further checking
60+
cat path.out > log.txt & sleep 5
61+
62+
# write the jerryscript "test" command in the input named pipe
63+
printf "test\r\n" > path.in
64+
sleep 5
65+
66+
# kill qemu executable process (which is marked as first job that runs in background)
67+
kill %1
68+
69+
# show the log output and check if the string "Hi JS World!" is present there
70+
cat log.txt
71+
if grep "Hi JS World!" log.txt > /dev/null; then echo -e \
72+
"\n\nQapla'! (it means \"Success\" in Klingon)"; else echo -e "\n\nScript has failed"; fi
73+
74+
# run the grep command again, so that in the case of not finding the string, the
75+
# grep command will return a non 0 value, which will make travis fail the build
76+
grep "Hi JS World!" log.txt > /dev/null

0 commit comments

Comments
 (0)