Ver código fonte

Merge pull request #1066 from open62541/hotfix/travis_fail

Fix travis not erroing on build fail
Stefan Profanter 7 anos atrás
pai
commit
1379397523

+ 12 - 9
.travis.yml

@@ -82,17 +82,20 @@ cache:
   directories:
     - $HOME/install
 
-before_install:
-- if [ ${TRAVIS_OS_NAME} == "linux" ] && [ "${COVERITY_SCAN_BRANCH}" = 1 ]; 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
-- if [ ${TRAVIS_OS_NAME} == "linux" ]; then sh ./tools/travis/travis_linux_before_install.sh; fi
-- if [ ${TRAVIS_OS_NAME} == "osx" ]; then sh ./tools/travis/travis_osx_before_install.sh; fi
+# combine all the commands into one single command. See https://github.com/travis-ci/travis-ci/issues/1066
+before_install: |
+ set -e
+ if [ ${TRAVIS_OS_NAME} == "linux" ] && [ "${COVERITY_SCAN_BRANCH}" = 1 ]; 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
+ if [ ${TRAVIS_OS_NAME} == "linux" ]; then sh ./tools/travis/travis_linux_before_install.sh; fi
+ if [ ${TRAVIS_OS_NAME} == "osx" ]; then sh ./tools/travis/travis_osx_before_install.sh; fi
 
-script:
-- if [ ${TRAVIS_OS_NAME} == "linux" ] && [ "${COVERITY_SCAN_BRANCH}" != 1 ]; then sh ./tools/travis/travis_linux_script.sh; fi
-- if [ ${TRAVIS_OS_NAME} == "osx" ] && [ "${COVERITY_SCAN_BRANCH}" != 1 ]; then sh ./tools/travis/travis_osx_script.sh; fi
+script: |
+ set -e
+ if [ ${TRAVIS_OS_NAME} == "linux" ] && [ "${COVERITY_SCAN_BRANCH}" != 1 ]; then sh ./tools/travis/travis_linux_script.sh; fi
+ if [ ${TRAVIS_OS_NAME} == "osx" ] && [ "${COVERITY_SCAN_BRANCH}" != 1 ]; then sh ./tools/travis/travis_osx_script.sh; fi
 
-after_success:
-- if [ ${TRAVIS_OS_NAME} == "linux" ]; then sh ./tools/travis/travis_linux_after_success.sh; fi
+after_success: |
+ if [ ${TRAVIS_OS_NAME} == "linux" ]; then sh ./tools/travis/travis_linux_after_success.sh; fi
 
 deploy:
   provider: releases

+ 4 - 2
src/server/ua_services_nodemanagement.c

