Introduce WOLFSSL_ESPIDF_EXIT_MESSAGE macro (+code review edits)

This commit is contained in:
gojimmypi
2024-03-07 00:44:11 -08:00
parent f011012d8e
commit 38d5eec445
2 changed files with 27 additions and 13 deletions

View File

@@ -24,21 +24,25 @@
#include "sdkconfig.h" #include "sdkconfig.h"
/* wolfSSL */ /* wolfSSL */
/* The wolfSSL user_settings.h file is automatically included by the settings.h
* file and should never be explicitly included in any other source files.
* The settings.h should also be listed above wolfssl library include files. */
#include <wolfssl/wolfcrypt/settings.h> #include <wolfssl/wolfcrypt/settings.h>
#include <user_settings.h>
#include <wolfssl/version.h> #include <wolfssl/version.h>
#include "wolfssl/wolfcrypt/port/Espressif/esp32-crypt.h" #include <wolfssl/wolfcrypt/port/Espressif/esp32-crypt.h>
#ifndef WOLFSSL_ESPIDF #ifndef WOLFSSL_ESPIDF
#warning "Problem with wolfSSL user_settings." #error "Problem with wolfSSL user_settings. " \
#warning "Check components/wolfssl/include" "Check components/wolfssl/include " \
"and confirm WOLFSSL_USER_SETTINGS is defined, " \
"typically in the component CMakeLists.txt"
#endif #endif
#include <wolfssl/wolfcrypt/types.h> #include <wolfssl/wolfcrypt/types.h>
#include <wolfcrypt/benchmark/benchmark.h> #include <wolfcrypt/benchmark/benchmark.h>
/* set to 0 for one benchmark, /* set to 0 for one benchmark,
** set to 1 for continous benchmark loop */ ** set to 1 for continuous benchmark loop */
#define BENCHMARK_LOOP 1 #define BENCHMARK_LOOP 0
/* check BENCH_ARGV in sdkconfig to determine need to set WOLFSSL_BENCH_ARGV */ /* check BENCH_ARGV in sdkconfig to determine need to set WOLFSSL_BENCH_ARGV */
#ifdef CONFIG_BENCH_ARGV #ifdef CONFIG_BENCH_ARGV
@@ -129,6 +133,7 @@ void my_atmel_free(int slotId)
/* the following are needed by benchmark.c with args */ /* the following are needed by benchmark.c with args */
#ifdef WOLFSSL_BENCH_ARGV #ifdef WOLFSSL_BENCH_ARGV
char* __argv[WOLFSSL_BENCH_ARGV_MAX_ARGUMENTS]; char* __argv[WOLFSSL_BENCH_ARGV_MAX_ARGUMENTS];
#define ARG_BUFF_SIZE 16
int construct_argv() int construct_argv()
{ {
@@ -137,7 +142,7 @@ int construct_argv()
int len = 0; int len = 0;
char *_argv; /* buffer for copying the string */ char *_argv; /* buffer for copying the string */
char *ch; /* char pointer to trace the string */ char *ch; /* char pointer to trace the string */
char buff[16] = { 0 }; /* buffer for a argument copy */ char buff[ARG_BUFF_SIZE] = { 0 }; /* buffer for a argument copy */
ESP_LOGI(TAG, "construct_argv arg:%s\n", CONFIG_BENCH_ARGV); ESP_LOGI(TAG, "construct_argv arg:%s\n", CONFIG_BENCH_ARGV);
len = strlen(CONFIG_BENCH_ARGV); len = strlen(CONFIG_BENCH_ARGV);
@@ -170,7 +175,7 @@ int construct_argv()
memset(buff, 0, sizeof(buff)); memset(buff, 0, sizeof(buff));
/* copy each args into buffer */ /* copy each args into buffer */
i = 0; i = 0;
while ((*ch != ' ') && (*ch != '\0') && (i < 16)) { while ((*ch != ' ') && (*ch != '\0') && (i <= ARG_BUFF_SIZE)) {
buff[i] = *ch; buff[i] = *ch;
++i; ++i;
++ch; ++ch;
@@ -193,14 +198,15 @@ int construct_argv()
void app_main(void) void app_main(void)
{ {
int stack_start = 0; int stack_start = 0;
ESP_LOGI(TAG, "---------------- wolfSSL Benchmark Example ------------");
ESP_LOGI(TAG, "---------------- wolfSSL Benchmark Example -------------");
ESP_LOGI(TAG, "--------------------------------------------------------"); ESP_LOGI(TAG, "--------------------------------------------------------");
ESP_LOGI(TAG, "--------------------------------------------------------"); ESP_LOGI(TAG, "--------------------------------------------------------");
ESP_LOGI(TAG, "---------------------- BEGIN MAIN ----------------------"); ESP_LOGI(TAG, "---------------------- BEGIN MAIN ----------------------");
ESP_LOGI(TAG, "--------------------------------------------------------"); ESP_LOGI(TAG, "--------------------------------------------------------");
ESP_LOGI(TAG, "--------------------------------------------------------"); ESP_LOGI(TAG, "--------------------------------------------------------");
#ifdef HAVE_VERSION_EXTENDED_INFO #if defined(HAVE_VERSION_EXTENDED_INFO) && defined(WOLFSSL_HAS_METRICS)
esp_ShowExtendedSystemInfo(); esp_ShowExtendedSystemInfo();
#endif #endif
@@ -236,7 +242,7 @@ void app_main(void)
ESP_LOGI(TAG, "Stack used: %d\n", ESP_LOGI(TAG, "Stack used: %d\n",
stack_start - uxTaskGetStackHighWaterMark(NULL)); stack_start - uxTaskGetStackHighWaterMark(NULL));
#ifdef WOLFSSL_HW_METRICS_DISABLED/* Remove _DISABLED upon #6990 Merge */ #if defined(WOLFSSL_HW_METRICS) && defined(WOLFSSL_HAS_METRICS)
esp_hw_show_metrics(); esp_hw_show_metrics();
#endif #endif
} while (BENCHMARK_LOOP); } while (BENCHMARK_LOOP);
@@ -249,8 +255,9 @@ void app_main(void)
ESP_LOGI(TAG, "Stack HWM: %d\n", uxTaskGetStackHighWaterMark(NULL)); ESP_LOGI(TAG, "Stack HWM: %d\n", uxTaskGetStackHighWaterMark(NULL));
#endif #endif
ESP_LOGI(TAG, "\n\nDone!\n\n" #ifdef WOLFSSL_ESPIDF_EXIT_MESSAGE
"If running from idf.py monitor, press twice: Ctrl+]"); ESP_LOGI(TAG, WOLFSSL_ESPIDF_EXIT_MESSAGE);
#endif
/* after the test, we'll just wait */ /* after the test, we'll just wait */
while (1) { while (1) {

View File

@@ -51,6 +51,13 @@
#define WOLFSSL_ESPIDF_BLANKLINE_MESSAGE "." #define WOLFSSL_ESPIDF_BLANKLINE_MESSAGE "."
#endif #endif
/* Optional exit message.
* The WOLFSSL_COMPLETE keyword exits wolfSSL test harness script. */
#define WOLFSSL_ESPIDF_EXIT_MESSAGE \
"\n\nDone!" \
"\n\nWOLFSSL_COMPLETE" \
"\n\nIf running from idf.py monitor, press twice: Ctrl+]"
/* exit codes to be used in tfm.c, sp_int.c, integer.c, etc. /* exit codes to be used in tfm.c, sp_int.c, integer.c, etc.
* *
* see wolfssl/wolfcrypt/error-crypt.h * see wolfssl/wolfcrypt/error-crypt.h