diff options
author | Jack Lloyd <[email protected]> | 2018-12-04 08:11:13 -0500 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2018-12-04 08:11:13 -0500 |
commit | 422ade7dc74a3221110fc2a173fc22f2e2cc235c (patch) | |
tree | af676105acd789f2abcf25e7ba27e895332257d7 | |
parent | 358716e869b6ad7a29e69eb68efcb343efa6e345 (diff) | |
parent | e7efc94ddc8dda6101d38870b44e4bcda6371be1 (diff) |
Merge GH #1767 Switch Travis builds to Xenial
-rwxr-xr-x | configure.py | 16 | ||||
-rw-r--r-- | src/configs/pylint.rc | 8 | ||||
-rw-r--r-- | src/lib/prov/openssl/openssl_ec.cpp | 8 | ||||
-rw-r--r-- | src/lib/utils/cpuid/cpuid_ppc.cpp | 4 | ||||
-rwxr-xr-x | src/scripts/bench.py | 2 | ||||
-rwxr-xr-x | src/scripts/build_docs.py | 2 | ||||
-rwxr-xr-x | src/scripts/ci/setup_travis.sh | 76 | ||||
-rw-r--r-- | src/scripts/ci/travis.yml | 27 | ||||
-rwxr-xr-x | src/scripts/ci_build.py | 37 | ||||
-rwxr-xr-x | src/scripts/dist.py | 2 | ||||
-rwxr-xr-x | src/scripts/install.py | 2 | ||||
-rwxr-xr-x | src/scripts/test_cli.py | 3 | ||||
-rw-r--r-- | src/tests/test_ffi.cpp | 10 |
13 files changed, 90 insertions, 107 deletions
diff --git a/configure.py b/configure.py index 4a708ecbe..a4f9ca062 100755 --- a/configure.py +++ b/configure.py @@ -146,12 +146,12 @@ class Version(object): (stdout, stderr) = vc.communicate() if vc.returncode != 0: - logging.debug('Error getting rev from %s - %d (%s)' - % (cmdname, vc.returncode, stderr)) + logging.debug('Error getting rev from %s - %d (%s)', + cmdname, vc.returncode, stderr) return 'unknown' rev = str(stdout).strip() - logging.debug('%s reported revision %s' % (cmdname, rev)) + logging.debug('%s reported revision %s', cmdname, rev) return '%s:%s' % (cmdname, rev) except OSError as e: @@ -2529,7 +2529,7 @@ class AmalgamationGenerator(object): pub_header_amalag.write_to_file(header_name, "BOTAN_AMALGAMATION_H_") isa_headers = {} - internal_headers = [] + internal_headers_list = [] def known_isa_header(hdr): if self._options.single_amalgamation_file: @@ -2543,9 +2543,9 @@ class AmalgamationGenerator(object): if isa: isa_headers[isa] = ''.join(AmalgamationGenerator.read_header(hdr)) else: - internal_headers.append(hdr) + internal_headers_list.append(hdr) - internal_headers = AmalgamationHeader(internal_headers) + internal_headers = AmalgamationHeader(internal_headers_list) header_int_name = '%s_internal.h' % (AmalgamationGenerator.filename_prefix) logging.info('Writing amalgamation header to %s' % (header_int_name)) internal_headers.write_to_file(header_int_name, "BOTAN_AMALGAMATION_INTERNAL_H_") @@ -2820,10 +2820,10 @@ def canonicalize_options(options, info_os, info_arch): shared_libs_supported = options.os in info_os and info_os[options.os].building_shared_supported() if not shared_libs_supported: - if options.build_shared_lib is not None: + if options.build_shared_lib is True: logging.warning('Shared libs not supported on %s, disabling shared lib support' % (options.os)) options.build_shared_lib = False - else: + elif options.build_shared_lib is None: logging.info('Shared libs not supported on %s, disabling shared lib support' % (options.os)) if options.os == 'windows' and options.build_shared_lib is None and options.build_static_lib is None: diff --git a/src/configs/pylint.rc b/src/configs/pylint.rc index 5dcff5650..aea9463e6 100644 --- a/src/configs/pylint.rc +++ b/src/configs/pylint.rc @@ -19,7 +19,7 @@ persistent=yes load-plugins= # Use multiple processes to speed up Pylint. -jobs=1 +jobs=3 # Allow loading of arbitrary C extensions. Extensions are imported into the # active Python interpreter and may run arbitrary code. @@ -60,7 +60,7 @@ confidence= # no Warning level messages displayed, use"--disable=all --enable=classes # --disable=W" -disable=missing-docstring,no-else-return,logging-not-lazy +disable=missing-docstring,no-else-return,logging-not-lazy,locally-disabled [REPORTS] @@ -226,7 +226,7 @@ ignored-modules= # List of classes names for which member attributes should not be checked # (useful for classes with attributes dynamically set). This supports can work # with qualified names. -ignored-classes=LexResult +ignored-classes=LexResult,argv # List of members which are set dynamically and missed by pylint inference # system, and so shouldn't trigger E1101 when accessed. Python regular @@ -241,7 +241,7 @@ init-import=no # A regular expression matching the name of dummy variables (i.e. expectedly # not used). -dummy-variables-rgx=_$|dummy +dummy-variables-rgx=_[a-z]*$ # List of additional names supposed to be defined in builtins. Remember that # you should avoid to define new builtins when possible. diff --git a/src/lib/prov/openssl/openssl_ec.cpp b/src/lib/prov/openssl/openssl_ec.cpp index 026dfa5e0..53ed081a1 100644 --- a/src/lib/prov/openssl/openssl_ec.cpp +++ b/src/lib/prov/openssl/openssl_ec.cpp @@ -328,20 +328,22 @@ class OpenSSL_ECDH_KA_Operation final : public PK_Ops::Key_Agreement_with_KDF const EC_GROUP* group = ::EC_KEY_get0_group(m_ossl_ec.get()); const size_t out_len = (::EC_GROUP_get_degree(group) + 7) / 8; secure_vector<uint8_t> out(out_len); - EC_POINT* pub_key = ::EC_POINT_new(group); + + std::unique_ptr<EC_POINT, std::function<void (EC_POINT*)>> pub_key( + ::EC_POINT_new(group), ::EC_POINT_free); if(!pub_key) throw OpenSSL_Error("EC_POINT_new", ERR_get_error()); const int os2ecp_rc = - ::EC_POINT_oct2point(group, pub_key, w, w_len, nullptr); + ::EC_POINT_oct2point(group, pub_key.get(), w, w_len, nullptr); if(os2ecp_rc != 1) throw OpenSSL_Error("EC_POINT_oct2point", ERR_get_error()); const int ecdh_rc = ::ECDH_compute_key(out.data(), out.size(), - pub_key, + pub_key.get(), m_ossl_ec.get(), /*KDF*/nullptr); diff --git a/src/lib/utils/cpuid/cpuid_ppc.cpp b/src/lib/utils/cpuid/cpuid_ppc.cpp index 43b684785..80a6241df 100644 --- a/src/lib/utils/cpuid/cpuid_ppc.cpp +++ b/src/lib/utils/cpuid/cpuid_ppc.cpp @@ -98,8 +98,10 @@ uint64_t CPUID::detect_cpu_features(size_t* cache_line_size) 0x003E, // IBM POWER6 0x003F, // IBM POWER7 0x004A, // IBM POWER7p - 0x004D, // IBM POWER8 0x004B, // IBM POWER8E + 0x004C, // IBM POWER8 NVL + 0x004D, // IBM POWER8 + 0x004E, // IBM POWER9 0x000C, // G4-7400 0x0039, // G5 970 0x003C, // G5 970FX diff --git a/src/scripts/bench.py b/src/scripts/bench.py index 13de0c077..1cc626366 100755 --- a/src/scripts/bench.py +++ b/src/scripts/bench.py @@ -129,7 +129,7 @@ def run_botan_bench(botan, runtime, buf_sizes, algo): runtime = .05 cmd = [botan, 'speed', '--format=json', '--msec=%d' % int(runtime * 1000), - '--buf-size=%s' % (','.join(map(str, buf_sizes))), algo] + '--buf-size=%s' % (','.join([str(i) for i in buf_sizes])), algo] output = run_command(cmd) output = json.loads(output) diff --git a/src/scripts/build_docs.py b/src/scripts/build_docs.py index 6de6f6d45..00d15f7eb 100755 --- a/src/scripts/build_docs.py +++ b/src/scripts/build_docs.py @@ -129,7 +129,7 @@ def sphinx_supports_concurrency(): match = re.match(r'^(?:[a-zA-Z_-]+) v?(([0-9]+)\.([0-9]+))', output) # default to using concurrency when uncertain version = StrictVersion(match.group(1)) if match else StrictVersion('1.2') - return version >= StrictVersion('1.2') + return version >= StrictVersion('1.4') def read_config(config): try: diff --git a/src/scripts/ci/setup_travis.sh b/src/scripts/ci/setup_travis.sh index f03947476..95831f7fe 100755 --- a/src/scripts/ci/setup_travis.sh +++ b/src/scripts/ci/setup_travis.sh @@ -1,87 +1,63 @@ #!/bin/bash -set -ev -which shellcheck > /dev/null && shellcheck "$0" # Run shellcheck on this if available -git clone --depth 1 https://github.com/randombit/botan-ci-tools +# Travis CI setup script for Botan build +# +# (C) 2015,2017 Simon Warta +# (C) 2016,2017,2018 Jack Lloyd -if [ "$TRAVIS_OS_NAME" = "linux" ]; then +command -v shellcheck > /dev/null && shellcheck "$0" # Run shellcheck on this if available - # ccache in Trusty is too old, use version from Xenial - sudo dpkg -i botan-ci-tools/ubuntu/ccache_3.2.4-1_amd64.deb +set -ev + +if [ "$TRAVIS_OS_NAME" = "linux" ]; then if [ "$BUILD_MODE" = "valgrind" ]; then sudo apt-get -qq update sudo apt-get install valgrind - elif [ "$BUILD_MODE" = "cross-win32" ]; then - # See https://github.com/travis-ci/travis-ci/issues/6460 - sudo dpkg --add-architecture i386 - sudo apt-get -qq update # have to run this after --add-architecture - sudo apt-get install wine g++-mingw-w64-i686 mingw-w64-i686-dev + elif [ "$BUILD_MODE" = "cross-win64" ]; then + sudo apt-get -qq update + sudo apt-get install wine g++-mingw-w64-x86-64 elif [ "${BUILD_MODE:0:5}" = "cross" ]; then - # Need updated qemu - sudo add-apt-repository -y ppa:ubuntu-cloud-archive/kilo-staging sudo apt-get -qq update - sudo apt-get install qemu-user if [ "$BUILD_MODE" = "cross-arm32" ]; then - sudo apt-get install g++-arm-linux-gnueabihf libc6-dev-armhf-cross + sudo apt-get install qemu-user g++-arm-linux-gnueabihf elif [ "$BUILD_MODE" = "cross-arm64" ]; then - sudo apt-get install g++-aarch64-linux-gnu libc6-dev-arm64-cross + sudo apt-get install qemu-user g++-aarch64-linux-gnu elif [ "$BUILD_MODE" = "cross-ppc32" ]; then - sudo apt-get install g++-powerpc-linux-gnu libc6-dev-powerpc-cross + sudo apt-get install qemu-user g++-powerpc-linux-gnu elif [ "$BUILD_MODE" = "cross-ppc64" ]; then - sudo apt-get install g++-powerpc64le-linux-gnu libc6-dev-ppc64el-cross + sudo apt-get install qemu-user g++-powerpc64le-linux-gnu + elif [ "$BUILD_MODE" = "cross-mips64" ]; then + sudo apt-get install qemu-user g++-mips64-linux-gnuabi64 fi elif [ "$BUILD_MODE" = "lint" ]; then - pip install --user pylint==1.9.2 + sudo apt-get -qq update + sudo apt-get install pylint elif [ "$BUILD_MODE" = "coverage" ]; then sudo apt-get -qq update - sudo apt-get install trousers libtspi-dev + sudo apt-get install trousers libtspi-dev lcov python-coverage - # SoftHSMv1 in 14.04 does not work + git clone --depth 1 https://github.com/randombit/botan-ci-tools + + # FIXME use distro softhsm2 package instead + # need to figure out ownership problem # Installs prebuilt SoftHSMv2 binaries into /tmp tar -C / -xvjf botan-ci-tools/softhsm2-trusty-bin.tar.bz2 /tmp/softhsm/bin/softhsm2-util --init-token --free --label test --pin 123456 --so-pin 12345678 - # need updated lcov for gcc 4.8 coverage format - sudo dpkg -i botan-ci-tools/ubuntu/lcov_1.12-2_all.deb - - (cd /home/travis/bin && ln -s gcov-4.8 gcov) - - pip install --user coverage pip install --user codecov==2.0.10 - elif [ "$BUILD_MODE" = "sonar" ]; then - sudo apt-get -qq update - sudo apt-get install trousers libtspi-dev - # installed llvm-3.4 conflicts with clang-3.9 in /usr/local - # we need a more recent llvm-cov for coverage reports - sudo apt-get remove llvm - - tar -C / -xvjf botan-ci-tools/softhsm2-trusty-bin.tar.bz2 - /tmp/softhsm/bin/softhsm2-util --init-token --free --label test --pin 123456 --so-pin 12345678 - - wget https://sonarqube.com/static/cpp/build-wrapper-linux-x86.zip - unzip build-wrapper-linux-x86.zip - elif [ "$BUILD_MODE" = "docs" ]; then sudo apt-get -qq update sudo apt-get install doxygen python-docutils - # The version of Sphinx in 14.04 is too old (1.2.2) and does not support - # all C++ features used in the manual. Install python-requests to avoid - # problem in Ubuntu packaged version, see - # http://stackoverflow.com/questions/32779919/no-module-named-for-requests - # - # Reinstall roman due to https://github.com/sphinx-doc/sphinx/issues/5022 - # - - sudo apt-get remove python-requests python-openssl python-roman - sudo pip install requests pyopenssl roman sphinx==1.7.9 + # Version of Sphinx in 16.04 is too old and dies on enum definitions + sudo pip install sphinx==1.7.9 fi elif [ "$TRAVIS_OS_NAME" = "osx" ]; then diff --git a/src/scripts/ci/travis.yml b/src/scripts/ci/travis.yml index 991fbbf6f..b2ac2539e 100644 --- a/src/scripts/ci/travis.yml +++ b/src/scripts/ci/travis.yml @@ -4,7 +4,7 @@ os: - linux - osx -dist: trusty +dist: xenial sudo: required compiler: @@ -19,14 +19,14 @@ env: matrix: - BUILD_MODE="shared" -# - BUILD_MODE="sonar" - BUILD_MODE="fuzzers" - BUILD_MODE="coverage" - BUILD_MODE="cross-ppc32" - BUILD_MODE="cross-ppc64" - BUILD_MODE="cross-arm32" - BUILD_MODE="cross-arm64" - - BUILD_MODE="cross-win32" + - BUILD_MODE="cross-mips64" + - BUILD_MODE="cross-win64" - BUILD_MODE="valgrind" - BUILD_MODE="static" - BUILD_MODE="mini-shared" @@ -41,15 +41,12 @@ matrix: - os: osx compiler: gcc - - os: osx - env: BUILD_MODE="sonar" - # XCode 9.4 ICEs on 32-bit ARM builds - os: osx env: BUILD_MODE="cross-arm32" # Run static, docs, lint, bsi, nist, fuzzers, coverage, valgrind, - # sonar, sanitizer, minimized and non-ARM cross builds only on Linux/gcc. + # sanitizer, minimized and non-ARM cross builds only on Linux/gcc. # The sanitizer builds under Clang run the tests very slowly and # cause CI timeouts. @@ -72,15 +69,13 @@ matrix: - compiler: clang env: BUILD_MODE="mini-shared" - compiler: clang - env: BUILD_MODE="cross-win32" + env: BUILD_MODE="cross-win64" - compiler: clang env: BUILD_MODE="cross-ppc32" - compiler: clang env: BUILD_MODE="cross-ppc64" - - # Use clang coverage for Sonar - - compiler: gcc - env: BUILD_MODE="sonar" + - compiler: clang + env: BUILD_MODE="cross-mips64" # No ARM Clang compiler on Linux - os: linux @@ -102,21 +97,15 @@ branches: - master - release-2 - coverity_scan + - travis-xenial git: depth: 5 cache: ccache: true - directories: - - $HOME/.sonar/cache addons: - #sonarcloud: - # organization: "randombit-github" - # token: - # secure: "JYwDxEZyCJ1aKLjAYB9YlyyIRkjeaY48iYqcMhmidx6/ploWXMbUzVpv5plLFbMGgeMy9sqa2I7Pbo7u3OdcBbbsogGtk/jomnjiauuNS6KcCHEEcVjBILfadxGJPL9F8/0KbcS2vnPpz/jVlRp18Uemud0yGGXXcDaY471sA50=" - coverity_scan: project: name: "randombit/botan" diff --git a/src/scripts/ci_build.py b/src/scripts/ci_build.py index 8c8e9912b..823d2255d 100755 --- a/src/scripts/ci_build.py +++ b/src/scripts/ci_build.py @@ -41,17 +41,18 @@ def determine_flags(target, target_os, target_cpu, target_cc, cc_bin, ccache, ro if is_cross_target: if target_os == 'osx': target_os = 'ios' - elif target == 'cross-win32': + elif target == 'cross-win64': target_os = 'mingw' make_prefix = [] test_prefix = [] test_cmd = [os.path.join(root_dir, 'botan-test')] - fast_tests = ['block', 'aead', 'hash', 'stream', 'mac', 'modes', + fast_tests = ['block', 'aead', 'hash', 'stream', 'mac', 'modes', 'kdf', 'hmac_drbg', 'hmac_drbg_unit', 'tls', 'ffi', - 'rsa_sign', 'rsa_verify', 'dh_kat', 'ecdsa_sign', 'curve25519_scalar', + 'rsa_sign', 'rsa_verify', 'dh_kat', + 'ecc_randomized', 'ecdh_kat', 'ecdsa_sign', 'curve25519_scalar', 'simd_32', 'os_utils', 'util', 'util_dates'] install_prefix = os.path.join(tempfile.gettempdir(), 'botan-install') @@ -94,7 +95,8 @@ def determine_flags(target, target_os, target_cpu, target_cc, cc_bin, ccache, ro if target == 'coverage': flags += ['--with-coverage-info', '--test-mode'] if target == 'valgrind': - flags += ['--with-valgrind'] + # valgrind in 16.04 has a bug with rdrand handling + flags += ['--with-valgrind', '--disable-rdrand'] test_prefix = ['valgrind', '--error-exitcode=9', '-v', '--leak-check=full', '--show-reachable=yes'] test_cmd += fast_tests if target == 'fuzzers': @@ -144,9 +146,11 @@ def determine_flags(target, target_os, target_cpu, target_cc, cc_bin, ccache, ro flags += ['--cpu=arm64', '--cc-abi-flags=-arch arm64 -stdlib=libc++'] else: raise Exception("Unknown cross target '%s' for iOS" % (target)) - elif target == 'cross-win32': - cc_bin = 'i686-w64-mingw32-g++' - flags += ['--cpu=x86_32', '--cc-abi-flags=-static', '--ar-command=i686-w64-mingw32-ar'] + elif target == 'cross-win64': + # MinGW in 16.04 is lacking std::mutex for unknown reason + cc_bin = 'x86_64-w64-mingw32-g++' + flags += ['--cpu=x86_64', '--cc-abi-flags=-static', + '--ar-command=x86_64-w64-mingw32-ar', '--without-os-feature=threads'] test_cmd = [os.path.join(root_dir, 'botan-test.exe')] # No runtime prefix required for Wine else: @@ -168,7 +172,11 @@ def determine_flags(target, target_os, target_cpu, target_cc, cc_bin, ccache, ro elif target == 'cross-ppc64': flags += ['--cpu=ppc64', '--with-endian=little'] cc_bin = 'powerpc64le-linux-gnu-g++' - test_prefix = ['qemu-ppc64le', '-L', '/usr/powerpc64le-linux-gnu/'] + test_prefix = ['qemu-ppc64le', '-cpu', 'POWER8', '-L', '/usr/powerpc64le-linux-gnu/'] + elif target == 'cross-mips64': + flags += ['--cpu=mips64', '--with-endian=big'] + cc_bin = 'mips64-linux-gnuabi64-g++' + test_prefix = ['qemu-mips64', '-L', '/usr/mips64-linux-gnuabi64/'] else: raise Exception("Unknown cross target '%s' for Linux" % (target)) else: @@ -381,7 +389,7 @@ def main(args=None): raise Exception('No python interpreters found cannot lint') pylint_rc = '--rcfile=%s' % (os.path.join(root_dir, 'src/configs/pylint.rc')) - pylint_flags = [pylint_rc, '--reports=no', '--score=no'] + pylint_flags = [pylint_rc, '--reports=no'] # Some disabled rules specific to Python2 # superfluous-parens: needed for Python3 compatible print statements @@ -407,14 +415,13 @@ def main(args=None): 'src/scripts/python_unittests.py', 'src/scripts/python_unittests_unix.py'] - for target in py_scripts: - target_path = os.path.join(root_dir, target) + full_paths = [os.path.join(root_dir, s) for s in py_scripts] - if use_python2: - cmds.append(['python2', '-m', 'pylint'] + pylint_flags + [py2_flags, target_path]) + if use_python2: + cmds.append(['python2', '-m', 'pylint'] + pylint_flags + [py2_flags] + full_paths) - if use_python3 and options.use_pylint3: - cmds.append(['python3', '-m', 'pylint'] + pylint_flags + [py3_flags, target_path]) + if use_python3 and options.use_pylint3: + cmds.append(['python3', '-m', 'pylint'] + pylint_flags + [py3_flags] + full_paths) else: config_flags, run_test_command, make_prefix = determine_flags( diff --git a/src/scripts/dist.py b/src/scripts/dist.py index a27784453..8a37a2581 100755 --- a/src/scripts/dist.py +++ b/src/scripts/dist.py @@ -311,7 +311,7 @@ def main(args=None): try: logging.info('Creating release for version %s' % (target_version)) - (major, minor, patch) = map(int, target_version.split('.')) + (major, minor, patch) = [int(x) for x in target_version.split('.')] assert target_version == '%d.%d.%d' % (major, minor, patch) target_version = target_version diff --git a/src/scripts/install.py b/src/scripts/install.py index 03a15ba3e..a539a8930 100755 --- a/src/scripts/install.py +++ b/src/scripts/install.py @@ -16,6 +16,7 @@ import os import shutil import sys import subprocess +import traceback def parse_command_line(args): @@ -269,6 +270,5 @@ if __name__ == '__main__': sys.exit(main(sys.argv)) except Exception as e: # pylint: disable=broad-except logging.error('Failure: %s' % (e)) - import traceback logging.info(traceback.format_exc()) sys.exit(1) diff --git a/src/scripts/test_cli.py b/src/scripts/test_cli.py index 6445a3669..239c05175 100755 --- a/src/scripts/test_cli.py +++ b/src/scripts/test_cli.py @@ -42,7 +42,6 @@ def setup_logging(options): def test_cli(cmd, cmd_options, expected_output=None, cmd_input=None, expected_stderr=None): global TESTS_RUN - global TESTS_FAILED TESTS_RUN += 1 @@ -518,7 +517,7 @@ def cli_tls_socket_tests(): (stdout, stderr) = tls_client.communicate() - if len(stderr) != 0: # pylint: disable=len-as-condition + if stderr: logging.error("Got unexpected stderr output %s" % (stderr)) if b'Handshake complete' not in stdout: diff --git a/src/tests/test_ffi.cpp b/src/tests/test_ffi.cpp index 50c85eff6..fddc9874d 100644 --- a/src/tests/test_ffi.cpp +++ b/src/tests/test_ffi.cpp @@ -209,7 +209,15 @@ class FFI_Unit_Tests final : public Test std::vector<uint8_t> outbuf(512); - if(TEST_FFI_OK(botan_rng_init, (&rng, "user-threadsafe"))) + rc = botan_rng_init(&rng, "user-threadsafe"); + result.confirm("Either success or not implemented", rc == 0 || rc == BOTAN_FFI_ERROR_NOT_IMPLEMENTED); + + if(rc != 0) + { + REQUIRE_FFI_OK(botan_rng_init, (&rng, "user")); + } + + if(rc == 0) { TEST_FFI_OK(botan_rng_get, (rng, outbuf.data(), outbuf.size())); TEST_FFI_OK(botan_rng_reseed, (rng, 256)); |