Prepare the benchmark command wrapped with the necessary environment variables for introspection and environment forwarding ahead of privilege escalation and isolation.
(
config: &ExecutorConfig,
execution_context: &ExecutionContext,
)
| 116 | /// Prepare the benchmark command wrapped with the necessary environment variables for |
| 117 | /// introspection and environment forwarding ahead of privilege escalation and isolation. |
| 118 | fn walltime_bench_cmd( |
| 119 | config: &ExecutorConfig, |
| 120 | execution_context: &ExecutionContext, |
| 121 | ) -> Result<(NamedTempFile, NamedTempFile, CommandBuilder)> { |
| 122 | let path_value = build_path_env(config.enable_introspection)?; |
| 123 | |
| 124 | let mut extra_env = get_base_injected_env( |
| 125 | RunnerMode::Walltime, |
| 126 | &execution_context.profile_folder, |
| 127 | &execution_context.config, |
| 128 | ); |
| 129 | extra_env.insert("PATH".into(), path_value); |
| 130 | |
| 131 | // We have to write the benchmark command to a script, to ensure proper formatting |
| 132 | // and to not have to manually escape everything. |
| 133 | let mut script_file = NamedTempFile::new()?; |
| 134 | script_file.write_all(get_bench_command(config)?.as_bytes())?; |
| 135 | |
| 136 | let mut bench_cmd = CommandBuilder::new("bash"); |
| 137 | bench_cmd.arg(script_file.path()); |
| 138 | let (mut bench_cmd, env_file) = wrap_with_env(bench_cmd, &extra_env)?; |
| 139 | |
| 140 | if let Some(cwd) = &config.working_directory { |
| 141 | let abs_cwd = canonicalize(cwd)?; |
| 142 | bench_cmd.current_dir(abs_cwd); |
| 143 | } |
| 144 | |
| 145 | Ok((env_file, script_file, bench_cmd)) |
| 146 | } |
| 147 | } |
| 148 | |
| 149 | #[async_trait(?Send)] |
nothing calls this directly
no test coverage detected