mirror of
https://gitee.com/openharmony/arkcompiler_toolchain
synced 2024-11-23 07:30:33 +00:00
Test case supplement
Test case supplement for debug singal instance Issue:https://gitee.com/openharmony/arkcompiler_toolchain/issues/IAXKUS Signed-off-by: swx1282997 <shiminnan@huawei.com>
This commit is contained in:
parent
fa2f7d1ae6
commit
6457c85152
@ -44,6 +44,63 @@ def test_suite_main_instance_01_debug():
|
||||
return config
|
||||
|
||||
|
||||
@pytest.fixture(scope='class')
|
||||
def test_suite_main_instance_02_debug():
|
||||
logging.info('running main_instance_02 in debug mode')
|
||||
config = {
|
||||
'start_mode': '-D',
|
||||
'connect_server_port': 15702,
|
||||
'debugger_server_port': 15703,
|
||||
'bundle_name': 'com.example.mainInstance02',
|
||||
'hap_name': 'MainInstance02.hap',
|
||||
'hap_path': rf'{os.path.dirname(__file__)}\..\resource\MainInstance02.hap',
|
||||
'file_path': {
|
||||
'entry_ability': 'entry|entry|1.0.0|src/main/ets/entryability/EntryAbility.ts',
|
||||
'index': 'entry|entry|1.0.0|src/main/ets/pages/Index.ts',
|
||||
}
|
||||
}
|
||||
launch_hap(config)
|
||||
return config
|
||||
|
||||
|
||||
@pytest.fixture(scope='class')
|
||||
def test_suite_main_instance_03_debug():
|
||||
logging.info('running main_instance_03 in debug mode')
|
||||
config = {
|
||||
'start_mode': '-D',
|
||||
'connect_server_port': 15704,
|
||||
'debugger_server_port': 15705,
|
||||
'bundle_name': 'com.example.mainInstance03',
|
||||
'hap_name': 'MainInstance03.hap',
|
||||
'hap_path': rf'{os.path.dirname(__file__)}\..\resource\MainInstance03.hap',
|
||||
'file_path': {
|
||||
'entry_ability': 'entry|entry|1.0.0|src/main/ets/entryability/EntryAbility.ts',
|
||||
'index': 'entry|entry|1.0.0|src/main/ets/pages/Index.ts',
|
||||
}
|
||||
}
|
||||
launch_hap(config)
|
||||
return config
|
||||
|
||||
|
||||
@pytest.fixture(scope='class')
|
||||
def test_suite_main_instance_04_debug():
|
||||
logging.info('running main_instance_04 in debug mode')
|
||||
config = {
|
||||
'start_mode': '-D',
|
||||
'connect_server_port': 15706,
|
||||
'debugger_server_port': 15707,
|
||||
'bundle_name': 'com.example.mainInstance04',
|
||||
'hap_name': 'MainInstance04.hap',
|
||||
'hap_path': rf'{os.path.dirname(__file__)}\..\resource\MainInstance04.hap',
|
||||
'file_path': {
|
||||
'entry_ability': 'entry|entry|1.0.0|src/main/ets/entryability/EntryAbility.ts',
|
||||
'index': 'entry|entry|1.0.0|src/main/ets/pages/Index.ts',
|
||||
}
|
||||
}
|
||||
launch_hap(config)
|
||||
return config
|
||||
|
||||
|
||||
@pytest.fixture(scope='class')
|
||||
def test_suite_worker_08_debug():
|
||||
logging.info('running worker_08 in debug mode')
|
||||
@ -104,26 +161,6 @@ def test_suite_worker_06_debug():
|
||||
return config
|
||||
|
||||
|
||||
@pytest.fixture(scope='class')
|
||||
def test_suite_worker_06_debug():
|
||||
logging.info('running worker_06 in debug mode')
|
||||
config = {
|
||||
'start_mode': '-D',
|
||||
'connect_server_port': 15694,
|
||||
'debugger_server_port': 15695,
|
||||
'bundle_name': 'com.example.multiWorker06',
|
||||
'hap_name': 'MultiWorker06.hap',
|
||||
'hap_path': rf'{os.path.dirname(__file__)}\..\resource\MultiWorker06.hap',
|
||||
'file_path': {
|
||||
'entry_ability': 'entry|entry|1.0.0|src/main/ets/entryability/EntryAbility.ts',
|
||||
'index': 'entry|entry|1.0.0|src/main/ets/pages/Index.ts',
|
||||
'worker': 'entry|entry|1.0.0|src/main/ets/workers/Worker.ts'
|
||||
}
|
||||
}
|
||||
launch_hap(config)
|
||||
return config
|
||||
|
||||
|
||||
@pytest.fixture(scope='class')
|
||||
def test_suite_worker_05_debug():
|
||||
logging.info('running worker_05 in debug mode')
|
||||
|
185
test/autotest/scenario_test/test_main_breakpoint.py
Normal file
185
test/autotest/scenario_test/test_main_breakpoint.py
Normal file
@ -0,0 +1,185 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
Description: Scenario test case.
|
||||
"""
|
||||
|
||||
import logging
|
||||
import os
|
||||
import time
|
||||
|
||||
import pytest
|
||||
|
||||
from aw import Application
|
||||
from aw import Utils
|
||||
from aw import debugger, runtime
|
||||
from aw.api import debugger_api, runtime_api
|
||||
|
||||
|
||||
@pytest.mark.debug
|
||||
@pytest.mark.timeout(60)
|
||||
class TestDebug21:
|
||||
"""
|
||||
测试用例:单实例Sendable对象成员方法上普通断点的设置/取消
|
||||
测试步骤:
|
||||
1. 连接 connect server 和主线程 debugger server
|
||||
2. 主线程使能 Runtime 和 Debugger
|
||||
3. 主线程运行等待的调试器
|
||||
4. 主线程解析 entry_ability 和 index 文件
|
||||
5. 主线程 Index.ts 文件设置断点并运行
|
||||
6. 主线程 resume 验证是否正确命中断点
|
||||
7. 关闭主线程 debugger server 和 connect server 连接
|
||||
测试代码:
|
||||
@Sendable
|
||||
class TestClass {
|
||||
desc: string = "XXXXXXXX";// 自定义设置类成员
|
||||
taskNum: number = XXXXXXXX;
|
||||
get getTaskNum(): number {// 自定义设置类成员方法
|
||||
return this.taskNum;// 实例debug21断点
|
||||
}
|
||||
}
|
||||
const testInstance = new TestClass();
|
||||
let taskNumber = testInstance.getTaskNum;
|
||||
"""
|
||||
|
||||
def setup_method(self):
|
||||
logging.info('Start running TestDebug21: setup')
|
||||
|
||||
self.log_path = rf'{os.path.dirname(__file__)}\..\log'
|
||||
self.hilog_file_name = 'test_debug_21.hilog.txt'
|
||||
self.id_generator = Utils.message_id_generator()
|
||||
|
||||
# receive the hilog before the test start
|
||||
Utils.clear_fault_log()
|
||||
self.hilog_process, self.write_thread = Utils.save_hilog(log_path=self.log_path,
|
||||
file_name=self.hilog_file_name,
|
||||
debug_on=True)
|
||||
|
||||
def teardown_method(self):
|
||||
Application.uninstall(self.config['bundle_name'])
|
||||
|
||||
# terminate the hilog receive process after the test done
|
||||
time.sleep(3)
|
||||
self.hilog_process.stdout.close()
|
||||
self.hilog_process.terminate()
|
||||
self.hilog_process.wait()
|
||||
self.write_thread.join()
|
||||
|
||||
Utils.save_fault_log(log_path=self.log_path)
|
||||
logging.info('TestDebug21 done')
|
||||
|
||||
def test(self, test_suite_main_instance_02_debug):
|
||||
logging.info('Start running TestDebug21: test')
|
||||
self.config = test_suite_main_instance_02_debug
|
||||
websocket = self.config['websocket']
|
||||
taskpool = self.config['taskpool']
|
||||
pid = self.config['pid']
|
||||
self.debugger_impl = debugger_api.DebuggerImpl(self.id_generator, websocket)
|
||||
self.runtime_impl = runtime_api.RuntimeImpl(self.id_generator, websocket)
|
||||
|
||||
taskpool.submit(websocket.main_task(taskpool, self.procedure, pid))
|
||||
taskpool.await_taskpool()
|
||||
taskpool.task_join()
|
||||
if taskpool.task_exception:
|
||||
raise taskpool.task_exception
|
||||
|
||||
async def procedure(self, websocket):
|
||||
################################################################################################################
|
||||
# main thread: connect the debugger server
|
||||
################################################################################################################
|
||||
main_thread = await self.debugger_impl.connect_to_debugger_server(self.config['pid'], True)
|
||||
logging.info(f'Connect to the debugger server of instance: {main_thread.instance_id}')
|
||||
################################################################################################################
|
||||
# main thread: Runtime.enable
|
||||
################################################################################################################
|
||||
await self.runtime_impl.send("Runtime.enable", main_thread)
|
||||
################################################################################################################
|
||||
# main thread: Debugger.enable
|
||||
################################################################################################################
|
||||
await self.debugger_impl.send("Debugger.enable", main_thread)
|
||||
################################################################################################################
|
||||
# main thread: Runtime.runIfWaitingForDebugger
|
||||
################################################################################################################
|
||||
await self.runtime_impl.send("Runtime.runIfWaitingForDebugger", main_thread)
|
||||
################################################################################################################
|
||||
# main thread: Debugger.scriptParsed
|
||||
################################################################################################################
|
||||
response = await self.debugger_impl.recv("Debugger.scriptParsed", main_thread)
|
||||
assert response['params']['url'] == self.config['file_path']['entry_ability']
|
||||
assert response['params']['endLine'] == 0
|
||||
################################################################################################################
|
||||
# main thread: Debugger.paused
|
||||
################################################################################################################
|
||||
response = await self.debugger_impl.recv("Debugger.paused", main_thread)
|
||||
assert response['params']['callFrames'][0]['url'] == self.config['file_path']['entry_ability']
|
||||
assert response['params']['reason'] == 'Break on start'
|
||||
################################################################################################################
|
||||
# main thread: Debugger.resume
|
||||
################################################################################################################
|
||||
await self.debugger_impl.send("Debugger.resume", main_thread)
|
||||
################################################################################################################
|
||||
# main thread: Debugger.scriptParsed
|
||||
################################################################################################################
|
||||
response = await self.debugger_impl.recv("Debugger.scriptParsed", main_thread)
|
||||
assert response['params']['url'] == self.config['file_path']['index']
|
||||
assert response['params']['endLine'] == 0
|
||||
################################################################################################################
|
||||
# main thread: Debugger.paused
|
||||
################################################################################################################
|
||||
response = await self.debugger_impl.recv("Debugger.paused", main_thread)
|
||||
assert response['params']['callFrames'][0]['url'] == self.config['file_path']['index']
|
||||
assert response['params']['reason'] == 'Break on start'
|
||||
################################################################################################################
|
||||
# main thread: Debugger.removeBreakpointsByUrl
|
||||
################################################################################################################
|
||||
params = debugger.RemoveBreakpointsUrl(self.config['file_path']['index'])
|
||||
await self.debugger_impl.send("Debugger.removeBreakpointsByUrl", main_thread, params)
|
||||
################################################################################################################
|
||||
# main thread: Debugger.getPossibleAndSetBreakpointByUrl
|
||||
################################################################################################################
|
||||
locations = [debugger.BreakLocationUrl(url=self.config['file_path']['index'], line_number=74)]
|
||||
params = debugger.SetBreakpointsLocations(locations)
|
||||
response = await self.debugger_impl.send("Debugger.getPossibleAndSetBreakpointsByUrl",
|
||||
main_thread, params)
|
||||
assert response['result']['locations'][0]['id'] == 'id:74:0:' + self.config['file_path']['index']
|
||||
################################################################################################################
|
||||
# main thread: Debugger.resume
|
||||
################################################################################################################
|
||||
await self.debugger_impl.send("Debugger.resume", main_thread)
|
||||
################################################################################################################
|
||||
# main thread: Debugger.paused, hit breakpoint
|
||||
################################################################################################################
|
||||
response = await self.debugger_impl.recv("Debugger.paused", main_thread)
|
||||
assert response['params']['callFrames'][0]['url'] == self.config['file_path']['index']
|
||||
assert response['params']['hitBreakpoints'] == ['id:74:15:' + self.config['file_path']['index']]
|
||||
################################################################################################################
|
||||
# main thread: Debugger.resume
|
||||
################################################################################################################
|
||||
await self.debugger_impl.send("Debugger.resume", main_thread)
|
||||
###############################################################################################################
|
||||
# main thread: click on the screen
|
||||
################################################################################################################
|
||||
Application.click_on_middle()
|
||||
################################################################################################################
|
||||
# main thread: Debugger.disable
|
||||
################################################################################################################
|
||||
await self.debugger_impl.send("Debugger.disable", main_thread)
|
||||
################################################################################################################
|
||||
# close the websocket connections
|
||||
################################################################################################################
|
||||
await websocket.send_msg_to_debugger_server(main_thread.instance_id, main_thread.send_msg_queue, 'close')
|
||||
await websocket.send_msg_to_connect_server('close')
|
||||
################################################################################################################
|
192
test/autotest/scenario_test/test_main_breakpoint_class.py
Normal file
192
test/autotest/scenario_test/test_main_breakpoint_class.py
Normal file
@ -0,0 +1,192 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
Description: Scenario test case.
|
||||
"""
|
||||
|
||||
import logging
|
||||
import os
|
||||
import time
|
||||
|
||||
import pytest
|
||||
|
||||
from aw import Application
|
||||
from aw import Utils
|
||||
from aw import debugger, runtime
|
||||
from aw.api import debugger_api, runtime_api
|
||||
|
||||
|
||||
@pytest.mark.debug
|
||||
@pytest.mark.timeout(60)
|
||||
class TestDebug22:
|
||||
"""
|
||||
测试用例:单实例Sendable类信息查看
|
||||
测试步骤:
|
||||
1. 连接 connect server 和主线程 debugger server
|
||||
2. 主线程使能 Runtime 和 Debugger
|
||||
3. 主线程运行等待的调试器
|
||||
4. 主线程解析 entry_ability 和 index 文件
|
||||
5. 主线程 Index.ts 文件设置断点
|
||||
6. 主线程 resume 验证是否正确命中断点
|
||||
7. 主线程查询类对象并验证是否携带 Sendable 标签
|
||||
8. 关闭主线程 debugger server 和 connect server 连接
|
||||
测试代码:
|
||||
@Sendable
|
||||
class TestClass {
|
||||
desc: string = "XXXXXXXX";// 自定义设置类成员
|
||||
taskNum: number = XXXXXXXX;
|
||||
get getTaskNum(): number {// 自定义设置类成员方法
|
||||
return this.taskNum;
|
||||
}
|
||||
}
|
||||
const testInstance = new TestClass();
|
||||
let taskNumber = testInstance.getTaskNum;// 实例debug22断点查询处
|
||||
"""
|
||||
|
||||
def setup_method(self):
|
||||
logging.info('Start running TestDebug22: setup')
|
||||
|
||||
self.log_path = rf'{os.path.dirname(__file__)}\..\log'
|
||||
self.hilog_file_name = 'test_debug_22.hilog.txt'
|
||||
self.id_generator = Utils.message_id_generator()
|
||||
|
||||
# receive the hilog before the test start
|
||||
Utils.clear_fault_log()
|
||||
self.hilog_process, self.write_thread = Utils.save_hilog(log_path=self.log_path,
|
||||
file_name=self.hilog_file_name,
|
||||
debug_on=True)
|
||||
|
||||
def teardown_method(self):
|
||||
Application.uninstall(self.config['bundle_name'])
|
||||
|
||||
# terminate the hilog receive process after the test done
|
||||
time.sleep(3)
|
||||
self.hilog_process.stdout.close()
|
||||
self.hilog_process.terminate()
|
||||
self.hilog_process.wait()
|
||||
self.write_thread.join()
|
||||
|
||||
Utils.save_fault_log(log_path=self.log_path)
|
||||
logging.info('TestDebug22 done')
|
||||
|
||||
def test(self, test_suite_main_instance_02_debug):
|
||||
logging.info('Start running TestDebug22: test')
|
||||
self.config = test_suite_main_instance_02_debug
|
||||
websocket = self.config['websocket']
|
||||
taskpool = self.config['taskpool']
|
||||
pid = self.config['pid']
|
||||
self.debugger_impl = debugger_api.DebuggerImpl(self.id_generator, websocket)
|
||||
self.runtime_impl = runtime_api.RuntimeImpl(self.id_generator, websocket)
|
||||
|
||||
taskpool.submit(websocket.main_task(taskpool, self.procedure, pid))
|
||||
taskpool.await_taskpool()
|
||||
taskpool.task_join()
|
||||
if taskpool.task_exception:
|
||||
raise taskpool.task_exception
|
||||
|
||||
async def procedure(self, websocket):
|
||||
################################################################################################################
|
||||
# main thread: connect the debugger server
|
||||
################################################################################################################
|
||||
main_thread = await self.debugger_impl.connect_to_debugger_server(self.config['pid'], True)
|
||||
logging.info(f'Connect to the debugger server of instance: {main_thread.instance_id}')
|
||||
################################################################################################################
|
||||
# main thread: Runtime.enable
|
||||
################################################################################################################
|
||||
await self.runtime_impl.send("Runtime.enable", main_thread)
|
||||
################################################################################################################
|
||||
# main thread: Debugger.enable
|
||||
################################################################################################################
|
||||
await self.debugger_impl.send("Debugger.enable", main_thread)
|
||||
################################################################################################################
|
||||
# main thread: Runtime.runIfWaitingForDebugger
|
||||
################################################################################################################
|
||||
await self.runtime_impl.send("Runtime.runIfWaitingForDebugger", main_thread)
|
||||
################################################################################################################
|
||||
# main thread: Debugger.scriptParsed
|
||||
################################################################################################################
|
||||
response = await self.debugger_impl.recv("Debugger.scriptParsed", main_thread)
|
||||
assert response['params']['url'] == self.config['file_path']['entry_ability']
|
||||
assert response['params']['endLine'] == 0
|
||||
################################################################################################################
|
||||
# main thread: Debugger.paused
|
||||
################################################################################################################
|
||||
response = await self.debugger_impl.recv("Debugger.paused", main_thread)
|
||||
assert response['params']['callFrames'][0]['url'] == self.config['file_path']['entry_ability']
|
||||
assert response['params']['reason'] == 'Break on start'
|
||||
################################################################################################################
|
||||
# main thread: Debugger.resume
|
||||
################################################################################################################
|
||||
await self.debugger_impl.send("Debugger.resume", main_thread)
|
||||
################################################################################################################
|
||||
# main thread: Debugger.scriptParsed
|
||||
################################################################################################################
|
||||
response = await self.debugger_impl.recv("Debugger.scriptParsed", main_thread)
|
||||
assert response['params']['url'] == self.config['file_path']['index']
|
||||
assert response['params']['endLine'] == 0
|
||||
################################################################################################################
|
||||
# main thread: Debugger.paused
|
||||
################################################################################################################
|
||||
response = await self.debugger_impl.recv("Debugger.paused", main_thread)
|
||||
assert response['params']['callFrames'][0]['url'] == self.config['file_path']['index']
|
||||
assert response['params']['reason'] == 'Break on start'
|
||||
################################################################################################################
|
||||
# main thread: Debugger.removeBreakpointsByUrl
|
||||
################################################################################################################
|
||||
params = debugger.RemoveBreakpointsUrl(self.config['file_path']['index'])
|
||||
await self.debugger_impl.send("Debugger.removeBreakpointsByUrl", main_thread, params)
|
||||
################################################################################################################
|
||||
# main thread: Debugger.getPossibleAndSetBreakpointByUrl
|
||||
################################################################################################################
|
||||
locations = [debugger.BreakLocationUrl(url=self.config['file_path']['index'], line_number=78)]
|
||||
params = debugger.SetBreakpointsLocations(locations)
|
||||
response = await self.debugger_impl.send("Debugger.getPossibleAndSetBreakpointsByUrl",
|
||||
main_thread, params)
|
||||
assert response['result']['locations'][0]['id'] == 'id:78:0:' + self.config['file_path']['index']
|
||||
################################################################################################################
|
||||
# main thread: Debugger.resume
|
||||
################################################################################################################
|
||||
await self.debugger_impl.send("Debugger.resume", main_thread)
|
||||
################################################################################################################
|
||||
# main thread: Debugger.paused, hit breakpoint
|
||||
################################################################################################################
|
||||
response = await self.debugger_impl.recv("Debugger.paused", main_thread)
|
||||
assert response['params']['callFrames'][0]['url'] == self.config['file_path']['index']
|
||||
assert response['params']['hitBreakpoints'] == ['id:78:17:' + self.config['file_path']['index']]
|
||||
################################################################################################################
|
||||
# main thread: Runtime.getProperties and check sendable
|
||||
################################################################################################################
|
||||
params = debugger.EvaluateOnCallFrameParams('testInstance')
|
||||
response = await self.debugger_impl.send("Debugger.evaluateOnCallFrame", main_thread, params)
|
||||
assert '[Sendable]' in response['result']['result']['description']
|
||||
################################################################################################################
|
||||
# main thread: Debugger.resume
|
||||
################################################################################################################
|
||||
await self.debugger_impl.send("Debugger.resume", main_thread)
|
||||
################################################################################################################
|
||||
# main thread: click on the screen
|
||||
################################################################################################################
|
||||
Application.click_on_middle()
|
||||
################################################################################################################
|
||||
# main thread: Debugger.disable
|
||||
################################################################################################################
|
||||
await self.debugger_impl.send("Debugger.disable", main_thread)
|
||||
################################################################################################################
|
||||
# close the websocket connections
|
||||
################################################################################################################
|
||||
await websocket.send_msg_to_debugger_server(main_thread.instance_id, main_thread.send_msg_queue, 'close')
|
||||
await websocket.send_msg_to_connect_server('close')
|
||||
################################################################################################################
|
182
test/autotest/scenario_test/test_main_exception_breakpoint_01.py
Normal file
182
test/autotest/scenario_test/test_main_exception_breakpoint_01.py
Normal file
@ -0,0 +1,182 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
Description: Scenario test case.
|
||||
"""
|
||||
|
||||
import logging
|
||||
import os
|
||||
import time
|
||||
|
||||
import pytest
|
||||
|
||||
from aw import Application
|
||||
from aw import Utils
|
||||
from aw import debugger, runtime
|
||||
from aw.api import debugger_api, runtime_api
|
||||
|
||||
|
||||
@pytest.mark.debug
|
||||
@pytest.mark.timeout(60)
|
||||
class TestDebug24:
|
||||
"""
|
||||
测试用例:单实例异常断点的设置/取消
|
||||
测试步骤:
|
||||
1. 连接 connect server 和主线程 debugger server
|
||||
2. 主线程使能 Runtime 和 Debugger
|
||||
3. 主线程运行等待的调试器
|
||||
4. 主线程解析 entry_ability 和 index 文件
|
||||
5. 设置异常捕获状态 ALL
|
||||
6. 主线程 resume(Debugger.resume)命中异常断点,验证异常断点信息 CAUGHT 类型异常
|
||||
7. 主线程 resume(Debugger.resume)命中异常断点,验证异常断点信息 UNCAUGHT 类型异常
|
||||
8. 关闭主线程 debugger server 和 connect server 连接
|
||||
测试代码:
|
||||
function main() {
|
||||
try {
|
||||
throw new Error("This is a caught error");
|
||||
} catch (error) {
|
||||
console.log("After error");
|
||||
}
|
||||
throw new Error("This is a uncaught error");
|
||||
}
|
||||
|
||||
main();
|
||||
"""
|
||||
|
||||
def setup_method(self):
|
||||
logging.info('Start running TestDebug24: setup')
|
||||
|
||||
self.log_path = rf'{os.path.dirname(__file__)}\..\log'
|
||||
self.hilog_file_name = 'test_debug_24.hilog.txt'
|
||||
self.id_generator = Utils.message_id_generator()
|
||||
|
||||
# receive the hilog before the test start
|
||||
Utils.clear_fault_log()
|
||||
self.hilog_process, self.write_thread = Utils.save_hilog(log_path=self.log_path,
|
||||
file_name=self.hilog_file_name,
|
||||
debug_on=True)
|
||||
|
||||
def teardown_method(self):
|
||||
Application.uninstall(self.config['bundle_name'])
|
||||
|
||||
# terminate the hilog receive process after the test done
|
||||
time.sleep(3)
|
||||
self.hilog_process.stdout.close()
|
||||
self.hilog_process.terminate()
|
||||
self.hilog_process.wait()
|
||||
self.write_thread.join()
|
||||
|
||||
Utils.save_fault_log(log_path=self.log_path)
|
||||
logging.info('TestDebug24 done')
|
||||
|
||||
def test(self, test_suite_main_instance_04_debug):
|
||||
logging.info('Start running TestDebug24: test')
|
||||
self.config = test_suite_main_instance_04_debug
|
||||
websocket = self.config['websocket']
|
||||
taskpool = self.config['taskpool']
|
||||
pid = self.config['pid']
|
||||
self.debugger_impl = debugger_api.DebuggerImpl(self.id_generator, websocket)
|
||||
self.runtime_impl = runtime_api.RuntimeImpl(self.id_generator, websocket)
|
||||
|
||||
taskpool.submit(websocket.main_task(taskpool, self.procedure, pid))
|
||||
taskpool.await_taskpool()
|
||||
taskpool.task_join()
|
||||
if taskpool.task_exception:
|
||||
raise taskpool.task_exception
|
||||
|
||||
async def procedure(self, websocket):
|
||||
################################################################################################################
|
||||
# main thread: connect the debugger server
|
||||
################################################################################################################
|
||||
main_thread = await self.debugger_impl.connect_to_debugger_server(self.config['pid'], True)
|
||||
logging.info(f'Connect to the debugger server of instance: {main_thread.instance_id}')
|
||||
################################################################################################################
|
||||
# main thread: Runtime.enable
|
||||
################################################################################################################
|
||||
await self.runtime_impl.send("Runtime.enable", main_thread)
|
||||
################################################################################################################
|
||||
# main thread: Debugger.enable
|
||||
################################################################################################################
|
||||
await self.debugger_impl.send("Debugger.enable", main_thread)
|
||||
################################################################################################################
|
||||
# main thread: Runtime.runIfWaitingForDebugger
|
||||
################################################################################################################
|
||||
await self.runtime_impl.send("Runtime.runIfWaitingForDebugger", main_thread)
|
||||
################################################################################################################
|
||||
# main thread: Debugger.scriptParsed
|
||||
################################################################################################################
|
||||
response = await self.debugger_impl.recv("Debugger.scriptParsed", main_thread)
|
||||
assert response['params']['url'] == self.config['file_path']['entry_ability']
|
||||
assert response['params']['endLine'] == 0
|
||||
################################################################################################################
|
||||
# main thread: Debugger.paused
|
||||
################################################################################################################
|
||||
response = await self.debugger_impl.recv("Debugger.paused", main_thread)
|
||||
assert response['params']['callFrames'][0]['url'] == self.config['file_path']['entry_ability']
|
||||
assert response['params']['reason'] == 'Break on start'
|
||||
################################################################################################################
|
||||
# main thread: Debugger.resume
|
||||
################################################################################################################
|
||||
await self.debugger_impl.send("Debugger.resume", main_thread)
|
||||
################################################################################################################
|
||||
# main thread: Debugger.scriptParsed
|
||||
################################################################################################################
|
||||
response = await self.debugger_impl.recv("Debugger.scriptParsed", main_thread)
|
||||
assert response['params']['url'] == self.config['file_path']['index']
|
||||
assert response['params']['endLine'] == 0
|
||||
################################################################################################################
|
||||
# main thread: Debugger.paused
|
||||
################################################################################################################
|
||||
response = await self.debugger_impl.recv("Debugger.paused", main_thread)
|
||||
assert response['params']['callFrames'][0]['url'] == self.config['file_path']['index']
|
||||
assert response['params']['reason'] == 'Break on start'
|
||||
################################################################################################################
|
||||
# main thread: Debugger.setPauseOnExceptions
|
||||
################################################################################################################
|
||||
params = debugger.PauseOnExceptionsState.ALL
|
||||
await self.debugger_impl.send("Debugger.setPauseOnExceptions", main_thread, params)
|
||||
################################################################################################################
|
||||
# main thread: Debugger.resume
|
||||
################################################################################################################
|
||||
await self.debugger_impl.send("Debugger.resume", main_thread)
|
||||
################################################################################################################
|
||||
# main thread: Debugger.paused
|
||||
################################################################################################################
|
||||
response = await self.debugger_impl.recv("Debugger.paused", main_thread)
|
||||
assert response['params']['callFrames'][0]['url'] == self.config['file_path']['index']
|
||||
assert response['params']['reason'] == 'exception'
|
||||
assert 'This is a caught error' in response['params']['data']['unserializableValue']
|
||||
################################################################################################################
|
||||
# main thread: Debugger.resume
|
||||
################################################################################################################
|
||||
await self.debugger_impl.send("Debugger.resume", main_thread)
|
||||
################################################################################################################
|
||||
# main thread: Debugger.paused
|
||||
################################################################################################################
|
||||
response = await self.debugger_impl.recv("Debugger.paused", main_thread)
|
||||
assert response['params']['callFrames'][0]['url'] == self.config['file_path']['index']
|
||||
assert response['params']['reason'] == 'exception'
|
||||
assert 'This is a uncaught error' in response['params']['data']['unserializableValue']
|
||||
################################################################################################################
|
||||
# main thread: Debugger.resume
|
||||
################################################################################################################
|
||||
await self.debugger_impl.send("Debugger.resume", main_thread)
|
||||
################################################################################################################
|
||||
# close the websocket connections
|
||||
################################################################################################################
|
||||
await websocket.send_msg_to_debugger_server(main_thread.instance_id, main_thread.send_msg_queue, 'close')
|
||||
await websocket.send_msg_to_connect_server('close')
|
||||
################################################################################################################
|
170
test/autotest/scenario_test/test_main_exception_breakpoint_02.py
Normal file
170
test/autotest/scenario_test/test_main_exception_breakpoint_02.py
Normal file
@ -0,0 +1,170 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
Description: Scenario test case.
|
||||
"""
|
||||
|
||||
import logging
|
||||
import os
|
||||
import time
|
||||
|
||||
import pytest
|
||||
|
||||
from aw import Application
|
||||
from aw import Utils
|
||||
from aw import debugger, runtime
|
||||
from aw.api import debugger_api, runtime_api
|
||||
|
||||
|
||||
@pytest.mark.debug
|
||||
@pytest.mark.timeout(60)
|
||||
class TestDebug25:
|
||||
"""
|
||||
测试用例:单实例异常断点的设置/取消
|
||||
测试步骤:
|
||||
1. 连接 connect server 和主线程 debugger server
|
||||
2. 主线程使能 Runtime 和 Debugger
|
||||
3. 主线程运行等待的调试器
|
||||
4. 主线程解析 entry_ability 和 index 文件
|
||||
5. 设置异常捕获状态 UNCAUGHT
|
||||
6. 主线程 resume(Debugger.resume)命中异常断点,验证异常断点信息 UNCAUGHT 类型异常
|
||||
7. 关闭主线程 debugger server 和 connect server 连接
|
||||
测试代码:
|
||||
function main() {
|
||||
try {
|
||||
throw new Error("This is a caught error");
|
||||
} catch (error) {
|
||||
console.log("After error");
|
||||
}
|
||||
throw new Error("This is a uncaught error");
|
||||
}
|
||||
|
||||
main();
|
||||
"""
|
||||
|
||||
def setup_method(self):
|
||||
logging.info('Start running TestDebug25: setup')
|
||||
|
||||
self.log_path = rf'{os.path.dirname(__file__)}\..\log'
|
||||
self.hilog_file_name = 'test_debug_25.hilog.txt'
|
||||
self.id_generator = Utils.message_id_generator()
|
||||
|
||||
# receive the hilog before the test start
|
||||
Utils.clear_fault_log()
|
||||
self.hilog_process, self.write_thread = Utils.save_hilog(log_path=self.log_path,
|
||||
file_name=self.hilog_file_name,
|
||||
debug_on=True)
|
||||
|
||||
def teardown_method(self):
|
||||
Application.uninstall(self.config['bundle_name'])
|
||||
|
||||
# terminate the hilog receive process after the test done
|
||||
time.sleep(3)
|
||||
self.hilog_process.stdout.close()
|
||||
self.hilog_process.terminate()
|
||||
self.hilog_process.wait()
|
||||
self.write_thread.join()
|
||||
|
||||
Utils.save_fault_log(log_path=self.log_path)
|
||||
logging.info('TestDebug25 done')
|
||||
|
||||
def test(self, test_suite_main_instance_04_debug):
|
||||
logging.info('Start running TestDebug25: test')
|
||||
self.config = test_suite_main_instance_04_debug
|
||||
websocket = self.config['websocket']
|
||||
taskpool = self.config['taskpool']
|
||||
pid = self.config['pid']
|
||||
self.debugger_impl = debugger_api.DebuggerImpl(self.id_generator, websocket)
|
||||
self.runtime_impl = runtime_api.RuntimeImpl(self.id_generator, websocket)
|
||||
|
||||
taskpool.submit(websocket.main_task(taskpool, self.procedure, pid))
|
||||
taskpool.await_taskpool()
|
||||
taskpool.task_join()
|
||||
if taskpool.task_exception:
|
||||
raise taskpool.task_exception
|
||||
|
||||
async def procedure(self, websocket):
|
||||
################################################################################################################
|
||||
# main thread: connect the debugger server
|
||||
################################################################################################################
|
||||
main_thread = await self.debugger_impl.connect_to_debugger_server(self.config['pid'], True)
|
||||
logging.info(f'Connect to the debugger server of instance: {main_thread.instance_id}')
|
||||
################################################################################################################
|
||||
# main thread: Runtime.enable
|
||||
################################################################################################################
|
||||
await self.runtime_impl.send("Runtime.enable", main_thread)
|
||||
################################################################################################################
|
||||
# main thread: Debugger.enable
|
||||
################################################################################################################
|
||||
await self.debugger_impl.send("Debugger.enable", main_thread)
|
||||
################################################################################################################
|
||||
# main thread: Runtime.runIfWaitingForDebugger
|
||||
################################################################################################################
|
||||
await self.runtime_impl.send("Runtime.runIfWaitingForDebugger", main_thread)
|
||||
################################################################################################################
|
||||
# main thread: Debugger.scriptParsed
|
||||
################################################################################################################
|
||||
response = await self.debugger_impl.recv("Debugger.scriptParsed", main_thread)
|
||||
assert response['params']['url'] == self.config['file_path']['entry_ability']
|
||||
assert response['params']['endLine'] == 0
|
||||
################################################################################################################
|
||||
# main thread: Debugger.paused
|
||||
################################################################################################################
|
||||
response = await self.debugger_impl.recv("Debugger.paused", main_thread)
|
||||
assert response['params']['callFrames'][0]['url'] == self.config['file_path']['entry_ability']
|
||||
assert response['params']['reason'] == 'Break on start'
|
||||
################################################################################################################
|
||||
# main thread: Debugger.resume
|
||||
################################################################################################################
|
||||
await self.debugger_impl.send("Debugger.resume", main_thread)
|
||||
################################################################################################################
|
||||
# main thread: Debugger.scriptParsed
|
||||
################################################################################################################
|
||||
response = await self.debugger_impl.recv("Debugger.scriptParsed", main_thread)
|
||||
assert response['params']['url'] == self.config['file_path']['index']
|
||||
assert response['params']['endLine'] == 0
|
||||
################################################################################################################
|
||||
# main thread: Debugger.paused
|
||||
################################################################################################################
|
||||
response = await self.debugger_impl.recv("Debugger.paused", main_thread)
|
||||
assert response['params']['callFrames'][0]['url'] == self.config['file_path']['index']
|
||||
assert response['params']['reason'] == 'Break on start'
|
||||
################################################################################################################
|
||||
# main thread: Debugger.setPauseOnExceptions
|
||||
################################################################################################################
|
||||
params = debugger.PauseOnExceptionsState.UNCAUGHT
|
||||
await self.debugger_impl.send("Debugger.setPauseOnExceptions", main_thread, params)
|
||||
################################################################################################################
|
||||
# main thread: Debugger.resume
|
||||
################################################################################################################
|
||||
await self.debugger_impl.send("Debugger.resume", main_thread)
|
||||
################################################################################################################
|
||||
# main thread: Debugger.paused
|
||||
################################################################################################################
|
||||
response = await self.debugger_impl.recv("Debugger.paused", main_thread)
|
||||
assert response['params']['callFrames'][0]['url'] == self.config['file_path']['index']
|
||||
assert response['params']['reason'] == 'exception'
|
||||
assert 'This is a uncaught error' in response['params']['data']['unserializableValue']
|
||||
################################################################################################################
|
||||
# main thread: Debugger.resume
|
||||
################################################################################################################
|
||||
await self.debugger_impl.send("Debugger.resume", main_thread)
|
||||
################################################################################################################
|
||||
# close the websocket connections
|
||||
################################################################################################################
|
||||
await websocket.send_msg_to_debugger_server(main_thread.instance_id, main_thread.send_msg_queue, 'close')
|
||||
await websocket.send_msg_to_connect_server('close')
|
||||
################################################################################################################
|
159
test/autotest/scenario_test/test_main_exception_breakpoint_03.py
Normal file
159
test/autotest/scenario_test/test_main_exception_breakpoint_03.py
Normal file
@ -0,0 +1,159 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
Description: Scenario test case.
|
||||
"""
|
||||
|
||||
import logging
|
||||
import os
|
||||
import time
|
||||
|
||||
import pytest
|
||||
|
||||
from aw import Application
|
||||
from aw import Utils
|
||||
from aw import debugger, runtime
|
||||
from aw.api import debugger_api, runtime_api
|
||||
|
||||
|
||||
@pytest.mark.debug
|
||||
@pytest.mark.timeout(60)
|
||||
class TestDebug26:
|
||||
"""
|
||||
测试用例:单实例异常断点的设置/取消
|
||||
测试步骤:
|
||||
1. 连接 connect server 和主线程 debugger server
|
||||
2. 主线程使能 Runtime 和 Debugger
|
||||
3. 主线程运行等待的调试器
|
||||
4. 主线程解析 entry_ability 和 index 文件
|
||||
5. 设置异常捕获状态 NONE
|
||||
6. 不捕获异常无法命中异常断点
|
||||
7. 关闭主线程 debugger server 和 connect server 连接
|
||||
测试代码:
|
||||
function main() {
|
||||
try {
|
||||
throw new Error("This is a caught error");
|
||||
} catch (error) {
|
||||
console.log("After error");
|
||||
}
|
||||
throw new Error("This is a uncaught error");
|
||||
}
|
||||
|
||||
main();
|
||||
"""
|
||||
|
||||
def setup_method(self):
|
||||
logging.info('Start running TestDebug26: setup')
|
||||
|
||||
self.log_path = rf'{os.path.dirname(__file__)}\..\log'
|
||||
self.hilog_file_name = 'test_debug_26.hilog.txt'
|
||||
self.id_generator = Utils.message_id_generator()
|
||||
|
||||
# receive the hilog before the test start
|
||||
Utils.clear_fault_log()
|
||||
self.hilog_process, self.write_thread = Utils.save_hilog(log_path=self.log_path,
|
||||
file_name=self.hilog_file_name,
|
||||
debug_on=True)
|
||||
|
||||
def teardown_method(self):
|
||||
Application.uninstall(self.config['bundle_name'])
|
||||
|
||||
# terminate the hilog receive process after the test done
|
||||
time.sleep(3)
|
||||
self.hilog_process.stdout.close()
|
||||
self.hilog_process.terminate()
|
||||
self.hilog_process.wait()
|
||||
self.write_thread.join()
|
||||
|
||||
Utils.save_fault_log(log_path=self.log_path)
|
||||
logging.info('TestDebug26 done')
|
||||
|
||||
def test(self, test_suite_main_instance_04_debug):
|
||||
logging.info('Start running TestDebug26: test')
|
||||
self.config = test_suite_main_instance_04_debug
|
||||
websocket = self.config['websocket']
|
||||
taskpool = self.config['taskpool']
|
||||
pid = self.config['pid']
|
||||
self.debugger_impl = debugger_api.DebuggerImpl(self.id_generator, websocket)
|
||||
self.runtime_impl = runtime_api.RuntimeImpl(self.id_generator, websocket)
|
||||
|
||||
taskpool.submit(websocket.main_task(taskpool, self.procedure, pid))
|
||||
taskpool.await_taskpool()
|
||||
taskpool.task_join()
|
||||
if taskpool.task_exception:
|
||||
raise taskpool.task_exception
|
||||
|
||||
async def procedure(self, websocket):
|
||||
################################################################################################################
|
||||
# main thread: connect the debugger server
|
||||
################################################################################################################
|
||||
main_thread = await self.debugger_impl.connect_to_debugger_server(self.config['pid'], True)
|
||||
logging.info(f'Connect to the debugger server of instance: {main_thread.instance_id}')
|
||||
################################################################################################################
|
||||
# main thread: Runtime.enable
|
||||
################################################################################################################
|
||||
await self.runtime_impl.send("Runtime.enable", main_thread)
|
||||
################################################################################################################
|
||||
# main thread: Debugger.enable
|
||||
################################################################################################################
|
||||
await self.debugger_impl.send("Debugger.enable", main_thread)
|
||||
################################################################################################################
|
||||
# main thread: Runtime.runIfWaitingForDebugger
|
||||
################################################################################################################
|
||||
await self.runtime_impl.send("Runtime.runIfWaitingForDebugger", main_thread)
|
||||
################################################################################################################
|
||||
# main thread: Debugger.scriptParsed
|
||||
################################################################################################################
|
||||
response = await self.debugger_impl.recv("Debugger.scriptParsed", main_thread)
|
||||
assert response['params']['url'] == self.config['file_path']['entry_ability']
|
||||
assert response['params']['endLine'] == 0
|
||||
################################################################################################################
|
||||
# main thread: Debugger.paused
|
||||
################################################################################################################
|
||||
response = await self.debugger_impl.recv("Debugger.paused", main_thread)
|
||||
assert response['params']['callFrames'][0]['url'] == self.config['file_path']['entry_ability']
|
||||
assert response['params']['reason'] == 'Break on start'
|
||||
################################################################################################################
|
||||
# main thread: Debugger.resume
|
||||
################################################################################################################
|
||||
await self.debugger_impl.send("Debugger.resume", main_thread)
|
||||
################################################################################################################
|
||||
# main thread: Debugger.scriptParsed
|
||||
################################################################################################################
|
||||
response = await self.debugger_impl.recv("Debugger.scriptParsed", main_thread)
|
||||
assert response['params']['url'] == self.config['file_path']['index']
|
||||
assert response['params']['endLine'] == 0
|
||||
################################################################################################################
|
||||
# main thread: Debugger.paused
|
||||
################################################################################################################
|
||||
response = await self.debugger_impl.recv("Debugger.paused", main_thread)
|
||||
assert response['params']['callFrames'][0]['url'] == self.config['file_path']['index']
|
||||
assert response['params']['reason'] == 'Break on start'
|
||||
################################################################################################################
|
||||
# main thread: Debugger.setPauseOnExceptions
|
||||
################################################################################################################
|
||||
params = debugger.PauseOnExceptionsState.NONE
|
||||
await self.debugger_impl.send("Debugger.setPauseOnExceptions", main_thread, params)
|
||||
################################################################################################################
|
||||
# main thread: Debugger.resume
|
||||
################################################################################################################
|
||||
await self.debugger_impl.send("Debugger.resume", main_thread)
|
||||
################################################################################################################
|
||||
# close the websocket connections
|
||||
################################################################################################################
|
||||
await websocket.send_msg_to_debugger_server(main_thread.instance_id, main_thread.send_msg_queue, 'close')
|
||||
await websocket.send_msg_to_connect_server('close')
|
||||
################################################################################################################
|
205
test/autotest/scenario_test/test_main_smart_step_into.py
Normal file
205
test/autotest/scenario_test/test_main_smart_step_into.py
Normal file
@ -0,0 +1,205 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
Description: Scenario test case.
|
||||
"""
|
||||
|
||||
import logging
|
||||
import os
|
||||
import time
|
||||
|
||||
import pytest
|
||||
|
||||
from aw import Application
|
||||
from aw import Utils
|
||||
from aw import debugger, runtime
|
||||
from aw.api import debugger_api, runtime_api
|
||||
|
||||
|
||||
@pytest.mark.debug
|
||||
@pytest.mark.timeout(60)
|
||||
class TestDebug23:
|
||||
"""
|
||||
测试用例:单实例smartStepinto调试
|
||||
测试步骤:
|
||||
1. 连接 connect server 和主线程 debugger server
|
||||
2. 主线程使能 Runtime 和 Debugger
|
||||
3. 主线程运行等待的调试器
|
||||
4. 主线程解析 entry_ability 和 index 文件
|
||||
5. 主线程 Index.ts 文件设置断点并运行
|
||||
6. 主线程 resume 验证是否正确命中断点
|
||||
7. 主线程 smartStepInto 验证传回的函数信息
|
||||
8. 关闭主线程 debugger server 和 connect server 连接
|
||||
测试代码:
|
||||
function test1() {
|
||||
return taskNumber;
|
||||
}
|
||||
|
||||
function test2() {
|
||||
return taskNumber + 5;
|
||||
}
|
||||
|
||||
function main() {
|
||||
test1();
|
||||
taskNumber = test1() + test2();// 实例debug23断点处
|
||||
}
|
||||
|
||||
main();
|
||||
"""
|
||||
|
||||
def setup_method(self):
|
||||
logging.info('Start running TestDebug23: setup')
|
||||
|
||||
self.log_path = rf'{os.path.dirname(__file__)}\..\log'
|
||||
self.hilog_file_name = 'test_debug_23.hilog.txt'
|
||||
self.id_generator = Utils.message_id_generator()
|
||||
|
||||
# receive the hilog before the test start
|
||||
Utils.clear_fault_log()
|
||||
self.hilog_process, self.write_thread = Utils.save_hilog(log_path=self.log_path,
|
||||
file_name=self.hilog_file_name,
|
||||
debug_on=True)
|
||||
|
||||
def teardown_method(self):
|
||||
Application.uninstall(self.config['bundle_name'])
|
||||
|
||||
# terminate the hilog receive process after the test done
|
||||
time.sleep(3)
|
||||
self.hilog_process.stdout.close()
|
||||
self.hilog_process.terminate()
|
||||
self.hilog_process.wait()
|
||||
self.write_thread.join()
|
||||
|
||||
Utils.save_fault_log(log_path=self.log_path)
|
||||
logging.info('TestDebug23 done')
|
||||
|
||||
def test(self, test_suite_main_instance_03_debug):
|
||||
logging.info('Start running TestDebug23: test')
|
||||
self.config = test_suite_main_instance_03_debug
|
||||
websocket = self.config['websocket']
|
||||
taskpool = self.config['taskpool']
|
||||
pid = self.config['pid']
|
||||
self.debugger_impl = debugger_api.DebuggerImpl(self.id_generator, websocket)
|
||||
self.runtime_impl = runtime_api.RuntimeImpl(self.id_generator, websocket)
|
||||
|
||||
taskpool.submit(websocket.main_task(taskpool, self.procedure, pid))
|
||||
taskpool.await_taskpool()
|
||||
taskpool.task_join()
|
||||
if taskpool.task_exception:
|
||||
raise taskpool.task_exception
|
||||
|
||||
async def procedure(self, websocket):
|
||||
################################################################################################################
|
||||
# main thread: connect the debugger server
|
||||
################################################################################################################
|
||||
main_thread = await self.debugger_impl.connect_to_debugger_server(self.config['pid'], True)
|
||||
logging.info(f'Connect to the debugger server of instance: {main_thread.instance_id}')
|
||||
################################################################################################################
|
||||
# main thread: Runtime.enable
|
||||
################################################################################################################
|
||||
await self.runtime_impl.send("Runtime.enable", main_thread)
|
||||
################################################################################################################
|
||||
# main thread: Debugger.enable
|
||||
################################################################################################################
|
||||
await self.debugger_impl.send("Debugger.enable", main_thread)
|
||||
################################################################################################################
|
||||
# main thread: Runtime.runIfWaitingForDebugger
|
||||
################################################################################################################
|
||||
await self.runtime_impl.send("Runtime.runIfWaitingForDebugger", main_thread)
|
||||
################################################################################################################
|
||||
# main thread: Debugger.scriptParsed
|
||||
################################################################################################################
|
||||
response = await self.debugger_impl.recv("Debugger.scriptParsed", main_thread)
|
||||
assert response['params']['url'] == self.config['file_path']['entry_ability']
|
||||
assert response['params']['endLine'] == 0
|
||||
################################################################################################################
|
||||
# main thread: Debugger.paused
|
||||
################################################################################################################
|
||||
response = await self.debugger_impl.recv("Debugger.paused", main_thread)
|
||||
assert response['params']['callFrames'][0]['url'] == self.config['file_path']['entry_ability']
|
||||
assert response['params']['reason'] == 'Break on start'
|
||||
################################################################################################################
|
||||
# main thread: Debugger.resume
|
||||
################################################################################################################
|
||||
await self.debugger_impl.send("Debugger.resume", main_thread)
|
||||
################################################################################################################
|
||||
# main thread: Debugger.scriptParsed
|
||||
################################################################################################################
|
||||
response = await self.debugger_impl.recv("Debugger.scriptParsed", main_thread)
|
||||
assert response['params']['url'] == self.config['file_path']['index']
|
||||
assert response['params']['endLine'] == 0
|
||||
################################################################################################################
|
||||
# main thread: Debugger.paused
|
||||
################################################################################################################
|
||||
response = await self.debugger_impl.recv("Debugger.paused", main_thread)
|
||||
assert response['params']['callFrames'][0]['url'] == self.config['file_path']['index']
|
||||
assert response['params']['reason'] == 'Break on start'
|
||||
################################################################################################################
|
||||
# main thread: Debugger.removeBreakpointsByUrl
|
||||
################################################################################################################
|
||||
params = debugger.RemoveBreakpointsUrl(self.config['file_path']['index'])
|
||||
await self.debugger_impl.send("Debugger.removeBreakpointsByUrl", main_thread, params)
|
||||
################################################################################################################
|
||||
# main thread: Debugger.getPossibleAndSetBreakpointByUrl
|
||||
################################################################################################################
|
||||
locations = [debugger.BreakLocationUrl(url=self.config['file_path']['index'], line_number=73)]
|
||||
params = debugger.SetBreakpointsLocations(locations)
|
||||
response = await self.debugger_impl.send("Debugger.getPossibleAndSetBreakpointsByUrl",
|
||||
main_thread, params)
|
||||
assert response['result']['locations'][0]['id'] == 'id:73:0:' + self.config['file_path']['index']
|
||||
################################################################################################################
|
||||
# main thread: Debugger.resume
|
||||
################################################################################################################
|
||||
await self.debugger_impl.send("Debugger.resume", main_thread)
|
||||
################################################################################################################
|
||||
# main thread: Debugger.paused, hit breakpoint
|
||||
################################################################################################################
|
||||
response = await self.debugger_impl.recv("Debugger.paused", main_thread)
|
||||
assert response['params']['callFrames'][0]['url'] == self.config['file_path']['index']
|
||||
assert response['params']['hitBreakpoints'] == ['id:73:17:' + self.config['file_path']['index']]
|
||||
################################################################################################################
|
||||
# main thread: Debugger.smartStepInto
|
||||
################################################################################################################
|
||||
params = debugger.SmartStepIntoParams(url=self.config['file_path']['index'], line_number=69)
|
||||
await self.debugger_impl.send("Debugger.smartStepInto", main_thread, params)
|
||||
################################################################################################################
|
||||
# main thread: Debugger.resume
|
||||
################################################################################################################
|
||||
await self.debugger_impl.send("Debugger.resume", main_thread)
|
||||
# main thread: Debugger.paused
|
||||
response = await self.debugger_impl.recv("Debugger.paused", main_thread)
|
||||
assert response['params']['callFrames'][0]['url'] == self.config['file_path']['index']
|
||||
assert response['params']['callFrames'][0]['functionName'] == 'test2'
|
||||
assert response['params']['reason'] == 'other'
|
||||
assert response['params']['hitBreakpoints'] == ['id:69:11:' + self.config['file_path']['index']]
|
||||
################################################################################################################
|
||||
# main thread: Debugger.resume
|
||||
################################################################################################################
|
||||
await self.debugger_impl.send("Debugger.resume", main_thread)
|
||||
################################################################################################################
|
||||
# main thread: click on the screen
|
||||
################################################################################################################
|
||||
Application.click_on_middle()
|
||||
################################################################################################################
|
||||
# main thread: Debugger.disable
|
||||
################################################################################################################
|
||||
await self.debugger_impl.send("Debugger.disable", main_thread)
|
||||
################################################################################################################
|
||||
# close the websocket connections
|
||||
################################################################################################################
|
||||
await websocket.send_msg_to_debugger_server(main_thread.instance_id, main_thread.send_msg_queue, 'close')
|
||||
await websocket.send_msg_to_connect_server('close')
|
||||
################################################################################################################
|
Loading…
Reference in New Issue
Block a user