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

Function create_run_script

src/executor/valgrind/measure.rs:68–92  ·  view source on GitHub ↗

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

()

Source from the content-addressed store, hash-verified

66
67/// Creates the shell script on disk and returns the path to it.
68fn create_run_script() -> anyhow::Result<TempPath> {
69 // The command is wrapped in a shell script, which executes it in a
70 // subprocess and then writes the exit code to a file. The process will
71 // always exit with status code 0, unless valgrind fails.
72 //
73 // Args:
74 // 1. The command to execute
75 // 2. The path to the file where the exit code will be written
76 const WRAPPER_SCRIPT: &str = r#"#!/usr/bin/env bash
77bash -c "$1"
78status=$?
79echo -n "$status" > "$2"
80"#;
81
82 let rwx = std::fs::Permissions::from_mode(0o777);
83 let mut script_file = tempfile::Builder::new()
84 .suffix(".sh")
85 .permissions(rwx)
86 .tempfile()?;
87 script_file.write_all(WRAPPER_SCRIPT.as_bytes())?;
88
89 // Note: We have to convert the file to a path to be able to execute it.
90 // Otherwise this will fail with 'File is busy' error.
91 Ok(script_file.into_temp_path())
92}
93
94/// Dumps every per-process `valgrind.<pid>.log` in the folder to help debug a failure.
95fn dump_valgrind_logs(profile_folder: &Path) {

Callers 2

measureFunction · 0.70
safe_runFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected