aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/go/testdata/script
diff options
context:
space:
mode:
Diffstat (limited to 'src/cmd/go/testdata/script')
-rw-r--r--src/cmd/go/testdata/script/mod_replace_gopkgin.txt3
-rw-r--r--src/cmd/go/testdata/script/trampoline_reuse_test.txt100
-rw-r--r--src/cmd/go/testdata/script/version_buildvcs_git_gpg.txt105
3 files changed, 103 insertions, 105 deletions
diff --git a/src/cmd/go/testdata/script/mod_replace_gopkgin.txt b/src/cmd/go/testdata/script/mod_replace_gopkgin.txt
index df752d9716..8cb034c36c 100644
--- a/src/cmd/go/testdata/script/mod_replace_gopkgin.txt
+++ b/src/cmd/go/testdata/script/mod_replace_gopkgin.txt
@@ -4,6 +4,9 @@
# even if there is an explicit go.mod file containing the
# gopkg.in path.
+skip 'skipping test that depends on an unreliable third-party server; see https://go.dev/issue/54503'
+ # TODO(#54043): Make this test hermetic and re-enable it.
+
[short] skip
[!net] skip
[!exec:git] skip
diff --git a/src/cmd/go/testdata/script/trampoline_reuse_test.txt b/src/cmd/go/testdata/script/trampoline_reuse_test.txt
new file mode 100644
index 0000000000..bca897c16d
--- /dev/null
+++ b/src/cmd/go/testdata/script/trampoline_reuse_test.txt
@@ -0,0 +1,100 @@
+# Verify PPC64 does not reuse a trampoline which is too far away.
+# This tests an edge case where the direct call relocation addend should
+# be ignored when computing the distance from the direct call to the
+# already placed trampoline
+[short] skip
+[!ppc64] [!ppc64le] skip
+[aix] skip
+
+# Note, this program does not run. Presumably, 'DWORD $0' is simpler to
+# assembly 2^26 or so times.
+#
+# We build something which should be laid out as such:
+#
+# bar.Bar
+# main.Func1
+# bar.Bar+400-tramp0
+# main.BigAsm
+# main.Func2
+# bar.Bar+400-tramp1
+#
+# bar.Bar needs to be placed far enough away to generate relocations
+# from main package calls. and main.Func1 and main.Func2 are placed
+# a bit more than the direct call limit apart, but not more than 0x400
+# bytes beyond it (to verify the reloc calc).
+
+go build
+
+-- go.mod --
+
+module foo
+
+go 1.19
+
+-- main.go --
+
+package main
+
+import "foo/bar"
+
+func Func1()
+
+func main() {
+ Func1()
+ bar.Bar2()
+}
+
+-- foo.s --
+
+TEXT main·Func1(SB),0,$0-0
+ CALL bar·Bar+0x400(SB)
+ CALL main·BigAsm(SB)
+// A trampoline will be placed here to bar.Bar
+
+// This creates a gap sufficiently large to prevent trampoline reuse
+#define NOP64 DWORD $0; DWORD $0; DWORD $0; DWORD $0; DWORD $0; DWORD $0; DWORD $0; DWORD $0;
+#define NOP256 NOP64 NOP64 NOP64 NOP64
+#define NOP2S10 NOP256 NOP256 NOP256 NOP256
+#define NOP2S12 NOP2S10 NOP2S10 NOP2S10 NOP2S10
+#define NOP2S14 NOP2S12 NOP2S12 NOP2S12 NOP2S12
+#define NOP2S16 NOP2S14 NOP2S14 NOP2S14 NOP2S14
+#define NOP2S18 NOP2S16 NOP2S16 NOP2S16 NOP2S16
+#define NOP2S20 NOP2S18 NOP2S18 NOP2S18 NOP2S18
+#define NOP2S22 NOP2S20 NOP2S20 NOP2S20 NOP2S20
+#define NOP2S24 NOP2S22 NOP2S22 NOP2S22 NOP2S22
+#define BIGNOP NOP2S24 NOP2S24
+TEXT main·BigAsm(SB),0,$0-0
+ // Fill to the direct call limit so Func2 must generate a new trampoline.
+ // As the implicit trampoline above is just barely unreachable.
+ BIGNOP
+ MOVD $main·Func2(SB), R3
+
+TEXT main·Func2(SB),0,$0-0
+ CALL bar·Bar+0x400(SB)
+// Another trampoline should be placed here.
+
+-- bar/bar.s --
+
+#define NOP64 DWORD $0; DWORD $0; DWORD $0; DWORD $0; DWORD $0; DWORD $0; DWORD $0; DWORD $0;
+#define NOP256 NOP64 NOP64 NOP64 NOP64
+#define NOP2S10 NOP256 NOP256 NOP256 NOP256
+#define NOP2S12 NOP2S10 NOP2S10 NOP2S10 NOP2S10
+#define NOP2S14 NOP2S12 NOP2S12 NOP2S12 NOP2S12
+#define NOP2S16 NOP2S14 NOP2S14 NOP2S14 NOP2S14
+#define NOP2S18 NOP2S16 NOP2S16 NOP2S16 NOP2S16
+#define NOP2S20 NOP2S18 NOP2S18 NOP2S18 NOP2S18
+#define NOP2S22 NOP2S20 NOP2S20 NOP2S20 NOP2S20
+#define NOP2S24 NOP2S22 NOP2S22 NOP2S22 NOP2S22
+#define BIGNOP NOP2S24 NOP2S24 NOP2S10
+// A very big not very interesting function.
+TEXT bar·Bar(SB),0,$0-0
+ BIGNOP
+
+-- bar/bar.go --
+
+package bar
+
+func Bar()
+
+func Bar2() {
+}
diff --git a/src/cmd/go/testdata/script/version_buildvcs_git_gpg.txt b/src/cmd/go/testdata/script/version_buildvcs_git_gpg.txt
deleted file mode 100644
index dcf97d7c44..0000000000
--- a/src/cmd/go/testdata/script/version_buildvcs_git_gpg.txt
+++ /dev/null
@@ -1,105 +0,0 @@
-# This test checks that VCS information is stamped into Go binaries even when
-# the current commit is signed and the use has configured git to display commit
-# signatures.
-
-[!exec:git] skip
-[!exec:gpg] skip
-[short] skip
-env GOBIN=$GOPATH/bin
-env GNUPGHOME=$WORK/.gpupg
-mkdir $GNUPGHOME
-chmod 0700 $GNUPGHOME
-
-# Create GPG key
-exec gpg --batch --passphrase '' --quick-generate-key gopher@golang.org
-exec gpg --list-secret-keys --with-colons gopher@golang.org
-cp stdout keyinfo.txt
-go run extract_key_id.go keyinfo.txt
-cp stdout keyid.txt
-
-# Initialize repo
-cd repo/
-exec git init
-exec git config user.email gopher@golang.org
-exec git config user.name 'J.R. Gopher'
-exec git config --add log.showSignature true
-go run ../configure_signing_key.go ../keyid.txt
-
-# Create signed commit
-cd a
-exec git add -A
-exec git commit -m 'initial commit' --gpg-sign
-exec git log
-
-# Verify commit signature does not interfere with versioning
-go install
-go version -m $GOBIN/a
-stdout '^\tbuild\tvcs\.revision='
-stdout '^\tbuild\tvcs\.time='
-stdout '^\tbuild\tvcs\.modified=false$'
-
--- repo/README --
-Far out in the uncharted backwaters of the unfashionable end of the western
-spiral arm of the Galaxy lies a small, unregarded yellow sun.
--- repo/a/go.mod --
-module example.com/a
-
-go 1.18
--- repo/a/a.go --
-package main
-
-func main() {}
-
--- extract_key_id.go --
-package main
-
-import "fmt"
-import "io/ioutil"
-import "os"
-import "strings"
-
-func main() {
- err := run(os.Args[1])
- if err != nil {
- panic(err)
- }
-}
-
-func run(keyInfoFilePath string) error {
- contents, err := ioutil.ReadFile(keyInfoFilePath)
- if err != nil {
- return err
- }
- lines := strings.Split(string(contents), "\n")
- for _, line := range lines {
- fields := strings.Split(line, ":")
- if fields[0] == "sec" {
- fmt.Print(fields[4])
- return nil
- }
- }
- return fmt.Errorf("key ID not found in: %s", keyInfoFilePath)
-}
-
--- configure_signing_key.go --
-package main
-
-import "io/ioutil"
-import "os"
-import "os/exec"
-
-func main() {
- err := run(os.Args[1])
- if err != nil {
- panic(err)
- }
-}
-
-func run(keyIdFilePath string) error {
- keyId, err := ioutil.ReadFile(keyIdFilePath)
- if err != nil {
- return err
- }
- gitCmd := exec.Command("git", "config", "user.signingKey", string(keyId))
- return gitCmd.Run()
-}