def main(): env = gym.make('FuzzLibPNG-v0') print("dict_size={} eof={}".format(env.dict_size(), env.eof())) env.reset() c = coverage.Coverage() inputs = [ [1, env.eof()] + [0] * 1022, [env.eof()] + [0] * 1023, [1, env.eof()] + [0] * 1022, ] for i in inputs: obs, reward, done, info = env.step(np.array(i)) c.add(info['step_coverage']) print(("STEP: reward={} done={} " + "step={}/{}/{} total={}/{}/{} " + "sum={}/{}/{} action={}").format( reward, done, info['step_coverage'].skip_path_count(), info['step_coverage'].transition_count(), info['step_coverage'].crash_count(), info['total_coverage'].skip_path_count(), info['total_coverage'].transition_count(), info['total_coverage'].crash_count(), c.skip_path_count(), c.transition_count(), c.crash_count(), i[:13], )) if done: env.reset() print("DONE!")
def main(): env = gym.make('FuzzSimpleBits-v0') print("dict_size={} eof={}".format(env.dict_size(), env.eof())) env.reset() c = coverage.Coverage() inputs = [ [1, 256] + [0] * 62, [256] + [0] * 63, [1, 1, 256] + [0] * 61, [1, 1, 256] + [0] * 61, [1, 1, 256] + [0] * 61, [12, 256] + [0] * 62, [12, 7, 256] + [0] * 61, [1, 256] + [0] * 62, [1, 2, 256] + [0] * 61, [1, 2, 3, 256] + [0] * 60, [1, 2, 3, 4, 256] + [0] * 59, [1, 2, 3, 4, 5, 256] + [0] * 58, [1, 1, 256] + [0] * 61, [1, 1, 256] + [0] * 61, [0, 1, 2, 3, 4, 5, 6, 7, 8, 0, 256] + [0] * 53, [0, 1, 2, 3, 4, 5, 6, 7, 8, 0, 1, 256] + [0] * 52, [0, 1, 2, 3, 4, 5, 6, 7, 8, 0, 1, 0, 256] + [0] * 51, [1, 1, 256] + [0] * 61, ] for i in inputs: obs, reward, done, info = env.step(np.array(i)) c.add(info['step_coverage']) print('obs coords where > 0: ', np.where(np.array(obs) > 0)) print('input_data used:', info['input_data']) print(("STEP: reward={} done={} " + "step={}/{}/{} total={}/{}/{} " + "sum={}/{}/{} action={}").format( reward, done, info['step_coverage'].skip_path_count(), info['step_coverage'].transition_count(), info['step_coverage'].crash_count(), info['total_coverage'].skip_path_count(), info['total_coverage'].transition_count(), info['total_coverage'].crash_count(), c.skip_path_count(), c.transition_count(), c.crash_count(), i[:13], )) if done: env.reset() print("DONE!")
def main(): env = gym.make('FuzzSimpleBits-v0') print("dict_size={} eof={}".format(env.dict_size(), env.eof())) MAX_STEPS = 5000 env.reset() c = coverage.Coverage() for _ in range(MAX_STEPS): # take a random action. If there's an RL agent, the agent would control # action selection. obs, reward, done, info = env.step(env.action_space.sample()) # print('obs coords where > 0: ', np.where(np.array(obs) > 0)) # debug print('input_data used:', info['input_data']) if info['action'] == 'run': c.add(info['step_coverage']) # update records print( ("STEP: reward={} done={} " + "step={}/{}/{} total={}/{}/{} " + "sum={}/{}/{} action={}").format( reward, done, info['step_coverage'].skip_path_count(), info['step_coverage'].transition_count(), info['step_coverage'].crash_count(), info['total_coverage'].skip_path_count(), info['total_coverage'].transition_count(), info['total_coverage'].crash_count(), c.skip_path_count(), c.transition_count(), c.crash_count(), info['action'], )) else: print(("STEP: reward={} done={} action={}").format( reward, done, info['action'])) if done: env.reset() print("ENV RESET")
def reset(self): self.total_coverage = coverage.Coverage() return coverage.Coverage().observation()