diff options
| author | Austin Clements <austin@google.com> | 2023-05-04 12:13:27 -0400 |
|---|---|---|
| committer | Austin Clements <austin@google.com> | 2023-05-12 11:59:56 +0000 |
| commit | bf6c55a8b313752667b51194485fa206110d71f9 (patch) | |
| tree | 8dd81bdb6e48bc77d7923ba985a91b6b7daa341e /misc/cgo/errors/testdata | |
| parent | a25688d406f2a4296d39b22a2b10aea7178eddc6 (diff) | |
| download | go-bf6c55a8b313752667b51194485fa206110d71f9.tar.xz | |
misc/cgo: move easy tests to cmd/cgo/internal
This moves most misc/cgo tests to cmd/cgo/internal. This is mostly a
trivial rename and updating dist/test.go for the new paths, plus
excluding these packages from regular dist test registration. A few
tests were sensitive to what path they ran in, so we update those.
This will let these tests access facilities in internal/testenv.
For #37486.
Change-Id: I3ed417c7c22d9b667f2767c0cb1f59118fcd4af6
Reviewed-on: https://go-review.googlesource.com/c/go/+/492720
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Diffstat (limited to 'misc/cgo/errors/testdata')
| -rw-r--r-- | misc/cgo/errors/testdata/err1.go | 22 | ||||
| -rw-r--r-- | misc/cgo/errors/testdata/err2.go | 110 | ||||
| -rw-r--r-- | misc/cgo/errors/testdata/err4.go | 15 | ||||
| -rw-r--r-- | misc/cgo/errors/testdata/issue11097a.go | 15 | ||||
| -rw-r--r-- | misc/cgo/errors/testdata/issue11097b.go | 15 | ||||
| -rw-r--r-- | misc/cgo/errors/testdata/issue14669.go | 23 | ||||
| -rw-r--r-- | misc/cgo/errors/testdata/issue18452.go | 18 | ||||
| -rw-r--r-- | misc/cgo/errors/testdata/issue18889.go | 7 | ||||
| -rw-r--r-- | misc/cgo/errors/testdata/issue28069.go | 26 | ||||
| -rw-r--r-- | misc/cgo/errors/testdata/issue28721.go | 29 | ||||
| -rw-r--r-- | misc/cgo/errors/testdata/issue33061.go | 17 | ||||
| -rw-r--r-- | misc/cgo/errors/testdata/issue42580.go | 44 | ||||
| -rw-r--r-- | misc/cgo/errors/testdata/issue50710.go | 14 | ||||
| -rw-r--r-- | misc/cgo/errors/testdata/long_double_size.go | 16 | ||||
| -rw-r--r-- | misc/cgo/errors/testdata/malloc.go | 34 |
15 files changed, 0 insertions, 405 deletions
diff --git a/misc/cgo/errors/testdata/err1.go b/misc/cgo/errors/testdata/err1.go deleted file mode 100644 index ced7443599..0000000000 --- a/misc/cgo/errors/testdata/err1.go +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package main - -/* -#cgo LDFLAGS: -L/nonexist - -void test() { - xxx; // ERROR HERE -} - -// Issue 8442. Cgo output unhelpful error messages for -// invalid C preambles. -void issue8442foo(UNDEF*); // ERROR HERE -*/ -import "C" - -func main() { - C.test() -} diff --git a/misc/cgo/errors/testdata/err2.go b/misc/cgo/errors/testdata/err2.go deleted file mode 100644 index aa941584c3..0000000000 --- a/misc/cgo/errors/testdata/err2.go +++ /dev/null @@ -1,110 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package main - -/* -#include <stdio.h> - -typedef struct foo foo_t; -typedef struct bar bar_t; - -foo_t *foop; - -long double x = 0; - -static int transform(int x) { return x; } - -typedef void v; -void F(v** p) {} - -void fvi(void *p, int x) {} - -void fppi(int** p) {} - -int i; -void fi(int i) {} -*/ -import "C" -import ( - "unsafe" -) - -func main() { - s := "" - _ = s - C.malloc(s) // ERROR HERE - - x := (*C.bar_t)(nil) - C.foop = x // ERROR HERE - - // issue 13129: used to output error about C.unsignedshort with CC=clang - var x1 C.ushort - x1 = int(0) // ERROR HERE: C\.ushort - - // issue 13423 - _ = C.fopen() // ERROR HERE - - // issue 13467 - var x2 rune = '✈' - var _ rune = C.transform(x2) // ERROR HERE: C\.int - - // issue 13635: used to output error about C.unsignedchar. - // This test tests all such types. - var ( - _ C.uchar = "uc" // ERROR HERE: C\.uchar - _ C.schar = "sc" // ERROR HERE: C\.schar - _ C.ushort = "us" // ERROR HERE: C\.ushort - _ C.uint = "ui" // ERROR HERE: C\.uint - _ C.ulong = "ul" // ERROR HERE: C\.ulong - _ C.longlong = "ll" // ERROR HERE: C\.longlong - _ C.ulonglong = "ull" // ERROR HERE: C\.ulonglong - _ C.complexfloat = "cf" // ERROR HERE: C\.complexfloat - _ C.complexdouble = "cd" // ERROR HERE: C\.complexdouble - ) - - // issue 13830 - // cgo converts C void* to Go unsafe.Pointer, so despite appearances C - // void** is Go *unsafe.Pointer. This test verifies that we detect the - // problem at build time. - { - type v [0]byte - - f := func(p **v) { - C.F((**C.v)(unsafe.Pointer(p))) // ERROR HERE - } - var p *v - f(&p) - } - - // issue 16116 - _ = C.fvi(1) // ERROR HERE - - // Issue 16591: Test that we detect an invalid call that was being - // hidden by a type conversion inserted by cgo checking. - { - type x *C.int - var p *x - C.fppi(p) // ERROR HERE - } - - // issue 26745 - _ = func(i int) int { - // typecheck reports at column 14 ('+'), but types2 reports at - // column 10 ('C'). - // TODO(mdempsky): Investigate why, and see if types2 can be - // updated to match typecheck behavior. - return C.i + 1 // ERROR HERE: \b(10|14)\b - } - _ = func(i int) { - // typecheck reports at column 7 ('('), but types2 reports at - // column 8 ('i'). The types2 position is more correct, but - // updating typecheck here is fundamentally challenging because of - // IR limitations. - C.fi(i) // ERROR HERE: \b(7|8)\b - } - - C.fi = C.fi // ERROR HERE - -} diff --git a/misc/cgo/errors/testdata/err4.go b/misc/cgo/errors/testdata/err4.go deleted file mode 100644 index 8e5f78e987..0000000000 --- a/misc/cgo/errors/testdata/err4.go +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2017 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package main - -/* -long double x = 0; -*/ -import "C" - -func main() { - _ = C.x // ERROR HERE - _ = C.x -} diff --git a/misc/cgo/errors/testdata/issue11097a.go b/misc/cgo/errors/testdata/issue11097a.go deleted file mode 100644 index 028d10ce5c..0000000000 --- a/misc/cgo/errors/testdata/issue11097a.go +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2015 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package main - -/* -//enum test { foo, bar }; -*/ -import "C" - -func main() { - var a = C.enum_test(1) // ERROR HERE - _ = a -} diff --git a/misc/cgo/errors/testdata/issue11097b.go b/misc/cgo/errors/testdata/issue11097b.go deleted file mode 100644 index b00f24fc10..0000000000 --- a/misc/cgo/errors/testdata/issue11097b.go +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2015 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package main - -/* -//enum test { foo, bar }; -*/ -import "C" - -func main() { - p := new(C.enum_test) // ERROR HERE - _ = p -} diff --git a/misc/cgo/errors/testdata/issue14669.go b/misc/cgo/errors/testdata/issue14669.go deleted file mode 100644 index 04d2bcb631..0000000000 --- a/misc/cgo/errors/testdata/issue14669.go +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Issue 14669: test that fails when build with CGO_CFLAGS selecting -// optimization. - -package p - -/* -const int E = 1; - -typedef struct s { - int c; -} s; -*/ -import "C" - -func F() { - _ = C.s{ - c: C.E, - } -} diff --git a/misc/cgo/errors/testdata/issue18452.go b/misc/cgo/errors/testdata/issue18452.go deleted file mode 100644 index 0386d76892..0000000000 --- a/misc/cgo/errors/testdata/issue18452.go +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2017 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Issue 18452: show pos info in undefined name errors - -package p - -import ( - "C" - "fmt" -) - -func a() { - fmt.Println("Hello, world!") - C.function_that_does_not_exist() // ERROR HERE - C.pi // ERROR HERE -} diff --git a/misc/cgo/errors/testdata/issue18889.go b/misc/cgo/errors/testdata/issue18889.go deleted file mode 100644 index bba6b8f9bb..0000000000 --- a/misc/cgo/errors/testdata/issue18889.go +++ /dev/null @@ -1,7 +0,0 @@ -package main - -import "C" - -func main() { - _ = C.malloc // ERROR HERE -} diff --git a/misc/cgo/errors/testdata/issue28069.go b/misc/cgo/errors/testdata/issue28069.go deleted file mode 100644 index e19a3b45bd..0000000000 --- a/misc/cgo/errors/testdata/issue28069.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2018 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Test that the error message for an unrepresentable typedef in a -// union appears on the right line. This test is only run if the size -// of long double is larger than 64. - -package main - -/* -typedef long double Float128; - -typedef struct SV { - union { - Float128 float128; - } value; -} SV; -*/ -import "C" - -type ts struct { - tv *C.SV // ERROR HERE -} - -func main() {} diff --git a/misc/cgo/errors/testdata/issue28721.go b/misc/cgo/errors/testdata/issue28721.go deleted file mode 100644 index 0eb2a9271c..0000000000 --- a/misc/cgo/errors/testdata/issue28721.go +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2018 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// cgo should reject the use of mangled C names. - -package main - -/* -typedef struct a { - int i; -} a; -void fn(void) {} -*/ -import "C" - -type B _Ctype_struct_a // ERROR HERE - -var a _Ctype_struct_a // ERROR HERE - -type A struct { - a *_Ctype_struct_a // ERROR HERE -} - -var notExist _Ctype_NotExist // ERROR HERE - -func main() { - _Cfunc_fn() // ERROR HERE -} diff --git a/misc/cgo/errors/testdata/issue33061.go b/misc/cgo/errors/testdata/issue33061.go deleted file mode 100644 index 77d5f7a7c9..0000000000 --- a/misc/cgo/errors/testdata/issue33061.go +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2019 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// cgo shouldn't crash if there is an extra argument with a C reference. - -package main - -// void F(void* p) {}; -import "C" - -import "unsafe" - -func F() { - var i int - C.F(unsafe.Pointer(&i), C.int(0)) // ERROR HERE -} diff --git a/misc/cgo/errors/testdata/issue42580.go b/misc/cgo/errors/testdata/issue42580.go deleted file mode 100644 index aba80dfeba..0000000000 --- a/misc/cgo/errors/testdata/issue42580.go +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright 2021 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Issue 42580: cmd/cgo: shifting identifier position in ast - -package cgotest - -// typedef int (*intFunc) (); -// -// char* strarg = ""; -// -// int func_with_char(char* arg, void* dummy) -// {return 5;} -// -// int* get_arr(char* arg, void* dummy) -// {return NULL;} -import "C" -import "unsafe" - -// Test variables -var ( - checkedPointer = []byte{1} - doublePointerChecked = []byte{1} - singleInnerPointerChecked = []byte{1} -) - -// This test checks the positions of variable identifiers. -// Changing the positions of the test variables idents after this point will break the test. - -func TestSingleArgumentCast() C.int { - retcode := C.func_with_char((*C.char)(unsafe.Pointer(&checkedPointer[0])), unsafe.Pointer(C.strarg)) - return retcode -} - -func TestSingleArgumentCastRecFuncAsSimpleArg() C.int { - retcode := C.func_with_char((*C.char)(unsafe.Pointer(C.get_arr((*C.char)(unsafe.Pointer(&singleInnerPointerChecked[0])), unsafe.Pointer(C.strarg)))), nil) - return retcode -} - -func TestSingleArgumentCastRecFunc() C.int { - retcode := C.func_with_char((*C.char)(unsafe.Pointer(C.get_arr((*C.char)(unsafe.Pointer(&doublePointerChecked[0])), unsafe.Pointer(C.strarg)))), unsafe.Pointer(C.strarg)) - return retcode -} diff --git a/misc/cgo/errors/testdata/issue50710.go b/misc/cgo/errors/testdata/issue50710.go deleted file mode 100644 index dffea22903..0000000000 --- a/misc/cgo/errors/testdata/issue50710.go +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2022 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package main - -// size_t StrLen(_GoString_ s) { -// return _GoStringLen(s); -// } -import "C" - -func main() { - C.StrLen1() // ERROR HERE -} diff --git a/misc/cgo/errors/testdata/long_double_size.go b/misc/cgo/errors/testdata/long_double_size.go deleted file mode 100644 index 8b797f886a..0000000000 --- a/misc/cgo/errors/testdata/long_double_size.go +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2017 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package main - -/* -const int sizeofLongDouble = sizeof(long double); -*/ -import "C" - -import "fmt" - -func main() { - fmt.Println(C.sizeofLongDouble) -} diff --git a/misc/cgo/errors/testdata/malloc.go b/misc/cgo/errors/testdata/malloc.go deleted file mode 100644 index 65da0208b9..0000000000 --- a/misc/cgo/errors/testdata/malloc.go +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Test that C.malloc does not return nil. - -package main - -// #include <stdlib.h> -import "C" - -import ( - "fmt" - "runtime" -) - -func main() { - var size C.size_t - size-- - - // The Dragonfly libc succeeds when asked to allocate - // 0xffffffffffffffff bytes, so pass a different value that - // causes it to fail. - if runtime.GOOS == "dragonfly" { - size = C.size_t(0x7fffffff << (32 * (^uintptr(0) >> 63))) - } - - p := C.malloc(size) - if p == nil { - fmt.Println("malloc: C.malloc returned nil") - // Just exit normally--the test script expects this - // program to crash, so exiting normally indicates failure. - } -} |
