mirror of
https://github.com/rwinkhart/sys.git
synced 2026-09-01 14:47:28 -04:00
unix: add SignalNum to convert signal name to a number
Fixes golang/go#28027 Change-Id: Idf8b554e0fd102fd8b2f2f2ea0fa47bf139303da Reviewed-on: https://go-review.googlesource.com/c/164778 Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
This commit is contained in:
committed by
Tobias Klauser
parent
b6889370fb
commit
d455e41777
@@ -98,6 +98,27 @@ func TestErrnoSignalName(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestSignalNum(t *testing.T) {
|
||||
testSignals := []struct {
|
||||
name string
|
||||
want syscall.Signal
|
||||
}{
|
||||
{"SIGHUP", syscall.SIGHUP},
|
||||
{"SIGPIPE", syscall.SIGPIPE},
|
||||
{"SIGSEGV", syscall.SIGSEGV},
|
||||
{"NONEXISTS", 0},
|
||||
}
|
||||
for _, ts := range testSignals {
|
||||
t.Run(fmt.Sprintf("%s/%d", ts.name, ts.want), func(t *testing.T) {
|
||||
got := unix.SignalNum(ts.name)
|
||||
if got != ts.want {
|
||||
t.Errorf("SignalNum(%s) returned %d, want %d", ts.name, got, ts.want)
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
func TestFcntlInt(t *testing.T) {
|
||||
t.Parallel()
|
||||
file, err := ioutil.TempFile("", "TestFnctlInt")
|
||||
|
||||
Reference in New Issue
Block a user