-
Notifications
You must be signed in to change notification settings - Fork 12
/
sandbox.rs
84 lines (71 loc) · 2.17 KB
/
sandbox.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
mod common;
use common::{eval_dag, setup};
use task_maker_dag::{Execution, ExecutionCommand, ExecutionDAG, ExecutionGroup};
#[test]
fn test_remove_output_file() {
setup();
let mut dag = ExecutionDAG::new();
let mut exec = Execution::new("exec", ExecutionCommand::system("rm"));
exec.args(vec!["file1"])
.capture_stdout(1000)
.capture_stderr(1000)
.output("file1");
dag.on_execution_done(&exec.uuid, |res| {
assert!(!res.status.is_success(), "rm didn't fail: {:?}", res);
Ok(())
});
dag.add_execution(exec);
eval_dag(dag);
}
#[cfg(not(target_os = "macos"))]
#[test]
fn test_chmod_dir() {
setup();
let mut dag = ExecutionDAG::new();
let mut exec = Execution::new("exec", ExecutionCommand::system("chmod"));
exec.args(vec!["777", "."])
.capture_stdout(1000)
.capture_stderr(1000)
.output("file1");
dag.on_execution_done(&exec.uuid, |res| {
assert!(!res.status.is_success(), "chmod didn't fail: {:?}", res);
Ok(())
});
dag.add_execution(exec);
eval_dag(dag);
}
#[test]
fn test_create_files() {
setup();
let mut dag = ExecutionDAG::new();
let mut exec = Execution::new("exec", ExecutionCommand::system("touch"));
exec.args(vec!["lolnope"])
.capture_stdout(1000)
.capture_stderr(1000);
dag.on_execution_done(&exec.uuid, |res| {
assert!(!res.status.is_success(), "touch didn't fail: {:?}", res);
Ok(())
});
dag.add_execution(exec);
eval_dag(dag);
}
#[test]
fn test_list_fifo() {
setup();
let mut dag = ExecutionDAG::new();
let mut group = ExecutionGroup::new("group");
let fifo = group.new_fifo();
let fifo_dir = fifo.sandbox_path().parent().unwrap().to_owned();
group.new_fifo();
let mut exec = Execution::new("exec", ExecutionCommand::system("ls"));
exec.args(vec![fifo_dir.to_str().unwrap()])
.capture_stdout(1000)
.capture_stderr(1000)
.output("file1");
dag.on_execution_done(&exec.uuid, |res| {
assert!(!res.status.is_success(), "ls didn't fail: {:?}", res);
Ok(())
});
dag.add_execution(exec);
eval_dag(dag);
}