-
Notifications
You must be signed in to change notification settings - Fork 7.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'test/move_touch_related_unit_tests_to_test_apps' into '…
…master' test: move touch related unit tests to test apps Closes IDFCI-1283, IDFCI-1156, and IDF-5766 See merge request espressif/esp-idf!19348
- Loading branch information
Showing
45 changed files
with
383 additions
and
202 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
idf_component_register(SRC_DIRS . param_test touch_sensor_test dac_dma_test | ||
PRIV_INCLUDE_DIRS include param_test/include touch_sensor_test/include | ||
idf_component_register(SRC_DIRS . param_test dac_dma_test | ||
PRIV_INCLUDE_DIRS include param_test/include | ||
PRIV_REQUIRES cmock test_utils driver nvs_flash esp_serial_slave_link | ||
esp_timer esp_adc esp_event esp_wifi) | ||
target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# This is the project CMakeLists.txt file for the test subproject | ||
cmake_minimum_required(VERSION 3.16) | ||
|
||
include($ENV{IDF_PATH}/tools/cmake/project.cmake) | ||
project(touch_sensor_v1_test) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
| Supported Targets | ESP32 | | ||
| ----------------- | ----- | |
3 changes: 3 additions & 0 deletions
3
components/driver/test_apps/touch_sensor_v1/main/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
idf_component_register(SRCS "test_app_main.c" "test_touch_v1.c" | ||
WHOLE_ARCHIVE | ||
) |
40 changes: 40 additions & 0 deletions
40
components/driver/test_apps/touch_sensor_v1/main/test_app_main.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#include "unity.h" | ||
#include "unity_test_runner.h" | ||
#include "esp_heap_caps.h" | ||
|
||
#define TEST_MEMORY_LEAK_THRESHOLD (-200) | ||
|
||
static size_t before_free_8bit; | ||
static size_t before_free_32bit; | ||
|
||
static void check_leak(size_t before_free, size_t after_free, const char *type) | ||
{ | ||
ssize_t delta = after_free - before_free; | ||
printf("MALLOC_CAP_%s: Before %u bytes free, After %u bytes free (delta %d)\n", type, before_free, after_free, delta); | ||
TEST_ASSERT_MESSAGE(delta >= TEST_MEMORY_LEAK_THRESHOLD, "memory leak"); | ||
} | ||
|
||
void setUp(void) | ||
{ | ||
before_free_8bit = heap_caps_get_free_size(MALLOC_CAP_8BIT); | ||
before_free_32bit = heap_caps_get_free_size(MALLOC_CAP_32BIT); | ||
} | ||
|
||
void tearDown(void) | ||
{ | ||
size_t after_free_8bit = heap_caps_get_free_size(MALLOC_CAP_8BIT); | ||
size_t after_free_32bit = heap_caps_get_free_size(MALLOC_CAP_32BIT); | ||
check_leak(before_free_8bit, after_free_8bit, "8BIT"); | ||
check_leak(before_free_32bit, after_free_32bit, "32BIT"); | ||
} | ||
|
||
void app_main(void) | ||
{ | ||
unity_run_menu(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
components/driver/test_apps/touch_sensor_v1/pytest_touch_sensor_v1.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD | ||
# SPDX-License-Identifier: Unlicense OR CC0-1.0 | ||
import pytest | ||
from pytest_embedded import Dut | ||
|
||
|
||
@pytest.mark.esp32 | ||
@pytest.mark.generic | ||
def test_touch_sensor_v1(dut: Dut) -> None: | ||
dut.expect_exact('Press ENTER to see the list of tests') | ||
dut.write('*') | ||
dut.expect_unity_test_output(timeout=60) |
2 changes: 2 additions & 0 deletions
2
components/driver/test_apps/touch_sensor_v1/sdkconfig.defaults
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
CONFIG_FREERTOS_HZ=1000 | ||
CONFIG_ESP_TASK_WDT=n |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# This is the project CMakeLists.txt file for the test subproject | ||
cmake_minimum_required(VERSION 3.16) | ||
|
||
include($ENV{IDF_PATH}/tools/cmake/project.cmake) | ||
project(touch_sensor_v2_test) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
| Supported Targets | ESP32-S2 | ESP32-S3 | | ||
| ----------------- | -------- | -------- | |
3 changes: 3 additions & 0 deletions
3
components/driver/test_apps/touch_sensor_v2/main/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
idf_component_register(SRCS "test_app_main.c" "test_touch_v2.c" "touch_scope.c" | ||
WHOLE_ARCHIVE | ||
) |
41 changes: 41 additions & 0 deletions
41
components/driver/test_apps/touch_sensor_v2/main/test_app_main.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#include "unity.h" | ||
#include "unity_test_runner.h" | ||
#include "esp_heap_caps.h" | ||
|
||
// que_touch may be created in any case and reused among all cases so we can't free it, the threshold is left for that | ||
#define TEST_MEMORY_LEAK_THRESHOLD (-500) | ||
|
||
static size_t before_free_8bit; | ||
static size_t before_free_32bit; | ||
|
||
static void check_leak(size_t before_free, size_t after_free, const char *type) | ||
{ | ||
ssize_t delta = after_free - before_free; | ||
printf("MALLOC_CAP_%s: Before %u bytes free, After %u bytes free (delta %d)\n", type, before_free, after_free, delta); | ||
TEST_ASSERT_MESSAGE(delta >= TEST_MEMORY_LEAK_THRESHOLD, "memory leak"); | ||
} | ||
|
||
void setUp(void) | ||
{ | ||
before_free_8bit = heap_caps_get_free_size(MALLOC_CAP_8BIT); | ||
before_free_32bit = heap_caps_get_free_size(MALLOC_CAP_32BIT); | ||
} | ||
|
||
void tearDown(void) | ||
{ | ||
size_t after_free_8bit = heap_caps_get_free_size(MALLOC_CAP_8BIT); | ||
size_t after_free_32bit = heap_caps_get_free_size(MALLOC_CAP_32BIT); | ||
check_leak(before_free_8bit, after_free_8bit, "8BIT"); | ||
check_leak(before_free_32bit, after_free_32bit, "32BIT"); | ||
} | ||
|
||
void app_main(void) | ||
{ | ||
unity_run_menu(); | ||
} |
Oops, something went wrong.