internal/testpty: move from os/signal/internal/pty

We're going to use this for another test, so make it more accessible.

Preparation for #37486.

Change-Id: If194cc4244c4b9e1b1f253759b813555b39ad67e
Reviewed-on: https://go-review.googlesource.com/c/go/+/449502
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
This commit is contained in:
Austin Clements 2022-11-10 16:02:48 -05:00
parent 80d8c77a43
commit 334d8e453b
5 changed files with 8 additions and 9 deletions

View File

@ -558,7 +558,7 @@ var depsRules = `
< internal/obscuretestdata; < internal/obscuretestdata;
CGO, OS, fmt CGO, OS, fmt
< os/signal/internal/pty; < internal/testpty;
NET, testing, math/rand NET, testing, math/rand
< golang.org/x/net/nettest; < golang.org/x/net/nettest;

View File

@ -4,10 +4,9 @@
//go:build ((aix || dragonfly || freebsd || (linux && !android) || netbsd || openbsd) && cgo) || darwin //go:build ((aix || dragonfly || freebsd || (linux && !android) || netbsd || openbsd) && cgo) || darwin
// Package pty is a simple pseudo-terminal package for Unix systems, // Package testpty is a simple pseudo-terminal package for Unix systems,
// implemented by calling C functions via cgo. // implemented by calling C functions via cgo.
// This is only used for testing the os/signal package. package testpty
package pty
import ( import (
"fmt" "fmt"

View File

@ -4,7 +4,7 @@
//go:build cgo && (aix || dragonfly || freebsd || (linux && !android) || netbsd || openbsd) //go:build cgo && (aix || dragonfly || freebsd || (linux && !android) || netbsd || openbsd)
package pty package testpty
/* /*
#define _XOPEN_SOURCE 600 #define _XOPEN_SOURCE 600

View File

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
package pty package testpty
import ( import (
"internal/syscall/unix" "internal/syscall/unix"

View File

@ -14,10 +14,10 @@ import (
"context" "context"
"encoding/binary" "encoding/binary"
"fmt" "fmt"
"internal/testpty"
"os" "os"
"os/exec" "os/exec"
"os/signal" "os/signal"
ptypkg "os/signal/internal/pty"
"runtime" "runtime"
"strconv" "strconv"
"syscall" "syscall"
@ -105,9 +105,9 @@ func TestTerminalSignal(t *testing.T) {
t.Parallel() t.Parallel()
pty, procTTYName, err := ptypkg.Open() pty, procTTYName, err := testpty.Open()
if err != nil { if err != nil {
ptyErr := err.(*ptypkg.PtyError) ptyErr := err.(*testpty.PtyError)
if ptyErr.FuncName == "posix_openpt" && ptyErr.Errno == syscall.EACCES { if ptyErr.FuncName == "posix_openpt" && ptyErr.Errno == syscall.EACCES {
t.Skip("posix_openpt failed with EACCES, assuming chroot and skipping") t.Skip("posix_openpt failed with EACCES, assuming chroot and skipping")
} }