test importing a C struct type

This seems to work so far, but we weren't testing it.

For #384.
pull/399/head
Daniel Martí 5 years ago committed by lu4p
parent aafd845418
commit 8d162dcd04

@ -2,7 +2,7 @@ env GOPRIVATE=test/main
garble build garble build
exec ./main exec ./main
cmp stderr main.stderr cmp stdout main.stdout
binsubstr main$exe 'privateAdd' binsubstr main$exe 'privateAdd'
[short] stop # no need to verify this with -short [short] stop # no need to verify this with -short
@ -10,18 +10,18 @@ binsubstr main$exe 'privateAdd'
env GOPRIVATE=* env GOPRIVATE=*
garble build garble build
exec ./main exec ./main
cmp stderr main.stderr cmp stdout main.stdout
binsubstr main$exe 'privateAdd' binsubstr main$exe 'privateAdd'
env GOPRIVATE=test/main env GOPRIVATE=test/main
garble -tiny build garble -tiny build
exec ./main exec ./main
cmp stderr main.stderr cmp stdout main.stdout
binsubstr main$exe 'privateAdd' binsubstr main$exe 'privateAdd'
go build go build
exec ./main exec ./main
cmp stderr main.stderr cmp stdout main.stdout
-- go.mod -- -- go.mod --
module test/main module test/main
@ -42,20 +42,28 @@ extern void goCallback();
static void callGoCallback() { static void callGoCallback() {
goCallback(); goCallback();
} }
struct portedStruct {
char* PortedField;
};
*/ */
import "C" import "C"
import "fmt"
func main() { func main() {
println(C.privateAdd(C.int(1), C.int(2))) fmt.Println(C.privateAdd(C.int(1), C.int(2)))
_, _ = user.Current() _, _ = user.Current()
fmt.Printf("%#v\n", C.struct_portedStruct{})
C.callGoCallback() C.callGoCallback()
} }
//export goCallback //export goCallback
func goCallback() { func goCallback() {
println("go callback") fmt.Println("go callback")
} }
-- main.stderr -- -- main.stdout --
3 3
main._Ctype_struct_portedStruct{PortedField:(*main._Ctype_char)(nil)}
go callback go callback

Loading…
Cancel
Save