Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI on ARM #50

Merged
merged 31 commits into from
Jan 11, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
8e4a516
Trying ARM QEMU #1
PJK Jan 10, 2017
993c8fc
Trying ARM QEMU #2
PJK Jan 10, 2017
f5ec940
Trying ARM QEMU #3
PJK Jan 10, 2017
34ccc78
Trying ARM QEMU #4
PJK Jan 10, 2017
1c9fabb
Trying ARM QEMU #5
PJK Jan 10, 2017
a11362c
Trying ARM QEMU #6
PJK Jan 10, 2017
9571f93
Trying ARM QEMU #7
PJK Jan 10, 2017
e020d4f
Trying ARM QEMU #8
PJK Jan 10, 2017
814f7a1
Trying ARM QEMU -- exec bit
PJK Jan 10, 2017
3143401
Trying ARM QEMU -- cppcheck
PJK Jan 10, 2017
db1b32b
Trying ARM QEMU -- cmake
PJK Jan 10, 2017
5031b4d
Trying ARM QEMU -- less verbose commands
PJK Jan 10, 2017
175c52a
Trying ARM QEMU -- xcompile #1
PJK Jan 11, 2017
e386f10
Trying ARM QEMU -- xcompile #2
PJK Jan 11, 2017
172add6
Trying ARM QEMU -- xcompile #3
PJK Jan 11, 2017
897cefd
Trying ARM QEMU -- xcompile #4
PJK Jan 11, 2017
4544d73
Trying ARM QEMU -- xcompile #5
PJK Jan 11, 2017
d1577af
Trying ARM QEMU -- xcompile #6
PJK Jan 11, 2017
181e438
Trying ARM QEMU -- xcompile #7
PJK Jan 11, 2017
daea648
Trying ARM QEMU -- xcompile #8
PJK Jan 11, 2017
78eb528
Trying ARM QEMU -- xcompile #9
PJK Jan 11, 2017
248949c
Trying ARM QEMU -- xcompile #10
PJK Jan 11, 2017
ebd91d4
Trying ARM QEMU -- xcompile #11
PJK Jan 11, 2017
cd9fe2d
Trying ARM QEMU -- xcompile #12
PJK Jan 11, 2017
1d05b7b
Trying ARM QEMU -- xcompile #13
PJK Jan 11, 2017
6573057
Trying ARM QEMU -- xcompile #14
PJK Jan 11, 2017
3c833c9
Trying ARM QEMU -- xcompile #15
PJK Jan 11, 2017
725afc2
Trying ARM QEMU -- xcompile sudo install cmocka
PJK Jan 11, 2017
311f084
Trying ARM QEMU -- #16
PJK Jan 11, 2017
e7c3a2f
Trying ARM QEMU -- cleanup
PJK Jan 11, 2017
73a9ac3
More minor improvements
PJK Jan 11, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
126 changes: 126 additions & 0 deletions .travis-qemu.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
#!/bin/bash
# Based on a test script from avsm/ocaml repo https://github.com/avsm/ocaml
# Adapted from https://www.tomaz.me/2013/12/02/running-travis-ci-tests-on-arm.html

set -e

CHROOT_DIR=/tmp/arm-chroot
MIRROR=http://archive.raspbian.org/raspbian
VERSION=wheezy
CHROOT_ARCH=armhf

# Debian package dependencies for the host
HOST_DEPENDENCIES="debootstrap qemu-user-static binfmt-support sbuild"

# Debian package dependencies for the chrooted environment
GUEST_DEPENDENCIES="cmake git"

function setup_arm_chroot {
# Host dependencies
sudo apt-get install -qq -y ${HOST_DEPENDENCIES}

# Create chrooted environment
sudo mkdir ${CHROOT_DIR}
sudo debootstrap --foreign --no-check-gpg --include=fakeroot,build-essential \
--arch=${CHROOT_ARCH} ${VERSION} ${CHROOT_DIR} ${MIRROR}
sudo cp /usr/bin/qemu-arm-static ${CHROOT_DIR}/usr/bin/
sudo chroot ${CHROOT_DIR} ./debootstrap/debootstrap --second-stage
sudo sbuild-createchroot --arch=${CHROOT_ARCH} --foreign --setup-only \
${VERSION} ${CHROOT_DIR} ${MIRROR}

# Create file with environment variables which will be used inside chrooted
# environment
echo "export ARCH=${ARCH}" > envvars.sh
echo "export TRAVIS_BUILD_DIR=${TRAVIS_BUILD_DIR}" >> envvars.sh
chmod a+x envvars.sh

# Install dependencies inside chroot
sudo chroot ${CHROOT_DIR} apt-get update
sudo chroot ${CHROOT_DIR} apt-get --allow-unauthenticated install \
-qq -y ${GUEST_DEPENDENCIES}

# Create build dir and copy travis build files to our chroot environ ment
sudo mkdir -p ${CHROOT_DIR}/${TRAVIS_BUILD_DIR}
sudo rsync -a ${TRAVIS_BUILD_DIR}/ ${CHROOT_DIR}/${TRAVIS_BUILD_DIR}/

# Indicate chroot environment has been set up
sudo touch ${CHROOT_DIR}/.chroot_is_done

# Call ourselves again which will cause tests to run
sudo chroot ${CHROOT_DIR} bash -c "cd ${TRAVIS_BUILD_DIR} && ./.travis-qemu.sh"
}


