]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/link: new test case for Darwin/DWARF
authorThan McIntosh <thanm@google.com>
Sat, 25 May 2019 01:04:49 +0000 (21:04 -0400)
committerThan McIntosh <thanm@google.com>
Thu, 30 May 2019 19:12:55 +0000 (19:12 +0000)
Test case for issue 32233.

Updates #32233.

Change-Id: I0e3b4a46832f39de4ef36d8fd8c6070bf9b1a019
Reviewed-on: https://go-review.googlesource.com/c/go/+/178726
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/cmd/link/internal/ld/dwarf_test.go
src/cmd/link/internal/ld/testdata/issue32233/lib/ObjC.m [new file with mode: 0644]
src/cmd/link/internal/ld/testdata/issue32233/lib/lib.go [new file with mode: 0644]
src/cmd/link/internal/ld/testdata/issue32233/main/main.go [new file with mode: 0644]

index 190a54c4c38d486fead3c5e6f251d1ca9cc7e5c7..df193e5d3d052f57ee6b8017519ef0815efb4c11 100644 (file)
@@ -1195,3 +1195,26 @@ func TestPackageNameAttr(t *testing.T) {
                }
        }
 }
+
+func TestMachoIssue32233(t *testing.T) {
+       testenv.MustHaveGoBuild(t)
+       testenv.MustHaveCGO(t)
+
+       if runtime.GOOS != "darwin" {
+               t.Skip("skipping; test only interesting on darwin")
+       }
+
+       tmpdir, err := ioutil.TempDir("", "TestMachoIssue32233")
+       if err != nil {
+               t.Fatalf("could not create directory: %v", err)
+       }
+       defer os.RemoveAll(tmpdir)
+
+       wd, err2 := os.Getwd()
+       if err2 != nil {
+               t.Fatalf("where am I? %v", err)
+       }
+       pdir := filepath.Join(wd, "testdata", "issue32233", "main")
+       f := gobuildTestdata(t, tmpdir, pdir, DefaultOpt)
+       f.Close()
+}
diff --git a/src/cmd/link/internal/ld/testdata/issue32233/lib/ObjC.m b/src/cmd/link/internal/ld/testdata/issue32233/lib/ObjC.m
new file mode 100644 (file)
index 0000000..78e6e9e
--- /dev/null
@@ -0,0 +1,14 @@
+// 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.
+
+#import <Foundation/Foundation.h>
+#import <UserNotifications/UserNotifications.h>
+
+BOOL function(void) {
+  if (@available(macOS 10.14, *)) {
+    UNUserNotificationCenter *center =
+        [UNUserNotificationCenter currentNotificationCenter];
+  }
+  return NO;
+}
diff --git a/src/cmd/link/internal/ld/testdata/issue32233/lib/lib.go b/src/cmd/link/internal/ld/testdata/issue32233/lib/lib.go
new file mode 100644 (file)
index 0000000..efd56fb
--- /dev/null
@@ -0,0 +1,19 @@
+// 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.
+
+package lib
+
+/*
+#cgo darwin CFLAGS: -mmacosx-version-min=10.10 -D__MAC_OS_X_VERSION_MAX_ALLOWED=101450 -Wunguarded-availability-new
+#cgo darwin LDFLAGS: -framework Foundation -framework UserNotifications
+#include "stdlib.h"
+int function(void);
+*/
+import "C"
+import "fmt"
+
+func DoC() {
+       C.function()
+       fmt.Println("called c function")
+}
diff --git a/src/cmd/link/internal/ld/testdata/issue32233/main/main.go b/src/cmd/link/internal/ld/testdata/issue32233/main/main.go
new file mode 100644 (file)
index 0000000..ed0838a
--- /dev/null
@@ -0,0 +1,11 @@
+// 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.
+
+package main
+
+import "cmd/link/internal/ld/testdata/issue32233/lib"
+
+func main() {
+       lib.DoC()
+}