Преглед на файлове

Use Dockerized travis builds and add gcc8 build to matrix

Stefan Profanter преди 5 години
родител
ревизия
6d44b199ef

+ 167 - 45
.travis.yml

@@ -1,7 +1,7 @@
-language: c
+# using c for language overwrites our compilers
+language: generic
 
-# use new build environment (docker)
-sudo: required
+sudo: false
 
 env:
   global:
@@ -16,43 +16,173 @@ dist: trusty
 matrix:
   fast_finish: true
   include:
+    #
     - os: linux
-      compiler: gcc
+      addons:
+        apt:
+          sources:
+            # see https://github.com/travis-ci/apt-source-whitelist/blob/master/ubuntu.json
+            - ubuntu-toolchain-r-test
+          packages:
+            - binutils-mingw-w64-i686
+            - build-essential
+            - check
+            - cmake
+            - gcc-multilib
+            - g++-mingw-w64-i686
+            - g++-mingw-w64-x86-64
+            - g++-multilib
+            - graphviz
+            - libsubunit-dev
+            - libx11-dev
+            - mingw-w64
+            - python-six
+            - python3-six
+            - texlive-fonts-recommended
+            - texlive-latex-extra
+            - texlive-latex-recommended
+            - valgrind
+            - wget
+            - xutils-dev
+            - zip
       env:
         - ANALYZE=false
+        - CC=gcc-4.8
+        - CXX=g++-4.8
         - PYTHON=python2
+        - MINGW=true
     - os: linux
-      compiler: clang
+      addons:
+        apt:
+          sources:
+            - ubuntu-toolchain-r-test
+          packages:
+            - check
+            - gcc-8
+            - gcc-8-multilib
+            - g++-8
+            - g++-8-multilib
+            - graphviz
+            - linux-libc-dev:i386
+            - python-six
+            - python3-six
+            - texlive-fonts-recommended
+            - texlive-latex-extra
+            - texlive-latex-recommended
+            - valgrind
       env:
         - ANALYZE=false
+        - CC=gcc-8
+        - CXX=g++-8
         - PYTHON=python2
     - os: linux
-      compiler: clang
+      addons:
+        apt:
+          sources:
+            - llvm-toolchain-trusty-6.0
+            - ubuntu-toolchain-r-test
+          packages:
+            - check
+            - clang-6.0
+            - clang-tidy-6.0
+            - graphviz
+            - python-six
+            - texlive-fonts-recommended
+            - texlive-latex-extra
+            - texlive-latex-recommended
+            - valgrind
+      env:
+        - ANALYZE=false
+        - CC=clang-6.0
+        - CXX=clang++-6.0
+        - PYTHON=python2
+    - os: linux
+      addons:
+        apt:
+          sources:
+            - llvm-toolchain-trusty-6.0
+            - ubuntu-toolchain-r-test
+          packages:
+            - check
+            - clang-6.0
+            - clang-tidy-6.0
+            - graphviz
+            - python3-six
+            - texlive-fonts-recommended
+            - texlive-latex-extra
+            - texlive-latex-recommended
+            - valgrind
       env:
         - ANALYZE=false
+        - CC=clang-6.0
+        - CXX=clang++-6.0
         - PYTHON=python3
     - os: linux
-      compiler: tcc
+      addons:
+        apt:
+          packages:
+            - check
+            - graphviz
+            - python-six
+            - python3-six
+            - texlive-fonts-recommended
+            - texlive-latex-extra
+            - texlive-latex-recommended
       env:
         - ANALYZE=false
+        - CC=tcc
         - PYTHON=python2
     - os: linux
-      compiler: gcc
-      env: ANALYZE=true
+      addons:
+        apt:
+          packages:
+            - cppcheck
+      env:
+        - ANALYZE=true
+        - CC=gcc-4.8
+        - CXX=g++-4.8
     - os: linux
-      compiler: clang
-      env: ANALYZE=true
+      addons:
+        apt:
+          sources:
+            - llvm-toolchain-trusty-6.0
+            - ubuntu-toolchain-r-test
+          packages:
+            - check
+            - clang-6.0
+            - clang-tidy-6.0
+            - graphviz
+            - python-six
+            - python3-six
+            - texlive-fonts-recommended
+            - texlive-latex-extra
+            - texlive-latex-recommended
+      env:
+        - ANALYZE=true
+        - PYTHON=python3
+        - CC=clang-6.0
+        - CXX=clang++-6.0
     #- os: linux
     #  compiler: gcc
     #  env: LINT=true
     - os: linux
-      compiler: gcc
-      env: DOCKER=true
-      services:
-        - docker
+      env:
+        - DOCKER=true
     - os: linux
-      compiler: clang
-      env: FUZZER=true
+      addons:
+        apt:
+          sources:
+            - llvm-toolchain-trusty-6.0
+            - ubuntu-toolchain-r-test
+          packages:
+            - check
+            - clang-6.0
+            - clang-tidy-6.0
+            - libfuzzer-6.0-dev
+            - python-six
+            - python3-six
+      env:
+        - FUZZER=true
     - os: osx
       compiler: clang
       # disable homebrew auto update which takes a lot of time
@@ -61,7 +191,6 @@ matrix:
         directories:
           - $HOME/Library/Caches/Homebrew
     - os: linux
-      compiler: gcc
       addons:
         sonarcloud:
           organization: open62541
@@ -69,43 +198,19 @@ matrix:
             - master
             - sonarcloud
       env:
+        - CC=gcc-4.9
+        - CXX=g++-4.9
         - SONAR=true
         - PYTHON=python2
       cache:
         directories:
           - '$HOME/.sonar/cache'
 addons:
-  apt:
-    sources:
-      # see https://github.com/travis-ci/apt-source-whitelist/blob/master/ubuntu.json
-    packages:
-      - binutils-mingw-w64-i686
-      - build-essential
-      - check
-      - cmake
-      - cppcheck
-      - gcc-multilib
-      - g++-mingw-w64-i686
-      - g++-mingw-w64-x86-64
-      - g++-multilib
-      - graphviz
-      - libsubunit-dev
-      - libx11-dev
-      - mingw-w64
-      - python-six
-      - python3-six
-      - texlive-fonts-recommended
-      - texlive-latex-extra
-      - texlive-latex-recommended
-      - valgrind
-      - wget
-      - xutils-dev
-      - zip
   coverity_scan:
     project:
       name: "open62541/open62541"
       description: "Build submitted by Travis"
-    notification_email: null@plt.rwth-aachen.de
+    notification_email: noreply@open62541.org
     build_command_prepend: "mkdir build && cd build && cmake .."
     build_command: "make"
     branch_pattern: coverity_scan
@@ -120,6 +225,23 @@ cache:
 # combine all the commands into one single command. See https://github.com/travis-ci/travis-ci/issues/1066
 before_install: |
  set -e
