MCPcopy Create free account
hub / github.com/FuzzAnything/PromptFuzz / check_programs_are_correct

Method check_programs_are_correct

src/execution/sanitize.rs:159–194  ·  view source on GitHub ↗
(
        &self,
        programs: &[Program],
        deopt: &Deopt,
    )

Source from the content-addressed store, hash-verified

157 }
158
159 pub fn check_programs_are_correct(
160 &self,
161 programs: &[Program],
162 deopt: &Deopt,
163 ) -> Result<Vec<Option<ProgramError>>> {
164 let mut program_paths = Vec::new();
165 for program in programs.iter() {
166 let temp_path = deopt.get_work_seed_by_id(program.id)?;
167 let mut content = String::new();
168 content.push_str(crate::deopt::utils::format_library_header_strings(deopt));
169 content.push_str(&program.serialize());
170 std::fs::write(&temp_path, content)?;
171 program_paths.push(temp_path);
172 }
173 let res = self.concurrent_check_batch(&program_paths)?;
174 // print the time usage of the sanitization
175 utils::print_san_cost(&program_paths)?;
176
177 // clean out the failure cache.
178 for (i, has_err) in res.iter().enumerate() {
179 let path = &program_paths[i];
180 let dir = get_file_dirname(path);
181 cleanup_sanitize_dir(&dir)?;
182 if let Some(err) = has_err {
183 // skip delete the hang and fuzzer error programs, those may contain true bugs.
184 if let ProgramError::Hang(_) = err {
185 continue;
186 }
187 if let ProgramError::Fuzzer(_) = err {
188 continue;
189 }
190 std::fs::remove_dir_all(dir)?;
191 }
192 }
193 Ok(res)
194 }
195
196 /// Using multi-process to run a fixed size of batch of programs, and check the program correctness.
197 pub fn concurrent_check_batch(

Callers 1

Calls 8

print_san_costFunction · 0.85
get_file_dirnameFunction · 0.85
cleanup_sanitize_dirFunction · 0.85
get_work_seed_by_idMethod · 0.80
serializeMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected