mirror of
https://github.com/go-delve/delve.git
synced 2025-10-28 20:53:42 +08:00
service/debugger: make TestDebugger_LaunchWithTTY pass on FreeBSD (#2982)
FreeBSD does not have lsof, rather it has fstat. Additionally, the TTY name does not match up with the current code.
This commit is contained in:
@ -10,6 +10,7 @@ import (
|
|||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/creack/pty"
|
"github.com/creack/pty"
|
||||||
@ -87,12 +88,17 @@ func TestDebugger_LaunchWithTTY(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
cmd := exec.Command("lsof", "-p", fmt.Sprintf("%d", d.ProcessPid()))
|
openFileCmd, wantTTYName := "lsof", tty.Name()
|
||||||
|
if runtime.GOOS == "freebsd" {
|
||||||
|
openFileCmd = "fstat"
|
||||||
|
wantTTYName = strings.TrimPrefix(wantTTYName, "/dev/")
|
||||||
|
}
|
||||||
|
cmd := exec.Command(openFileCmd, "-p", fmt.Sprintf("%d", d.ProcessPid()))
|
||||||
result, err := cmd.CombinedOutput()
|
result, err := cmd.CombinedOutput()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
if !bytes.Contains(result, []byte(tty.Name())) {
|
if !bytes.Contains(result, []byte(wantTTYName)) {
|
||||||
t.Fatal("process open file list does not contain expected tty")
|
t.Fatalf("process open file list does not contain expected tty %q", wantTTYName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user