mirror of
https://github.com/GaloisInc/cryptol.git
synced 2024-10-26 22:29:08 +03:00
FFI: Set up tests
This commit is contained in:
parent
e4880c979d
commit
7294acc805
2
tests/.gitignore
vendored
2
tests/.gitignore
vendored
@ -1 +1,3 @@
|
||||
output
|
||||
*.so
|
||||
*.dylib
|
||||
|
28
tests/ffi/Makefile
Normal file
28
tests/ffi/Makefile
Normal file
@ -0,0 +1,28 @@
|
||||
CFLAGS += -Wall -Werror
|
||||
|
||||
# For each C file foo.c, we make a phony target foo, then depending on the OS
|
||||
# map that to either foo.dylib or foo.so.
|
||||
|
||||
CFILES = $(wildcard *.c)
|
||||
TARGETS = $(CFILES:.c=)
|
||||
|
||||
all: $(TARGETS)
|
||||
|
||||
.PHONY: all clean $(TARGETS)
|
||||
|
||||
ifeq ($(shell uname),Darwin)
|
||||
EXT = .dylib
|
||||
else
|
||||
EXT = .so
|
||||
endif
|
||||
|
||||
$(TARGETS): %: %$(EXT)
|
||||
|
||||
%.dylib: %.c
|
||||
$(CC) $(CFLAGS) -dynamiclib $< -o $@
|
||||
|
||||
%.so: %.c
|
||||
$(CC) $(CFLAGS) -fPIC -shared $< -o $@
|
||||
|
||||
clean:
|
||||
rm *$(EXT)
|
3
tests/ffi/test-ffi.c
Normal file
3
tests/ffi/test-ffi.c
Normal file
@ -0,0 +1,3 @@
|
||||
int add(int x, int y) {
|
||||
return x + y;
|
||||
}
|
1
tests/ffi/test-ffi.cry
Normal file
1
tests/ffi/test-ffi.cry
Normal file
@ -0,0 +1 @@
|
||||
foreign add : [32] -> [32] -> [32]
|
3
tests/ffi/test-ffi.icry
Normal file
3
tests/ffi/test-ffi.icry
Normal file
@ -0,0 +1,3 @@
|
||||
:! make -s test-ffi
|
||||
:l test-ffi.cry
|
||||
add 1 2
|
4
tests/ffi/test-ffi.icry.stdout
Normal file
4
tests/ffi/test-ffi.icry.stdout
Normal file
@ -0,0 +1,4 @@
|
||||
Loading module Cryptol
|
||||
Loading module Cryptol
|
||||
Loading module Main
|
||||
0x00000003
|
Loading…
Reference in New Issue
Block a user