Skip to content

Commit a599ccc

Browse files
author
Brian Huffman
committed
Add integration test for using llvm_points_to with Cryptol tuples.
Fixes #159.
1 parent 6789b1a commit a599ccc

File tree

5 files changed

+49
-0
lines changed

5 files changed

+49
-0
lines changed

intTests/test_llvm_tuple/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_tuple/test.bc

3.5 KB
Binary file not shown.

intTests/test_llvm_tuple/test.c

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#include <stdint.h>
2+
3+
struct triple {
4+
uint8_t first[4];
5+
uint16_t second;
6+
uint16_t third;
7+
};
8+
9+
void swap (struct triple *p) {
10+
uint8_t temp1;
11+
uint16_t temp2;
12+
temp1 = p->first[0];
13+
p->first[0] = p->first[3];
14+
p->first[3] = temp1;
15+
temp1 = p->first[1];
16+
p->first[1] = p->first[2];
17+
p->first[2] = temp1;
18+
temp2 = p->second;
19+
p->second = p->third;
20+
p->third = temp2;
21+
}

intTests/test_llvm_tuple/test.saw

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// This is a test demonstrating the use of `llvm_points_to` with a
2+
// struct pointer and a single Cryptol term of tuple type.
3+
// https://github.com/GaloisInc/saw-script/issues/159
4+
5+
bc <- llvm_load_module "test.bc";
6+
7+
let i8 = llvm_int 8;
8+
let i16 = llvm_int 16;
9+
10+
let {{
11+
swap_spec : ([4][8], [16], [16]) -> ([4][8], [16], [16])
12+
swap_spec (xs, y, z) = (reverse xs, z, y)
13+
}};
14+
15+
swap_ov <-
16+
llvm_verify bc "swap" [] false
17+
do {
18+
let t = llvm_struct "struct.triple";
19+
p <- llvm_alloc t;
20+
x <- llvm_fresh_var "x" t;
21+
llvm_points_to p (llvm_term x);
22+
llvm_execute_func [p];
23+
llvm_points_to p (llvm_term {{ swap_spec x }});
24+
}
25+
z3;

intTests/test_llvm_tuple/test.sh

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

0 commit comments

Comments
 (0)