+
+ # set paths for locally installed libs (like liburcu)
+ export LOCAL_PKG=$HOME/install
+ mkdir -p $LOCAL_PKG/lib
+ mkdir -p $LOCAL_PKG/include
+ mkdir -p $LOCAL_PKG/bin
+ export LIBRARY_PATH=$LOCAL_PKG/lib:$LIBRARY_PATH
+ export C_INCLUDE_PATH=$LOCAL_PKG/include:$C_INCLUDE_PATH
+ export CPLUS_INCLUDE_PATH=$LOCAL_PKG/include:$CPLUS_INCLUDE_PATH
+ export PKG_CONFIG_PATH=$LOCAL_PKG/lib/pkgconfig:$PKG_CONFIG_PATH
+ export PATH=$LOCAL_PKG:$LOCAL_PKG/bin:$PATH
+ export CMAKE_PREFIX_PATH=$LOCAL_PKG:CMAKE_PREFIX_PATH
+ # set local path for python packages
+ export PATH=$PATH:$HOME/.local/bin # linux
+ export PATH=$PATH:$HOME/Library/Python #OS X
+ export PATH=$PATH:$HOME/Library/Python/2.7/bin #OS X
+
  # Exit travis if on coverity_scan branch and not first build
  test $TRAVIS_BRANCH != coverity_scan -o ${TRAVIS_JOB_NUMBER##*.} = 1 || exit 0
  if [ ${TRAVIS_OS_NAME} == "linux" ]; then echo -n | openssl s_client -connect scan.coverity.com:443 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' | sudo tee -a /etc/ssl/certs/ca-; fi

+ 1 - 1
tests/CMakeLists.txt

@@ -2,7 +2,7 @@
 find_package(Check REQUIRED)
 set(LIBS ${CHECK_LIBRARIES} ${open62541_LIBRARIES})
 include_directories(${CHECK_INCLUDE_DIRS})
-find_package(Threads REQUIRED)
+#find_package(Threads REQUIRED)
 if(NOT MSVC AND UA_ENABLE_UNIT_TESTS_MEMCHECK)
     find_package(Valgrind REQUIRED)
 endif()

+ 4 - 4
tests/fuzz/generate_corpus.sh

@@ -27,9 +27,9 @@ if [ -z ${TRAVIS+x} ]; then
 	export CC=clang-5.0
 	export CXX=clang++-5.0
 else
-	# Travis needs an older clang
-	export CC=clang-3.9
-	export CXX=clang++-3.9
+	# Travis needs a specific
+	export CC=clang-6.0
+	export CXX=clang++-6.0
 fi
 # First build and run the unit tests without any specific fuzz settings
 cmake -DUA_BUILD_FUZZING_CORPUS=ON -DUA_BUILD_UNIT_TESTS=ON -DUA_ENABLE_DISCOVERY_MULTICAST=ON -DUA_ENABLE_ENCRYPTION=ON ..
@@ -118,4 +118,4 @@ done
 
 
 merge_corpus $BUILD_DIR_FUZZ_MODE/bin/fuzz_binary_message $BASE_DIR/tests/fuzz/fuzz_binary_message_corpus/generated $CORPUS_COMBINED
-if [ $? -ne 0 ] ; then exit 1 ; fi
+if [ $? -ne 0 ] ; then exit 1 ; fi

+ 3 - 2
tests/server/check_discovery.c

@@ -423,8 +423,9 @@ START_TEST(Client_find_on_network_registered) {
 
     //DNS limits name to max 63 chars (+ \0)
     //We need this ugly casting, otherwise gcc >7.2 will complain about format-truncation, but we want it here
-    snprintf(urls[0], 64, "LDS_test-%s", (char*)*((void**)&hostname));
-    snprintf(urls[1], 64, "Register_test-%s", (char*)*((void**)&hostname));
+    void *hostnameVoid = (void*)hostname;
+    snprintf(urls[0], 64, "LDS_test-%s", (char*)hostnameVoid);
+    snprintf(urls[1], 64, "Register_test-%s", (char*)hostnameVoid);
     expectedUris[0] = UA_STRING(urls[0]);
     expectedUris[1] = UA_STRING(urls[1]);
     FindOnNetworkAndCheck(expectedUris, 2, NULL, NULL, NULL, 0);

+ 8 - 0
tools/cmake/FindMbedTLS.cmake

@@ -1,3 +1,11 @@
+#check environment variable
+if("$ENV{MBEDTLS_FOLDER_INCLUDE}")
+    set(MBEDTLS_FOLDER_INCLUDE "$ENV{MBEDTLS_FOLDER_INCLUDE}")
+endif()
+if("$ENV{MBEDTLS_FOLDER_LIBRARY}")
+    set(MBEDTLS_FOLDER_LIBRARY "$ENV{MBEDTLS_FOLDER_LIBRARY}")
+endif()
+
 find_path(MBEDTLS_INCLUDE_DIRS mbedtls/ssl.h HINTS ${MBEDTLS_FOLDER_INCLUDE})
 
 if(UA_BUILD_OSS_FUZZ)

+ 25 - 23
tools/travis/travis_linux_before_install.sh

@@ -5,27 +5,36 @@ set -ev
 if [ -z ${DOCKER+x} ] && [ -z ${SONAR+x} ]; then
 	# Only on non-docker builds required
 
-	echo "=== Installing from external package sources ===" && echo -en 'travis_fold:start:before_install.external\\r'
-
-	if [ "$CC" = "clang" ]; then
-		# the ubuntu repo has a somehow broken clang-3.9 compiler. We want to use the one from the llvm repo
-		# See https://github.com/openssl/openssl/commit/404c76f4ee1dc51c0d200e2b60a6340aadb44e38
-		sudo cp .travis-apt-pin.preferences /etc/apt/preferences.d/no-ubuntu-clang
-		curl -sSL "http://apt.llvm.org/llvm-snapshot.gpg.key" | sudo -E apt-key add -
-		echo "deb http://apt.llvm.org/trusty/ llvm-toolchain-trusty-3.9 main" | sudo tee -a /etc/apt/sources.list > /dev/null
-		sudo -E apt-add-repository -y "ppa:ubuntu-toolchain-r/test"
-		sudo -E apt-get -yq update
-		sudo -E apt-get -yq --no-install-suggests --no-install-recommends --force-yes install clang-3.9 clang-tidy-3.9 libfuzzer-3.9-dev
-	fi
+ 	echo "=== Installing from external package sources in $LOCAL_PKG ===" && echo -en 'travis_fold:start:before_install.external\\r'
+
+   # Increase the environment version to force a rebuild of the packages
+    # The version is writen to the cache file after every build of the dependencies
+    ENV_VERSION="1"
+    ENV_INSTALLED=""
+    if [ -e $LOCAL_PKG/.build_env ]; then
+        echo "=== No cached build environment ==="
+        read -r ENV_INSTALLED < $LOCAL_PKG/.build_env
+    fi
+
+    # travis caches the $LOCAL_PKG dir. If it is loaded, we don't need to reinstall the packages
+    if [ "$ENV_VERSION" = "$ENV_INSTALLED" ]; then
+        echo "=== The build environment is current ==="
+        exit 0
+    fi
+
+    echo "=== The build environment is outdated ==="
+
+    # Clean up
+    rm -rf $LOCAL_PKG/*
 
 	if [ "$CC" = "tcc" ]; then
 		mkdir tcc_install && cd tcc_install
 		wget https://download.savannah.gnu.org/releases/tinycc/tcc-0.9.27.tar.bz2
 		tar xf tcc-0.9.27.tar.bz2
 		cd tcc-0.9.27
-		./configure
+		./configure --prefix=$LOCAL_PKG
 		make
-		sudo make install
+		make install
 		cd ../..
 		rm -rf tcc_install
 	fi
@@ -33,9 +42,9 @@ if [ -z ${DOCKER+x} ] && [ -z ${SONAR+x} ]; then
 	wget https://github.com/ARMmbed/mbedtls/archive/mbedtls-2.7.1.tar.gz
 	tar xf mbedtls-2.7.1.tar.gz
 	cd mbedtls-mbedtls-2.7.1
-	cmake -DENABLE_TESTING=Off .
+	cmake -DENABLE_TESTING=Off -DCMAKE_INSTALL_PREFIX=$LOCAL_PKG .
 	make -j
-	sudo make install
+	make install
 
 	echo -en 'travis_fold:end:script.before_install.external\\r'
 
@@ -46,11 +55,4 @@ if [ -z ${DOCKER+x} ] && [ -z ${SONAR+x} ]; then
 	pip install --user cpplint
 	echo -en 'travis_fold:end:script.before_install.python\\r'
 
-	echo "=== Installed versions are ===" && echo -en 'travis_fold:start:before_install.versions\\r'
-	clang --version
-	g++ --version
-	cppcheck --version
-	valgrind --version
-	echo -en 'travis_fold:end:script.before_install.versions\\r'
-
 fi

+ 7 - 6
tools/travis/travis_linux_script.sh

@@ -56,11 +56,11 @@ fi
 
 if [ $ANALYZE = "true" ]; then
     echo "=== Running static code analysis ===" && echo -en 'travis_fold:start:script.analyze\\r'
-    if [ "$CC" = "clang" ]; then
+    if ! case $CC in clang*) false;; esac; then
         mkdir -p build
         cd build
-        scan-build cmake -DUA_BUILD_EXAMPLES=ON -DUA_BUILD_UNIT_TESTS=ON ..
-        scan-build -enable-checker security.FloatLoopCounter \
+        scan-build-6.0 cmake -DUA_BUILD_EXAMPLES=ON -DUA_BUILD_UNIT_TESTS=ON ..
+        scan-build-6.0 -enable-checker security.FloatLoopCounter \
           -enable-checker security.insecureAPI.UncheckedReturn \
           --status-bugs -v \
           make -j
@@ -68,8 +68,8 @@ if [ $ANALYZE = "true" ]; then
 
         mkdir -p build
         cd build
-        scan-build cmake -DUA_ENABLE_AMALGAMATION=ON ..
-        scan-build -enable-checker security.FloatLoopCounter \
+        scan-build-6.0 cmake -DUA_ENABLE_AMALGAMATION=ON ..
+        scan-build-6.0 -enable-checker security.FloatLoopCounter \
           -enable-checker security.insecureAPI.UncheckedReturn \
           --status-bugs -v \
           make -j
@@ -116,8 +116,9 @@ else
     if [ $? -ne 0 ] ; then exit 1 ; fi
     cd .. && rm build -rf
     echo -en 'travis_fold:end:script.build.ns0\\r'
+
     # cross compilation only with gcc
-    if [ "$CC" = "gcc" ]; then
+    if ! [ -z ${MINGW+x} ]; then
         echo -e "\r\n== Cross compile release build for MinGW 32 bit =="  && echo -en 'travis_fold:start:script.build.cross_mingw32\\r'
         mkdir -p build && cd build
         cmake -DCMAKE_TOOLCHAIN_FILE=../tools/cmake/Toolchain-mingw32.cmake -DUA_ENABLE_AMALGAMATION=ON -DCMAKE_BUILD_TYPE=Release -DUA_BUILD_EXAMPLES=ON ..