diff --git a/ChangeLog.d/stop_cmake_out_of_build_running_on_16.04.txt b/ChangeLog.d/stop_cmake_out_of_build_running_on_16.04.txt new file mode 100644 index 000000000..000b4e7b4 --- /dev/null +++ b/ChangeLog.d/stop_cmake_out_of_build_running_on_16.04.txt @@ -0,0 +1,4 @@ +Bugfix + * Prevent CMake out of source tests from running on Ubuntu 16.04, as this can + cause failures due to race conditions with generated files. + diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh index 2d6538552..c07ef34f5 100755 --- a/tests/scripts/all.sh +++ b/tests/scripts/all.sh @@ -2940,6 +2940,36 @@ component_test_valgrind () { fi } +support_test_cmake_out_of_source () { + distrib_id="" + distrib_ver="" + distrib_ver_minor="" + distrib_ver_major="" + + # Attempt to parse lsb-release to find out distribution and version. If not + # found this should fail safe (test is supported). + if [[ -f /etc/lsb-release ]]; then + + while read -r lsb_line; do + case "$lsb_line" in + "DISTRIB_ID"*) distrib_id=${lsb_line/#DISTRIB_ID=};; + "DISTRIB_RELEASE"*) distrib_ver=${lsb_line/#DISTRIB_RELEASE=};; + esac + done < /etc/lsb-release + + distrib_ver_major="${distrib_ver%%.*}" + distrib_ver="${distrib_ver#*.}" + distrib_ver_minor="${distrib_ver%%.*}" + fi + + # Running the out of source CMake test on Ubuntu 16.04 using more than one + # processor (as the CI does) can create a race condition whereby the build + # fails to see a generated file, despite that file actually having been + # generated. This problem appears to go away with 18.04 or newer, so make + # the out of source tests unsupported on Ubuntu 16.04. + [ "$distrib_id" != "Ubuntu" ] || [ "$distrib_ver_major" -gt 16 ] +} + component_test_cmake_out_of_source () { msg "build: cmake 'out-of-source' build" MBEDTLS_ROOT_DIR="$PWD"