]> Cypherpunks repositories - gostls13.git/commitdiff
misc/cgo/testplugin: set the package name in TestIssue19534
authorBryan C. Mills <bcmills@google.com>
Thu, 19 May 2022 14:41:32 +0000 (10:41 -0400)
committerGopher Robot <gobot@golang.org>
Thu, 19 May 2022 15:38:08 +0000 (15:38 +0000)
The fix for #19534 (in CL 40994) adjusted escaping in the
dynamically-linked name lookup logic for the plugin package. However,
the regression test added for it incorrectly included quotes within
the -ldflags flag, causing the flag to inadvertently be ignored.

Possibly in that same CL or possibly at some other point, the
condition that the test thought it was checking stopped working: the
dynamic lookup used the path passed to ldflags, but the object file
actually contained the symbol indexed by the original package name.

Ideally we should stop mucking around with ldflags in this test and
run 'go build' from a suitably-named directory instead, to mimic the
actual conditions in which the original bug was reported. For now, as
a more targeted fix, we can pass the '-p' flag to the compiler to
adjust the package path used at compile time to match the one that
will be set at link time.

For #43177.
Updates #19534.

Change-Id: I9763961feb37cfb05dee543f273492e91a350663
Reviewed-on: https://go-review.googlesource.com/c/go/+/407314
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
misc/cgo/testplugin/plugin_test.go

index d373642e45977c3026712e414fcb46e1e9c0fdbe..e8587e69ba826e9942ceb85b922aff01a30c583e 100644 (file)
@@ -218,7 +218,7 @@ func TestIssue18676(t *testing.T) {
 
 func TestIssue19534(t *testing.T) {
        // Test that we can load a plugin built in a path with non-alpha characters.
-       goCmd(t, "build", "-buildmode=plugin", "-ldflags='-pluginpath=issue.19534'", "-o", "plugin.so", "./issue19534/plugin.go")
+       goCmd(t, "build", "-buildmode=plugin", "-gcflags=-p=issue.19534", "-ldflags=-pluginpath=issue.19534", "-o", "plugin.so", "./issue19534/plugin.go")
        goCmd(t, "build", "-o", "issue19534.exe", "./issue19534/main.go")
        run(t, "./issue19534.exe")
 }