Skip to content

Commit

Permalink
Add test case for #1788
Browse files Browse the repository at this point in the history
The fix for #1828 also addresses many of the symptoms of #1788, so let's add
a test case to ensure that those symptoms remain cured.
  • Loading branch information
RyanGlScott committed Mar 9, 2023
1 parent eb05b49 commit 53b5ef0
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 0 deletions.
17 changes: 17 additions & 0 deletions intTests/test1788/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
CC = clang
CFLAGS = -g -frecord-command-line -O0

all: test.bc test.exe

test.bc: test.c
$(CC) $(CFLAGS) -c -emit-llvm $< -o $@

test.o: test.c
$(CC) $(CFLAGS) -c $< -o $@

test.exe: test.o
$(CC) $(CFLAGS) $< -o $@

.PHONY: clean
clean:
rm -f test.bc test.exe
Binary file added intTests/test1788/test.bc
Binary file not shown.
5 changes: 5 additions & 0 deletions intTests/test1788/test.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include <stdint.h>

uint32_t mult(uint32_t x) {
return x * 0x85EBCA77U;
}
13 changes: 13 additions & 0 deletions intTests/test1788/test.saw
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// This test case ensures that ABC can prove that a C implementation of the
// `mult` function is equivalent to a direct Cryptol implementation of the
// same function.

let
{{
cryptol_mult : [32] -> [32]
cryptol_mult x = x * 0x85EBCA77
}};

m <- llvm_load_module "test.bc";
llvm_mult <- llvm_extract m "mult";
prove abc {{ \x -> llvm_mult x == cryptol_mult x }};
3 changes: 3 additions & 0 deletions intTests/test1788/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
set -e

$SAW test.saw

0 comments on commit 53b5ef0

Please sign in to comment.