[修改] 增加freeRTOS
1. 版本FreeRTOSv202212.01,命名为kernel;
This commit is contained in:
@ -0,0 +1,58 @@
|
||||
# Include filepaths for source and include.
|
||||
include( ${MODULE_ROOT_DIR}/sigv4FilePaths.cmake )
|
||||
|
||||
find_package(OpenSSL REQUIRED)
|
||||
|
||||
# ==================== Define your project name (edit) ========================
|
||||
set(project_name "sigv4")
|
||||
|
||||
# ===================== Create your mock here (edit) ========================
|
||||
# ================= Create the library under test here (edit) ==================
|
||||
|
||||
# list the files you would like to test here
|
||||
list(APPEND real_source_files
|
||||
${SIGV4_SOURCES}
|
||||
)
|
||||
# list the directories the module under test includes
|
||||
list(APPEND real_include_directories
|
||||
.
|
||||
${SIGV4_INCLUDE_PUBLIC_DIRS}
|
||||
"${CMAKE_CURRENT_LIST_DIR}/../include"
|
||||
)
|
||||
|
||||
# ===================== Create UnitTest Code here (edit) =====================
|
||||
|
||||
# list the directories your test needs to include
|
||||
list(APPEND test_include_directories
|
||||
.
|
||||
${SIGV4_INCLUDE_PUBLIC_DIRS}
|
||||
)
|
||||
|
||||
# ============================= (end edit) ===================================
|
||||
|
||||
set(real_name "${project_name}_real")
|
||||
|
||||
create_real_library(${real_name}
|
||||
"${real_source_files}"
|
||||
"${real_include_directories}"
|
||||
"${mock_name}"
|
||||
)
|
||||
|
||||
list(APPEND utest_link_list
|
||||
lib${real_name}.a
|
||||
)
|
||||
|
||||
list(APPEND utest_dep_list
|
||||
${real_name}
|
||||
)
|
||||
|
||||
set(utest_name "${project_name}_utest")
|
||||
set(utest_source "${project_name}_utest.c")
|
||||
create_test(${utest_name}
|
||||
${utest_source}
|
||||
"${utest_link_list}"
|
||||
"${utest_dep_list}"
|
||||
"${test_include_directories}"
|
||||
)
|
||||
|
||||
target_link_libraries(${utest_name} OpenSSL::SSL)
|
||||
@ -0,0 +1,58 @@
|
||||
# Macro utility to clone the CMock submodule.
|
||||
macro( clone_cmock )
|
||||
find_package( Git REQUIRED )
|
||||
message( "Cloning submodule CMock." )
|
||||
execute_process( COMMAND rm -rf ${CMOCK_DIR}
|
||||
COMMAND ${GIT_EXECUTABLE} submodule update --checkout --init --recursive ${CMOCK_DIR}
|
||||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
||||
RESULT_VARIABLE CMOCK_CLONE_RESULT )
|
||||
|
||||
if( NOT ${CMOCK_CLONE_RESULT} STREQUAL "0" )
|
||||
message( FATAL_ERROR "Failed to clone CMock submodule." )
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
# Macro utility to add library targets for Unity and CMock to build configuration.
|
||||
macro( add_cmock_targets )
|
||||
# Build Configuration for CMock and Unity libraries.
|
||||
list( APPEND CMOCK_INCLUDE_DIRS
|
||||
"${CMOCK_DIR}/vendor/unity/src/"
|
||||
"${CMOCK_DIR}/vendor/unity/extras/fixture/src"
|
||||
"${CMOCK_DIR}/vendor/unity/extras/memory/src"
|
||||
"${CMOCK_DIR}/src"
|
||||
)
|
||||
|
||||
add_library(cmock STATIC
|
||||
"${CMOCK_DIR}/src/cmock.c"
|
||||
)
|
||||
|
||||
set_target_properties(cmock PROPERTIES
|
||||
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib
|
||||
POSITION_INDEPENDENT_CODE ON
|
||||
COMPILE_FLAGS "-Og"
|
||||
)
|
||||
|
||||
target_include_directories(cmock PUBLIC
|
||||
${CMOCK_DIR}/src
|
||||
${CMOCK_DIR}/vendor/unity/src/
|
||||
${CMOCK_DIR}/examples
|
||||
${CMOCK_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
add_library(unity STATIC
|
||||
"${CMOCK_DIR}/vendor/unity/src/unity.c"
|
||||
"${CMOCK_DIR}/vendor/unity/extras/fixture/src/unity_fixture.c"
|
||||
"${CMOCK_DIR}/vendor/unity/extras/memory/src/unity_memory.c"
|
||||
)
|
||||
|
||||
set_target_properties(unity PROPERTIES
|
||||
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib
|
||||
POSITION_INDEPENDENT_CODE ON
|
||||
)
|
||||
|
||||
target_include_directories(unity PUBLIC
|
||||
${CMOCK_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
target_link_libraries(cmock unity)
|
||||
endmacro()
|
||||
@ -0,0 +1,111 @@
|
||||
/*
|
||||
* SigV4 Library v1.2.0
|
||||
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file sigv4_config.h
|
||||
* @brief The default values for configuration macros used by the SigV4 Library.
|
||||
*
|
||||
* @note This file should NOT be modified. If custom values are needed for any
|
||||
* configuration macros, a sigv4_config.h file should be provided to the SigV4
|
||||
* Library to override the default values defined in this file. To use
|
||||
* the custom config file, the preprocessor macro SIGV4_DO_NOT_USE_CUSTOM_CONFIG
|
||||
* must NOT be set.
|
||||
*/
|
||||
|
||||
#ifndef SIGV4_CONFIG_H_
|
||||
#define SIGV4_CONFIG_H_
|
||||
|
||||
|
||||
#define LOGGING_LEVEL_DEBUG 1
|
||||
|
||||
/* @[code_example_loggingmacros] */
|
||||
/************* Define Logging Macros using printf function ***********/
|
||||
|
||||
#define PrintfError( ... ) printf( "[%d] Error: ", __LINE__ ); printf( __VA_ARGS__ ); printf( "\n" )
|
||||
#define PrintfWarn( ... ) printf( "[%d] Warn: ", __LINE__ ); printf( __VA_ARGS__ ); printf( "\n" )
|
||||
#define PrintfInfo( ... ) printf( "[%d] Info: ", __LINE__ ); printf( __VA_ARGS__ ); printf( "\n" )
|
||||
#define PrintfDebug( ... ) printf( "[%d] Debug: ", __LINE__ ); printf( __VA_ARGS__ ); printf( "\n" )
|
||||
|
||||
#ifdef LOGGING_LEVEL_ERROR
|
||||
#define LogError( message ) PrintfError message
|
||||
#elif defined( LOGGING_LEVEL_WARNING )
|
||||
#define LogError( message ) PrintfError message
|
||||
#define LogWarn( message ) PrintfWarn message
|
||||
#elif defined( LOGGING_LEVEL_INFO )
|
||||
#define LogError( message ) PrintfError message
|
||||
#define LogWarn( message ) PrintfWarn message
|
||||
#define LogInfo( message ) PrintfInfo message
|
||||
#elif defined( LOGGING_LEVEL_DEBUG )
|
||||
#define LogError( message ) PrintfError message
|
||||
#define LogWarn( message ) PrintfWarn message
|
||||
#define LogInfo( message ) PrintfInfo message
|
||||
#define LogDebug( message ) PrintfDebug message
|
||||
#endif /* ifdef LOGGING_LEVEL_ERROR */
|
||||
|
||||
/**************************************************/
|
||||
/* @[code_example_loggingmacros] */
|
||||
|
||||
/**
|
||||
* @brief Macro defining the size of the internal buffer used for incremental
|
||||
* canonicalization and hashing.
|
||||
*
|
||||
* A buffer of this size in bytes is declared on the stack. It should be be
|
||||
* large enough for the digest output of the specified hash function.
|
||||
*
|
||||
* <b>Possible values:</b> Any positive 32 bit integer. <br>
|
||||
* <b>Default value:</b> `1024`
|
||||
*/
|
||||
#ifndef SIGV4_PROCESSING_BUFFER_LENGTH
|
||||
#define SIGV4_PROCESSING_BUFFER_LENGTH 428
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Macro defining the maximum number of headers in the request, used to
|
||||
* assist the library in sorting header fields during canonicalization.
|
||||
*
|
||||
* This macro should be updated if the number of request headers the application
|
||||
* wishes to sign is higher or lower than the default value (100).
|
||||
*
|
||||
* <b>Possible values:</b> Any positive 32 bit integer. <br>
|
||||
* <b>Default value:</b> `100`
|
||||
*/
|
||||
#ifndef SIGV4_MAX_HTTP_HEADER_COUNT
|
||||
#define SIGV4_MAX_HTTP_HEADER_COUNT 7U
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Macro defining the maximum number of query key/value pairs, used to
|
||||
* assist the library in sorting query keys during canonicalization.
|
||||
*
|
||||
* This macro should be updated if the number of query key/value pairs the
|
||||
* application wishes to sign is higher or lower than the default value (100).
|
||||
*
|
||||
* <b>Possible values:</b> Any positive 32 bit integer. <br>
|
||||
* <b>Default value:</b> `100`
|
||||
*/
|
||||
#ifndef SIGV4_MAX_QUERY_PAIR_COUNT
|
||||
#define SIGV4_MAX_QUERY_PAIR_COUNT 5U
|
||||
#endif
|
||||
|
||||
#endif /* ifndef SIGV4_CONFIG_H_ */
|
||||
1390
kernel/FreeRTOS-Plus/Source/AWS/sigv4/test/unit-test/sigv4_utest.c
Normal file
1390
kernel/FreeRTOS-Plus/Source/AWS/sigv4/test/unit-test/sigv4_utest.c
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user