From 8d162dcd04e9f2d76e83359dff67b0134d37a54f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Mon, 13 Sep 2021 08:58:55 +0200 Subject: [PATCH] test importing a C struct type This seems to work so far, but we weren't testing it. For #384. --- testdata/scripts/cgo.txt | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/testdata/scripts/cgo.txt b/testdata/scripts/cgo.txt index d2e1a45..98c4786 100644 --- a/testdata/scripts/cgo.txt +++ b/testdata/scripts/cgo.txt @@ -2,7 +2,7 @@ env GOPRIVATE=test/main garble build exec ./main -cmp stderr main.stderr +cmp stdout main.stdout binsubstr main$exe 'privateAdd' [short] stop # no need to verify this with -short @@ -10,18 +10,18 @@ binsubstr main$exe 'privateAdd' env GOPRIVATE=* garble build exec ./main -cmp stderr main.stderr +cmp stdout main.stdout binsubstr main$exe 'privateAdd' env GOPRIVATE=test/main garble -tiny build exec ./main -cmp stderr main.stderr +cmp stdout main.stdout binsubstr main$exe 'privateAdd' go build exec ./main -cmp stderr main.stderr +cmp stdout main.stdout -- go.mod -- module test/main @@ -42,20 +42,28 @@ extern void goCallback(); static void callGoCallback() { goCallback(); } + +struct portedStruct { + char* PortedField; +}; */ import "C" +import "fmt" func main() { - println(C.privateAdd(C.int(1), C.int(2))) + fmt.Println(C.privateAdd(C.int(1), C.int(2))) _, _ = user.Current() + fmt.Printf("%#v\n", C.struct_portedStruct{}) + C.callGoCallback() } //export goCallback func goCallback() { - println("go callback") + fmt.Println("go callback") } --- main.stderr -- +-- main.stdout -- 3 +main._Ctype_struct_portedStruct{PortedField:(*main._Ctype_char)(nil)} go callback