if [ "${ARCH}" = "arm" ]; then
if [ -e "/.chroot_is_done" ]; then
# We are inside ARM chroot
echo "Running inside chrooted environment, will execute only tests"

. ./envvars.sh

# We need CMocka since the executables are dynamically linked
git clone git://git.cryptomilk.org/projects/cmocka.git
mkdir cmocka_build && cd cmocka_build
cmake ../cmocka
make VERBOSE=1
make install
cd ..

# Hack: We don't have the right CMake (takes too long to compile), but this works
ctest -VV
else
# Compilation on QEMU is too slow and times out on Travis. Crosscompile at the host
echo "Initial execution on ARM environment, will crosscompile"
arm-linux-gnueabihf-gcc-4.6 -v

# Crosscompile CMocka
pushd $HOME
git clone git://git.cryptomilk.org/projects/cmocka.git
mkdir cmocka_build && cd cmocka_build
cmake ../cmocka \
-DCMAKE_C_COMPILER=arm-linux-gnueabihf-gcc-4.6
make VERBOSE=1
sudo make install
cd ..
rm -rf cmocka cmocka_build
popd

# Crosscompile libcbor
cmake $SOURCE \
-DCBOR_CUSTOM_ALLOC=ON \
-DCMAKE_BUILD_TYPE=Debug \
-DWITH_TESTS=ON \
-DCMAKE_C_COMPILER=arm-linux-gnueabihf-gcc-4.6
make VERBOSE=1

# ARM test run, need to set up chrooted environment first
echo "Setting up chrooted ARM environment"
setup_arm_chroot
fi
else
# Proceed as normal
gem install coveralls-lcov
pushd $HOME
git clone git://git.cryptomilk.org/projects/cmocka.git
mkdir cmocka_build && cd cmocka_build
cmake ../cmocka
make -j 2
sudo make install
cd ..
rm -rf cmocka cmocka_build
popd

echo "Running tests"
cppcheck . --error-exitcode=1 --suppressions cppcheck_suppressions.txt --force

cmake . -DCBOR_CUSTOM_ALLOC=ON -DCMAKE_BUILD_TYPE=Debug -DWITH_TESTS=ON -DCMAKE_PREFIX_PATH=$HOME/usr/local
make VERBOSE=1

ctest -VV

ctest -T memcheck | tee memcheck.out
if grep -q 'Memory Leak\|IPW\|Uninitialized Memory Conditional\|Uninitialized Memory Read' memcheck.out; then
exit 1
fi
fi

29 changes: 12 additions & 17 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,6 @@
language: c

sudo: false

before_install:
- gem install coveralls-lcov
- pushd $HOME
- git clone git://git.cryptomilk.org/projects/cmocka.git
- mkdir cmocka_build && cd cmocka_build
- cmake -DCMAKE_INSTALL_PREFIX=$HOME ../cmocka
- make -j 2
- make install
# Confuses CMake search
- cd ..
- rm -rf cmocka cmocka_build
- popd
sudo: true

matrix:
include:
Expand Down Expand Up @@ -49,11 +36,19 @@ matrix:
- cmake
- cmake-data
env: CC="gcc-6" CXX="g++-6"


- env: ARCH=arm
addons:
apt:
sources:
- george-edison55-precise-backports # cmake 3.2.3 / doxygen 1.8.3
packages:
- gcc-arm-linux-gnueabihf
- libc6-dev-armhf-cross
- cmake
- cmake-data

script:
- export SOURCE=$(pwd) && ./buildscript.sh
- "bash -ex .travis-qemu.sh"

notifications:
email: false
17 changes: 0 additions & 17 deletions buildscript.sh

This file was deleted.