From 52617d2fdd4c56a6942d776e8f733bebbb8edc49 Mon Sep 17 00:00:00 2001 From: Gabor Buella Date: Thu, 7 Sep 2017 15:04:07 +0200 Subject: [PATCH] Use pmemfile in travis tests --- utils/docker/images/Dockerfile.fedora-25 | 15 ++++ utils/docker/images/Dockerfile.ubuntu-16.04 | 20 +++++ utils/docker/images/build-image.sh | 2 + utils/docker/images/build-pmemfile.sh | 92 +++++++++++++++++++++ utils/docker/images/install-nvml.sh | 51 ++++++++++++ utils/docker/run-coverage.sh | 12 ++- 6 files changed, 191 insertions(+), 1 deletion(-) create mode 100755 utils/docker/images/build-pmemfile.sh create mode 100755 utils/docker/images/install-nvml.sh diff --git a/utils/docker/images/Dockerfile.fedora-25 b/utils/docker/images/Dockerfile.fedora-25 index 5c11880e..7bcf3bfa 100644 --- a/utils/docker/images/Dockerfile.fedora-25 +++ b/utils/docker/images/Dockerfile.fedora-25 @@ -45,11 +45,17 @@ RUN dnf install -y \ cmake \ gcc \ git \ + libcap-devel \ + libunwind-devel \ make \ pandoc \ + perl-Text-Diff \ rpm-build \ passwd \ sudo \ + sqlite \ + tcl-devel \ + wget \ which \ whois @@ -60,8 +66,17 @@ RUN useradd -m $USER RUN echo $USERPASS | passwd $USER --stdin RUN gpasswd wheel -a $USER +# Install nvml +COPY install-nvml.sh install-nvml.sh +RUN ./install-nvml.sh rpm + USER $USER +# Build pmemfile +COPY libsyscall_intercept_hook_point.h libsyscall_intercept_hook_point.h +COPY build-pmemfile.sh build-pmemfile.sh +RUN ./build-pmemfile.sh + # Set required environment variables ENV OS fedora ENV OS_VER 25 diff --git a/utils/docker/images/Dockerfile.ubuntu-16.04 b/utils/docker/images/Dockerfile.ubuntu-16.04 index fb379da5..51f832d3 100644 --- a/utils/docker/images/Dockerfile.ubuntu-16.04 +++ b/utils/docker/images/Dockerfile.ubuntu-16.04 @@ -41,17 +41,27 @@ MAINTAINER gabor.buella@intel.com # Update the Apt cache and install basic tools RUN apt-get update RUN apt-get install -y \ + autoconf \ + automake \ clang \ curl \ cmake \ + debhelper \ + devscripts \ + doxygen \ git \ + libcap-dev \ libcapstone-dev \ + libunwind-dev \ pandoc \ + libtext-diff-perl \ pkg-config \ debhelper \ devscripts \ ruby \ sudo \ + sqlite3 \ + tcl-dev \ wget \ whois @@ -61,8 +71,18 @@ ENV USER user ENV USERPASS pass RUN useradd -m $USER -g sudo -p `mkpasswd $USERPASS` + +# Install nvml +COPY install-nvml.sh install-nvml.sh +RUN ./install-nvml.sh dpkg + USER $USER +# Build pmemfile +COPY libsyscall_intercept_hook_point.h libsyscall_intercept_hook_point.h +COPY build-pmemfile.sh build-pmemfile.sh +RUN ./build-pmemfile.sh + # Set required environment variables ENV OS ubuntu ENV OS_VER 16.04 diff --git a/utils/docker/images/build-image.sh b/utils/docker/images/build-image.sh index fe552774..815dc4d3 100755 --- a/utils/docker/images/build-image.sh +++ b/utils/docker/images/build-image.sh @@ -61,6 +61,8 @@ if [[ ! -f "Dockerfile.$os_ver" ]]; then exit 1 fi +cp ../../../include/libsyscall_intercept_hook_point.h libsyscall_intercept_hook_point.h + # Build a Docker image tagged with PROJECT/OS:VER tag=${DOCKER_USER}/${PROJECT}_$1 sudo docker build -t $tag \ diff --git a/utils/docker/images/build-pmemfile.sh b/utils/docker/images/build-pmemfile.sh new file mode 100755 index 00000000..6de1d07a --- /dev/null +++ b/utils/docker/images/build-pmemfile.sh @@ -0,0 +1,92 @@ +#!/bin/bash -ex +# +# Copyright 2017, Intel Corporation +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# +# * Neither the name of the copyright holder nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +# +# build-pmemfile.sh - builds libpmemfile +# + +# libpmemfile needs syscall_intercept to build, so create a mock library +# that looks like libsyscall_intercept (as long as it is used for linking +# with, not for executing). +mkdir -p ~/mock_syscall_intercept +cp libsyscall_intercept_hook_point.h ~/mock_syscall_intercept/. + +cd +cd mock_syscall_intercept + +echo int intercept_hook_point\; > mock_syscall_intercept.c +echo int intercept_hook_point_clone_child\; >> mock_syscall_intercept.c +echo int syscall_no_intercept\(void\) \{return 0\;\} >> mock_syscall_intercept.c +echo int syscall_hook_in_process_allowed\(void\) \{return 0\;\} >> mock_syscall_intercept.c + +gcc -xc -nostdlib -shared mock_syscall_intercept.c -o libsyscall_intercept.so + +echo Name: libsyscall_intercept > libsyscall_intercept.pc +echo Version: mock >> libsyscall_intercept.pc +echo Description: Mock libsyscall_intercept >> libsyscall_intercept.pc +echo includedir=$PWD >> libsyscall_intercept.pc +echo Libs: -L$PWD -lsyscall_intercept >> libsyscall_intercept.pc +echo Cflags: -I$PWD >> libsyscall_intercept.pc + +# Set some environment variables, allowing cmake to find the mock library +export LD_LIBRARY_PATH=$PWD +export PKG_CONFIG_PATH=$PWD + +cd + +# Build pmemfile. +# The tests from pmemfile repo are going to be used, so there is no point +# in calling `make install`. +# Trying to make a minimal build here, not needing libpmemfile-posix tests, +# antool tests. +git clone https://github.com/pmem/pmemfile.git +cd pmemfile +git checkout a7f1d347bfdbabec3b0e0b1dca50542ec6c267e3 +mkdir build +cd build +cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo \ + -DBUILD_LIBPMEMFILE=ON \ + -DAUTO_GENERATE_SOURCES=OFF \ + -DTESTS_USE_FORCED_PMEM=ON \ + -DDEVELOPER_MODE=OFF \ + -DFAULT_INJECTION=OFF \ + -DLONG_TESTS=OFF \ + -DTRACE_TESTS=ON \ + -DUSE_ASAN=OFF \ + -DUSE_UBSAN=OFF \ + -DANTOOL_TESTS=SKIP \ + -DBUILD_LIBPMEMFILE_POSIX_TESTS=OFF \ + -DBUILD_LIBPMEMFILE_TESTS=ON \ + .. +make +cd +rm -rf mock_syscall_intercept diff --git a/utils/docker/images/install-nvml.sh b/utils/docker/images/install-nvml.sh new file mode 100755 index 00000000..e089c254 --- /dev/null +++ b/utils/docker/images/install-nvml.sh @@ -0,0 +1,51 @@ +#!/bin/bash -ex +# +# Copyright 2017, Intel Corporation +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# +# * Neither the name of the copyright holder nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +# +# install-nvml.sh - installs libpmem & libpmemobj +# + +mkdir nvml +cd nvml + +if [ "$1" = "dpkg" ]; then + wget https://github.com/pmem/nvml/releases/download/1.3/nvml-1.3-dpkgs.tar.gz + tar -xzf nvml-1.3-dpkgs.tar.gz + sudo dpkg -i libpmem_*.deb libpmem-dev_*.deb libpmemobj_*.deb libpmemobj-dev_*.deb +elif [ "$1" = "rpm" ]; then + wget https://github.com/pmem/nvml/releases/download/1.3/nvml-1.3-rpms.tar.gz + tar -xzf nvml-1.3-rpms.tar.gz + sudo rpm -i x86_64/libpmem-*.rpm x86_64/libpmemobj-*.rpm +fi + +cd .. +rm -rf nvml diff --git a/utils/docker/run-coverage.sh b/utils/docker/run-coverage.sh index 17060959..4bcb8b90 100755 --- a/utils/docker/run-coverage.sh +++ b/utils/docker/run-coverage.sh @@ -46,6 +46,16 @@ CC=gcc cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo \ make ctest --output-on-failure -bash <(curl -s https://codecov.io/bash) +bash <(curl -s https://codecov.io/bash) -c -F regular_tests +find . -name ".coverage" -exec rm {} \; +find . -name "coverage.xml" -exec rm {} \; +find . -name "*.gcov" -exec rm {} \; +find . -name "*.gcda" -exec rm {} \; + +pushd ~/pmemfile/build +LD_LIBRARY_PATH=$WORKDIR/build ctest --output-on-failure -R preload_ +popd +bash <(curl -s https://codecov.io/bash) -c -F pmemfile_tests + cd .. rm -r build