fix(mbed-tls)

This commit is contained in:
Jacob Heider 2023-08-03 14:43:16 -04:00 committed by Jacob Heider
parent f82da9d012
commit a9360043c7

View file

@ -12,37 +12,48 @@ build:
dependencies: dependencies:
cmake.org: '*' cmake.org: '*'
tea.xyz/gx/cc: c99 tea.xyz/gx/cc: c99
linux/aarch64:
llvm.org: <16 # otherwise we get an error from the arm_neon.h include
tea.xyz/gx/make: '*' tea.xyz/gx/make: '*'
python.org: ^3.11 python.org: ^3.11
script: | script:
# MBEDTLS_THREADING_PTHREAD - enable pthread mutexes # MBEDTLS_THREADING_PTHREAD - enable pthread mutexes
# MBEDTLS_THREADING_C - allow use of mutexes within mbed TLS # MBEDTLS_THREADING_C - allow use of mutexes within mbed TLS
# MBEDTLS_SSL_DTLS_SRTP - enable DTLS-SRTP extension # MBEDTLS_SSL_DTLS_SRTP - enable DTLS-SRTP extension
sed -i.bak \ - run: CFG=include/mbedtls/mbedtls_config.h
-e "s://#define MBEDTLS_THREADING_PTHREAD:#define MBEDTLS_THREADING_PTHREAD:" \ if: '>=3'
-e "s://#define MBEDTLS_THREADING_C:#define MBEDTLS_THREADING_C:" \ - run: CFG=include/mbedtls/config.h
-e "s://#define MBEDTLS_SSL_DTLS_SRTP:#define MBEDTLS_SSL_DTLS_SRTP:" \ if: '<3'
include/mbedtls/mbedtls_config.h
rm include/mbedtls/mbedtls_config.h.bak
cmake -S . -B build $ARGS - |
cmake --build build sed -i.bak \
-e "s://#define MBEDTLS_THREADING_PTHREAD:#define MBEDTLS_THREADING_PTHREAD:" \
-e "s://#define MBEDTLS_THREADING_C:#define MBEDTLS_THREADING_C:" \
-e "s://#define MBEDTLS_SSL_DTLS_SRTP:#define MBEDTLS_SSL_DTLS_SRTP:" \
$CFG
rm $CFG.bak
- cmake -S . -B build $ARGS
- cmake --build build
# We run CTest because this is a crypto library. Running tests in parallel causes failures. # We run CTest because this is a crypto library. Running tests in parallel causes failures.
# https://github.com/Mbed-TLS/mbedtls/issues/4980 # https://github.com/Mbed-TLS/mbedtls/issues/4980
ctest --parallel 1 --test-dir build --rerun-failed --output-on-failure - ctest --parallel 1 --test-dir build --rerun-failed --output-on-failure
cmake --install build - cmake --install build
# Why does Mbedtls ship with a "Hello World" executable. Let's remove that. # Why does Mbedtls ship with a "Hello World" executable. Let's remove that.
rm -f {{prefix}}/bin/hello - run: rm -f hello
working-directory: ${{prefix}}/bin/
# Rename benchmark & selftest, which are awfully generic names. # Rename benchmark & selftest, which are awfully generic names.
mv {{prefix}}/bin/benchmark {{prefix}}/bin/mbedtls-benchmark - run: |
mv {{prefix}}/bin/selftest {{prefix}}/bin/mbedtls-selftest mv benchmark mbedtls-benchmark
mv selftest mbedtls-selftest
working-directory: ${{prefix}}/bin
# Demonstration files shouldn't be in the main bin # Demonstration files shouldn't be in the main bin
mkdir -p {{prefix}}/libexec - run: mv ../bin/mpi_demo mpi_demo
mv {{prefix}}/bin/mpi_demo {{prefix}}/libexec/mpi_demo working-directory: ${{prefix}}/libexec
env: env:
ARGS: ARGS:
- -DCMAKE_BUILD_TYPE=Release - -DCMAKE_BUILD_TYPE=Release
@ -55,9 +66,8 @@ build:
test: test:
dependencies: dependencies:
tea.xyz/gx/cc: c99 tea.xyz/gx/cc: c99
script: | script:
printf '%s' 'This is a test file' > testfile.txt - printf '%s' 'This is a test file' > testfile.txt
# Don't remove the space between the checksum and filename. It will break. - test "$(generic_sum SHA256 testfile.txt)" = "$SUM"
expected_checksum="e2d0fe1585a63ec6009c8016ff8dda8b17719a637405a4e23c0ff81339148249 testfile.txt" env:
actual_checksum="$({{prefix}}/bin/generic_sum SHA256 testfile.txt)" SUM: e2d0fe1585a63ec6009c8016ff8dda8b17719a637405a4e23c0ff81339148249 testfile.txt
test "$actual_checksum" = "$expected_checksum"