From a83189c75468833fc64c383d1e259656c068957b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=A9=B9=E6=98=8A?= Date: Mon, 28 Jul 2025 16:14:02 +0800 Subject: [PATCH] Add testcase MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Issue: #ICPG7C Signed-off-by: 詹昊 --- test/autotest/aw/cdp/debugger.py | 33 +++++++++- .../autotest/aw/implement_api/debugger_api.py | 20 +++++- .../TestMainBasicFuncWithGPSOff.py | 34 ++++++++++ .../performance/TestMainBasicFuncWithGPSOn.py | 63 +++++++++++++------ .../TestWorkerBasicFuncWithGPSOff.py | 34 ++++++++++ .../TestWorkerBasicFuncWithGPSOn.py | 63 +++++++++++++------ 6 files changed, 209 insertions(+), 38 deletions(-) diff --git a/test/autotest/aw/cdp/debugger.py b/test/autotest/aw/cdp/debugger.py index 3f94fb32..288bc81d 100644 --- a/test/autotest/aw/cdp/debugger.py +++ b/test/autotest/aw/cdp/debugger.py @@ -19,7 +19,7 @@ Description: Python CDP Debugger. from dataclasses import dataclass, field from enum import Enum -from typing import Optional +from typing import Optional, List @dataclass @@ -88,6 +88,14 @@ class BreakLocationUrl: return json +@dataclass +class SymbolicBreakpoint: + functionName: str + + def to_json(self): + return {'functionName': self.functionName} + + @dataclass class RemoveBreakpointsUrl: url: str = "" @@ -98,6 +106,11 @@ class SetBreakpointsLocations: locations: list = field(default_factory=list) +@dataclass +class SymbolicBreakpoints: + SymbolicBreakpoints: List[SymbolicBreakpoint] = field(default_factory=list) + + def enable(params: EnableAccelerateLaunchParams | None): command = {'method': 'Debugger.enable'} if params is not None: @@ -128,6 +141,24 @@ def get_possible_and_set_breakpoint_by_url(params: SetBreakpointsLocations): return command +def set_symbolic_breakpoints(params: SymbolicBreakpoints): + symbolicBreakpoints = [] + for symbolicBreakpoint in params.SymbolicBreakpoints: + symbolicBreakpoints.append(symbolicBreakpoint.to_json()) + command = {'method': 'Debugger.setSymbolicBreakpoints', + 'params': {'symbolicBreakpoints': symbolicBreakpoints}} + return command + + +def remove_symbolic_breakpoints(params: SymbolicBreakpoints): + symbolicBreakpoints = [] + for symbolicBreakpoint in params.SymbolicBreakpoints: + symbolicBreakpoints.append(symbolicBreakpoint.to_json()) + command = {'method': 'Debugger.removeSymbolicBreakpoints', + 'params': {'symbolicBreakpoints': symbolicBreakpoints}} + return command + + def step_over(): command = {'method': 'Debugger.stepOver'} return command diff --git a/test/autotest/aw/implement_api/debugger_api.py b/test/autotest/aw/implement_api/debugger_api.py index 333050c3..368e7658 100644 --- a/test/autotest/aw/implement_api/debugger_api.py +++ b/test/autotest/aw/implement_api/debugger_api.py @@ -42,6 +42,8 @@ class DebuggerImpl(ProtocolImpl): "removeBreakpointsByUrl": (self.remove_breakpoints_by_url, ProtocolType.send), "getPossibleAndSetBreakpointsByUrl": (self.get_possible_and_set_breakpoints_by_url, ProtocolType.send), + "setSymbolicBreakpoints": (self.set_symbolic_breakpoints, ProtocolType.send), + "removeSymbolicBreakpoints": (self.remove_symbolic_breakpoints, ProtocolType.send), "stepOver": (self.step_over, ProtocolType.send), "stepInto": (self.step_into, ProtocolType.send), "stepOut": (self.step_out, ProtocolType.send), @@ -139,6 +141,22 @@ class DebuggerImpl(ProtocolImpl): CommonUtils.assert_equal(response['id'], message_id) return response + async def set_symbolic_breakpoints(self, message_id, connection, params): + response = await comm_with_debugger_server(self.websocket, connection, + debugger.set_symbolic_breakpoints(params), + message_id) + response = json.loads(response) + CommonUtils.assert_equal(response['id'], message_id) + return response + + async def remove_symbolic_breakpoints(self, message_id, connection, params): + response = await comm_with_debugger_server(self.websocket, connection, + debugger.remove_symbolic_breakpoints(params), + message_id) + response = json.loads(response) + CommonUtils.assert_equal(response['id'], message_id) + return response + async def step_over(self, message_id, connection, params): response = await comm_with_debugger_server(self.websocket, connection, debugger.step_over(), message_id) @@ -211,7 +229,7 @@ class DebuggerImpl(ProtocolImpl): response = json.loads(response) CommonUtils.assert_equal(response['id'], message_id) return response - + async def save_all_possible_breakpoints(self, message_id, connection, params): response = await comm_with_debugger_server(self.websocket, connection, debugger.save_all_possible_breakpoints(params), message_id) diff --git a/test/autotest/testcases/toolchain/performance/TestMainBasicFuncWithGPSOff.py b/test/autotest/testcases/toolchain/performance/TestMainBasicFuncWithGPSOff.py index fa7dbbdd..ee7c3333 100644 --- a/test/autotest/testcases/toolchain/performance/TestMainBasicFuncWithGPSOff.py +++ b/test/autotest/testcases/toolchain/performance/TestMainBasicFuncWithGPSOff.py @@ -124,6 +124,17 @@ class TestMainBasicFuncWithGPSOff(TestCase): ################################################################################################################ await self.debugger_impl.send("Debugger.enable", main_thread) ################################################################################################################ + # main thread: Debugger.setSymbolicBreakpoints + ################################################################################################################ + symbolicBreakpoints = [debugger.SymbolicBreakpoint(functionName='testDebug')] + for i in range(1, 51): + symbolicBreakpoints.append(debugger.SymbolicBreakpoint(functionName='testDebug' + str(i))) + params = debugger.SymbolicBreakpoints(symbolicBreakpoints) + start_time = datetime.now() + await self.debugger_impl.send("Debugger.setSymbolicBreakpoints", main_thread, params) + end_time = datetime.now() + self.performance_utils.add_time_data("SetSymbolicBreakpoints", 10, (end_time - start_time).microseconds // 1000) + ################################################################################################################ # main thread: Runtime.runIfWaitingForDebugger ################################################################################################################ await self.runtime_impl.send("Runtime.runIfWaitingForDebugger", main_thread) @@ -631,6 +642,29 @@ class TestMainBasicFuncWithGPSOff(TestCase): params = debugger.RemoveBreakpointsUrl(self.config['file_path']['params']) await self.debugger_impl.send("Debugger.removeBreakpointsByUrl", main_thread, params) ################################################################################################################ + # main thread: Debugger.removeSymbolicBreakpoints + ################################################################################################################ + symbolicBreakpoints = [debugger.SymbolicBreakpoint(functionName='testDebug')] + for i in range(1, 51): + symbolicBreakpoints.append(debugger.SymbolicBreakpoint(functionName='testDebug' + str(i))) + params = debugger.SymbolicBreakpoints(symbolicBreakpoints) + start_time = datetime.now() + await self.debugger_impl.send("Debugger.removeSymbolicBreakpoints", main_thread, params) + end_time = datetime.now() + self.performance_utils.add_time_data("RemoveSymbolicBreakpoints", 10, + (end_time - start_time).microseconds // 1000) + for i in range(999): + start_time = datetime.now() + await self.debugger_impl.send("Debugger.setSymbolicBreakpoints", main_thread, params) + end_time = datetime.now() + self.performance_utils.add_time_data("SetSymbolicBreakpoints", 10, + (end_time - start_time).microseconds // 1000) + start_time = datetime.now() + await self.debugger_impl.send("Debugger.removeSymbolicBreakpoints", main_thread, params) + end_time = datetime.now() + self.performance_utils.add_time_data("RemoveSymbolicBreakpoints", 10, + (end_time - start_time).microseconds // 1000) + ################################################################################################################ # main thread: Debugger.resume ################################################################################################################ await self.debugger_impl.send("Debugger.resume", main_thread) diff --git a/test/autotest/testcases/toolchain/performance/TestMainBasicFuncWithGPSOn.py b/test/autotest/testcases/toolchain/performance/TestMainBasicFuncWithGPSOn.py index 28c37914..ed5e7f44 100644 --- a/test/autotest/testcases/toolchain/performance/TestMainBasicFuncWithGPSOn.py +++ b/test/autotest/testcases/toolchain/performance/TestMainBasicFuncWithGPSOn.py @@ -124,6 +124,17 @@ class TestMainBasicFuncWithGPSOn(TestCase): ################################################################################################################ await self.debugger_impl.send("Debugger.enable", main_thread) ################################################################################################################ + # main thread: Debugger.setSymbolicBreakpoints + ################################################################################################################ + symbolicBreakpoints = [debugger.SymbolicBreakpoint(functionName='testDropFrame')] + for i in range(1, 51): + symbolicBreakpoints.append(debugger.SymbolicBreakpoint(functionName='testDebug' + str(i))) + params = debugger.SymbolicBreakpoints(symbolicBreakpoints) + start_time = datetime.now() + await self.debugger_impl.send("Debugger.setSymbolicBreakpoints", main_thread, params) + end_time = datetime.now() + self.performance_utils.add_time_data("SetSymbolicBreakpoints", 10, (end_time - start_time).microseconds // 1000) + ################################################################################################################ # main thread: Runtime.runIfWaitingForDebugger ################################################################################################################ await self.runtime_impl.send("Runtime.runIfWaitingForDebugger", main_thread) @@ -210,20 +221,6 @@ class TestMainBasicFuncWithGPSOn(TestCase): self.config['file_path']['drop_frame']) self.common_utils.assert_equal(response['params']['reason'], 'Break on start') ################################################################################################################ - # main thread: Debugger.removeBreakpointsByUrl - ################################################################################################################ - params = debugger.RemoveBreakpointsUrl(self.config['file_path']['drop_frame']) - await self.debugger_impl.send("Debugger.removeBreakpointsByUrl", main_thread, params) - ################################################################################################################ - # main thread: Debugger.getPossibleAndSetBreakpointByUrl - ################################################################################################################ - locations = [debugger.BreakLocationUrl(url=self.config['file_path']['drop_frame'], line_number=4)] - params = debugger.SetBreakpointsLocations(locations) - response = await self.debugger_impl.send("Debugger.getPossibleAndSetBreakpointsByUrl", - main_thread, params) - self.common_utils.assert_equal(response['result']['locations'][0]['id'], - 'id:4:0:' + self.config['file_path']['drop_frame']) - ################################################################################################################ # main thread: Debugger.resume ################################################################################################################ await self.debugger_impl.send("Debugger.resume", main_thread) @@ -350,7 +347,13 @@ class TestMainBasicFuncWithGPSOn(TestCase): self.performance_utils.add_time_data("StepOut", 8, (end_time - start_time).microseconds // 1000) # Debugger.resume await self.debugger_impl.send("Debugger.resume", main_thread) - await self.debugger_impl.recv("Debugger.paused", main_thread) + if i != 499: + await self.debugger_impl.recv("Debugger.paused", main_thread) + else: + response = await self.debugger_impl.recv("Debugger.paused", main_thread) + print("response is ", response) + self.common_utils.assert_equal(response['params']['callFrames'][0]['functionName'], 'testDropFrame') + self.common_utils.assert_equal(response['params']['reason'], 'Symbol') ################################################################################################################ # main thread: Debugger.dropFrame ################################################################################################################ @@ -367,10 +370,11 @@ class TestMainBasicFuncWithGPSOn(TestCase): end_time = datetime.now() self.performance_utils.add_time_data("ResumeAndPaused", 8, (end_time - start_time).microseconds // 1000) ################################################################################################################ - # main thread: Debugger.removeBreakpointsByUrl + # main thread: Debugger.removeSymbolicBreakpoints ################################################################################################################ - params = debugger.RemoveBreakpointsUrl(self.config['file_path']['drop_frame']) - await self.debugger_impl.send("Debugger.removeBreakpointsByUrl", main_thread, params) + symbolicBreakpoints = [debugger.SymbolicBreakpoint(functionName='testDropFrame')] + params = debugger.SymbolicBreakpoints(symbolicBreakpoints) + await self.debugger_impl.send("Debugger.removeSymbolicBreakpoints", main_thread, params) ################################################################################################################ # main thread: Debugger.resume ################################################################################################################ @@ -631,6 +635,29 @@ class TestMainBasicFuncWithGPSOn(TestCase): params = debugger.RemoveBreakpointsUrl(self.config['file_path']['params']) await self.debugger_impl.send("Debugger.removeBreakpointsByUrl", main_thread, params) ################################################################################################################ + # main thread: Debugger.removeSymbolicBreakpoints + ################################################################################################################ + symbolicBreakpoints = [debugger.SymbolicBreakpoint(functionName='testDropFrame')] + for i in range(1, 51): + symbolicBreakpoints.append(debugger.SymbolicBreakpoint(functionName='testDebug' + str(i))) + params = debugger.SymbolicBreakpoints(symbolicBreakpoints) + start_time = datetime.now() + await self.debugger_impl.send("Debugger.removeSymbolicBreakpoints", main_thread, params) + end_time = datetime.now() + self.performance_utils.add_time_data("RemoveSymbolicBreakpoints", 10, + (end_time - start_time).microseconds // 1000) + for i in range(999): + start_time = datetime.now() + await self.debugger_impl.send("Debugger.setSymbolicBreakpoints", main_thread, params) + end_time = datetime.now() + self.performance_utils.add_time_data("SetSymbolicBreakpoints", 10, + (end_time - start_time).microseconds // 1000) + start_time = datetime.now() + await self.debugger_impl.send("Debugger.removeSymbolicBreakpoints", main_thread, params) + end_time = datetime.now() + self.performance_utils.add_time_data("RemoveSymbolicBreakpoints", 10, + (end_time - start_time).microseconds // 1000) + ################################################################################################################ # main thread: Debugger.resume ################################################################################################################ await self.debugger_impl.send("Debugger.resume", main_thread) diff --git a/test/autotest/testcases/toolchain/performance/TestWorkerBasicFuncWithGPSOff.py b/test/autotest/testcases/toolchain/performance/TestWorkerBasicFuncWithGPSOff.py index aa73b6e9..354b55e7 100644 --- a/test/autotest/testcases/toolchain/performance/TestWorkerBasicFuncWithGPSOff.py +++ b/test/autotest/testcases/toolchain/performance/TestWorkerBasicFuncWithGPSOff.py @@ -259,6 +259,17 @@ class TestWorkerBasicFuncWithGPSOff(TestCase): ################################################################################################################ await self.debugger_impl.send("Debugger.enable", worker_thread) ################################################################################################################ + # main thread: Debugger.setSymbolicBreakpoints + ################################################################################################################ + symbolicBreakpoints = [debugger.SymbolicBreakpoint(functionName='testDebug')] + for i in range(1, 51): + symbolicBreakpoints.append(debugger.SymbolicBreakpoint(functionName='testDebug' + str(i))) + params = debugger.SymbolicBreakpoints(symbolicBreakpoints) + start_time = datetime.now() + await self.debugger_impl.send("Debugger.setSymbolicBreakpoints", worker_thread, params) + end_time = datetime.now() + self.performance_utils.add_time_data("SetSymbolicBreakpoints", 10, (end_time - start_time).microseconds // 1000) + ################################################################################################################ # worker thread: Runtime.runIfWaitingForDebugger ################################################################################################################ await self.runtime_impl.send("Runtime.runIfWaitingForDebugger", worker_thread) @@ -755,6 +766,29 @@ class TestWorkerBasicFuncWithGPSOff(TestCase): params = debugger.RemoveBreakpointsUrl(self.config['file_path']['params']) await self.debugger_impl.send("Debugger.removeBreakpointsByUrl", worker_thread, params) ################################################################################################################ + # main thread: Debugger.removeSymbolicBreakpoints + ################################################################################################################ + symbolicBreakpoints = [debugger.SymbolicBreakpoint(functionName='testDebug')] + for i in range(1, 51): + symbolicBreakpoints.append(debugger.SymbolicBreakpoint(functionName='testDebug' + str(i))) + params = debugger.SymbolicBreakpoints(symbolicBreakpoints) + start_time = datetime.now() + await self.debugger_impl.send("Debugger.removeSymbolicBreakpoints", worker_thread, params) + end_time = datetime.now() + self.performance_utils.add_time_data("RemoveSymbolicBreakpoints", 10, + (end_time - start_time).microseconds // 1000) + for i in range(999): + start_time = datetime.now() + await self.debugger_impl.send("Debugger.SetSymbolicBreakpoints", worker_thread, params) + end_time = datetime.now() + self.performance_utils.add_time_data("setSymbolicBreakpoints", 10, + (end_time - start_time).microseconds // 1000) + start_time = datetime.now() + await self.debugger_impl.send("Debugger.removeSymbolicBreakpoints", worker_thread, params) + end_time = datetime.now() + self.performance_utils.add_time_data("RemoveSymbolicBreakpoints", 10, + (end_time - start_time).microseconds // 1000) + ################################################################################################################ # worker thread: Debugger.resume ################################################################################################################ await self.debugger_impl.send("Debugger.resume", worker_thread) diff --git a/test/autotest/testcases/toolchain/performance/TestWorkerBasicFuncWithGPSOn.py b/test/autotest/testcases/toolchain/performance/TestWorkerBasicFuncWithGPSOn.py index a8f8fc57..6ade4e63 100644 --- a/test/autotest/testcases/toolchain/performance/TestWorkerBasicFuncWithGPSOn.py +++ b/test/autotest/testcases/toolchain/performance/TestWorkerBasicFuncWithGPSOn.py @@ -259,6 +259,17 @@ class TestWorkerBasicFuncWithGPSOn(TestCase): ################################################################################################################ await self.debugger_impl.send("Debugger.enable", worker_thread) ################################################################################################################ + # main thread: Debugger.setSymbolicBreakpoints + ################################################################################################################ + symbolicBreakpoints = [debugger.SymbolicBreakpoint(functionName='testDropFrame')] + for i in range(1, 51): + symbolicBreakpoints.append(debugger.SymbolicBreakpoint(functionName='testDebug' + str(i))) + params = debugger.SymbolicBreakpoints(symbolicBreakpoints) + start_time = datetime.now() + await self.debugger_impl.send("Debugger.setSymbolicBreakpoints", worker_thread, params) + end_time = datetime.now() + self.performance_utils.add_time_data("SetSymbolicBreakpoints", 10, (end_time - start_time).microseconds // 1000) + ################################################################################################################ # worker thread: Runtime.runIfWaitingForDebugger ################################################################################################################ await self.runtime_impl.send("Runtime.runIfWaitingForDebugger", worker_thread) @@ -330,20 +341,6 @@ class TestWorkerBasicFuncWithGPSOn(TestCase): self.config['file_path']['drop_frame']) self.common_utils.assert_equal(response['params']['reason'], 'Break on start') ################################################################################################################ - # worker thread: Debugger.removeBreakpointsByUrl - ################################################################################################################ - params = debugger.RemoveBreakpointsUrl(self.config['file_path']['drop_frame']) - await self.debugger_impl.send("Debugger.removeBreakpointsByUrl", worker_thread, params) - ################################################################################################################ - # worker thread: Debugger.getPossibleAndSetBreakpointByUrl - ################################################################################################################ - locations = [debugger.BreakLocationUrl(url=self.config['file_path']['drop_frame'], line_number=4)] - params = debugger.SetBreakpointsLocations(locations) - response = await self.debugger_impl.send("Debugger.getPossibleAndSetBreakpointsByUrl", - worker_thread, params) - self.common_utils.assert_equal(response['result']['locations'][0]['id'], - 'id:4:0:' + self.config['file_path']['drop_frame']) - ################################################################################################################ # worker thread: Debugger.resume ################################################################################################################ await self.debugger_impl.send("Debugger.resume", worker_thread) @@ -472,7 +469,13 @@ class TestWorkerBasicFuncWithGPSOn(TestCase): self.performance_utils.add_time_data("StepOut(worker)", 8, (end_time - start_time).microseconds // 1000) # Debugger.resume await self.debugger_impl.send("Debugger.resume", worker_thread) - await self.debugger_impl.recv("Debugger.paused", worker_thread) + if i != 499: + await self.debugger_impl.recv("Debugger.paused", worker_thread) + else: + response = await self.debugger_impl.recv("Debugger.paused", worker_thread) + print("response is ", response) + self.common_utils.assert_equal(response['params']['callFrames'][0]['functionName'], 'testDropFrame') + self.common_utils.assert_equal(response['params']['reason'], 'Symbol') ################################################################################################################ # worker thread: Debugger.dropFrame ################################################################################################################ @@ -490,10 +493,11 @@ class TestWorkerBasicFuncWithGPSOn(TestCase): self.performance_utils.add_time_data("ResumeAndPaused(worker)", 8, (end_time - start_time).microseconds // 1000) ################################################################################################################ - # worker thread: Debugger.removeBreakpointsByUrl + # main thread: Debugger.removeSymbolicBreakpoints ################################################################################################################ - params = debugger.RemoveBreakpointsUrl(self.config['file_path']['drop_frame']) - await self.debugger_impl.send("Debugger.removeBreakpointsByUrl", worker_thread, params) + symbolicBreakpoints = [debugger.SymbolicBreakpoint(functionName='testDropFrame')] + params = debugger.SymbolicBreakpoints(symbolicBreakpoints) + await self.debugger_impl.send("Debugger.removeSymbolicBreakpoints", worker_thread, params) ################################################################################################################ # worker thread: Debugger.resume ################################################################################################################ @@ -755,6 +759,29 @@ class TestWorkerBasicFuncWithGPSOn(TestCase): params = debugger.RemoveBreakpointsUrl(self.config['file_path']['params']) await self.debugger_impl.send("Debugger.removeBreakpointsByUrl", worker_thread, params) ################################################################################################################ + # main thread: Debugger.removeSymbolicBreakpoints + ################################################################################################################ + symbolicBreakpoints = [debugger.SymbolicBreakpoint(functionName='testDropFrame')] + for i in range(1, 51): + symbolicBreakpoints.append(debugger.SymbolicBreakpoint(functionName='testDebug' + str(i))) + params = debugger.SymbolicBreakpoints(symbolicBreakpoints) + start_time = datetime.now() + await self.debugger_impl.send("Debugger.removeSymbolicBreakpoints", worker_thread, params) + end_time = datetime.now() + self.performance_utils.add_time_data("RemoveSymbolicBreakpoints", 10, + (end_time - start_time).microseconds // 1000) + for i in range(999): + start_time = datetime.now() + await self.debugger_impl.send("Debugger.setSymbolicBreakpoints", worker_thread, params) + end_time = datetime.now() + self.performance_utils.add_time_data("SetSymbolicBreakpoints", 10, + (end_time - start_time).microseconds // 1000) + start_time = datetime.now() + await self.debugger_impl.send("Debugger.removeSymbolicBreakpoints", worker_thread, params) + end_time = datetime.now() + self.performance_utils.add_time_data("RemoveSymbolicBreakpoints", 10, + (end_time - start_time).microseconds // 1000) + ################################################################################################################ # worker thread: Debugger.resume ################################################################################################################ await self.debugger_impl.send("Debugger.resume", worker_thread) -- Gitee