1
0
mirror of https://github.com/golang/go synced 2024-11-07 09:06:20 -07:00
go/src/syscall/syscall_ptrace_test.go
Russ Cox d4b2638234 all: go fmt std cmd (but revert vendor)
Make all our package sources use Go 1.17 gofmt format
(adding //go:build lines).

Part of //go:build change (#41184).
See https://golang.org/design/draft-gobuild

Change-Id: Ia0534360e4957e58cd9a18429c39d0e32a6addb4
Reviewed-on: https://go-review.googlesource.com/c/go/+/294430
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jason A. Donenfeld <Jason@zx2c4.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-02-20 03:54:50 +00:00

39 lines
824 B
Go

// Copyright 2019 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd
// +build darwin dragonfly freebsd linux netbsd openbsd
package syscall_test
import (
"internal/testenv"
"os"
"os/exec"
"syscall"
"testing"
)
func TestExecPtrace(t *testing.T) {
testenv.MustHaveExec(t)
bin, err := exec.LookPath("sh")
if err != nil {
t.Skipf("skipped because sh is not available")
}
attr := &os.ProcAttr{
Sys: &syscall.SysProcAttr{
Ptrace: true,
},
}
proc, err := os.StartProcess(bin, []string{bin}, attr)
if err == nil {
proc.Kill()
}
if err != nil && !os.IsPermission(err) {
t.Fatalf("StartProcess with ptrace enabled failed: %v", err)
}
}