mirror of
https://github.com/golang/term.git
synced 2026-02-08 19:56:05 +03:00
term: use pseudo terminal in TestIsTerminalTerm on linux
Use /dev/ptmx to create a new pseudo terminal and use this in TestIsTerminalTerm. This should fix the test failing with ENXIO on some linux builders. Change-Id: I39880d2cb538e3e9c8063ac79b5380ed00a476f5 Reviewed-on: https://go-review.googlesource.com/c/term/+/201417 Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
committed by
Tobias Klauser
parent
f887077f25
commit
159e5304a9
@@ -5,32 +5,14 @@
|
||||
package term_test
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
"golang.org/x/term"
|
||||
)
|
||||
|
||||
func TestIsTerminalTerm(t *testing.T) {
|
||||
|
||||
dir, err := ioutil.TempDir("", "TestIsTerminalTerm")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer os.RemoveAll(dir)
|
||||
|
||||
tty := filepath.Join(dir, "tty")
|
||||
err = unix.Mknod(tty, unix.S_IFCHR, int(unix.Mkdev(5, 0)))
|
||||
if err == unix.EPERM {
|
||||
t.Skip("no permission to create terminal file, skipping test")
|
||||
} else if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
file, err := os.Open(tty)
|
||||
file, err := os.OpenFile("/dev/ptmx", os.O_RDWR, 0)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user