@@ -1573,7 +1573,8 @@ deleteOneWayReference(UA_Server *server, UA_Session *session, UA_Node *node,
 
             /* One matching target remaining */
             if(refs->targetIdsSize > 0) {
-                refs->targetIds[j-1] = refs->targetIds[refs->targetIdsSize];
+                if  (j-1 != refs->targetIdsSize) // avoid valgrind error: Source and destination overlap in memcpy
+                    refs->targetIds[j-1] = refs->targetIds[refs->targetIdsSize];
                 return UA_STATUSCODE_GOOD;
             }
 
@@ -1582,7 +1583,8 @@ deleteOneWayReference(UA_Server *server, UA_Session *session, UA_Node *node,
             UA_NodeId_deleteMembers(&refs->referenceTypeId);
             node->referencesSize--;
             if(node->referencesSize > 0) {
-                node->references[i-1] = node->references[node->referencesSize];
+                if (i-1 != node->referencesSize) // avoid valgrind error: Source and destination overlap in memcpy
+                    node->references[i-1] = node->references[node->referencesSize];
                 return UA_STATUSCODE_GOOD;
             }
 

+ 9 - 1
tests/check_server_userspace.c

@@ -9,6 +9,12 @@
 #include "ua_config_standard.h"
 #include "check.h"
 
+#ifdef __clang__
+//required for ck_assert_ptr_eq and const casting
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wincompatible-pointer-types-discards-qualifiers"
+#endif
+
 START_TEST(Server_addNamespace_ShallWork)
 {
     UA_ServerConfig config = UA_ServerConfig_standard;
@@ -86,4 +92,6 @@ int main(void) {
     return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
 }
 
-
+#ifdef __clang__
+#pragma clang diagnostic pop
+#endif

+ 11 - 0
tests/check_services_attributes.c

@@ -15,6 +15,12 @@
 #include "ua_config_standard.h"
 #include "server/ua_server_internal.h"
 
+#ifdef __clang__
+//required for ck_assert_ptr_eq and const casting
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wincompatible-pointer-types-discards-qualifiers"
+#endif
+
 static UA_StatusCode
 readCPUTemperature(void *handle, const UA_NodeId nodeid, UA_Boolean sourceTimeStamp,
                    const UA_NumericRange *range, UA_DataValue *dataValue) {
@@ -1024,3 +1030,8 @@ int main(void) {
     srunner_free(sr);
     return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
 }
+
+
+#ifdef __clang__
+#pragma clang diagnostic pop
+#endif

+ 10 - 0
tests/check_types_custom.c

@@ -8,6 +8,12 @@
 #include "ua_util.h"
 #include "check.h"
 
+#ifdef __clang__
+//required for ck_assert_ptr_eq and const casting
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wincompatible-pointer-types-discards-qualifiers"
+#endif
+
 /* The standard-defined datatypes are stored in the global array UA_TYPES. User
  * can create their own UA_CUSTOM_TYPES array (the name doesn't matter) and
  * provide it to the server / client. The type will be automatically decoded if
@@ -203,3 +209,7 @@ int main(void) {
 
     return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
 }
+
+#ifdef __clang__
+#pragma clang diagnostic pop
+#endif

+ 35 - 22
tools/travis/travis_linux_script.sh

@@ -1,5 +1,5 @@
 #!/bin/bash
-set -ev
+set -e
 
 # Docker build test
 if ! [ -z ${DOCKER+x} ]; then
@@ -73,6 +73,7 @@ else
     cd build
     cmake -DCMAKE_BUILD_TYPE=Debug -DUA_ENABLE_GENERATE_NAMESPACE0=On -DUA_BUILD_EXAMPLES=ON  ..
     make -j
+    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
@@ -81,28 +82,31 @@ else
         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 ..
         make -j
+        if [ $? -ne 0 ] ; then exit 1 ; fi
         zip -r open62541-win32.zip ../../doc_latex/open62541.pdf ../LICENSE ../AUTHORS ../README.md ./bin/examples/server.exe ./bin/examples/client.exe ./bin/libopen62541.dll.a open62541.h open62541.c
         cp open62541-win32.zip ..
         cd .. && rm build -rf
-    	echo -en 'travis_fold:end:script.build.cross_mingw32\\r'
+        echo -en 'travis_fold:end:script.build.cross_mingw32\\r'
 
         echo -e "\r\n== Cross compile release build for MinGW 64 bit =="  && echo -en 'travis_fold:start:script.build.cross_mingw64\\r'
         mkdir -p build && cd build
         cmake -DCMAKE_TOOLCHAIN_FILE=../tools/cmake/Toolchain-mingw64.cmake -DUA_ENABLE_AMALGAMATION=ON -DCMAKE_BUILD_TYPE=Release -DUA_BUILD_EXAMPLES=ON ..
         make -j
+        if [ $? -ne 0 ] ; then exit 1 ; fi
         zip -r open62541-win64.zip ../../doc_latex/open62541.pdf ../LICENSE ../AUTHORS ../README.md ./bin/examples/server.exe ./bin/examples/client.exe ./bin/libopen62541.dll.a open62541.h open62541.c
         cp open62541-win64.zip ..
         cd .. && rm build -rf
-    	echo -en 'travis_fold:end:script.build.cross_mingw64\\r'
+        echo -en 'travis_fold:end:script.build.cross_mingw64\\r'
 
         echo -e "\r\n== Cross compile release build for 32-bit linux =="  && echo -en 'travis_fold:start:script.build.cross_linux\\r'
         mkdir -p build && cd build
         cmake -DCMAKE_TOOLCHAIN_FILE=../tools/cmake/Toolchain-gcc-m32.cmake -DUA_ENABLE_AMALGAMATION=ON -DCMAKE_BUILD_TYPE=Release -DUA_BUILD_EXAMPLES=ON ..
         make -j
+        if [ $? -ne 0 ] ; then exit 1 ; fi
         tar -pczf open62541-linux32.tar.gz ../../doc_latex/open62541.pdf ../LICENSE ../AUTHORS ../README.md ./bin/examples/server ./bin/examples/client ./bin/libopen62541.a open62541.h open62541.c
         cp open62541-linux32.tar.gz ..
         cd .. && rm build -rf
-    	echo -en 'travis_fold:end:script.build.cross_linux\\r'
+        echo -en 'travis_fold:end:script.build.cross_linux\\r'
 
         echo -e "\r\n== Cross compile release build for RaspberryPi =="  && echo -en 'travis_fold:start:script.build.cross_raspi\\r'
         mkdir -p build && cd build
@@ -110,53 +114,60 @@ else
         export PATH=$PATH:./tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/
         cmake -DCMAKE_TOOLCHAIN_FILE=../tools/cmake/Toolchain-rpi64.cmake -DUA_ENABLE_AMALGAMATION=ON -DCMAKE_BUILD_TYPE=Release -DUA_BUILD_EXAMPLES=ON ..
         make -j
+        if [ $? -ne 0 ] ; then exit 1 ; fi
         tar -pczf open62541-raspberrypi.tar.gz ../../doc_latex/open62541.pdf ../LICENSE ../AUTHORS ../README.md ./bin/examples/server ./bin/examples/client ./bin/libopen62541.a open62541.h open62541.c
         cp open62541-raspberrypi.tar.gz ..
         cd .. && rm build -rf
-    	echo -en 'travis_fold:end:script.build.cross_raspi\\r'
+        echo -en 'travis_fold:end:script.build.cross_raspi\\r'
     fi
 
     echo -e "\r\n== Compile release build for 64-bit linux =="  && echo -en 'travis_fold:start:script.build.linux_64\\r'
     mkdir -p build && cd build
     cmake -DCMAKE_BUILD_TYPE=Release -DUA_ENABLE_AMALGAMATION=ON -DUA_BUILD_EXAMPLES=ON ..
     make -j
+    if [ $? -ne 0 ] ; then exit 1 ; fi
     tar -pczf open62541-linux64.tar.gz ../../doc_latex/open62541.pdf ../LICENSE ../AUTHORS ../README.md ./bin/examples/server ./bin/examples/client ./bin/libopen62541.a open62541.h open62541.c
     cp open62541-linux64.tar.gz ..
     cp open62541.h ../.. # copy single file-release
     cp open62541.c ../.. # copy single file-release
     cd .. && rm build -rf
-	echo -en 'travis_fold:end:script.build.linux_64\\r'
+    echo -en 'travis_fold:end:script.build.linux_64\\r'
 
     echo -e "\r\n== Building the C++ example =="  && echo -en 'travis_fold:start:script.build.example\\r'
     mkdir -p build && cd build
     cp ../../open62541.* .
     gcc -std=c99 -c open62541.c
     g++ ../examples/server.cpp -I./ open62541.o -lrt -o cpp-server
+    if [ $? -ne 0 ] ; then exit 1 ; fi
     cd .. && rm build -rf
-	echo -en 'travis_fold:end:script.build.example\\r'
-
-	echo "Compile as shared lib version" && echo -en 'travis_fold:start:script.build.shared_libs\\r'
-	mkdir -p build && cd build
-	cmake -DBUILD_SHARED_LIBS=ON -DUA_ENABLE_AMALGAMATION=ON -DUA_BUILD_EXAMPLES=ON ..
-	make -j
-	cd .. && rm build -rf
-	echo -en 'travis_fold:end:script.build.shared_libs\\r'echo -e "\r\n==Compile multithreaded version==" && echo -en 'travis_fold:start:script.build.multithread\\r'
-	mkdir -p build && cd build
-	cmake -DUA_ENABLE_MULTITHREADING=ON -DUA_BUILD_EXAMPLES=ON ..
-	make -j
-	cd .. && rm build -rf
-	echo -en 'travis_fold:end:script.build.multithread\\r'
+    echo -en 'travis_fold:end:script.build.example\\r'
+
+    echo "Compile as shared lib version" && echo -en 'travis_fold:start:script.build.shared_libs\\r'
+    mkdir -p build && cd build
+    cmake -DBUILD_SHARED_LIBS=ON -DUA_ENABLE_AMALGAMATION=ON -DUA_BUILD_EXAMPLES=ON ..
+    make -j
+    if [ $? -ne 0 ] ; then exit 1 ; fi
+    cd .. && rm build -rf
+    echo -en 'travis_fold:end:script.build.shared_libs\\r'echo -e "\r\n==Compile multithreaded version==" && echo -en 'travis_fold:start:script.build.multithread\\r'
+    mkdir -p build && cd build
+    cmake -DUA_ENABLE_MULTITHREADING=ON -DUA_BUILD_EXAMPLES=ON ..
+    make -j
+    if [ $? -ne 0 ] ; then exit 1 ; fi
+    cd .. && rm build -rf
+    echo -en 'travis_fold:end:script.build.multithread\\r'
 
     echo -e "\r\n== Compile without discovery version ==" && echo -en 'travis_fold:start:script.build.unit_test_valgrind\\r'
     mkdir -p build && cd build
     cmake -DUA_ENABLE_DISCOVERY=OFF -DUA_ENABLE_DISCOVERY_MULTICAST=OFF -DUA_BUILD_EXAMPLES=ON ..
     make -j
+    if [ $? -ne 0 ] ; then exit 1 ; fi
     cd .. && rm build -rf
 
     echo -e "\r\n== Compile discovery without multicast version =="
     mkdir -p build && cd build
     cmake -DUA_ENABLE_DISCOVERY=ON -DUA_ENABLE_DISCOVERY_MULTICAST=OFF -DUA_BUILD_EXAMPLES=ON ..
     make -j
+    if [ $? -ne 0 ] ; then exit 1 ; fi
     cd .. && rm build -rf
 
 
@@ -164,21 +175,23 @@ else
     mkdir -p build && cd build
     cmake -DUA_ENABLE_MULTITHREADING=ON -DUA_ENABLE_DISCOVERY=ON -DUA_ENABLE_DISCOVERY_MULTICAST=ON -DUA_BUILD_EXAMPLES=ON ..
     make -j
+    if [ $? -ne 0 ] ; then exit 1 ; fi
     cd .. && rm build -rf
-	echo -en 'travis_fold:end:script.build.multithread\\r'
+    echo -en 'travis_fold:end:script.build.multithread\\r'
 
     echo -e "\r\n== Debug build and unit tests (64 bit) ==" && echo -en 'travis_fold:start:script.build.unit_test_valgrind\\r'
     mkdir -p build && cd build
     cmake -DCMAKE_BUILD_TYPE=Debug -DUA_BUILD_EXAMPLES=ON -DUA_ENABLE_DISCOVERY=ON -DUA_ENABLE_DISCOVERY_MULTICAST=ON -DUA_BUILD_UNIT_TESTS=ON -DUA_ENABLE_COVERAGE=ON -DUA_ENABLE_VALGRIND_UNIT_TESTS=ON ..
     make -j && make test ARGS="-V"
-	echo -en 'travis_fold:end:script.build.unit_test_valgrind\\r'
+    if [ $? -ne 0 ] ; then exit 1 ; fi
+    echo -en 'travis_fold:end:script.build.unit_test_valgrind\\r'
 
     # without valgrind
     # echo -e "\r\n== Debug build and unit tests without valgrind ==" && echo -en 'travis_fold:start:script.build.unit_test\\r'
     # cmake -DCMAKE_BUILD_TYPE=Debug -DUA_BUILD_EXAMPLES=ON -DUA_ENABLE_DISCOVERY=ON -DUA_ENABLE_DISCOVERY_MULTICAST=ON -DUA_BUILD_UNIT_TESTS=ON -DUA_ENABLE_COVERAGE=ON -DUA_ENABLE_VALGRIND_UNIT_TESTS=OFF ..
     # make -j && make test ARGS="-V"
     # (./bin/examples/server & export pid=$!; sleep 2; kill -INT $pid; wait $pid);
-	# echo -en 'travis_fold:end:script.build.unit_test\\r'
+    # echo -en 'travis_fold:end:script.build.unit_test\\r'
 
     # only run coveralls on main repo, otherwise it fails uploading the files
     echo -e "\r\n== -> Current repo: ${TRAVIS_REPO_SLUG} =="