Skip to content

Commit 72b3b2c

Browse files
author
Brian Huffman
committed
Add regression test for #635.
1 parent 39b489b commit 72b3b2c

File tree

5 files changed

+51
-0
lines changed

5 files changed

+51
-0
lines changed

intTests/test_llvm_alignment/Makefile

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
test.bc : test.c
2+
clang -c -emit-llvm -g -o test.bc test.c

intTests/test_llvm_alignment/test.bc

3 KB
Binary file not shown.

intTests/test_llvm_alignment/test.c

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#include <stdint.h>
2+
3+
void write (uint64_t *p, uint64_t x) {
4+
*p = x;
5+
}
6+
7+
void write_unaligned (uint8_t *p, uint64_t x) {
8+
write((uint64_t *)(p + 1), x);
9+
}

intTests/test_llvm_alignment/test.saw

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// This is a regression test for saw-script issue #635.
2+
// https://github.com/GaloisInc/saw-script/issues/635
3+
4+
bc <- llvm_load_module "test.bc";
5+
6+
let i8 = llvm_int 8;
7+
let i64 = llvm_int 64;
8+
9+
write_ov <-
10+
crucible_llvm_verify bc "write" [] false
11+
do {
12+
p <- crucible_alloc i64;
13+
x <- crucible_fresh_var "x" i64;
14+
crucible_execute_func [p, crucible_term x];
15+
crucible_points_to p (crucible_term x);
16+
}
17+
z3;
18+
19+
let write_unaligned_spec =
20+
do {
21+
p <- crucible_alloc (llvm_array 16 i8);
22+
b <- crucible_fresh_var "b" (llvm_array 16 i8);
23+
x <- crucible_fresh_var "x" i64;
24+
crucible_points_to p (crucible_term b);
25+
crucible_execute_func [p, crucible_term x];
26+
crucible_points_to p (crucible_term {{ take`{1} b # reverse (split x) # drop`{9} b }});
27+
};
28+
29+
fails (
30+
crucible_llvm_verify bc "write_unaligned" [] false
31+
write_unaligned_spec
32+
z3
33+
);
34+
35+
fails (
36+
crucible_llvm_verify bc "write_unaligned" [write_ov] false
37+
write_unaligned_spec
38+
z3
39+
);

intTests/test_llvm_alignment/test.sh

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
$SAW test.saw

0 commit comments

Comments
 (0)