Best Python code snippet using ATX
analyze.py
Source: analyze.py
1#!/usr/bin/python32import sys3import os4import math;5import glob;6import traceback7import matplotlib.pyplot as plt8from matplotlib.collections import PatchCollection9from matplotlib.patches import Rectangle10import numpy as np11import simplejson as json12from optparse import OptionParser13from analyze_debug import parseDebug14from analyze_work import plotWork15from analyze_corpus import plotCorpus16from analyze_signal import plotSignal17from analyze_coverage import plotCoverage18from analyze_programs import plotPrograms19from analyze_triage import plotTriage20from analyze_mab import plotMAB21from analyze_seeds import plotSeeds22from analyze_mutationtree import plotMutationTree23from analyze_crashes import plotCrashes24from plot import plot25if __name__ == "__main__":26 # tests = ["RAMINDEX-0.0", "RAMINDEX-0.2", "RAMINDEX-0.4", "RAMINDEX-0.6", "RAMINDEX-0.8", "RAMINDEX", "KCOV", "NOCOVER", "KCOV-0.0", "NOCOVER-0.0"]27 parser = OptionParser()28 parser.add_option("-B", "--blacklist", dest="blacklist",29 help="Blacklist", default="")30 parser.add_option("-a", "--all", dest="analyze_all", action="store_true",31 help="Analyze everything", default=False)32 parser.add_option("-c", "--coverage", dest="analyze_coverage", action="store_true",33 help="Analyze coverage", default=False)34 parser.add_option("-t", "--triage", dest="analyze_triage", action="store_true",35 help="Analyze triage", default=False)36 parser.add_option("-w", "--work", dest="analyze_work", action="store_true",37 help="Analyze work", default=False)38 parser.add_option("-p", "--program", dest="analyze_program", action="store_true",39 help="Analyze programs", default=False)40 parser.add_option("-m", "--mab", dest="analyze_mab", action="store_true",41 help="Analyze MAB", default=False)42 parser.add_option("-M", "--mutation-tree", dest="analyze_mutationtree", action="store_true",43 help="Analyze Mutation Tree", default=False)44 parser.add_option("-s", "--seed", dest="analyze_seed", action="store_true",45 help="Analyze Seed", default=False)46 parser.add_option("-C", "--crash", dest="analyze_crashes", action="store_true",47 help="Analyze Crashes", default=False)48 (options, args) = parser.parse_args()49 blacklist = options.blacklist.split(',') if len(options.blacklist) > 0 else []50 tests = [];51 for fn in glob.glob("log_*"):52 skip = False53 for b in blacklist:54 if b in fn:55 skip = True56 break;57 if not skip:58 tests.append(fn.strip("log_"))59 try:60 if options.analyze_coverage or options.analyze_all:61 plotCoverage(tests)62 if options.analyze_triage or options.analyze_all:63 plotTriage(tests)64 if options.analyze_work or options.analyze_all:65 plotWork(tests)66 if options.analyze_mab or options.analyze_all:67 plotMAB(tests)68 if options.analyze_program or options.analyze_all:69 plotPrograms(tests)70 if options.analyze_seed or options.analyze_all:71 plotSeeds(tests)72 if options.analyze_crashes or options.analyze_all:73 plotCrashes(tests)74 if options.analyze_mutationtree or options.analyze_all:75 plotMutationTree(tests)76 #plotSignal(tests)77 #plotCorpus(tests)78 #plotWork(tests)79 except:80 traceback.print_exc()81 """82 data_kcov = parseExp("syzlog_KCOV");83 data_ramindex = parseExp("syzlog_RAMINDEX");84 data_nocover = parseExp("syzlog_NOCOVER");85 # data_random = parseExp("syzlog_RANDOM");86 data = {"Kcov": data_kcov, "Ramindex": data_ramindex, "Nocover": data_nocover};87 plot(data, 1, 2, xlabel="Time elapsed (s)", title="Basic Block Coverage", outfile="execution.png");88 plot(data, 1, 3, xlabel="Time elapsed (s)", title="Hashed Coverage", outfile="execution_hashed.png");...
analysis.py
Source: analysis.py
1import pandas as pd2import matplotlib.pyplot as plt3import numpy as np4import seaborn as sns5def analyze_all(agent_name, data_file):6 analyze("{}_parametrized".format(agent_name), "data/{}_parametrized_total_results.csv".format(data_file), [0, 6, 7, 8])7 #analyze("{}_decay".format(agent_name), "data/{}_decaying_learning_parametrized_total_results.csv".format(data_file), [0, 6, 7])8 #analyze("{}_slow_decay".format(agent_name), "data/{}_slow_decaying_learning_parametrized_total_results.csv".format(data_file), [0, 6, 7])9 analyze_groups("{}_parametrized".format(agent_name), "data/{}_parametrized_total_results.csv".format(data_file))10def analyze_groups(agent_name, data_file):11 print agent_name12 print "-------------"13 # Read agent runs data14 agent_data = pd.read_csv(data_file)15 grouped = agent_data.groupby(['alpha', 'gamma', 'epsilon'])16 f = {'n_dest_reached':['mean','std'], 'last_dest_fail':['mean','std'], 'last_penalty':['mean','std'], 'len_qvals':['mean','std']}17 aggregated_result = grouped.agg(f).reset_index()18 19 sorted_results = aggregated_result.sort([('last_penalty', 'mean'), ('last_penalty', 'std')], ascending=[1, 0]).head(n=10)20 print sorted_results21 print "-------------"22 sorted_q = aggregated_result.sort([('n_dest_reached', 'mean'), ('n_dest_reached', 'std')], ascending=[0, 1]).head(n=10)23 print sorted_q24 print "====================================="25def analyze(agent_name, data_file, drop_columns):26 # Read agent runs data27 agent_data = pd.read_csv(data_file)28 29 # Remove parameter columns30 metrics_only = agent_data.drop(agent_data.columns[drop_columns], axis=1)31 print "Agent global Metrics"32 print metrics_only.describe()33 # Rewards will be plotted somewhere wlse34 metrics_only.drop("reward_sum", axis=1, inplace=True)35 sns.boxplot(data=metrics_only)36 plt.savefig("charts/{}_global_results_boxplot.png".format(agent_name))37 plt.close()38 filtered = agent_data.sort(['last_penalty', 'last_dest_fail', 'n_dest_reached'], ascending=[1, 1, 0]).head(n=10)39 40 print "-------------"41 print "Best 10"42 print filtered.describe()43 print "------------"44 print filtered45 to_plot = filtered.drop(agent_data.columns[drop_columns], axis=1)46 to_plot.drop("reward_sum", axis=1, inplace=True)47 sns.boxplot(data=to_plot)48 plt.savefig("charts/{}_filtered_results_boxplot.png".format(agent_name))49 plt.close()50 print "====================================="51 52if __name__ == '__main__':53 # Read agent runs data54 agent_data = pd.read_csv("data/LearningAgent_results.csv")55 drop_columns = [0, 1]56 # Remove parameter columns57 metrics_only = agent_data.drop(agent_data.columns[drop_columns], axis=1)58 print "Agent global Metrics"59 print metrics_only.describe()60 sns.boxplot(data=metrics_only)61 plt.savefig("charts/final_agent_boxplot.png")62 plt.close()63 #pd.set_option('display.max_columns', None)64 #pd.set_option('display.width', 1000)65 #analyze_all("only_input_without_waypoint","OnlyInputWithoutWaypointStateAgent")66 #analyze_all("input_with_waypoint","InputWithWaypointStateAgent")67 #analyze_all("input_with_waypoint_and_deadline","InputWithWaypointAndDeadlineStateAgent")68 #analyze_all("input_with_waypoint_without_right","WithoutRightStateAgent")69 #analyze_all("input_with_waypoint_without_right_and_reduced_left","LearningAgent")...
test.py
Source: test.py
...8 existed_before = os.path.isfile(filename)9 b = Backend("test.sonare")10 if not existed_before:11 load_elf(b, "test.so")12 analyze_all(b)13 else:14 b = Backend()15 load_elf(b, "test.so")16 analyze_all(b)17 print(f"found {len(b.names)} aliases")18 print(f"found {len(b.functions)} functions")19 for sec in b.sections.iter_by_addr():...
Check out the latest blogs from LambdaTest on this topic:
As part of one of my consulting efforts, I worked with a mid-sized company that was looking to move toward a more agile manner of developing software. As with any shift in work style, there is some bewilderment and, for some, considerable anxiety. People are being challenged to leave their comfort zones and embrace a continuously changing, dynamic working environment. And, dare I say it, testing may be the most ‘disturbed’ of the software roles in agile development.
QA testers have a unique role and responsibility to serve the customer. Serving the customer in software testing means protecting customers from application defects, failures, and perceived failures from missing or misunderstood requirements. Testing for known requirements based on documentation or discussion is the core of the testing profession. One unique way QA testers can both differentiate themselves and be innovative occurs when senseshaping is used to improve the application user experience.
Manual cross browser testing is neither efficient nor scalable as it will take ages to test on all permutations & combinations of browsers, operating systems, and their versions. Like every developer, I have also gone through that ‘I can do it all phase’. But if you are stuck validating your code changes over hundreds of browsers and OS combinations then your release window is going to look even shorter than it already is. This is why automated browser testing can be pivotal for modern-day release cycles as it speeds up the entire process of cross browser compatibility.
Unit testing is typically software testing within the developer domain. As the QA role expands in DevOps, QAOps, DesignOps, or within an Agile team, QA testers often find themselves creating unit tests. QA testers may create unit tests within the code using a specified unit testing tool, or independently using a variety of methods.
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!