Skip to content

Commit

Permalink
feat: add simple test for write syscall (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
mstarzinger committed Mar 2, 2021
1 parent d22b071 commit 90eb97b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
17 changes: 17 additions & 0 deletions examples/echo-line.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
uint64_t main() {
uint64_t a;
uint64_t* x;

a = 16;
x = malloc(8);

*x = 0;

while (a) {
read(0, x, 8);
write(1, x, 8);
a = a - 1;
}

return *x == 23;
}
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub enum MonsterError {
#[error("preprocessing failed with error")]
Preprocessing(anyhow::Error),

#[error("execution stopped with error")]
#[error("execution stopped with error, {0}")]
Execution(EngineError),
}

Expand Down
4 changes: 3 additions & 1 deletion tests/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ use std::{
time::Duration,
};

const TEST_FILES: [&str; 14] = [
const TEST_FILES: [&str; 15] = [
"arithmetic.c",
"echo-line.c",
"if-else.c", // needs timeout
"invalid-memory-access-2-35.c",
"division-by-zero-3-35.c",
Expand Down Expand Up @@ -175,6 +176,7 @@ fn execute_riscu<S: Solver>(source: PathBuf, object: PathBuf, solver: &S) {
matches!(
(file_name, bug.clone()),
("arithmetic.c", Bug::ExitCodeGreaterZero { .. }) |
("echo-line.c", Bug::ExitCodeGreaterZero { .. }) |
("invalid-memory-access-2-35.c", Bug::AccessToOutOfRangeAddress { .. }) |
("if-else.c", Bug::ExitCodeGreaterZero { .. }) |
("division-by-zero-3-35.c", Bug::DivisionByZero { .. }) |
Expand Down

0 comments on commit 90eb97b

Please sign in to comment.