Merge branch 'remove_monitor_tests_v5.1' into 'release/v5.1'

feat(tools/monitor): move target tests to monitor repo (v5.1)

See merge request espressif/esp-idf!26068
This commit is contained in:
Roland Dobai 2023-09-21 01:57:35 +08:00
commit cb174b0fe1
15 changed files with 0 additions and 228 deletions

View File

@ -1679,8 +1679,6 @@ tools/test_apps/system/longjmp_test/app_test.py
tools/test_apps/system/longjmp_test/main/hello_world_main.c
tools/test_apps/system/memprot/app_test.py
tools/test_apps/system/memprot/main/esp32s2/test_memprot_main.c
tools/test_apps/system/monitor_ide_integration/app_test.py
tools/test_apps/system/monitor_ide_integration/main/main.c
tools/test_apps/system/no_embedded_paths/check_for_file_paths.py
tools/test_apps/system/no_embedded_paths/main/test_no_embedded_paths_main.c
tools/test_apps/system/panic/app_test.py

View File

@ -24,6 +24,3 @@ pygobject; sys_platform != 'win32'
bleak
# future # addressed before under ble
protobuf
# tools/test_apps/system/monitor_ide_integration
SimpleWebSocketServer

View File

@ -142,16 +142,6 @@ tools/test_apps/system/memprot:
temporary: true
reason: the other targets are not tested yet
tools/test_apps/system/monitor_ide_integration:
enable:
- if: IDF_TARGET == "esp32" or IDF_TARGET == "esp32s2"
temporary: true
reason: the other targets are not tested yet
disable_test:
- if: IDF_TARGET == "esp32s2"
temporary: true
reason: lack of runners
tools/test_apps/system/no_embedded_paths:
enable:
- if: IDF_TARGET in ["esp32", "esp32c3", "esp32s2"]

View File

@ -1,4 +0,0 @@
cmake_minimum_required(VERSION 3.16)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(monitor_addr_lookup)

View File

@ -1,2 +0,0 @@
| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C6 | ESP32-H2 | ESP32-S2 | ESP32-S3 |
| ----------------- | ----- | -------- | -------- | -------- | -------- | -------- | -------- |

View File

@ -1,2 +0,0 @@
idf_component_register(SRCS "main.c"
INCLUDE_DIRS "")

View File

@ -1,42 +0,0 @@
/*
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Unlicense OR CC0-1.0
*/
#include <time.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
static volatile bool s_initialization_done = false;
static void initialize(void)
{
srand(time(0));
}
static int get_random_number(void)
{
if (!s_initialization_done) {
initialize();
s_initialization_done = true;
}
return rand();
}
void app_main(void)
{
volatile int number = get_random_number();
int *n = malloc(sizeof(int));
assert(n);
*n = number;
printf("app_main is running from 0x%x\n", (int) app_main);
printf("Initializer function at 0x%x\n", (int) initialize);
printf("Got %d stored at 0x%x and 0x%x from a function from 0x%x\n", *n, (int) n, (int) (&number), (int) get_random_number);
printf("This is the end of the report\n");
free(n);
}

View File

@ -1,43 +0,0 @@
# SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: Unlicense OR CC0-1.0
import os
import re
import sys
import pexpect
import pytest
from pytest_embedded import Dut
@pytest.mark.generic
@pytest.mark.supported_targets
def test_monitor_addr_lookup(config: str, dut: Dut) -> None:
# The port needs to be closed because esp_idf_monitor will connect to it
dut.serial.stop_redirect_thread()
monitor_cmd = ' '.join([sys.executable, '-m', 'esp_idf_monitor', os.path.join(dut.app.binary_path, 'monitor_addr_lookup.elf'),
'--port', str(dut.serial.port)])
monitor_log_path = os.path.join(dut.logdir, 'monitor.txt')
with open(monitor_log_path, 'w') as log, pexpect.spawn(monitor_cmd, logfile=log, timeout=5, encoding='utf-8', codec_errors='ignore') as p:
p.expect_exact('main_task: Calling app_main()')
ADDRESS = '0x[a-f0-9]{8}'
p.expect(re.compile(r'app_main is running from ({})'.format(ADDRESS)))
a = p.match.group(1)
p.expect_exact('{}: app_main at'.format(a))
p.expect(re.compile(r'Initializer function at ({})'.format(ADDRESS)))
a = p.match.group(1)
p.expect_exact('{}: initialize at'.format(a))
p.expect(re.compile(r'Got \d+ stored at ({}) and ({}) from a function from ({})'.format(ADDRESS, ADDRESS, ADDRESS)))
var1 = p.match.group(1)
var2 = p.match.group(2)
func = p.match.group(3)
match_index = p.expect([str(var1), str(var2), pexpect.TIMEOUT])
assert match_index == 2 # should be TIMEOUT because addr2line should not match addresses of variables
p.expect_exact('{}: get_random_number at'.format(func))
p.expect_exact('This is the end of the report')

