From d5ff883d674532c03b5211fbd3f1a9c17856d4f7 Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Sun, 4 Jun 2017 15:57:49 +0200 Subject: [PATCH] test/flash_tlv: only validate when BTSTACK_TEST is defined --- test/flash_tlv/Makefile | 1 + test/flash_tlv/hal_flash_sector_memory.c | 13 ++++++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/test/flash_tlv/Makefile b/test/flash_tlv/Makefile index 8758c8251..9aff13b0f 100644 --- a/test/flash_tlv/Makefile +++ b/test/flash_tlv/Makefile @@ -16,6 +16,7 @@ VPATH = \ ${BTSTACK_ROOT}/src CFLAGS = \ + -DBTSTACK_TEST \ -g \ -Wall \ -Wmissing-prototypes \ diff --git a/test/flash_tlv/hal_flash_sector_memory.c b/test/flash_tlv/hal_flash_sector_memory.c index 1fec7d8c1..4efb6508f 100644 --- a/test/flash_tlv/hal_flash_sector_memory.c +++ b/test/flash_tlv/hal_flash_sector_memory.c @@ -40,9 +40,10 @@ #include "stdint.h" #include "string.h" -// validate +#ifdef BTSTACK_TEST #include "stdio.h" #include // exit(..) +#endif #define HAL_FLASH_SECTOR_SIZE 128 #define HAL_FLASH_SECTOR_NUM 2 @@ -51,10 +52,11 @@ static uint8_t hal_flash_storage_bank_1[HAL_FLASH_SECTOR_SIZE]; static uint8_t hal_flash_storage_bank_2[HAL_FLASH_SECTOR_SIZE]; static uint8_t * hal_flash_storage_banks[] = {hal_flash_storage_bank_1, hal_flash_storage_bank_2}; -// validate that memory isn't written twice +#ifdef BTSTACK_TEST static uint8_t hal_flash_storage_bank_1_written[HAL_FLASH_SECTOR_SIZE]; static uint8_t hal_flash_storage_bank_2_written[HAL_FLASH_SECTOR_SIZE]; static uint8_t * hal_flash_storage_banks_written[] = {hal_flash_storage_bank_1_written, hal_flash_storage_bank_2_written}; +#endif uint32_t hal_flash_sector_get_size(void){ return HAL_FLASH_SECTOR_SIZE; @@ -63,8 +65,9 @@ uint32_t hal_flash_sector_get_size(void){ void hal_flash_sector_erase(int bank){ if (bank > 1) return; memset(hal_flash_storage_banks[bank], 0xff, HAL_FLASH_SECTOR_SIZE); - // validate +#ifdef BTSTACK_TEST memset(hal_flash_storage_banks_written[bank], 0, HAL_FLASH_SECTOR_SIZE); +#endif } void hal_flash_sector_init(void){ @@ -91,7 +94,7 @@ void hal_flash_sector_write(int bank, uint32_t offset, const uint8_t * data, uin if (offset > HAL_FLASH_SECTOR_SIZE) return; if ((offset + size) > HAL_FLASH_SECTOR_SIZE) return; - // validate start +#ifdef BTSTACK_TEST int i; for (i=0;i