Skip to content

Commit fa9ee61

Browse files
committed
fix: valgrind test
1 parent 02a3d37 commit fa9ee61

1 file changed

Lines changed: 27 additions & 46 deletions

File tree

src/run/runner/tests.rs

Lines changed: 27 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
use crate::prelude::*;
21
use crate::run::check_system::SystemInfo;
32
use crate::run::config::Config;
43
use crate::run::instruments::mongo_tracer::MongoTracer;
54
use crate::run::runner::executor::Executor;
65
use crate::run::runner::interfaces::RunData;
6+
use crate::run::runner::valgrind::executor::ValgrindExecutor;
77
use crate::run::{RunnerMode, runner::wall_time::executor::WallTimeExecutor};
88
use tempfile::TempDir;
99

@@ -15,41 +15,21 @@ const MULTILINE_ECHO_WITH_SEMICOLONS: &str = "echo \"Working\";
1515
echo \"with\";
1616
echo \"multiple lines\";";
1717

18-
const ENV_VAR_VALIDATION_SCRIPT: &str = "export MY_ENV_VAR=\"Hello\"
19-
output=$(echo \"$MY_ENV_VAR\")
20-
if [ \"$output\" != \"Hello\" ]; then
21-
echo \"Assertion failed: Expected 'Hello' but got '$output'\"
22-
exit 1
23-
fi";
24-
25-
const ENV_VAR_VALIDATION_FAIL_SCRIPT: &str = "MY_ENV_VAR=\"Wrong\"
26-
output=$(echo \"$MY_ENV_VAR\")
27-
if [ \"$output\" != \"Hello\" ]; then
28-
echo \"Assertion failed: Expected 'Hello' but got '$output'\"
29-
exit 1
30-
fi";
31-
3218
const DIRECTORY_CHECK_SCRIPT: &str = "cd /tmp
3319
# Check that the directory is actually changed
3420
if [ $(basename $(pwd)) != \"tmp\" ]; then
3521
exit 1
3622
fi";
3723

38-
const BENCHMARK_COMMANDS: [&str; 6] = [
24+
const BENCHMARK_COMMANDS: [&str; 5] = [
3925
"echo 'Hello, World!'",
40-
"date",
4126
MULTILINE_ECHO_WITH_SEMICOLONS,
4227
MULTILINE_ECHO_WITH_SEMICOLONS,
4328
MULTILINE_ECHO_SCRIPT,
4429
DIRECTORY_CHECK_SCRIPT,
45-
// ENV_VAR_VALIDATION_SCRIPT,
46-
// ENV_VAR_VALIDATION_FAIL_SCRIPT,
4730
];
48-
// temp_env::with_var("TEST_ENV_VAR", "test_value".into(), || {
49-
// assert_eq!(safe_run("echo $TEST_ENV_VAR"), (0, 0));
50-
// });
5131

52-
async fn create_test_setup() -> (SystemInfo, RunData, Option<MongoTracer>) {
32+
async fn create_test_setup() -> (SystemInfo, RunData, Option<MongoTracer>, TempDir) {
5333
let temp_dir = TempDir::new().unwrap();
5434

5535
let system_info = SystemInfo::test();
@@ -58,34 +38,35 @@ async fn create_test_setup() -> (SystemInfo, RunData, Option<MongoTracer>) {
5838
};
5939
let mongo_tracer = None;
6040

61-
(system_info, run_data, mongo_tracer)
41+
(system_info, run_data, mongo_tracer, temp_dir)
6242
}
6343

64-
// #[tokio::test]
65-
// async fn test_valgrind_executor() {
66-
// let executor = ValgrindExecutor;
67-
// let (system_info, run_data, _mongo_tracer) = create_test_setup().await;
68-
69-
// let config = Config {
70-
// mode: RunnerMode::Instrumentation,
71-
// command: "echo 'Hello, World!'".to_string(),
72-
// ..Config::test()
73-
// };
74-
75-
// executor.setup(&system_info).await.unwrap();
76-
// executor
77-
// .run(&config, &system_info, &run_data, &None)
78-
// .await
79-
// .unwrap();
80-
// executor
81-
// .teardown(&config, &system_info, &run_data)
82-
// .await
83-
// .unwrap();
84-
// }
44+
#[tokio::test]
45+
async fn test_valgrind_executor() {
46+
let (system_info, run_data, _mongo_tracer, _temp_dir) = create_test_setup().await;
47+
48+
let executor = ValgrindExecutor;
49+
executor.setup(&system_info).await.unwrap();
50+
51+
for cmd in BENCHMARK_COMMANDS {
52+
eprintln!("Running command: {cmd}");
53+
54+
let config = Config {
55+
mode: RunnerMode::Instrumentation,
56+
command: cmd.to_string(),
57+
..Config::test()
58+
};
59+
60+
executor
61+
.run(&config, &system_info, &run_data, &None)
62+
.await
63+
.unwrap();
64+
}
65+
}
8566

8667
#[tokio::test]
8768
async fn test_walltime_executor() {
88-
let (system_info, run_data, _mongo_tracer) = create_test_setup().await;
69+
let (system_info, run_data, _mongo_tracer, _temp_dir) = create_test_setup().await;
8970

9071
let executor = WallTimeExecutor::new();
9172
executor.setup(&system_info).await.unwrap();

0 commit comments

Comments
 (0)