|
| 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