Monkey Crash解析脚本

脚本语言:python v2.7

解析原理:monkey出现crash时,日志都会以”// CRASH: + package name + pid”行开始记录;monkey执行随机事件,该行内容以”:Sending”或”:Switch”开头

脚本代码:

source_file_path = $(your monkey log file)

crash_file_path = $(file to restore crash)



def crash_analysis():

    analysis_flag = False

    crash_content = []

    read_lines = open(source_file_path)

    for line in read_lines:

        if ((line != None) & (line.startWith("// CRASH:")):

            analysis_flag = True

        elif ((line != None) & line.startswith(":Sending") & analysisFlag):

            analysis_flag = False
    
        elif ((line != None) & line.startswith(":Switch") & analysisFlag):

            analysis_flag = False

        if (analysis_flag):

            crash_content.append(line)

    file_out = open(crash_file_path, 'w')

    file_out.writelines(crash_content)

    file_out.close()



crash_analysis()
    原文作者:和平北路
    原文地址: https://www.jianshu.com/p/3493faae1e25
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