summaryrefslogtreecommitdiff
path: root/misc
diff options
context:
space:
mode:
authorAlan Donovan <adonovan@google.com>2014-10-30 14:01:14 -0400
committerAlan Donovan <adonovan@google.com>2014-10-30 14:01:14 -0400
commit453d54bea44562b2b3a1d3831f28edab994a4fde (patch)
tree033d0d975d248f1696cf51bc9a259cadb059c8f0 /misc
parentd97a45f202fe0beace96e37f40763d32f2520e13 (diff)
downloadgo-453d54bea44562b2b3a1d3831f28edab994a4fde.tar.gz
cmd/cgo: avoid worklist nondeterminism.
+ Regression test. Fixes issue 9026. LGTM=rsc R=rsc CC=golang-codereviews https://codereview.appspot.com/162490043
Diffstat (limited to 'misc')
-rw-r--r--misc/cgo/test/cgo_test.go1
-rw-r--r--misc/cgo/test/issue9026.go33
2 files changed, 34 insertions, 0 deletions
diff --git a/misc/cgo/test/cgo_test.go b/misc/cgo/test/cgo_test.go
index 3b289ba7b..fbdfac87a 100644
--- a/misc/cgo/test/cgo_test.go
+++ b/misc/cgo/test/cgo_test.go
@@ -62,5 +62,6 @@ func Test8517(t *testing.T) { test8517(t) }
func Test8811(t *testing.T) { test8811(t) }
func TestReturnAfterGrow(t *testing.T) { testReturnAfterGrow(t) }
func TestReturnAfterGrowFromGo(t *testing.T) { testReturnAfterGrowFromGo(t) }
+func Test9026(t *testing.T) { test9026(t) }
func BenchmarkCgoCall(b *testing.B) { benchCgoCall(b) }
diff --git a/misc/cgo/test/issue9026.go b/misc/cgo/test/issue9026.go
new file mode 100644
index 000000000..b17440452
--- /dev/null
+++ b/misc/cgo/test/issue9026.go
@@ -0,0 +1,33 @@
+package cgotest
+
+/*
+typedef struct {} git_merge_file_input;
+
+typedef struct {} git_merge_file_options;
+
+int git_merge_file(
+ git_merge_file_input *in,
+ git_merge_file_options *opts) {}
+*/
+import "C"
+import (
+ "fmt"
+ "testing"
+)
+
+func test9026(t *testing.T) {
+ var in C.git_merge_file_input
+ var opts *C.git_merge_file_options
+ C.git_merge_file(&in, opts)
+
+ // Test that the generated type names are deterministic.
+ // (Previously this would fail about 10% of the time.)
+ //
+ // Brittle: the assertion may fail spuriously when the algorithm
+ // changes, but should remain stable otherwise.
+ got := fmt.Sprintf("%T %T", in, opts)
+ want := "cgotest._Ctype_struct___12 *cgotest._Ctype_struct___13"
+ if got != want {
+ t.Errorf("Non-deterministic type names: got %s, want %s", got, want)
+ }
+}