View File

@ -1,4 +0,0 @@
cmake_minimum_required(VERSION 3.16)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(panic)

View File

@ -1,2 +0,0 @@
| Supported Targets | ESP32 | ESP32-S2 |
| ----------------- | ----- | -------- |

View File

@ -1,2 +0,0 @@
idf_component_register(SRCS "main.c"
INCLUDE_DIRS "")

View File

@ -1,18 +0,0 @@
/* Monitor-IDE integration test
This example code is in the Public Domain (or CC0 licensed, at your option.)
Unless required by applicable law or agreed to in writing, this
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied.
*/
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_system.h"
void app_main(void)
{
int *p = (int *)4;
vTaskDelay(2000 / portTICK_PERIOD_MS);
*p = 0;
}

View File

@ -1,92 +0,0 @@
# SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: Unlicense OR CC0-1.0
import json
import logging
import multiprocessing
import os
import re
import sys
from types import TracebackType
from typing import Optional, Type, TypeVar
import pexpect
import pytest
from pytest_embedded import Dut
from SimpleWebSocketServer import SimpleWebSocketServer, WebSocket
WebSocketServerType = TypeVar('WebSocketServerType')
class IDEWSProtocol(WebSocket):
def handleMessage(self) -> None:
try:
j = json.loads(self.data)
except Exception as e:
logging.info(f'Server ignores error: {e}')
return
event = j.get('event')
if event and 'prog' in j and ((event == 'gdb_stub' and 'port' in j) or
(event == 'coredump' and 'file' in j)):
payload = {'event': 'debug_finished'}
self.sendMessage(json.dumps(payload))
logging.info(f'Server sent: {payload}')
else:
logging.info(f'Server received: {j}')
def handleConnected(self) -> None:
logging.info(f'{self.address} connected to server')
def handleClose(self) -> None:
logging.info(f'{self.address} closed the connection')
class WebSocketServer(object):
HOST = '127.0.0.1'
PORT = 1123
def run(self) -> None:
server = SimpleWebSocketServer(self.HOST, self.PORT, IDEWSProtocol)
while not self.exit_event.is_set():
server.serveonce()
def __init__(self) -> None:
self.exit_event = multiprocessing.Event()
self.proc = multiprocessing.Process(target=self.run)
self.proc.start()
def __enter__(self: WebSocketServerType) -> WebSocketServerType:
return self
def __exit__(self, exc_type: Optional[Type[BaseException]], exc_value: Optional[BaseException], traceback:
Optional[TracebackType]) -> None:
self.exit_event.set()
self.proc.join(10)
if self.proc.is_alive():
logging.info('Process cannot be joined')
@pytest.mark.esp32
@pytest.mark.generic
@pytest.mark.parametrize('config', ['gdb_stub', 'coredump'], indirect=True)
def test_monitor_ide_integration(config: str, dut: Dut) -> None:
# The port needs to be closed because esp_idf_monitor will connect to it
dut.serial.stop_redirect_thread()
monitor_cmd = ' '.join([sys.executable, '-m', 'esp_idf_monitor', os.path.join(dut.app.binary_path, 'panic.elf'),
'--port', str(dut.serial.port),
'--ws', f'ws://{WebSocketServer.HOST}:{WebSocketServer.PORT}'])
monitor_log_path = os.path.join(dut.logdir, 'monitor.txt')
with open(monitor_log_path, 'w') as log, WebSocketServer(), pexpect.spawn(monitor_cmd,
logfile=log,
timeout=5,
encoding='utf-8',
codec_errors='ignore') as p:
p.expect(re.compile(r'Guru Meditation Error'), timeout=10)
p.expect_exact('Communicating through WebSocket')
# The elements of dictionary can be printed in different order depending on the Python version.
p.expect(re.compile(r"WebSocket sent: \{.*'event': '" + config + "'"))
p.expect_exact('Waiting for debug finished event')
p.expect(re.compile(r"WebSocket received: \{'event': 'debug_finished'\}"))
p.expect_exact('Communications through WebSocket is finished')

View File

@ -1 +0,0 @@
CONFIG_ESP_COREDUMP_ENABLE_TO_UART=y

View File

@ -1 +0,0 @@
CONFIG_ESP_SYSTEM_PANIC_GDBSTUB=y