MCPcopy Create free account
hub / github.com/CodSpeedHQ/codspeed / create_run_script

Function create_run_script

src/executor/valgrind/measure.rs:86–110  ·  view source on GitHub ↗

Creates the shell script on disk and returns the path to it.

()

Source from the content-addressed store, hash-verified

84
85/// Creates the shell script on disk and returns the path to it.
86fn create_run_script() -> anyhow::Result<TempPath> {
87 // The command is wrapped in a shell script, which executes it in a
88 // subprocess and then writes the exit code to a file. The process will
89 // always exit with status code 0, unless valgrind fails.
90 //
91 // Args:
92 // 1. The command to execute
93 // 2. The path to the file where the exit code will be written
94 const WRAPPER_SCRIPT: &str = r#"#!/usr/bin/env bash
95bash -c "$1"
96status=$?
97echo -n "$status" > "$2"
98"#;
99
100 let rwx = std::fs::Permissions::from_mode(0o777);
101 let mut script_file = tempfile::Builder::new()
102 .suffix(".sh")
103 .permissions(rwx)
104 .tempfile()?;
105 script_file.write_all(WRAPPER_SCRIPT.as_bytes())?;
106
107 // Note: We have to convert the file to a path to be able to execute it.
108 // Otherwise this will fail with 'File is busy' error.
109 Ok(script_file.into_temp_path())
110}
111
112/// Dumps every per-process `valgrind.<pid>.log` in the folder to help debug a failure.
113fn dump_valgrind_logs(profile_folder: &Path) {

Callers 2

measureFunction · 0.85
safe_runFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected