コード例 #1
0
def executeMutant(package, start_activity, original_apk, file_path, img_path,
                  commands):
    executeApk(package, start_activity, file_path, img_path)
    original_image = "{}/{}_0.png".format(img_path, original_apk)
    instrumented_image = "{}/{}_0.png".format(img_path,
                                              os.path.basename(file_path))

    similar, crashed = checkSimilarPictures(original_image, instrumented_image)
    if (not similar):
        return True, crashed

    result = False, crashed

    img_index = 1
    for i, c in enumerate(commands):
        if c == 'screenshot':
            img_name = "{}_{}.png".format(os.path.basename(file_path),
                                          img_index)
            instrumented_image = captureScreen(img_name, img_path)
            original_image = "{}/{}_{}.png".format(img_path, original_apk,
                                                   img_index)
            img_index += 1
            similar, crashed = checkSimilarPictures(original_image,
                                                    instrumented_image)
            if (not similar):
                # result = True, crashed
                return True, crashed
        else:
            executeCommand(c)

            if ((i + 1) % EVENTS_PER_IMAGE) == 0:
                img_name = "{}_{}.png".format(os.path.basename(file_path),
                                              img_index)
                instrumented_image = captureScreen(img_name, img_path)
                original_image = "{}/{}_{}.png".format(img_path, original_apk,
                                                       img_index)
                img_index += 1
                similar, crashed = checkSimilarPictures(
                    original_image, instrumented_image)
                if (not similar):
                    # result = True, crashed
                    return True, crashed

    if (len(commands) % EVENTS_PER_IMAGE) != 0:
        img_name = "{}_{}.png".format(os.path.basename(file_path), img_index)
        instrumented_image = captureScreen(img_name, img_path)
        original_image = "{}/{}_{}.png".format(img_path, original_apk,
                                               img_index)
        similar, crashed = checkSimilarPictures(original_image,
                                                instrumented_image)
        if (not similar):
            # result = True, crashed
            return True, crashed
    return result
コード例 #2
0
def analyze_results(basepath, file_name1, file_name2):
    image1 = os.path.join(basepath, file_name1)
    image2 = os.path.join(basepath, file_name2)
    
    similar, crashed = checkSimilarPictures(image1, image2)
    
    return similar
コード例 #3
0
ファイル: result_analyzer.py プロジェクト: zsoltk/muDroid
def analyze_results(file_name, directory):
    mutants_list = os.path.join(directory, 'mutants')
    with open(mutants_list, 'rb') as handle:
        mutants = json.load(handle)

    for m in mutants:
        index = 0
        print 'Processing mutants %d' % m['id']
        instrumented_image = os.path.join(directory, '%s_%d.apk_%d.png' % (file_name, m['id'], index))
        # print instrumented_image
        while(os.path.exists(instrumented_image)):
            original_image = os.path.join(directory, '%s.apk_%d.png' % (file_name, index))
            # print original_image, instrumented_image
            similar, crashed = checkSimilarPictures(original_image, instrumented_image)
            m['crashed'] = crashed
            if not similar:
                m['killed'] = True
                break
            index += 1
            instrumented_image = os.path.join(directory, '%s_%d.apk_%d.png' % (file_name, m['id'], index))

    with open(mutants_list, 'wb') as handle:
        json.dump(mutants, handle)

    ReportGenerator.generateReport(mutants, directory)
コード例 #4
0
def analyze_results(file_name1, file_name2):
    image1 = os.path.join(SCREENSHOTS_DIRECTORY, file_name1)
    image2 = os.path.join(SCREENSHOTS_DIRECTORY, file_name2)

    similar, crashed = checkSimilarPictures(image1, image2)

    return similar
コード例 #5
0
def executeMutant(package, start_activity, original_apk, file_path, img_path, commands):
    executeApk(package, start_activity, file_path, img_path)
    original_image = "{}/{}_0.png".format(img_path, original_apk)
    instrumented_image = "{}/{}_0.png".format(img_path, os.path.basename(file_path))

    similar, crashed = checkSimilarPictures(original_image, instrumented_image)
    if(not similar):
        return True, crashed

    result = False, crashed

    img_index = 1
    for i, c in enumerate(commands):
        if c == 'screenshot':
            img_name= "{}_{}.png".format(os.path.basename(file_path), img_index)
            instrumented_image = captureScreen(img_name, img_path)
            original_image = "{}/{}_{}.png".format(img_path, original_apk, img_index)
            img_index += 1
            similar, crashed = checkSimilarPictures(original_image, instrumented_image)
            if(not similar):
                # result = True, crashed
                return True, crashed
        else:
            executeCommand(c)

            if ((i+1) % EVENTS_PER_IMAGE) == 0:
                img_name= "{}_{}.png".format(os.path.basename(file_path), img_index)
                instrumented_image = captureScreen(img_name, img_path)
                original_image = "{}/{}_{}.png".format(img_path, original_apk, img_index)
                img_index += 1
                similar, crashed = checkSimilarPictures(original_image, instrumented_image)
                if(not similar):
                    # result = True, crashed
                    return True, crashed

    if (len(commands) % EVENTS_PER_IMAGE) != 0:
        img_name= "{}_{}.png".format(os.path.basename(file_path), img_index)
        instrumented_image = captureScreen(img_name, img_path)
        original_image = "{}/{}_{}.png".format(img_path, original_apk, img_index)
        similar, crashed = checkSimilarPictures(original_image, instrumented_image)
        if(not similar):
            # result = True, crashed
            return True, crashed
    return result