diff --git a/.azure-pipelines/azure-pipelines-win.yml b/.azure-pipelines/azure-pipelines-win.yml index bf71b962d14..f577e1b4663 100644 --- a/.azure-pipelines/azure-pipelines-win.yml +++ b/.azure-pipelines/azure-pipelines-win.yml @@ -52,6 +52,7 @@ jobs: - powershell: ./tools/azure-devops/win/install.ps1 displayName: Install Requirements + errorActionPreference: continue # Errors are handled in the script - powershell: ./tools/azure-devops/win/build.ps1 displayName: "Build: $(CC_NAME)" errorActionPreference: continue # If set to Stop, we only get a truncated exception message. Error is handled by checking exit code @@ -83,6 +84,7 @@ jobs: - powershell: ./tools/azure-devops/win/install.ps1 displayName: Install Requirements + errorActionPreference: continue # Errors are handled in the script - powershell: ./tools/azure-devops/win/build.ps1 displayName: "Build: $(CC_NAME)" errorActionPreference: continue # If set to Stop, we only get a truncated exception message. Error is handled by checking exit code diff --git a/src/pubsub/ua_pubsub_writer.c b/src/pubsub/ua_pubsub_writer.c index fb408ace904..691a7fbd445 100644 --- a/src/pubsub/ua_pubsub_writer.c +++ b/src/pubsub/ua_pubsub_writer.c @@ -1218,6 +1218,10 @@ UA_Server_addDataSetWriter(UA_Server *server, return UA_STATUSCODE_BADOUTOFMEMORY; } newDataSetWriter->lastSamplesCount = currentDataSetContext->fieldSize; + for(size_t i = 0; i < newDataSetWriter->lastSamplesCount; i++) { + UA_DataValue_init(&newDataSetWriter->lastSamples[i].value); + newDataSetWriter->lastSamples[i].valueChanged = false; + } } #endif diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 7cc9868658e..2840d69beaa 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -398,11 +398,11 @@ if(UA_ENABLE_PUBSUB) if(UA_ENABLE_PUBSUB_INFORMATIONMODEL) add_executable(check_pubsub_informationmodel pubsub/check_pubsub_informationmodel.c $ $) target_link_libraries(check_pubsub_informationmodel ${LIBS}) - add_test(check_pubsub_informationmodel ${TESTS_BINARY_DIR}/check_pubsub_informationmodel) + add_test_valgrind(check_pubsub_informationmodel ${TESTS_BINARY_DIR}/check_pubsub_informationmodel) if(UA_ENABLE_PUBSUB_INFORMATIONMODEL_METHODS) add_executable(check_pubsub_informationmodel_methods pubsub/check_pubsub_informationmodel_methods.c $ $) target_link_libraries(check_pubsub_informationmodel_methods ${LIBS}) - add_test(check_pubsub_informationmodel_methods ${TESTS_BINARY_DIR}/check_pubsub_informationmodel_methods) + add_test_valgrind(check_pubsub_informationmodel_methods ${TESTS_BINARY_DIR}/check_pubsub_informationmodel_methods) endif() endif() diff --git a/tests/client/check_client_subscriptions.c b/tests/client/check_client_subscriptions.c index 99e81a8bdd3..414b13baecb 100644 --- a/tests/client/check_client_subscriptions.c +++ b/tests/client/check_client_subscriptions.c @@ -42,8 +42,10 @@ static void setup(void) { } static void teardown(void) { - running = false; - THREAD_JOIN(server_thread); + if (running) { + running = false; + THREAD_JOIN(server_thread); + } UA_Server_run_shutdown(server); UA_Server_delete(server); } diff --git a/tools/azure-devops/win/build.ps1 b/tools/azure-devops/win/build.ps1 index 44bbf808d42..aded74aaac1 100644 --- a/tools/azure-devops/win/build.ps1 +++ b/tools/azure-devops/win/build.ps1 @@ -47,6 +47,40 @@ try { Copy-Item AUTHORS pack Copy-Item README.md pack + # Only execute unit tests on vs2017 to save compilation time + if ($env:CC_SHORTNAME -eq "vs2017") { + Write-Host -ForegroundColor Green "`n###################################################################" + Write-Host -ForegroundColor Green "`n##### Testing $env:CC_NAME with unit tests #####`n" + New-Item -ItemType directory -Path "build" + cd build + & cmake $cmake_cnf ` + -DBUILD_SHARED_LIBS:BOOL=OFF ` + -DCMAKE_BUILD_TYPE=Debug ` + -DUA_BUILD_EXAMPLES=OFF ` + -DUA_BUILD_UNIT_TESTS=ON ` + -DUA_ENABLE_DA=ON ` + -DUA_ENABLE_DISCOVERY=ON ` + -DUA_ENABLE_DISCOVERY_MULTICAST=ON ` + -DUA_ENABLE_ENCRYPTION:BOOL=$build_encryption ` + -DUA_ENABLE_JSON_ENCODING:BOOL=ON ` + -DUA_ENABLE_PUBSUB:BOOL=ON ` + -DUA_ENABLE_PUBSUB_DELTAFRAMES:BOOL=ON ` + -DUA_ENABLE_PUBSUB_INFORMATIONMODEL:BOOL=ON ` + -DUA_ENABLE_UNIT_TESTS_MEMCHECK=ON .. + & cmake --build . --config Debug + if ($LASTEXITCODE -and $LASTEXITCODE -ne 0) { + Write-Host -ForegroundColor Red "`n`n*** Make failed. Exiting ... ***" + exit $LASTEXITCODE + } + & cmake --build . --target test-verbose --config Debug -j 1 + if ($LASTEXITCODE -and $LASTEXITCODE -ne 0) { + Write-Host -ForegroundColor Red "`n`n*** Make failed. Exiting ... ***" + exit $LASTEXITCODE + } + cd .. + Remove-Item -Path build -Recurse -Force + } + Write-Host -ForegroundColor Green "`n###################################################################" Write-Host -ForegroundColor Green "`n##### Testing $env:CC_NAME with amalgamation #####`n" New-Item -ItemType directory -Path "build" @@ -55,6 +89,7 @@ try { -DCMAKE_BUILD_TYPE=RelWithDebInfo ` -DUA_BUILD_EXAMPLES:BOOL=OFF ` -DUA_ENABLE_AMALGAMATION:BOOL=ON ` + -DUA_ENABLE_SUBSCRIPTIONS_EVENTS:BOOL=ON ` -DUA_ENABLE_ENCRYPTION:BOOL=$build_encryption .. & cmake --build . --config RelWithDebInfo if ($LASTEXITCODE -and $LASTEXITCODE -ne 0) { @@ -79,7 +114,7 @@ try { -DUA_ENABLE_PUBSUB_INFORMATIONMODEL:BOOL=ON ` -DUA_ENABLE_SUBSCRIPTIONS_EVENTS:BOOL=ON ` -DUA_NAMESPACE_ZERO:STRING=FULL .. - & cmake --build . --config RelWithDebInfo + & cmake --build . --config Debug if ($LASTEXITCODE -and $LASTEXITCODE -ne 0) { Write-Host -ForegroundColor Red "`n`n*** Make failed. Exiting ... ***" exit $LASTEXITCODE @@ -137,37 +172,6 @@ try { } Remove-Item -Path build -Recurse -Force - # Only execute unit tests on vs2017 to save compilation time - if ($env:CC_SHORTNAME -eq "vs2017") { - Write-Host -ForegroundColor Green "`n###################################################################" - Write-Host -ForegroundColor Green "`n##### Testing $env:CC_NAME with unit tests #####`n" - New-Item -ItemType directory -Path "build" - cd build - & cmake $cmake_cnf ` - -DBUILD_SHARED_LIBS:BOOL=OFF ` - -DCMAKE_BUILD_TYPE=Debug ` - -DUA_BUILD_EXAMPLES=OFF ` - -DUA_BUILD_UNIT_TESTS=ON ` - -DUA_ENABLE_DA=ON ` - -DUA_ENABLE_DISCOVERY=ON ` - -DUA_ENABLE_DISCOVERY_MULTICAST=ON ` - -DUA_ENABLE_ENCRYPTION:BOOL=$build_encryption ` - -DUA_ENABLE_JSON_ENCODING:BOOL=ON ` - -DUA_ENABLE_PUBSUB:BOOL=ON ` - -DUA_ENABLE_PUBSUB_DELTAFRAMES:BOOL=ON ` - -DUA_ENABLE_PUBSUB_INFORMATIONMODEL:BOOL=ON ` - -DUA_ENABLE_UNIT_TESTS_MEMCHECK=ON .. - & cmake --build . --config Debug - if ($LASTEXITCODE -and $LASTEXITCODE -ne 0) { - Write-Host -ForegroundColor Red "`n`n*** Make failed. Exiting ... ***" - exit $LASTEXITCODE - } - & cmake --build . --target test-verbose --config Debug - if ($LASTEXITCODE -and $LASTEXITCODE -ne 0) { - Write-Host -ForegroundColor Red "`n`n*** Make failed. Exiting ... ***" - exit $LASTEXITCODE - } - } # # do not cache log # Remove-Item -Path c:\miktex\texmfs\data\miktex\log -Recurse -Force diff --git a/tools/azure-devops/win/install.ps1 b/tools/azure-devops/win/install.ps1 index 8c9513ce1a3..85b367c1d06 100644 --- a/tools/azure-devops/win/install.ps1 +++ b/tools/azure-devops/win/install.ps1 @@ -1,36 +1,53 @@ -$ErrorActionPreference = "Stop" - try { Write-Host -ForegroundColor Green "`n### Installing sphinx ###`n" & choco install -y sphinx --no-progress --source python + if ($LASTEXITCODE -and $LASTEXITCODE -ne 0) { + Write-Host -ForegroundColor Red "`n`n*** Install failed. Exiting ... ***" + exit $LASTEXITCODE + } if ($env:CC_SHORTNAME -eq "mingw" -or $env:CC_SHORTNAME -eq "clang-mingw") { Write-Host -ForegroundColor Green "`n### Installing msys64 ###`n" - # Install specific version of msys2. See https://github.com/open62541/open62541/issues/3233 - & choco install -y msys2 --version 20180531.0.0 --no-progress --params="/InstallDir:$env:MSYS2_ROOT /NoUpdate /NoPath" + & choco install -y msys2 --no-progress --params="/InstallDir:$env:MSYS2_ROOT /NoUpdate /NoPath" + if ($LASTEXITCODE -and $LASTEXITCODE -ne 0) { + Write-Host -ForegroundColor Red "`n`n*** Install failed. Exiting ... ***" + exit $LASTEXITCODE + } Write-Host -ForegroundColor Green "`n### Installing mbedtls via PacMan ###`n" # pacman may complain that the directory does not exist, thus create it. # See https://github.com/open62541/open62541/issues/2068 & C:\msys64\usr\bin\mkdir -p /var/cache/pacman/pkg - & cmd /c 'C:\\msys64\\usr\\bin\\pacman 2>&1' --noconfirm --needed -S mingw-w64-x86_64-mbedtls + & C:\msys64\usr\bin\pacman --noconfirm --needed -S mingw-w64-x86_64-mbedtls + if ($LASTEXITCODE -and $LASTEXITCODE -ne 0) { + Write-Host -ForegroundColor Red "`n`n*** Install failed. Exiting ... ***" + exit $LASTEXITCODE + } - Write-Host -ForegroundColor Green "`n### Installing clang via PacMan ###`n" - & cmd /c 'C:\\msys64\\usr\\bin\\pacman 2>&1' --noconfirm --needed -S mingw-w64-x86_64-clang mingw-w64-i686-clang } elseif ($env:CC_SHORTNAME -eq "vs2015" -or $env:CC_SHORTNAME -eq "vs2017") { Write-Host -ForegroundColor Green "`n### Installing mbedtls via vcpkg ###`n" & vcpkg install mbedtls:x86-windows-static + if ($LASTEXITCODE -and $LASTEXITCODE -ne 0) { + Write-Host -ForegroundColor Red "`n`n*** Install failed. Exiting ... ***" + exit $LASTEXITCODE + } Write-Host -ForegroundColor Green "`n### Installing libcheck via vcpkg ###`n" & vcpkg install check:x86-windows-static + if ($LASTEXITCODE -and $LASTEXITCODE -ne 0) { + Write-Host -ForegroundColor Red "`n`n*** Install failed. Exiting ... ***" + exit $LASTEXITCODE + } Write-Host -ForegroundColor Green "`n### Installing DrMemory ###`n" - # 12. March 2020: Hardcode Dr Memory Version to 2.2. Otherwise it fails with - # "Failed to take over all threads after multiple attempts." - # See: https://dev.azure.com/open62541/open62541/_build/results?buildId=1242&view=logs&j=0690d606-4da6-5fc6-313c-2fce474be087&t=6290dcff-a4f0-5630-9345-7cbc0279a890&l=1871 - & choco install -y --no-progress drmemory.portable --version 2.2.0 - $env:Path = 'C:\Program Files (x86)\Dr. Memory\bin;' + $env:Path + & choco install -y --no-progress drmemory.portable + if ($LASTEXITCODE -and $LASTEXITCODE -ne 0) { + Write-Host -ForegroundColor Red "`n`n*** Install failed. Exiting ... ***" + exit $LASTEXITCODE + } + #$env:Path = 'C:\Program Files (x86)\Dr. Memory\bin;' + $env:Path + #[System.Environment]::SetEnvironmentVariable('Path', $path, 'Machine') } if ($LASTEXITCODE -and $LASTEXITCODE -ne 0) {