Skip to content

Commit

Permalink
Merge pull request #137 from simonqhughes/sdh_iotmbl_2572_psa_storage…
Browse files Browse the repository at this point in the history
…_building_test_binaries

Add boiler-plate main.c file for building stdc test executables.
  • Loading branch information
kotegowder authored Feb 19, 2020
2 parents bfcf2e3 + ef66e16 commit b8a0b13
Show file tree
Hide file tree
Showing 2 changed files with 104 additions and 5 deletions.
31 changes: 31 additions & 0 deletions api-tests/platform/targets/tgt_dev_apis_stdc/nspe/common/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/** @file
* Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved.
* SPDX-License-Identifier : Apache-2.0
*
* 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.
**/

#include <stdint.h>

int32_t val_entry(void);

/**
@brief - PSA C main function, used for generating tgt_dev_apis_stdc test binaries.
@param - argc : the number of command line arguments.
argv : array containing command line arguments.
@return - error status
**/
int main(int argc, char**argv)
{
return val_entry();
}
78 changes: 73 additions & 5 deletions api-tests/platform/targets/tgt_dev_apis_stdc/target.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,63 @@
# * limitations under the License.
#**/

###############################################################################
# FUNCTION: _create_psa_stdc_exe()
# Function for generating PSA stdc test binaries linking with libraries
# external to the psa-arch-tests project. This function requires
# PSA_STORAGE_LIB_FILENAME to be specificed on the cmake command line,
# where the symbol is defined as the full path to the external PSA storage
# library to test. e.g.
# cmake ... -DPSA_STORAGE_LIB_FILENAME=/wdir/usr/lib/libpsastorage.so
# If the function is being used to generate a test binary for testing
# the mbed-crypto library then the function requires
# PSA_CRYPTO_LIB_FILENAME to be specificed on the cmake command line,
# where the symbol is defined as the full path to the external PSA crypto
# library to test. e.g.
# cmake ... -DPSA_CRYPTO_LIB_FILENAME=/wdir/mbed-crypto/library/ \
# libmbedcrypto.a
# ARGUMENTS:
# _exe_name Name of the test binary to generate.
# _api_dir PSA API directory name e.g. crypto,
# internal_trusted_storage or protected_storage.
###############################################################################
function(_create_psa_stdc_exe _exe_name _api_dir)

# Create the PSA test binary.
set(EXE_NAME ${_exe_name})

if(DEFINED PSA_STORAGE_LIB_FILENAME)
# Define PSA_STORAGE_LIB_NAME to be the name of the PSA Storage library to be tested.
get_filename_component(PSA_STORAGE_LIB_NAME ${PSA_STORAGE_LIB_FILENAME} NAME)

get_filename_component(PSA_STORAGE_LIB_DIR ${PSA_STORAGE_LIB_FILENAME} DIRECTORY)
link_directories(${PSA_STORAGE_LIB_DIR})
endif()

if(DEFINED PSA_CRYPTO_LIB_FILENAME)
# Define PSA_CRYPTO_LIB_NAME to be the name of the PSA Crypto library to be tested.
get_filename_component(PSA_CRYPTO_LIB_NAME ${PSA_CRYPTO_LIB_FILENAME} NAME)

get_filename_component(PSA_CRYPTO_LIB_DIR ${PSA_CRYPTO_LIB_FILENAME} DIRECTORY)
link_directories(${PSA_CRYPTO_LIB_DIR})
endif()

# Create list of test binary source files.
list(APPEND EXE_SRC ${PSA_ROOT_DIR}/platform/targets/${TARGET}/nspe/common/main.c)

# Create list of libraries to link to test binary
list(APPEND EXE_LIBS
${PROJECT_BINARY_DIR}/val/val_nspe.a
${PROJECT_BINARY_DIR}/platform/pal_nspe.a
${PROJECT_BINARY_DIR}/dev_apis/${_api_dir}/test_combine.a
${PSA_CRYPTO_LIB_NAME}
${PSA_STORAGE_LIB_NAME}
)

add_executable(${EXE_NAME} ${EXE_SRC})
target_link_libraries(${EXE_NAME} ${EXE_LIBS})
endfunction(_create_psa_stdc_exe)

# PAL C source files part of NSPE library
list(APPEND PAL_SRC_C_NSPE )

Expand All @@ -27,7 +84,6 @@ list(APPEND PAL_SRC_C_DRIVER_SP )
# PAL ASM source files part of SPE library - driver partition
list(APPEND PAL_SRC_ASM_DRIVER_SP )


# Listing all the sources required for given target
if(${SUITE} STREQUAL "IPC")
message(FATAL_ERROR "IPC not supported")
Expand All @@ -42,16 +98,28 @@ if(${SUITE} STREQUAL "CRYPTO")
list(APPEND PAL_SRC_C_NSPE
${PSA_ROOT_DIR}/platform/targets/${TARGET}/nspe/crypto/pal_crypto_intf.c
)
if(NOT DEFINED PSA_CRYPTO_LIB_FILENAME)
message(FATAL_ERROR "ERROR: PSA_CRYPTO_LIB_FILENAME undefined.")
endif()
_create_psa_stdc_exe(psa-arch-tests-crypto crypto)
endif()
if(${SUITE} STREQUAL "PROTECTED_STORAGE")
list(APPEND PAL_SRC_C_NSPE
${PSA_ROOT_DIR}/platform/targets/${TARGET}/nspe/protected_storage/pal_protected_storage_intf.c
)
${PSA_ROOT_DIR}/platform/targets/${TARGET}/nspe/protected_storage/pal_protected_storage_intf.c
)
if(NOT DEFINED PSA_STORAGE_LIB_FILENAME)
message(FATAL_ERROR "ERROR: PSA_STORAGE_LIB_FILENAME undefined.")
endif()
_create_psa_stdc_exe(psa-arch-tests-ps protected_storage)
endif()
if(${SUITE} STREQUAL "INTERNAL_TRUSTED_STORAGE")
list(APPEND PAL_SRC_C_NSPE
${PSA_ROOT_DIR}/platform/targets/${TARGET}/nspe/internal_trusted_storage/pal_internal_trusted_storage_intf.c
)
${PSA_ROOT_DIR}/platform/targets/${TARGET}/nspe/internal_trusted_storage/pal_internal_trusted_storage_intf.c
)
if(NOT DEFINED PSA_STORAGE_LIB_FILENAME)
message(FATAL_ERROR "ERROR: PSA_STORAGE_LIB_FILENAME undefined.")
endif()
_create_psa_stdc_exe(psa-arch-tests-its internal_trusted_storage)
endif()
if(${SUITE} STREQUAL "INITIAL_ATTESTATION")
message(FATAL_ERROR "Initial attestation not supported")
Expand Down

0 comments on commit b8a0b13

Please sign in to comment.