From 86ecd6008da3b0b0baa0833fd8932e91994a9f9b Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Fri, 28 Jun 2019 15:11:27 +0200 Subject: [PATCH 01/11] fuzzers: provide test targets Instead of having to find the fuzzer executables in our Azure test scripts, provide test targets for each of our fuzzers that will run them with the correct paths. --- ci/test.sh | 4 +--- fuzzers/CMakeLists.txt | 4 ++++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/ci/test.sh b/ci/test.sh index 9e12f53c3..cbc3925a9 100755 --- a/ci/test.sh +++ b/ci/test.sh @@ -256,9 +256,7 @@ if [ -z "$SKIP_FUZZERS" ]; then echo "## Running fuzzers" echo "##############################################################################" - for fuzzer in fuzzers/*_fuzzer; do - "${fuzzer}" "${SOURCE_DIR}/fuzzers/corpora/$(basename "${fuzzer%_fuzzer}")" || failure - done + ctest -V -R 'fuzzer' fi cleanup diff --git a/fuzzers/CMakeLists.txt b/fuzzers/CMakeLists.txt index 1c03aa980..59eca24d0 100644 --- a/fuzzers/CMakeLists.txt +++ b/fuzzers/CMakeLists.txt @@ -9,6 +9,8 @@ ENDIF () FILE(GLOB SRC_FUZZ RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *_fuzzer.c) FOREACH(fuzz_target_src ${SRC_FUZZ}) STRING(REPLACE ".c" "" fuzz_target_name ${fuzz_target_src}) + STRING(REPLACE "_fuzzer" "" fuzz_name ${fuzz_target_name}) + SET(${fuzz_target_name}_SOURCES ${fuzz_target_src} ${LIBGIT2_OBJECTS}) IF(USE_STANDALONE_FUZZERS) LIST(APPEND ${fuzz_target_name}_SOURCES "standalone_driver.c") @@ -16,4 +18,6 @@ FOREACH(fuzz_target_src ${SRC_FUZZ}) ADD_EXECUTABLE(${fuzz_target_name} ${${fuzz_target_name}_SOURCES}) SET_TARGET_PROPERTIES(${fuzz_target_name} PROPERTIES C_STANDARD 90) TARGET_LINK_LIBRARIES(${fuzz_target_name} ${LIBGIT2_LIBS}) + + ADD_TEST(${fuzz_target_name} "${CMAKE_CURRENT_BINARY_DIR}/${fuzz_target_name}" "${CMAKE_CURRENT_SOURCE_DIR}/corpora/${fuzz_name}") ENDFOREACH() From fe3b5da3ec9bfbca9f2d17ab6d3eddf39516c9c7 Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Fri, 19 Jul 2019 12:43:55 +0200 Subject: [PATCH 02/11] clar: provide ability to set summary file via environment As different test suites for our CI are mostly defined via CMake, it's hard to run those tests with a summary file path as that'd require us to add another parameter to all unit tests. As we do not want to unconditionally run unit tests with a summary file, we would have to add another CMake build parameter for test execution, which is ugly. Instead, implement a way to provide a summary file path via the environment. --- tests/clar.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tests/clar.c b/tests/clar.c index 7c308dd34..ead13f46a 100644 --- a/tests/clar.c +++ b/tests/clar.c @@ -145,7 +145,7 @@ static struct { int report_suite_names; int write_summary; - const char *summary_filename; + char *summary_filename; struct clar_summary *summary; struct clar_explicit *explicit; @@ -474,8 +474,8 @@ clar_parse_args(int argc, char **argv) case 'r': _clar.write_summary = 1; - _clar.summary_filename = *(argument + 2) ? (argument + 2) : - "summary.xml"; + free(_clar.summary_filename); + _clar.summary_filename = strdup(*(argument + 2) ? (argument + 2) : "summary.xml"); break; default: @@ -493,6 +493,11 @@ clar_test_init(int argc, char **argv) "" ); + if ((_clar.summary_filename = getenv("CLAR_SUMMARY")) != NULL) { + _clar.write_summary = 1; + _clar.summary_filename = strdup(_clar.summary_filename); + } + if (argc > 1) clar_parse_args(argc, argv); @@ -553,6 +558,8 @@ clar_test_shutdown(void) report_next = report->next; free(report); } + + free(_clar.summary_filename); } int From d827b11b670f3331e5d924eadfe35c497b08035a Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Fri, 28 Jun 2019 13:20:54 +0200 Subject: [PATCH 03/11] tests: execute leak checker via CTest directly Right now, we have an awful hack in our test CI setup that extracts the test command from CTest's output and then prepends the leak checker. This is dependent on non-machine-parseable output from CMake and also breaks on various ocassions, like for example when we have spaces in the current path or when the path contains backslashes. Both conditions may easily be triggered on Win32 systems, and in fact they do break our Azure Pipelines builds. Remove the awful hack in favour of a new CMake build option "USE_LEAK_CHECKER". If specifying e.g. "-DUSE_LEAK_CHECKER=valgrind", then we will set up all tests to be run under valgrind. Like this, we can again simply execute ctest without needing to rely on evil sourcery. --- CMakeLists.txt | 1 + azure-pipelines.yml | 15 ++++-------- azure-pipelines/nightly.yml | 21 ++++++----------- ci/test.sh | 28 ++--------------------- script/leaks.sh | 6 +++++ script/valgrind.sh | 2 ++ libgit2_clar.supp => script/valgrind.supp | 0 tests/CMakeLists.txt | 20 +++++++++++----- 8 files changed, 37 insertions(+), 56 deletions(-) create mode 100755 script/leaks.sh create mode 100755 script/valgrind.sh rename libgit2_clar.supp => script/valgrind.supp (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 292fadd3c..6e6443a0c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -57,6 +57,7 @@ OPTION(USE_HTTPS "Enable HTTPS support. Can be set to a specific backend" ON) OPTION(USE_SHA1 "Enable SHA1. Can be set to CollisionDetection(ON)/HTTPS/Generic" ON) OPTION(USE_GSSAPI "Link with libgssapi for SPNEGO auth" OFF) OPTION(USE_STANDALONE_FUZZERS "Enable standalone fuzzers (compatible with gcc)" OFF) +OPTION(USE_LEAK_CHECKER "Run tests with leak checker" OFF) OPTION(VALGRIND "Configure build for valgrind" OFF) OPTION(DEBUG_POOL "Enable debug pool allocator" OFF) OPTION(ENABLE_WERROR "Enable compilation with -Werror" OFF) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 959960f07..0f92df38c 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -16,8 +16,7 @@ jobs: imageName: 'libgit2/trusty-amd64:latest' environmentVariables: | CC=gcc - CMAKE_OPTIONS=-DUSE_HTTPS=OpenSSL -DREGEX_BACKEND=builtin -DDEPRECATE_HARD=ON - LEAK_CHECK=valgrind + CMAKE_OPTIONS=-DUSE_HTTPS=OpenSSL -DREGEX_BACKEND=builtin -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind - job: linux_amd64_trusty_gcc_mbedtls displayName: 'Linux (amd64; Trusty; GCC; mbedTLS)' @@ -29,8 +28,7 @@ jobs: imageName: 'libgit2/trusty-amd64:latest' environmentVariables: | CC=gcc - CMAKE_OPTIONS=-DUSE_HTTPS=mbedTLS -DUSE_SHA1=HTTPS -DDEPRECATE_HARD=ON - LEAK_CHECK=valgrind + CMAKE_OPTIONS=-DUSE_HTTPS=mbedTLS -DUSE_SHA1=HTTPS -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind - job: linux_amd64_trusty_clang_openssl displayName: 'Linux (amd64; Trusty; Clang; OpenSSL)' @@ -42,8 +40,7 @@ jobs: imageName: 'libgit2/trusty-amd64:latest' environmentVariables: | CC=clang - CMAKE_OPTIONS=-DUSE_HTTPS=OpenSSL -DDEPRECATE_HARD=ON - LEAK_CHECK=valgrind + CMAKE_OPTIONS=-DUSE_HTTPS=OpenSSL -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind - job: linux_amd64_trusty_clang_mbedtls displayName: 'Linux (amd64; Trusty; Clang; mbedTLS)' @@ -55,8 +52,7 @@ jobs: imageName: 'libgit2/trusty-amd64:latest' environmentVariables: | CC=clang - CMAKE_OPTIONS=-DUSE_HTTPS=mbedTLS -DUSE_SHA1=HTTPS -DREGEX_BACKEND=pcre -DDEPRECATE_HARD=ON - LEAK_CHECK=valgrind + CMAKE_OPTIONS=-DUSE_HTTPS=mbedTLS -DUSE_SHA1=HTTPS -DREGEX_BACKEND=pcre -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind - job: macos displayName: 'macOS' @@ -70,8 +66,7 @@ jobs: environmentVariables: TMPDIR: $(Agent.TempDirectory) PKG_CONFIG_PATH: /usr/local/opt/openssl/lib/pkgconfig - LEAK_CHECK: leaks - CMAKE_OPTIONS: -G Ninja -DREGEX_BACKEND=regcomp_l -DDEPRECATE_HARD=ON + CMAKE_OPTIONS: -G Ninja -DREGEX_BACKEND=regcomp_l -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=leaks SKIP_SSH_TESTS: true - job: windows_vs_amd64 diff --git a/azure-pipelines/nightly.yml b/azure-pipelines/nightly.yml index c2997160c..a79e92680 100644 --- a/azure-pipelines/nightly.yml +++ b/azure-pipelines/nightly.yml @@ -12,8 +12,7 @@ jobs: imageName: 'libgit2/trusty-amd64:latest' environmentVariables: | CC=gcc - CMAKE_OPTIONS=-DUSE_HTTPS=OpenSSL -DREGEX_BACKEND=builtin -DDEPRECATE_HARD=ON - LEAK_CHECK=valgrind + CMAKE_OPTIONS=-DUSE_HTTPS=OpenSSL -DREGEX_BACKEND=builtin -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind RUN_INVASIVE_TESTS=true - job: linux_amd64_trusty_gcc_mbedtls @@ -26,8 +25,7 @@ jobs: imageName: 'libgit2/trusty-amd64:latest' environmentVariables: | CC=gcc - CMAKE_OPTIONS=-DUSE_HTTPS=mbedTLS -DUSE_SHA1=HTTPS -DDEPRECATE_HARD=ON - LEAK_CHECK=valgrind + CMAKE_OPTIONS=-DUSE_HTTPS=mbedTLS -DUSE_SHA1=HTTPS -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind RUN_INVASIVE_TESTS=true - job: linux_amd64_trusty_clang_openssl @@ -40,8 +38,7 @@ jobs: imageName: 'libgit2/trusty-amd64:latest' environmentVariables: | CC=clang - CMAKE_OPTIONS=-DUSE_HTTPS=OpenSSL -DDEPRECATE_HARD=ON - LEAK_CHECK=valgrind + CMAKE_OPTIONS=-DUSE_HTTPS=OpenSSL -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind RUN_INVASIVE_TESTS=true - job: linux_amd64_trusty_clang_mbedtls @@ -54,8 +51,7 @@ jobs: imageName: 'libgit2/trusty-amd64:latest' environmentVariables: | CC=clang - CMAKE_OPTIONS=-DUSE_HTTPS=mbedTLS -DUSE_SHA1=HTTPS -DREGEX_BACKEND=pcre -DDEPRECATE_HARD=ON - LEAK_CHECK=valgrind + CMAKE_OPTIONS=-DUSE_HTTPS=mbedTLS -DUSE_SHA1=HTTPS -DREGEX_BACKEND=pcre -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind RUN_INVASIVE_TESTS=true - job: macos @@ -70,8 +66,7 @@ jobs: environmentVariables: TMPDIR: $(Agent.TempDirectory) PKG_CONFIG_PATH: /usr/local/opt/openssl/lib/pkgconfig - LEAK_CHECK: leaks - CMAKE_OPTIONS: -G Ninja -DREGEX_BACKEND=regcomp_l -DDEPRECATE_HARD=ON + CMAKE_OPTIONS: -G Ninja -DREGEX_BACKEND=regcomp_l -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=leaks RUN_INVASIVE_TESTS: true SKIP_SSH_TESTS: true @@ -139,8 +134,7 @@ jobs: imageName: 'libgit2/bionic-x86:latest' environmentVariables: | CC=gcc - CMAKE_OPTIONS=-DUSE_HTTPS=OpenSSL -DDEPRECATE_HARD=ON - LEAK_CHECK=valgrind + CMAKE_OPTIONS=-DUSE_HTTPS=OpenSSL -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind RUN_INVASIVE_TESTS=true - job: linux_x86_bionic_clang_openssl @@ -154,8 +148,7 @@ jobs: imageName: 'libgit2/bionic-x86:latest' environmentVariables: | CC=clang - CMAKE_OPTIONS=-DUSE_HTTPS=OpenSSL -DDEPRECATE_HARD=ON - LEAK_CHECK=valgrind + CMAKE_OPTIONS=-DUSE_HTTPS=OpenSSL -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind RUN_INVASIVE_TESTS=true - job: linux_arm32_bionic_gcc_openssl diff --git a/ci/test.sh b/ci/test.sh index cbc3925a9..69b4273a5 100755 --- a/ci/test.sh +++ b/ci/test.sh @@ -13,9 +13,6 @@ USER=${USER:-$(whoami)} SUCCESS=1 -VALGRIND="valgrind --leak-check=full --show-reachable=yes --error-exitcode=125 --num-callers=50 --suppressions=\"$SOURCE_DIR/libgit2_clar.supp\"" -LEAKS="MallocStackLogging=1 MallocScribble=1 MallocLogFile=/dev/null CLAR_AT_EXIT=\"leaks -quiet \$PPID\"" - cleanup() { echo "Cleaning up..." @@ -32,29 +29,7 @@ cleanup() { echo "Done." } -# Ask ctest what it would run if we were to invoke it directly. This lets -# us manage the test configuration in a single place (tests/CMakeLists.txt) -# instead of running clar here as well. But it allows us to wrap our test -# harness with a leak checker like valgrind. Append the option to write -# JUnit-style XML files. run_test() { - TEST_CMD=$(ctest -N -V -R "^${1}$" | sed -n 's/^[0-9]*: Test command: //p') - - if [ -z "$TEST_CMD" ]; then - echo "Could not find tests: $1" - exit 1 - fi - - TEST_CMD="${TEST_CMD} -r${BUILD_DIR}/results_${1}.xml" - - if [ "$LEAK_CHECK" = "valgrind" ]; then - RUNNER="$VALGRIND $TEST_CMD" - elif [ "$LEAK_CHECK" = "leaks" ]; then - RUNNER="$LEAKS $TEST_CMD" - else - RUNNER="$TEST_CMD" - fi - if [[ "$GITTEST_FLAKY_RETRY" > 0 ]]; then ATTEMPTS_REMAIN=$GITTEST_FLAKY_RETRY else @@ -70,7 +45,8 @@ run_test() { fi RETURN_CODE=0 - eval $RUNNER || RETURN_CODE=$? && true + + CLAR_SUMMARY="${BUILD_DIR}/results_${1}.xml" ctest -V -R "^${1}$" || RETURN_CODE=$? && true if [ "$RETURN_CODE" -eq 0 ]; then break diff --git a/script/leaks.sh b/script/leaks.sh new file mode 100755 index 000000000..efeead516 --- /dev/null +++ b/script/leaks.sh @@ -0,0 +1,6 @@ +#!/bin/sh +export MallocStackLogging=1 +export MallocScribble=1 +export MallocLogFile=/dev/null +export CLAR_AT_EXIT="leaks -quiet \$PPID" +exec "$@" diff --git a/script/valgrind.sh b/script/valgrind.sh new file mode 100755 index 000000000..b5deed2b0 --- /dev/null +++ b/script/valgrind.sh @@ -0,0 +1,2 @@ +#!/bin/bash +exec valgrind --leak-check=full --show-reachable=yes --error-exitcode=125 --num-callers=50 --suppressions="$(dirname "${BASH_SOURCE[0]}")/valgrind.supp" "$@" diff --git a/libgit2_clar.supp b/script/valgrind.supp similarity index 100% rename from libgit2_clar.supp rename to script/valgrind.supp diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index e39fd6f7b..a97e8fe21 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -57,9 +57,17 @@ IF (MSVC_IDE) SET_SOURCE_FILES_PROPERTIES("precompiled.c" COMPILE_FLAGS "/Ycprecompiled.h") ENDIF () -ADD_TEST(offline "${libgit2_BINARY_DIR}/libgit2_clar" -v -xonline) -ADD_TEST(invasive "${libgit2_BINARY_DIR}/libgit2_clar" -v -score::ftruncate -sfilter::stream::bigfile -sodb::largefiles -siterator::workdir::filesystem_gunk -srepo::init -srepo::init::at_filesystem_root) -ADD_TEST(online "${libgit2_BINARY_DIR}/libgit2_clar" -v -sonline) -ADD_TEST(gitdaemon "${libgit2_BINARY_DIR}/libgit2_clar" -v -sonline::push) -ADD_TEST(ssh "${libgit2_BINARY_DIR}/libgit2_clar" -v -sonline::push -sonline::clone::ssh_cert -sonline::clone::ssh_with_paths) -ADD_TEST(proxy "${libgit2_BINARY_DIR}/libgit2_clar" -v -sonline::clone::proxy) +FUNCTION(ADD_CLAR_TEST name) + IF (NOT USE_LEAK_CHECKER STREQUAL "OFF") + ADD_TEST(${name} "${libgit2_SOURCE_DIR}/script/${USE_LEAK_CHECKER}.sh" "${libgit2_BINARY_DIR}/libgit2_clar" ${ARGN}) + ELSE() + ADD_TEST(${name} "${libgit2_BINARY_DIR}/libgit2_clar" ${ARGN}) + ENDIF() +ENDFUNCTION(ADD_CLAR_TEST) + +ADD_CLAR_TEST(offline -v -xonline) +ADD_CLAR_TEST(invasive -v -score::ftruncate -sfilter::stream::bigfile -sodb::largefiles -siterator::workdir::filesystem_gunk -srepo::init -srepo::init::at_filesystem_root) +ADD_CLAR_TEST(online -v -sonline) +ADD_CLAR_TEST(gitdaemon -v -sonline::push) +ADD_CLAR_TEST(ssh -v -sonline::push -sonline::clone::ssh_cert -sonline::clone::ssh_with_paths) +ADD_CLAR_TEST(proxy -v -sonline::clone::proxy) From ffac520e8301ed83fb229dec7393898bf00df423 Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Mon, 24 Jun 2019 16:19:35 +0200 Subject: [PATCH 04/11] azure: move build scripts into "azure-pipelines" directory Since we have migrated to Azure Pipelines, we have deprecated and subsequentally removed all infrastructure for AppVeyor and Travis. Thus it doesn't make a lot of sense to have the split between "ci/" and "azure-pipelines/" directories anymoer, as "azure-pipelines/" is essentially our only CI. Move all CI scripts into the "azure-pipelines/" directory to have everything centrally located and to remove clutter in the top-level directory. --- azure-pipelines.yml | 6 +++--- azure-pipelines/bash.yml | 4 ++-- {ci => azure-pipelines}/build.ps1 | 0 {ci => azure-pipelines}/build.sh | 0 {ci => azure-pipelines}/coverity-build.sh | 0 {ci => azure-pipelines}/coverity-publish.sh | 0 azure-pipelines/coverity.yml | 4 ++-- azure-pipelines/docker.yml | 4 ++-- azure-pipelines/nightly.yml | 6 +++--- azure-pipelines/powershell.yml | 4 ++-- {ci => azure-pipelines}/setup-linux.sh | 0 {ci => azure-pipelines}/setup-mingw.ps1 | 0 {ci => azure-pipelines}/setup-osx.sh | 0 {ci => azure-pipelines}/test.ps1 | 0 {ci => azure-pipelines}/test.sh | 0 15 files changed, 14 insertions(+), 14 deletions(-) rename {ci => azure-pipelines}/build.ps1 (100%) rename {ci => azure-pipelines}/build.sh (100%) rename {ci => azure-pipelines}/coverity-build.sh (100%) rename {ci => azure-pipelines}/coverity-publish.sh (100%) rename {ci => azure-pipelines}/setup-linux.sh (100%) rename {ci => azure-pipelines}/setup-mingw.ps1 (100%) rename {ci => azure-pipelines}/setup-osx.sh (100%) rename {ci => azure-pipelines}/test.ps1 (100%) rename {ci => azure-pipelines}/test.sh (100%) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 0f92df38c..397e377ff 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -59,7 +59,7 @@ jobs: pool: vmImage: 'macOS 10.13' steps: - - bash: . '$(Build.SourcesDirectory)/ci/setup-osx.sh' + - bash: . '$(Build.SourcesDirectory)/azure-pipelines/setup-osx.sh' displayName: Setup - template: azure-pipelines/bash.yml parameters: @@ -91,7 +91,7 @@ jobs: displayName: 'Windows (amd64; MinGW)' pool: Hosted steps: - - powershell: . '$(Build.SourcesDirectory)\ci\setup-mingw.ps1' + - powershell: . '$(Build.SourcesDirectory)\azure-pipelines\setup-mingw.ps1' displayName: Setup env: TEMP: $(Agent.TempDirectory) @@ -106,7 +106,7 @@ jobs: displayName: 'Windows (x86; MinGW)' pool: Hosted steps: - - powershell: . '$(Build.SourcesDirectory)\ci\setup-mingw.ps1' + - powershell: . '$(Build.SourcesDirectory)\azure-pipelines\setup-mingw.ps1' displayName: Setup workingDirectory: '$(Build.BinariesDirectory)' env: diff --git a/azure-pipelines/bash.yml b/azure-pipelines/bash.yml index d776a3649..33a442b57 100644 --- a/azure-pipelines/bash.yml +++ b/azure-pipelines/bash.yml @@ -1,10 +1,10 @@ # These are the steps used for building on machines with bash. steps: -- bash: . '$(Build.SourcesDirectory)/ci/build.sh' +- bash: . '$(Build.SourcesDirectory)/azure-pipelines/build.sh' displayName: Build workingDirectory: '$(Build.BinariesDirectory)' env: ${{ parameters.environmentVariables }} -- bash: . '$(Build.SourcesDirectory)/ci/test.sh' +- bash: . '$(Build.SourcesDirectory)/azure-pipelines/test.sh' displayName: Test workingDirectory: '$(Build.BinariesDirectory)' env: ${{ parameters.environmentVariables }} diff --git a/ci/build.ps1 b/azure-pipelines/build.ps1 similarity index 100% rename from ci/build.ps1 rename to azure-pipelines/build.ps1 diff --git a/ci/build.sh b/azure-pipelines/build.sh similarity index 100% rename from ci/build.sh rename to azure-pipelines/build.sh diff --git a/ci/coverity-build.sh b/azure-pipelines/coverity-build.sh similarity index 100% rename from ci/coverity-build.sh rename to azure-pipelines/coverity-build.sh diff --git a/ci/coverity-publish.sh b/azure-pipelines/coverity-publish.sh similarity index 100% rename from ci/coverity-publish.sh rename to azure-pipelines/coverity-publish.sh diff --git a/azure-pipelines/coverity.yml b/azure-pipelines/coverity.yml index d8d34229e..d8c6b3f66 100644 --- a/azure-pipelines/coverity.yml +++ b/azure-pipelines/coverity.yml @@ -18,7 +18,7 @@ jobs: envVars: | COVERITY_TOKEN=$(COVERITY_TOKEN) workDir: '/build' - containerCommand: '/src/ci/coverity-build.sh' + containerCommand: '/src/azure-pipelines/coverity-build.sh' detached: false - task: Docker@0 displayName: Publish @@ -31,6 +31,6 @@ jobs: envVars: | COVERITY_TOKEN=$(COVERITY_TOKEN) workDir: '/build' - containerCommand: '/src/ci/coverity-publish.sh' + containerCommand: '/src/azure-pipelines/coverity-publish.sh' detached: false continueOnError: true diff --git a/azure-pipelines/docker.yml b/azure-pipelines/docker.yml index 2744a63ae..2bbe686cd 100644 --- a/azure-pipelines/docker.yml +++ b/azure-pipelines/docker.yml @@ -14,7 +14,7 @@ steps: $(Build.BinariesDirectory):/build envVars: ${{ parameters.environmentVariables }} workDir: '/build' - containerCommand: '/src/ci/build.sh' + containerCommand: '/src/azure-pipelines/build.sh' detached: false - task: docker@0 displayName: Test @@ -26,7 +26,7 @@ steps: $(Build.BinariesDirectory):/build envVars: ${{ parameters.environmentVariables }} workDir: '/build' - containerCommand: '/src/ci/test.sh' + containerCommand: '/src/azure-pipelines/test.sh' detached: false - task: publishtestresults@2 displayName: Publish Test Results diff --git a/azure-pipelines/nightly.yml b/azure-pipelines/nightly.yml index a79e92680..8b2868f1c 100644 --- a/azure-pipelines/nightly.yml +++ b/azure-pipelines/nightly.yml @@ -59,7 +59,7 @@ jobs: pool: vmImage: 'macOS 10.13' steps: - - bash: . '$(Build.SourcesDirectory)/ci/setup-osx.sh' + - bash: . '$(Build.SourcesDirectory)/azure-pipelines/setup-osx.sh' displayName: Setup - template: bash.yml parameters: @@ -94,7 +94,7 @@ jobs: displayName: 'Windows (amd64; MinGW)' pool: Hosted steps: - - powershell: . '$(Build.SourcesDirectory)\ci\setup-mingw.ps1' + - powershell: . '$(Build.SourcesDirectory)\azure-pipelines\setup-mingw.ps1' displayName: Setup env: TEMP: $(Agent.TempDirectory) @@ -110,7 +110,7 @@ jobs: displayName: 'Windows (x86; MinGW)' pool: Hosted steps: - - powershell: . '$(Build.SourcesDirectory)\ci\setup-mingw.ps1' + - powershell: . '$(Build.SourcesDirectory)\azure-pipelines\setup-mingw.ps1' displayName: Setup workingDirectory: '$(Build.BinariesDirectory)' env: diff --git a/azure-pipelines/powershell.yml b/azure-pipelines/powershell.yml index a2eb175d5..96da4eaaa 100644 --- a/azure-pipelines/powershell.yml +++ b/azure-pipelines/powershell.yml @@ -1,10 +1,10 @@ # These are the steps used for building on machines with PowerShell. steps: -- powershell: . '$(Build.SourcesDirectory)\ci\build.ps1' +- powershell: . '$(Build.SourcesDirectory)\azure-pipelines\build.ps1' displayName: Build workingDirectory: '$(Build.BinariesDirectory)' env: ${{ parameters.environmentVariables }} -- powershell: . '$(Build.SourcesDirectory)\ci\test.ps1' +- powershell: . '$(Build.SourcesDirectory)\azure-pipelines\test.ps1' displayName: Test workingDirectory: '$(Build.BinariesDirectory)' env: ${{ parameters.environmentVariables }} diff --git a/ci/setup-linux.sh b/azure-pipelines/setup-linux.sh similarity index 100% rename from ci/setup-linux.sh rename to azure-pipelines/setup-linux.sh diff --git a/ci/setup-mingw.ps1 b/azure-pipelines/setup-mingw.ps1 similarity index 100% rename from ci/setup-mingw.ps1 rename to azure-pipelines/setup-mingw.ps1 diff --git a/ci/setup-osx.sh b/azure-pipelines/setup-osx.sh similarity index 100% rename from ci/setup-osx.sh rename to azure-pipelines/setup-osx.sh diff --git a/ci/test.ps1 b/azure-pipelines/test.ps1 similarity index 100% rename from ci/test.ps1 rename to azure-pipelines/test.ps1 diff --git a/ci/test.sh b/azure-pipelines/test.sh similarity index 100% rename from ci/test.sh rename to azure-pipelines/test.sh From d8e85d57ad0e681a78a7d2a98f6ba425143a41f6 Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Thu, 27 Jun 2019 15:01:24 +0200 Subject: [PATCH 05/11] azure: fix building in MinGW via Bash Azure Pipelines supports bash tasks on Windows hosts due to it always having Git for Windows included. To support this, the Git for Window directory is added to the PATH environment to make the bash shell available for execution. Unfortunately, this breaks CMake with the MinGW generator, as it has sanity checks to verify that no bash executable is in the PATH. So we can either remove Git for Windows from the path, but then we're unable to execute bash jobs. Or we can add it to the path, but then we're unable to execute CMake with the MinGW generator. Let's re-model how we set the PATH environment. Instead of setting up PATH for the complete build job, we now set a variable "BUILD_PATH" for the job. This variable is only being used when executing CMake so that it encounters a sanitizied PATH environment without GfW's bash shell. --- azure-pipelines.yml | 4 ++-- azure-pipelines/build.sh | 8 +++++--- azure-pipelines/nightly.yml | 4 ++-- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 397e377ff..7f491e0e1 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -99,8 +99,8 @@ jobs: - template: azure-pipelines/powershell.yml parameters: environmentVariables: + BUILD_PATH: $(Agent.TempDirectory)\mingw64\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files (x86)\CMake\bin CMAKE_OPTIONS: -G"MinGW Makefiles" -DDEPRECATE_HARD=ON - PATH: $(Agent.TempDirectory)\mingw64\bin;C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\CMake\bin - job: windows_mingw_x86 displayName: 'Windows (x86; MinGW)' @@ -115,8 +115,8 @@ jobs: - template: azure-pipelines/powershell.yml parameters: environmentVariables: + BUILD_PATH: $(Agent.TempDirectory)\mingw32\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files (x86)\CMake\bin CMAKE_OPTIONS: -G"MinGW Makefiles" -DDEPRECATE_HARD=ON - PATH: $(Agent.TempDirectory)\mingw32\bin;C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\CMake\bin - job: documentation displayName: 'Generate Documentation' diff --git a/azure-pipelines/build.sh b/azure-pipelines/build.sh index 7ffa610ae..319666b18 100755 --- a/azure-pipelines/build.sh +++ b/azure-pipelines/build.sh @@ -9,7 +9,9 @@ set -e SOURCE_DIR=${SOURCE_DIR:-$( cd "$( dirname "${BASH_SOURCE[0]}" )" && dirname $( pwd ) )} BUILD_DIR=$(pwd) +BUILD_PATH=${BUILD_PATH:=$PATH} CC=${CC:-cc} +CMAKE=$(which cmake) indent() { sed "s/^/ /"; } @@ -31,7 +33,7 @@ echo "Kernel version:" uname -a 2>&1 | indent echo "CMake version:" -cmake --version 2>&1 | indent +env PATH="$BUILD_PATH" "$CMAKE" --version 2>&1 | indent echo "Compiler version:" $CC --version 2>&1 | indent echo "" @@ -41,11 +43,11 @@ echo "## Configuring build environment" echo "##############################################################################" echo cmake ${SOURCE_DIR} -DENABLE_WERROR=ON -DBUILD_EXAMPLES=ON -DBUILD_FUZZERS=ON -DUSE_STANDALONE_FUZZERS=ON ${CMAKE_OPTIONS} -cmake ${SOURCE_DIR} -DENABLE_WERROR=ON -DBUILD_EXAMPLES=ON -DBUILD_FUZZERS=ON -DUSE_STANDALONE_FUZZERS=ON ${CMAKE_OPTIONS} +env PATH="$BUILD_PATH" "$CMAKE" ${SOURCE_DIR} -DENABLE_WERROR=ON -DBUILD_EXAMPLES=ON -DBUILD_FUZZERS=ON -DUSE_STANDALONE_FUZZERS=ON ${CMAKE_OPTIONS} echo "" echo "##############################################################################" echo "## Building libgit2" echo "##############################################################################" -cmake --build . +env PATH="$BUILD_PATH" "$CMAKE" --build . diff --git a/azure-pipelines/nightly.yml b/azure-pipelines/nightly.yml index 8b2868f1c..78e93f615 100644 --- a/azure-pipelines/nightly.yml +++ b/azure-pipelines/nightly.yml @@ -102,8 +102,8 @@ jobs: - template: powershell.yml parameters: environmentVariables: + BUILD_PATH: $(Agent.TempDirectory)\mingw64\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files (x86)\CMake\bin CMAKE_OPTIONS: -G"MinGW Makefiles" -DDEPRECATE_HARD=ON - PATH: $(Agent.TempDirectory)\mingw64\bin;C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\CMake\bin RUN_INVASIVE_TESTS: true - job: windows_mingw_x86 @@ -119,8 +119,8 @@ jobs: - template: powershell.yml parameters: environmentVariables: + BUILD_PATH: $(Agent.TempDirectory)\mingw32\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files (x86)\CMake\bin CMAKE_OPTIONS: -G"MinGW Makefiles" -DDEPRECATE_HARD=ON - PATH: $(Agent.TempDirectory)\mingw32\bin;C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\CMake\bin RUN_INVASIVE_TESTS: true - job: linux_x86_bionic_gcc_openssl From 443df2dffd9d6973a6d7219f1de75c66453ffbdb Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Mon, 24 Jun 2019 16:27:00 +0200 Subject: [PATCH 06/11] azure: replace mingw setup with bash We're about to phase out our Powershell scripts as Azure Pipelines does in fact support Bash scripts on all platforms. As a preparatory step, let's replace our MinGW setup script with a Bash script. --- azure-pipelines.yml | 4 ++-- azure-pipelines/nightly.yml | 4 ++-- azure-pipelines/setup-mingw.ps1 | 25 ------------------------- azure-pipelines/setup-mingw.sh | 15 +++++++++++++++ 4 files changed, 19 insertions(+), 29 deletions(-) delete mode 100644 azure-pipelines/setup-mingw.ps1 create mode 100755 azure-pipelines/setup-mingw.sh diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 7f491e0e1..98e809766 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -91,7 +91,7 @@ jobs: displayName: 'Windows (amd64; MinGW)' pool: Hosted steps: - - powershell: . '$(Build.SourcesDirectory)\azure-pipelines\setup-mingw.ps1' + - bash: . '$(Build.SourcesDirectory)\azure-pipelines\setup-mingw.sh' displayName: Setup env: TEMP: $(Agent.TempDirectory) @@ -106,7 +106,7 @@ jobs: displayName: 'Windows (x86; MinGW)' pool: Hosted steps: - - powershell: . '$(Build.SourcesDirectory)\azure-pipelines\setup-mingw.ps1' + - bash: . '$(Build.SourcesDirectory)\azure-pipelines\setup-mingw.sh' displayName: Setup workingDirectory: '$(Build.BinariesDirectory)' env: diff --git a/azure-pipelines/nightly.yml b/azure-pipelines/nightly.yml index 78e93f615..c494037ef 100644 --- a/azure-pipelines/nightly.yml +++ b/azure-pipelines/nightly.yml @@ -94,7 +94,7 @@ jobs: displayName: 'Windows (amd64; MinGW)' pool: Hosted steps: - - powershell: . '$(Build.SourcesDirectory)\azure-pipelines\setup-mingw.ps1' + - bash: . '$(Build.SourcesDirectory)\azure-pipelines\setup-mingw.sh' displayName: Setup env: TEMP: $(Agent.TempDirectory) @@ -110,7 +110,7 @@ jobs: displayName: 'Windows (x86; MinGW)' pool: Hosted steps: - - powershell: . '$(Build.SourcesDirectory)\azure-pipelines\setup-mingw.ps1' + - bash: . '$(Build.SourcesDirectory)\azure-pipelines\setup-mingw.sh' displayName: Setup workingDirectory: '$(Build.BinariesDirectory)' env: diff --git a/azure-pipelines/setup-mingw.ps1 b/azure-pipelines/setup-mingw.ps1 deleted file mode 100644 index 76ecd3987..000000000 --- a/azure-pipelines/setup-mingw.ps1 +++ /dev/null @@ -1,25 +0,0 @@ -Set-StrictMode -Version Latest - -$ErrorActionPreference = "Stop" -$PSDefaultParameterValues['*:ErrorAction'] = 'Stop' - -[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 - -[Reflection.Assembly]::LoadWithPartialName("System.IO.Compression.FileSystem"); - -Write-Host "##############################################################################" -Write-Host "## Downloading mingw" -Write-Host "##############################################################################" - -if ($env:ARCH -eq "amd64") { - $mingw_uri = "https://bintray.com/libgit2/build-dependencies/download_file?file_path=mingw-w64-x86_64-8.1.0-release-win32-seh-rt_v6-rev0.zip" - $platform = "x86_64" -} else { - $mingw_uri = "https://bintray.com/libgit2/build-dependencies/download_file?file_path=mingw-w64-i686-8.1.0-release-win32-sjlj-rt_v6-rev0.zip" - $platform = "x86" -} - -$wc = New-Object net.webclient -$wc.Downloadfile($mingw_uri, "${Env:TEMP}/mingw-${Env:ARCH}.zip") - -[System.IO.Compression.ZipFile]::ExtractToDirectory("${Env:TEMP}/mingw-${Env:ARCH}.zip", $Env:TEMP) diff --git a/azure-pipelines/setup-mingw.sh b/azure-pipelines/setup-mingw.sh new file mode 100755 index 000000000..1172c2077 --- /dev/null +++ b/azure-pipelines/setup-mingw.sh @@ -0,0 +1,15 @@ +#!/bin/sh -e + +echo "##############################################################################" +echo "## Downloading mingw" +echo "##############################################################################" + +case "$ARCH" in + amd64) + MINGW_URI="https://bintray.com/libgit2/build-dependencies/download_file?file_path=mingw-w64-x86_64-8.1.0-release-win32-seh-rt_v6-rev0.zip";; + x86) + MINGW_URI="https://bintray.com/libgit2/build-dependencies/download_file?file_path=mingw-w64-i686-8.1.0-release-win32-sjlj-rt_v6-rev0.zip";; +esac + +curl -s -L "$MINGW_URI" -o "$TEMP"/mingw-"$ARCH".zip +unzip -q "$TEMP"/mingw-"$ARCH".zip -d "$TEMP" From 8e356f48f86495fb9efd76d422e22a4853f2bf67 Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Sat, 20 Jul 2019 18:35:20 +0200 Subject: [PATCH 07/11] azure: explicitly specify CMake generator We currently specify the CMake generator as part of the CMAKE_OPTIONS variable. This is fine in the current setup, but during the conversion to drop PowerShell scripts this will prove problematic for all generators that have spaces in their names due to quoting issues. Convert to use an explicit CMAKE_GENERATOR variable that makes it easier to get quoting right. --- azure-pipelines.yml | 19 ++++++++++++++----- azure-pipelines/build.ps1 | 2 +- azure-pipelines/build.sh | 4 ++-- azure-pipelines/nightly.yml | 23 ++++++++++++++++++----- 4 files changed, 35 insertions(+), 13 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 98e809766..abe0c3ebe 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -16,6 +16,7 @@ jobs: imageName: 'libgit2/trusty-amd64:latest' environmentVariables: | CC=gcc + CMAKE_GENERATOR=Unix Makefiles CMAKE_OPTIONS=-DUSE_HTTPS=OpenSSL -DREGEX_BACKEND=builtin -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind - job: linux_amd64_trusty_gcc_mbedtls @@ -28,6 +29,7 @@ jobs: imageName: 'libgit2/trusty-amd64:latest' environmentVariables: | CC=gcc + CMAKE_GENERATOR=Unix Makefiles CMAKE_OPTIONS=-DUSE_HTTPS=mbedTLS -DUSE_SHA1=HTTPS -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind - job: linux_amd64_trusty_clang_openssl @@ -40,6 +42,7 @@ jobs: imageName: 'libgit2/trusty-amd64:latest' environmentVariables: | CC=clang + CMAKE_GENERATOR=Unix Makefiles CMAKE_OPTIONS=-DUSE_HTTPS=OpenSSL -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind - job: linux_amd64_trusty_clang_mbedtls @@ -52,6 +55,7 @@ jobs: imageName: 'libgit2/trusty-amd64:latest' environmentVariables: | CC=clang + CMAKE_GENERATOR=Unix Makefiles CMAKE_OPTIONS=-DUSE_HTTPS=mbedTLS -DUSE_SHA1=HTTPS -DREGEX_BACKEND=pcre -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind - job: macos @@ -66,7 +70,8 @@ jobs: environmentVariables: TMPDIR: $(Agent.TempDirectory) PKG_CONFIG_PATH: /usr/local/opt/openssl/lib/pkgconfig - CMAKE_OPTIONS: -G Ninja -DREGEX_BACKEND=regcomp_l -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=leaks + CMAKE_GENERATOR: Ninja + CMAKE_OPTIONS: -DREGEX_BACKEND=regcomp_l -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=leaks SKIP_SSH_TESTS: true - job: windows_vs_amd64 @@ -76,7 +81,8 @@ jobs: - template: azure-pipelines/powershell.yml parameters: environmentVariables: - CMAKE_OPTIONS: -DMSVC_CRTDBG=ON -G"Visual Studio 12 2013 Win64" -DDEPRECATE_HARD=ON + CMAKE_GENERATOR: Visual Studio 12 2013 Win64 + CMAKE_OPTIONS: -DMSVC_CRTDBG=ON -DDEPRECATE_HARD=ON - job: windows_vs_x86 displayName: 'Windows (x86; Visual Studio)' @@ -85,7 +91,8 @@ jobs: - template: azure-pipelines/powershell.yml parameters: environmentVariables: - CMAKE_OPTIONS: -DMSVC_CRTDBG=ON -G"Visual Studio 12 2013" -DDEPRECATE_HARD=ON -DUSE_SHA1=HTTPS + CMAKE_GENERATOR: Visual Studio 12 2013 + CMAKE_OPTIONS: -DMSVC_CRTDBG=ON -DDEPRECATE_HARD=ON -DUSE_SHA1=HTTPS - job: windows_mingw_amd64 displayName: 'Windows (amd64; MinGW)' @@ -100,7 +107,8 @@ jobs: parameters: environmentVariables: BUILD_PATH: $(Agent.TempDirectory)\mingw64\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files (x86)\CMake\bin - CMAKE_OPTIONS: -G"MinGW Makefiles" -DDEPRECATE_HARD=ON + CMAKE_GENERATOR: MinGW Makefiles + CMAKE_OPTIONS: -DDEPRECATE_HARD=ON - job: windows_mingw_x86 displayName: 'Windows (x86; MinGW)' @@ -116,7 +124,8 @@ jobs: parameters: environmentVariables: BUILD_PATH: $(Agent.TempDirectory)\mingw32\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files (x86)\CMake\bin - CMAKE_OPTIONS: -G"MinGW Makefiles" -DDEPRECATE_HARD=ON + CMAKE_GENERATOR: MinGW Makefiles + CMAKE_OPTIONS: -DDEPRECATE_HARD=ON - job: documentation displayName: 'Generate Documentation' diff --git a/azure-pipelines/build.ps1 b/azure-pipelines/build.ps1 index dbc458dfc..96f39db4c 100644 --- a/azure-pipelines/build.ps1 +++ b/azure-pipelines/build.ps1 @@ -18,7 +18,7 @@ Write-Host "#################################################################### Write-Host "## Configuring build environment" Write-Host "##############################################################################" -Invoke-Expression "cmake ${SourceDirectory} -DBUILD_EXAMPLES=ON -DBUILD_FUZZERS=ON -DUSE_STANDALONE_FUZZERS=ON -DENABLE_WERROR=ON ${Env:CMAKE_OPTIONS}" +Invoke-Expression "cmake ${SourceDirectory} -DBUILD_EXAMPLES=ON -DBUILD_FUZZERS=ON -DUSE_STANDALONE_FUZZERS=ON -DENABLE_WERROR=ON -G '${Env:CMAKE_GENERATOR}' ${Env:CMAKE_OPTIONS}" if ($LastExitCode -ne 0) { [Environment]::Exit($LastExitCode) } Write-Host "" diff --git a/azure-pipelines/build.sh b/azure-pipelines/build.sh index 319666b18..ac4d37b77 100755 --- a/azure-pipelines/build.sh +++ b/azure-pipelines/build.sh @@ -42,8 +42,8 @@ echo "########################################################################## echo "## Configuring build environment" echo "##############################################################################" -echo cmake ${SOURCE_DIR} -DENABLE_WERROR=ON -DBUILD_EXAMPLES=ON -DBUILD_FUZZERS=ON -DUSE_STANDALONE_FUZZERS=ON ${CMAKE_OPTIONS} -env PATH="$BUILD_PATH" "$CMAKE" ${SOURCE_DIR} -DENABLE_WERROR=ON -DBUILD_EXAMPLES=ON -DBUILD_FUZZERS=ON -DUSE_STANDALONE_FUZZERS=ON ${CMAKE_OPTIONS} +echo cmake ${SOURCE_DIR} -DENABLE_WERROR=ON -DBUILD_EXAMPLES=ON -DBUILD_FUZZERS=ON -DUSE_STANDALONE_FUZZERS=ON -G \"${CMAKE_GENERATOR}\" ${CMAKE_OPTIONS} +env PATH="$BUILD_PATH" "$CMAKE" ${SOURCE_DIR} -DENABLE_WERROR=ON -DBUILD_EXAMPLES=ON -DBUILD_FUZZERS=ON -DUSE_STANDALONE_FUZZERS=ON -G "${CMAKE_GENERATOR}" ${CMAKE_OPTIONS} echo "" echo "##############################################################################" diff --git a/azure-pipelines/nightly.yml b/azure-pipelines/nightly.yml index c494037ef..b6d5ed842 100644 --- a/azure-pipelines/nightly.yml +++ b/azure-pipelines/nightly.yml @@ -12,6 +12,7 @@ jobs: imageName: 'libgit2/trusty-amd64:latest' environmentVariables: | CC=gcc + CMAKE_GENERATOR=Unix Makefiles CMAKE_OPTIONS=-DUSE_HTTPS=OpenSSL -DREGEX_BACKEND=builtin -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind RUN_INVASIVE_TESTS=true @@ -25,6 +26,7 @@ jobs: imageName: 'libgit2/trusty-amd64:latest' environmentVariables: | CC=gcc + CMAKE_GENERATOR=Unix Makefiles CMAKE_OPTIONS=-DUSE_HTTPS=mbedTLS -DUSE_SHA1=HTTPS -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind RUN_INVASIVE_TESTS=true @@ -38,6 +40,7 @@ jobs: imageName: 'libgit2/trusty-amd64:latest' environmentVariables: | CC=clang + CMAKE_GENERATOR=Unix Makefiles CMAKE_OPTIONS=-DUSE_HTTPS=OpenSSL -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind RUN_INVASIVE_TESTS=true @@ -51,6 +54,7 @@ jobs: imageName: 'libgit2/trusty-amd64:latest' environmentVariables: | CC=clang + CMAKE_GENERATOR=Unix Makefiles CMAKE_OPTIONS=-DUSE_HTTPS=mbedTLS -DUSE_SHA1=HTTPS -DREGEX_BACKEND=pcre -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind RUN_INVASIVE_TESTS=true @@ -66,7 +70,8 @@ jobs: environmentVariables: TMPDIR: $(Agent.TempDirectory) PKG_CONFIG_PATH: /usr/local/opt/openssl/lib/pkgconfig - CMAKE_OPTIONS: -G Ninja -DREGEX_BACKEND=regcomp_l -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=leaks + CMAKE_GENERATOR: Ninja + CMAKE_OPTIONS: -DREGEX_BACKEND=regcomp_l -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=leaks RUN_INVASIVE_TESTS: true SKIP_SSH_TESTS: true @@ -77,7 +82,8 @@ jobs: - template: powershell.yml parameters: environmentVariables: - CMAKE_OPTIONS: -DMSVC_CRTDBG=ON -G"Visual Studio 12 2013 Win64" -DDEPRECATE_HARD=ON + CMAKE_GENERATOR: Visual Studio 12 2013 Win64 + CMAKE_OPTIONS: -DMSVC_CRTDBG=ON -DDEPRECATE_HARD=ON RUN_INVASIVE_TESTS: true - job: windows_vs_x86 @@ -87,7 +93,8 @@ jobs: - template: powershell.yml parameters: environmentVariables: - CMAKE_OPTIONS: -DMSVC_CRTDBG=ON -G"Visual Studio 12 2013" -DDEPRECATE_HARD=ON -DUSE_SHA1=HTTPS + CMAKE_GENERATOR: Visual Studio 12 2013 + CMAKE_OPTIONS: -DMSVC_CRTDBG=ON -DDEPRECATE_HARD=ON -DUSE_SHA1=HTTPS RUN_INVASIVE_TESTS: true - job: windows_mingw_amd64 @@ -103,7 +110,8 @@ jobs: parameters: environmentVariables: BUILD_PATH: $(Agent.TempDirectory)\mingw64\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files (x86)\CMake\bin - CMAKE_OPTIONS: -G"MinGW Makefiles" -DDEPRECATE_HARD=ON + CMAKE_GENERATOR: MinGW Makefiles + CMAKE_OPTIONS: -DDEPRECATE_HARD=ON RUN_INVASIVE_TESTS: true - job: windows_mingw_x86 @@ -120,7 +128,8 @@ jobs: parameters: environmentVariables: BUILD_PATH: $(Agent.TempDirectory)\mingw32\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files (x86)\CMake\bin - CMAKE_OPTIONS: -G"MinGW Makefiles" -DDEPRECATE_HARD=ON + CMAKE_GENERATOR: MinGW Makefiles + CMAKE_OPTIONS: -DDEPRECATE_HARD=ON RUN_INVASIVE_TESTS: true - job: linux_x86_bionic_gcc_openssl @@ -134,6 +143,7 @@ jobs: imageName: 'libgit2/bionic-x86:latest' environmentVariables: | CC=gcc + CMAKE_GENERATOR=Unix Makefiles CMAKE_OPTIONS=-DUSE_HTTPS=OpenSSL -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind RUN_INVASIVE_TESTS=true @@ -148,6 +158,7 @@ jobs: imageName: 'libgit2/bionic-x86:latest' environmentVariables: | CC=clang + CMAKE_GENERATOR=Unix Makefiles CMAKE_OPTIONS=-DUSE_HTTPS=OpenSSL -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind RUN_INVASIVE_TESTS=true @@ -162,6 +173,7 @@ jobs: imageName: 'libgit2/bionic-arm32:latest' environmentVariables: | CC=gcc + CMAKE_GENERATOR=Unix Makefiles CMAKE_OPTIONS=-DUSE_HTTPS=OpenSSL -DDEPRECATE_HARD=ON RUN_INVASIVE_TESTS=true SKIP_PROXY_TESTS=true @@ -177,6 +189,7 @@ jobs: imageName: 'libgit2/bionic-arm64:latest' environmentVariables: | CC=gcc + CMAKE_GENERATOR=Unix Makefiles CMAKE_OPTIONS=-DUSE_HTTPS=OpenSSL -DDEPRECATE_HARD=ON RUN_INVASIVE_TESTS=true SKIP_PROXY_TESTS=true From 1be4f896bd8c33e0acb8bcf5eda1f6d844c81c14 Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Fri, 19 Jul 2019 12:07:59 +0200 Subject: [PATCH 08/11] azure: avoid executing compiler if there is none Until now, we always had the CC variable defined in the build.sh pipeline. But as we're about to migrate the Windows jobs to Bash, as well, those will not have CC defined and thus we cannot use "$CC" to determine the compiler version. Fix this by only executing "$CC" if the variable was set. --- azure-pipelines/build.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/azure-pipelines/build.sh b/azure-pipelines/build.sh index ac4d37b77..6700d7bdb 100755 --- a/azure-pipelines/build.sh +++ b/azure-pipelines/build.sh @@ -10,7 +10,6 @@ set -e SOURCE_DIR=${SOURCE_DIR:-$( cd "$( dirname "${BASH_SOURCE[0]}" )" && dirname $( pwd ) )} BUILD_DIR=$(pwd) BUILD_PATH=${BUILD_PATH:=$PATH} -CC=${CC:-cc} CMAKE=$(which cmake) indent() { sed "s/^/ /"; } @@ -34,8 +33,11 @@ uname -a 2>&1 | indent echo "CMake version:" env PATH="$BUILD_PATH" "$CMAKE" --version 2>&1 | indent -echo "Compiler version:" -$CC --version 2>&1 | indent + +if test -n "$CC"; then + echo "Compiler version:" + "$CC" --version 2>&1 | indent +fi echo "" echo "##############################################################################" From 0cda525258c5b49c7b551db5905a103fee1237a3 Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Fri, 19 Jul 2019 12:09:58 +0200 Subject: [PATCH 09/11] azure: use bash scripts across all platforms Right now, we maintain semantically equivalent build scripts in both Bash and Powershell to support both Windows and non-Windows hosts. Azure Pipelines supports Bash on Windows, too, via Git for Windows, and as such it's not really required to maintain the Powershell scripts at all. Remove them to reduce our own maintenance burden. --- azure-pipelines.yml | 8 +- azure-pipelines/build.ps1 | 30 ------- azure-pipelines/nightly.yml | 8 +- azure-pipelines/powershell.yml | 17 ---- azure-pipelines/test.ps1 | 139 --------------------------------- 5 files changed, 8 insertions(+), 194 deletions(-) delete mode 100644 azure-pipelines/build.ps1 delete mode 100644 azure-pipelines/powershell.yml delete mode 100644 azure-pipelines/test.ps1 diff --git a/azure-pipelines.yml b/azure-pipelines.yml index abe0c3ebe..2d79dd3a6 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -78,7 +78,7 @@ jobs: displayName: 'Windows (amd64; Visual Studio)' pool: Hosted steps: - - template: azure-pipelines/powershell.yml + - template: azure-pipelines/bash.yml parameters: environmentVariables: CMAKE_GENERATOR: Visual Studio 12 2013 Win64 @@ -88,7 +88,7 @@ jobs: displayName: 'Windows (x86; Visual Studio)' pool: Hosted steps: - - template: azure-pipelines/powershell.yml + - template: azure-pipelines/bash.yml parameters: environmentVariables: CMAKE_GENERATOR: Visual Studio 12 2013 @@ -103,7 +103,7 @@ jobs: env: TEMP: $(Agent.TempDirectory) ARCH: amd64 - - template: azure-pipelines/powershell.yml + - template: azure-pipelines/bash.yml parameters: environmentVariables: BUILD_PATH: $(Agent.TempDirectory)\mingw64\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files (x86)\CMake\bin @@ -120,7 +120,7 @@ jobs: env: TEMP: $(Agent.TempDirectory) ARCH: x86 - - template: azure-pipelines/powershell.yml + - template: azure-pipelines/bash.yml parameters: environmentVariables: BUILD_PATH: $(Agent.TempDirectory)\mingw32\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files (x86)\CMake\bin diff --git a/azure-pipelines/build.ps1 b/azure-pipelines/build.ps1 deleted file mode 100644 index 96f39db4c..000000000 --- a/azure-pipelines/build.ps1 +++ /dev/null @@ -1,30 +0,0 @@ -Set-StrictMode -Version Latest - -$ErrorActionPreference = "Stop" -$PSDefaultParameterValues['*:ErrorAction'] = 'Stop' - -if ($Env:SOURCE_DIR) { $SourceDirectory = $Env:SOURCE_DIR } else { $SourceDirectory = Split-Path (Split-Path $MyInvocation.MyCommand.Path -Parent) -Parent } -$BuildDirectory = $(Get-Location).Path - -Write-Host "Source directory: ${SourceDirectory}" -Write-Host "Build directory: ${BuildDirectory}" -Write-Host "" -Write-Host "Operating system version:" -Get-CimInstance Win32_OperatingSystem | Select-Object Caption, Version, ServicePackMajorVersion, BuildNumber, OSArchitecture | Format-List -Write-Host "PATH: ${Env:PATH}" -Write-Host "" - -Write-Host "##############################################################################" -Write-Host "## Configuring build environment" -Write-Host "##############################################################################" - -Invoke-Expression "cmake ${SourceDirectory} -DBUILD_EXAMPLES=ON -DBUILD_FUZZERS=ON -DUSE_STANDALONE_FUZZERS=ON -DENABLE_WERROR=ON -G '${Env:CMAKE_GENERATOR}' ${Env:CMAKE_OPTIONS}" -if ($LastExitCode -ne 0) { [Environment]::Exit($LastExitCode) } - -Write-Host "" -Write-Host "##############################################################################" -Write-Host "## Building libgit2" -Write-Host "##############################################################################" - -cmake --build . -if ($LastExitCode -ne 0) { [Environment]::Exit($LastExitCode) } diff --git a/azure-pipelines/nightly.yml b/azure-pipelines/nightly.yml index b6d5ed842..eebc3eda9 100644 --- a/azure-pipelines/nightly.yml +++ b/azure-pipelines/nightly.yml @@ -79,7 +79,7 @@ jobs: displayName: 'Windows (amd64; Visual Studio)' pool: Hosted steps: - - template: powershell.yml + - template: bash.yml parameters: environmentVariables: CMAKE_GENERATOR: Visual Studio 12 2013 Win64 @@ -90,7 +90,7 @@ jobs: displayName: 'Windows (x86; Visual Studio)' pool: Hosted steps: - - template: powershell.yml + - template: bash.yml parameters: environmentVariables: CMAKE_GENERATOR: Visual Studio 12 2013 @@ -106,7 +106,7 @@ jobs: env: TEMP: $(Agent.TempDirectory) ARCH: amd64 - - template: powershell.yml + - template: bash.yml parameters: environmentVariables: BUILD_PATH: $(Agent.TempDirectory)\mingw64\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files (x86)\CMake\bin @@ -124,7 +124,7 @@ jobs: env: TEMP: $(Agent.TempDirectory) ARCH: x86 - - template: powershell.yml + - template: bash.yml parameters: environmentVariables: BUILD_PATH: $(Agent.TempDirectory)\mingw32\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files (x86)\CMake\bin diff --git a/azure-pipelines/powershell.yml b/azure-pipelines/powershell.yml deleted file mode 100644 index 96da4eaaa..000000000 --- a/azure-pipelines/powershell.yml +++ /dev/null @@ -1,17 +0,0 @@ -# These are the steps used for building on machines with PowerShell. -steps: -- powershell: . '$(Build.SourcesDirectory)\azure-pipelines\build.ps1' - displayName: Build - workingDirectory: '$(Build.BinariesDirectory)' - env: ${{ parameters.environmentVariables }} -- powershell: . '$(Build.SourcesDirectory)\azure-pipelines\test.ps1' - displayName: Test - workingDirectory: '$(Build.BinariesDirectory)' - env: ${{ parameters.environmentVariables }} -- task: PublishTestResults@2 - displayName: Publish Test Results - condition: succeededOrFailed() - inputs: - testResultsFiles: 'results_*.xml' - searchFolder: '$(Build.BinariesDirectory)' - mergeTestResults: true diff --git a/azure-pipelines/test.ps1 b/azure-pipelines/test.ps1 deleted file mode 100644 index 0c9e795f0..000000000 --- a/azure-pipelines/test.ps1 +++ /dev/null @@ -1,139 +0,0 @@ -Set-StrictMode -Version Latest - -$ErrorActionPreference = "Stop" -$PSDefaultParameterValues['*:ErrorAction'] = 'Stop' - -[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 - -$SourceDir = Split-Path (Split-Path (Get-Variable MyInvocation).Value.MyCommand.Path) -$BuildDir = Get-Location -$global:Success = $true - -if ($Env:SKIP_TESTS) { exit } - -# Ask ctest what it would run if we were to invoke it directly. This lets -# us manage the test configuration in a single place (tests/CMakeLists.txt) -# instead of running clar here as well. But it allows us to wrap our test -# harness with a leak checker like valgrind. Append the option to write -# JUnit-style XML files. -function run_test { - $TestName = $args[0] - - $TestCommand = (ctest -N -V -R "^$TestName$") -join "`n" - - if (-Not ($TestCommand -match "(?ms).*\n^[0-9]*: Test command: ")) { - echo "Could not find tests: $TestName" - exit - } - - $TestCommand = (ctest -N -V -R "^$TestName$") -join "`n" -replace "(?ms).*\n^[0-9]*: Test command: ","" -replace "\n.*","" - $TestCommand += " -r${BuildDir}\results_${TestName}.xml" - - if ($Env:GITTEST_FLAKY_RETRY -gt 0) { - $AttemptsRemain = $Env:GITTEST_FLAKY_RETRY - } else { - $AttemptsRemain = 1 - } - - $Failed = 0 - while ($AttemptsRemain -ne 0) { - if ($Failed -eq 1) { - Write-Host "" - Write-Host "Re-running flaky $TestName tests..." - Write-Host "" - } - - Invoke-Expression $TestCommand - if ($LastExitCode -eq 0) { - $Failed = 0 - break - } else { - $Failed = 1 - } - - $AttemptsRemain = $AttemptsRemain - 1 - } - - if ($Failed -eq 1) { $global:Success = $false } -} - -Write-Host "##############################################################################" -Write-Host "## Configuring test environment" -Write-Host "##############################################################################" - -if (-not $Env:SKIP_PROXY_TESTS) { - Invoke-WebRequest -Method GET -Uri https://github.com/ethomson/poxyproxy/releases/download/v0.7.0/poxyproxy-0.7.0.jar -OutFile poxyproxy.jar - - Write-Host "" - Write-Host "Starting HTTP proxy (Basic)..." - javaw -jar poxyproxy.jar --port 8080 --credentials foo:bar --auth-type basic --quiet - - Write-Host "" - Write-Host "Starting HTTP proxy (NTLM)..." - javaw -jar poxyproxy.jar --port 8090 --credentials foo:bar --auth-type ntlm --quiet -} - -if (-not $Env:SKIP_OFFLINE_TESTS) { - Write-Host "" - Write-Host "##############################################################################" - Write-Host "## Running (offline) tests" - Write-Host "##############################################################################" - - run_test offline -} - -if ($Env:RUN_INVASIVE_TESTS) { - Write-Host "" - Write-Host "##############################################################################" - Write-Host "## Running (invasive) tests" - Write-Host "##############################################################################" - - $Env:GITTEST_INVASIVE_FS_SIZE=1 - $Env:GITTEST_INVASIVE_MEMORY=1 - $Env:GITTEST_INVASIVE_SPEED=1 - run_test invasive - $Env:GITTEST_INVASIVE_FS_SIZE=$null - $Env:GITTEST_INVASIVE_MEMORY=$null - $Env:GITTEST_INVASIVE_SPEED=$null -} - -if (-not $Env:SKIP_ONLINE_TESTS) { - Write-Host "" - Write-Host "##############################################################################" - Write-Host "## Running (online) tests" - Write-Host "##############################################################################" - - $Env:GITTEST_FLAKY_RETRY=5 - run_test online - $Env:GITTEST_FLAKY_RETRY=0 -} - -if (-not $Env:SKIP_PROXY_TESTS) { - # Test HTTP Basic authentication - Write-Host "" - Write-Host "Running proxy tests (Basic authentication)" - Write-Host "" - - $Env:GITTEST_REMOTE_PROXY_HOST="localhost:8080" - $Env:GITTEST_REMOTE_PROXY_USER="foo" - $Env:GITTEST_REMOTE_PROXY_PASS="bar" - run_test proxy - - # Test NTLM authentication - Write-Host "" - Write-Host "Running proxy tests (NTLM authentication)" - Write-Host "" - - $Env:GITTEST_REMOTE_PROXY_HOST="localhost:8090" - $Env:GITTEST_REMOTE_PROXY_USER="foo" - $Env:GITTEST_REMOTE_PROXY_PASS="bar" - run_test proxy - - $Env:GITTEST_REMOTE_PROXY_HOST=$null - $Env:GITTEST_REMOTE_PROXY_USER=$null - $Env:GITTEST_REMOTE_PROXY_PASS=$null - - taskkill /F /IM javaw.exe -} - -if (-Not $global:Success) { exit 1 } From f867bfa88e6b89c2d620a8ec14efa69e0e27c400 Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Sat, 20 Jul 2019 18:35:46 +0200 Subject: [PATCH 10/11] azure: skip SSH tests on Win32 platforms On Win32 build hosts, we do not have an SSH daemon readily available and thus cannot perform the SSH tests. Let's skip the tests to not let Azure Pipelines fail. --- azure-pipelines.yml | 4 ++++ azure-pipelines/nightly.yml | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 2d79dd3a6..dda7ad59a 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -83,6 +83,7 @@ jobs: environmentVariables: CMAKE_GENERATOR: Visual Studio 12 2013 Win64 CMAKE_OPTIONS: -DMSVC_CRTDBG=ON -DDEPRECATE_HARD=ON + SKIP_SSH_TESTS: true - job: windows_vs_x86 displayName: 'Windows (x86; Visual Studio)' @@ -93,6 +94,7 @@ jobs: environmentVariables: CMAKE_GENERATOR: Visual Studio 12 2013 CMAKE_OPTIONS: -DMSVC_CRTDBG=ON -DDEPRECATE_HARD=ON -DUSE_SHA1=HTTPS + SKIP_SSH_TESTS: true - job: windows_mingw_amd64 displayName: 'Windows (amd64; MinGW)' @@ -109,6 +111,7 @@ jobs: BUILD_PATH: $(Agent.TempDirectory)\mingw64\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files (x86)\CMake\bin CMAKE_GENERATOR: MinGW Makefiles CMAKE_OPTIONS: -DDEPRECATE_HARD=ON + SKIP_SSH_TESTS: true - job: windows_mingw_x86 displayName: 'Windows (x86; MinGW)' @@ -126,6 +129,7 @@ jobs: BUILD_PATH: $(Agent.TempDirectory)\mingw32\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files (x86)\CMake\bin CMAKE_GENERATOR: MinGW Makefiles CMAKE_OPTIONS: -DDEPRECATE_HARD=ON + SKIP_SSH_TESTS: true - job: documentation displayName: 'Generate Documentation' diff --git a/azure-pipelines/nightly.yml b/azure-pipelines/nightly.yml index eebc3eda9..96cc3e561 100644 --- a/azure-pipelines/nightly.yml +++ b/azure-pipelines/nightly.yml @@ -85,6 +85,7 @@ jobs: CMAKE_GENERATOR: Visual Studio 12 2013 Win64 CMAKE_OPTIONS: -DMSVC_CRTDBG=ON -DDEPRECATE_HARD=ON RUN_INVASIVE_TESTS: true + SKIP_SSH_TESTS: true - job: windows_vs_x86 displayName: 'Windows (x86; Visual Studio)' @@ -96,6 +97,7 @@ jobs: CMAKE_GENERATOR: Visual Studio 12 2013 CMAKE_OPTIONS: -DMSVC_CRTDBG=ON -DDEPRECATE_HARD=ON -DUSE_SHA1=HTTPS RUN_INVASIVE_TESTS: true + SKIP_SSH_TESTS: true - job: windows_mingw_amd64 displayName: 'Windows (amd64; MinGW)' @@ -113,6 +115,7 @@ jobs: CMAKE_GENERATOR: MinGW Makefiles CMAKE_OPTIONS: -DDEPRECATE_HARD=ON RUN_INVASIVE_TESTS: true + SKIP_SSH_TESTS: true - job: windows_mingw_x86 displayName: 'Windows (x86; MinGW)' @@ -131,6 +134,7 @@ jobs: CMAKE_GENERATOR: MinGW Makefiles CMAKE_OPTIONS: -DDEPRECATE_HARD=ON RUN_INVASIVE_TESTS: true + SKIP_SSH_TESTS: true - job: linux_x86_bionic_gcc_openssl displayName: 'Linux (x86; Bionic; GCC; OpenSSL)' From 415ee616afdd4f1892410cdad8d24d9ac3bc977d Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Fri, 12 Jul 2019 09:40:13 +0200 Subject: [PATCH 11/11] azure-pipelines: make gitdaemon tests work on Win32 On Win32 builds, the PID file created by git-daemon contained in invalid PID that we were not able to kill afterwards. Somehow, it seems like the contained PID was wrapped in braces. Consequentially, kill(1) failed and thus caused the build to error. Fix this by directly grabbing the PID of the spawned git-daemon process. --- azure-pipelines/test.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/azure-pipelines/test.sh b/azure-pipelines/test.sh index 69b4273a5..56d8264d9 100755 --- a/azure-pipelines/test.sh +++ b/azure-pipelines/test.sh @@ -16,9 +16,9 @@ SUCCESS=1 cleanup() { echo "Cleaning up..." - if [ ! -z "$GITDAEMON_DIR" -a -f "${GITDAEMON_DIR}/pid" ]; then + if [ ! -z "$GITDAEMON_PID" ]; then echo "Stopping git daemon..." - kill $(cat "${GITDAEMON_DIR}/pid") + kill $GITDAEMON_PID fi if [ ! -z "$SSHD_DIR" -a -f "${SSHD_DIR}/pid" ]; then @@ -73,7 +73,8 @@ if [ -z "$SKIP_GITDAEMON_TESTS" ]; then echo "Starting git daemon..." GITDAEMON_DIR=`mktemp -d ${TMPDIR}/gitdaemon.XXXXXXXX` git init --bare "${GITDAEMON_DIR}/test.git" - git daemon --listen=localhost --export-all --enable=receive-pack --pid-file="${GITDAEMON_DIR}/pid" --base-path="${GITDAEMON_DIR}" "${GITDAEMON_DIR}" 2>/dev/null & + git daemon --listen=localhost --export-all --enable=receive-pack --base-path="${GITDAEMON_DIR}" "${GITDAEMON_DIR}" 2>/dev/null & + GITDAEMON_PID=$! fi if [ -z "$SKIP_PROXY_TESTS" ]; then