diff --git a/projects/libspdm/Dockerfile b/projects/libspdm/Dockerfile index 7f8313d73051..2161411ccc89 100644 --- a/projects/libspdm/Dockerfile +++ b/projects/libspdm/Dockerfile @@ -21,5 +21,5 @@ RUN apt-get update && apt-get install -y make autoconf automake libtool #RUN git config --global http.proxy http://proxy.example.com:80/ #RUN git config --global https.proxy https://proxy.example.com:80/ RUN git clone --depth 1 https://github.com/DMTF/libspdm.git libspdm && cd libspdm && git submodule update --init # or use other version control -COPY build.sh $SRC/ +COPY run_tests.sh build.sh $SRC/ WORKDIR $SRC/libspdm diff --git a/projects/libspdm/build.sh b/projects/libspdm/build.sh index 294e879c1a41..f6985812263b 100644 --- a/projects/libspdm/build.sh +++ b/projects/libspdm/build.sh @@ -16,10 +16,24 @@ ################################################################################ # build project -cd $SRC/libspdm mkdir build -cd build +pushd build cmake -DARCH=x64 -DTOOLCHAIN=LIBFUZZER -DTARGET=Release -DCRYPTO=mbedtls -DGCOV=ON .. -make copy_sample_key -make -cp -r ./bin/* $OUT \ No newline at end of file +make copy_sample_key -j$(nproc) +make -j$(nproc) +cp -r ./bin/* $OUT +popd + +# build unit testing that requires different TOOLCHAIN +# Unset CFLAGS that incompatible with unit testing build +unset CFLAGS +mkdir build-test +pushd build-test +cmake -DARCH=x64 -DTOOLCHAIN="CLANG" -DTARGET=Release -DCRYPTO=mbedtls .. +make -j$(nproc) +popd + +# Prepare sample key and unit testing binary +mkdir $SRC/unit_testing +cp -r $SRC/libspdm/unit_test/sample_key/* $SRC/unit_testing/ +cp $SRC/libspdm/build-test/bin/* $SRC/unit_testing/ diff --git a/projects/libspdm/run_tests.sh b/projects/libspdm/run_tests.sh new file mode 100644 index 000000000000..6ac0e0756897 --- /dev/null +++ b/projects/libspdm/run_tests.sh @@ -0,0 +1,27 @@ +#!/bin/bash -eu +# +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +################################################################################ + +cd $SRC/unit_testing + +# Run all unit testing (excluding failing one +./test_crypt && ./test_spdm_common && ./test_spdm_crypt && \ +./test_spdm_requester && ./test_spdm_responder && ./test_spdm_secured_message + +# Failing unit testing for reference +# ./test_spdm_fips && ./test_spdm_sample +