基于表格管理的SOC自动化测试脚本(二)

目录结构

log:存放用例日志路径。

testcase:测试模板路径。

utils:工具类路径。

configs.py:工具配置文件。

main.py:工具函数入口。

工具使用

命令行执行:

python main.py

调试模式:

将autoTest通过pycharm加载。

全量测试:右键执行main.py。

部分测试:主入口修改debugMode = True,module_list中添加需要测试的模块,多个模块用逗号分隔。

以下是config.py实现

import os
import time
import serial.tools.list_ports

# 主函数用
basedir = os.path.split(os.path.realpath(__file__))[0]
utils_home = os.sep.join([basedir, 'utils'])
# test_template_home = os.sep.join([basedir, 'testcase', 'test_template_build_config_run.xls'])
test_template_home = os.sep.join([basedir, 'testcase', 'test_template_on_chip.xls'])
host_log_home = "/home/test/log"

run_time = time.strftime('%Y%m%d%H%M', time.localtime(time.time()))
# 测试相关配置
test_configs = {
    'TEST_YES': 'Y',
    'TEST_NO': 'N',
    'SUCCESS': 'SUCCESS',
    'FAIL': 'FAIL',
    'TIMEOUT': 'TIMEOUT',
    'COST': 'COST',
    'sysIO_test': "upcie",
    'no_testing_required': 'No Testing Required',
    'registration_exception_0': "argv or run member is not equal to title or 1, please check",
    'registration_exception_1': "argv or run member is not equal to title or 1, please examine",
    'registration_exception_2': "Unknown command!"
}
# 服务器相关配置
host_configs = {
    'serverIP': '192.168.0.125',
    'serverPort': 22,
    'username': 'root',
    'password': '123456',
    'answering_shell': True,  # 是否开启应答式Shell(默认开启)
    'ps3_reset_cmd': 'ps3_reset',
    'apu_host': 'apu_host',
    'apu_host_cmd': """cd /home/test/0315_host_linux_fpga_test0721/
sh apuhost.sh
time_sleep(5)""",
    'host_ps3_rst_list': """cd /home/test/cs100_test/testscript
sh ps3F0HardResetOneTimeHBA.sh""",
    'host_ps3_reset_info': 'Initiate a ps3_reset from the host',
    "reboot_cmd": "reboot",
    "reboot_cmd_info": "Initiate reboot from the host",
    "reboot_cmd_result": "reboot success"
}
# 串口相关配置
serial_configs = {
    'baunRate': 115200,
    'port_list': list(serial.tools.list_ports.comports()),
}

TEST_YES, TEST_NO, SUCCESS, FAIL, TIMEOUT, COST, sysIO_test, no_testing_required, registration_exception_0, \
registration_exception_1, registration_exception_2 = test_configs['TEST_YES'], test_configs['TEST_NO'], \
                                                     test_configs['SUCCESS'], \
                                                     test_configs['FAIL'], test_configs['TIMEOUT'], \
                                                     test_configs['COST'], test_configs['sysIO_test'], \
                                                     test_configs['no_testing_required'], test_configs[
                                                         'registration_exception_0'], \
                                                     test_configs['registration_exception_1'], test_configs[
                                                         'registration_exception_2']

ip, port, username, password, answering, ps3_reset_cmd, host_ps3_rst_list, host_ps3_reset_info, reboot_cmd, \
reboot_cmd_info, reboot_cmd_result = host_configs['serverIP'], host_configs['serverPort'], host_configs['username'], \
                                     host_configs['password'], host_configs['answering_shell'],  \
                                     host_configs['ps3_reset_cmd'], host_configs['host_ps3_rst_list'], \
                                     host_configs['host_ps3_reset_info'], host_configs['reboot_cmd'], host_configs[
                                         "reboot_cmd_info"], host_configs[
                                         "reboot_cmd_result"]
apu_cmd = host_configs['apu_host']
apu_host_cmd = host_configs["apu_host_cmd"]
port_list, baunRate = serial_configs['port_list'], serial_configs['baunRate']

# 选择串口
port_list_name = []
if len(port_list) <= 0:
    raise Exception("The serial port can't find!")
else:
    for itms in port_list:
        port_list_name.append(itms.device)
# com3串口
# print(port_list_name)
serialPort_case = port_list_name[-1]
print("The test port is %s" % serialPort_case)

if __name__ == '__main__':
    print(type(reboot_cmd))

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值