Skip to content

Commit

Permalink
test: enable IOT_CORE_LOG_FILE to test iot_dump_log
Browse files Browse the repository at this point in the history
(cherry-picked from commit 478c82b)
Signed-off-by: Hyundo Lee <[email protected]>
  • Loading branch information
hdlee27 authored and Kwang-Hui committed Oct 22, 2020
1 parent f63f137 commit 512fdcc
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/iot_dump_log.c
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,10 @@ int st_create_log_dump(IOT_CTX *iot_ctx, char **log_dump_output, size_t max_log_
#else
#error "Need to choice STDK_IOT_CORE_LOG_FILE_TYPE first"
#endif
if (!logfile) {
IOT_ERROR("fail to open log file");
return IOT_ERROR_BAD_REQ;
}
#endif

if (need_base64) {
Expand Down
6 changes: 4 additions & 2 deletions stdkconfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ SET(STDK_UNITTEST_EXTRA_CFLAGS
CONFIG_STDK_IOT_CORE_SECURITY_BACKEND_SOFTWARE
#CONFIG_STDK_IOT_CORE_EASYSETUP_POSIX_TESTING
CONFIG_STDK_IOT_CORE_CRYPTO_SUPPORT_VERIFY

CONFIG_STDK_IOT_CORE_LOG_FILE
CONFIG_STDK_IOT_CORE_LOG_FILE_RAM_ONLY
CONFIG_STDK_IOT_CORE_LOG_FILE_RAM_BUF_SIZE=8192
#CONFIG_STDK_IOT_CORE_LOG_LEVEL_ERROR
#CONFIG_STDK_IOT_CORE_LOG_LEVEL_WARN
#CONFIG_STDK_IOT_CORE_LOG_LEVEL_INFO
#CONFIG_STDK_IOT_CORE_LOG_LEVEL_DEBUG
)
)
7 changes: 6 additions & 1 deletion test/TC_FUNC_iot_dump_log.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ void TC_iot_dump_create_dump_state_failure(void **state)
size_t max_log_dump_size = 0;
int mode = 0;
iot_error_t err;
#ifdef CONFIG_STDK_IOT_CORE_LOG_FILE
int malloc_test_count = 4;
#else
int malloc_test_count = 3;
#endif

// Given : max_log_dump_size is smaller than minimum
max_log_dump_size = 1;
Expand All @@ -57,7 +62,7 @@ void TC_iot_dump_create_dump_state_failure(void **state)

mode = IOT_DUMP_MODE_NEED_BASE64 | IOT_DUMP_MODE_NEED_DUMP_STATE;
max_log_dump_size = 500;
for (int i = 0; i < 3; i++) {
for (int i = 0; i < malloc_test_count; i++) {
// Given: malloc failure
do_not_use_mock_iot_os_malloc_failure();
set_mock_iot_os_malloc_failure_with_index(i);
Expand Down

0 comments on commit 512fdcc

Please sign in to comment.